diff --git a/build.gradle b/build.gradle index ac4274c38..aa32d780a 100644 --- a/build.gradle +++ b/build.gradle @@ -8,20 +8,19 @@ buildscript { configurations.all { resolutionStrategy { - force 'com.google.guava:guava:21.0' - force 'org.ow2.asm:asm:6.0_BETA' + force 'commons-io:commons-io:2.4' } } dependencies { classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4' - classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.7.5' - classpath 'org.ajoberstar:gradle-git:1.7.2' + classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.8.1' } } plugins { id 'net.minecrell.licenser' version '0.4.1' apply false + id "org.ajoberstar.grgit" version "2.3.0" } apply plugin: 'java' diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 7872f45bc..a2d043d73 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -5,8 +5,9 @@ - + + diff --git a/config/checkstyle/import-control.xml b/config/checkstyle/import-control.xml index eedd07857..28ccad1e4 100644 --- a/config/checkstyle/import-control.xml +++ b/config/checkstyle/import-control.xml @@ -15,6 +15,7 @@ + @@ -53,6 +54,7 @@ + diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 000000000..878bf1f7e --- /dev/null +++ b/gradle.properties @@ -0,0 +1,4 @@ +# Sets default memory used for gradle commands. Can be overridden by user or command line properties. +# This is required to provide enough memory for the Minecraft decompilation process. +org.gradle.jvmargs=-Xmx3G +org.gradle.daemon=false \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 29953ea14..0d4a95168 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index db93606ed..6cbc54326 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Mon Mar 25 18:59:14 EDT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip diff --git a/worldedit-bukkit/build.gradle b/worldedit-bukkit/build.gradle index acefe8c9b..a0214fa9b 100644 --- a/worldedit-bukkit/build.gradle +++ b/worldedit-bukkit/build.gradle @@ -4,14 +4,17 @@ apply plugin: 'maven' repositories { maven { url "https://hub.spigotmc.org/nexus/content/groups/public" } + maven { url "https://repo.codemc.org/repository/maven-public" } + maven { url 'https://papermc.io/repo/repository/maven-public/' } } dependencies { compile project(':worldedit-core') + compile 'net.milkbowl.vault:VaultAPI:1.7' compile 'com.sk89q:dummypermscompat:1.10' compile 'com.destroystokyo.paper:paper-api:1.13.2-R0.1-SNAPSHOT' - compile 'org.spigotmc:spigot:1.13.2-R0.1-SNAPSHOT' + compile 'org.slf4j:slf4j-jdk14:1.7.26' testCompile 'org.mockito:mockito-core:1.9.0-rc1' compile 'com.massivecraft:factions:2.8.0' compile 'com.drtshock:factions:1.6.9.5' @@ -77,7 +80,10 @@ task copyFiles { shadowJar { dependencies { + relocate "org.slf4j", "com.sk89q.worldedit.slf4j" include(dependency(':worldedit-core')) + include(dependency('org.slf4j:slf4j-api')) + include(dependency("org.slf4j:slf4j-jdk14")) } archiveName = "${parent.name}-${project.name.replaceAll("worldedit-", "")}-${parent.version}.jar" destinationDir = file '../target' diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/FlatFilePermissionsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/FlatFilePermissionsResolver.java index 3f2324596..9b5229cf3 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/FlatFilePermissionsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/FlatFilePermissionsResolver.java @@ -22,6 +22,8 @@ package com.sk89q.wepif; import com.sk89q.util.yaml.YAMLProcessor; import org.bukkit.OfflinePlayer; import org.bukkit.Server; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.BufferedReader; import java.io.File; @@ -32,12 +34,10 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; public class FlatFilePermissionsResolver implements PermissionsResolver { - private static final Logger log = Logger.getLogger(FlatFilePermissionsResolver.class.getCanonicalName()); + private static final Logger log = LoggerFactory.getLogger(FlatFilePermissionsResolver.class); private Map> userPermissionsCache; private Set defaultPermissionsCache; @@ -98,7 +98,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { } } } catch (IOException e) { - log.log(Level.WARNING, "Failed to load permissions", e); + log.warn("Failed to load permissions", e); } finally { try { if (buff != null) { @@ -164,7 +164,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { } } } catch (IOException e) { - log.log(Level.WARNING, "Failed to load permissions", e); + log.warn("Failed to load permissions", e); } finally { try { if (buff != null) { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java index fe23bfa46..ef12e2ff4 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java @@ -28,13 +28,12 @@ import org.bukkit.command.PluginCommand; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; - -import java.util.logging.Level; -import java.util.logging.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class NijiPermissionsResolver implements PermissionsResolver { - private static final Logger log = Logger.getLogger(NijiPermissionsResolver.class.getCanonicalName()); + private static final Logger log = LoggerFactory.getLogger(NijiPermissionsResolver.class); private Server server; private Permissions api; @@ -84,7 +83,7 @@ public class NijiPermissionsResolver implements PermissionsResolver { return api.Security.permission(player, permission); } } catch (Throwable t) { - log.log(Level.WARNING, "Failed to check permissions", t); + log.warn("Failed to check permissions", t); return false; } } @@ -98,7 +97,7 @@ public class NijiPermissionsResolver implements PermissionsResolver { return api.getHandler().has(server.getPlayerExact(name), permission); } } catch (Throwable t) { - log.log(Level.WARNING, "Failed to check permissions", t); + log.warn("Failed to check permissions", t); return false; } } @@ -115,7 +114,7 @@ public class NijiPermissionsResolver implements PermissionsResolver { return api.Security.inGroup(name, group); } } catch (Throwable t) { - log.log(Level.WARNING, "Failed to check groups", t); + log.warn("Failed to check groups", t); return false; } } @@ -139,7 +138,7 @@ public class NijiPermissionsResolver implements PermissionsResolver { return groups; } } catch (Throwable t) { - log.log(Level.WARNING, "Failed to get groups", t); + log.warn("Failed to get groups", t); return new String[0]; } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java index 4775d86c4..6514912a8 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java @@ -27,6 +27,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.plugin.Plugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; @@ -35,8 +37,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; public class PermissionsResolverManager implements PermissionsResolver { @@ -85,7 +85,7 @@ public class PermissionsResolverManager implements PermissionsResolver { private Server server; private PermissionsResolver permissionResolver; private YAMLProcessor config; - private Logger logger = Logger.getLogger(getClass().getCanonicalName()); + private Logger logger = LoggerFactory.getLogger(getClass()); private List> enabledResolvers = new ArrayList<>(); @SuppressWarnings("unchecked") @@ -119,7 +119,7 @@ public class PermissionsResolverManager implements PermissionsResolver { break; } } catch (Throwable e) { - logger.log(Level.WARNING, "Error in factory method for " + resolverClass.getSimpleName(), e); + logger.warn("Error in factory method for " + resolverClass.getSimpleName(), e); continue; } } @@ -195,14 +195,14 @@ public class PermissionsResolverManager implements PermissionsResolver { try { file.createNewFile(); } catch (IOException e) { - logger.log(Level.WARNING, "Failed to create new configuration file", e); + logger.warn("Failed to create new configuration file", e); } } config = new YAMLProcessor(file, false, YAMLFormat.EXTENDED); try { config.load(); } catch (IOException e) { - logger.log(Level.WARNING, "Error loading WEPIF configuration", e); + logger.warn("Error loading WEPIF configuration", e); } List keys = config.getKeys(null); config.setHeader(CONFIG_HEADER); @@ -232,7 +232,7 @@ public class PermissionsResolverManager implements PermissionsResolver { } catch (ClassNotFoundException e) {} if (next == null || !PermissionsResolver.class.isAssignableFrom(next)) { - logger.warning("WEPIF: Invalid or unknown class found in enabled resolvers: " + logger.warn("WEPIF: Invalid or unknown class found in enabled resolvers: " + nextName + ". Moving to disabled resolvers list."); i.remove(); disabledResolvers.add(nextName); diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/VaultResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/VaultResolver.java index a97017ceb..a918d601a 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/VaultResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/VaultResolver.java @@ -35,6 +35,9 @@ public class VaultResolver implements PermissionsResolver { return null; } RegisteredServiceProvider rsp = server.getServicesManager().getRegistration(Permission.class); + if (rsp == null) { + return null; + } perms = rsp.getProvider(); if (perms == null) { return null; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java index e68587283..a7dbf4b24 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java @@ -19,15 +19,25 @@ package com.sk89q.worldedit.bukkit; +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.Function; +import com.sk89q.worldedit.NotABlockException; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.IBukkitAdapter; import com.sk89q.worldedit.bukkit.adapter.SimpleBukkitAdapter; import com.sk89q.worldedit.entity.Entity; +import com.sk89q.worldedit.extension.input.InputParseException; +import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.World; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; @@ -37,6 +47,7 @@ import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.item.ItemType; import org.bukkit.Material; +import org.bukkit.block.Biome; import org.bukkit.block.data.BlockData; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -122,6 +133,26 @@ public enum BukkitAdapter { return getAdapter().adapt(gameMode); } + /** + * Create a WorldEdit BiomeType from a Bukkit one. + * + * @param biome Bukkit Biome + * @return WorldEdit BiomeType + */ + public static BiomeType adapt(Biome biome) { + return getAdapter().adapt(biome); + } + + public static Biome adapt(BiomeType biomeType) { + getAdapter().adapt(biomeType); + } + + /** + * Create a WorldEdit EntityType from a Bukkit one. + * + * @param entityType Bukkit EntityType + * @return WorldEdit EntityType + */ public static EntityType adapt(org.bukkit.entity.EntityType entityType) { return getAdapter().adapt(entityType); } @@ -146,6 +177,12 @@ public enum BukkitAdapter { return getAdapter().adapt(material); } + /** + * Create a Bukkit BlockData from a WorldEdit BlockStateHolder + * + * @param block The WorldEdit BlockStateHolder + * @return The Bukkit BlockData + */ public static > BlockData adapt(B block) { return getAdapter().adapt(block); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBiomeRegistry.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBiomeRegistry.java index cb0fea4de..27474678f 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBiomeRegistry.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBiomeRegistry.java @@ -19,16 +19,11 @@ package com.sk89q.worldedit.bukkit; -import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; -import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BiomeData; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.registry.BiomeRegistry; import org.bukkit.block.Biome; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - import javax.annotation.Nullable; /** @@ -41,35 +36,9 @@ class BukkitBiomeRegistry implements BiomeRegistry { @Nullable @Override - public BaseBiome createFromId(int id) { - return new BaseBiome(id); - } - - @Override - public List getBiomes() { - BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); - if (adapter != null) { - List biomes = new ArrayList<>(); - for (Biome biome : Biome.values()) { - int biomeId = adapter.getBiomeId(biome); - biomes.add(new BaseBiome(biomeId)); - } - return biomes; - } else { - return Collections.emptyList(); - } - } - - @Nullable - @Override - public BiomeData getData(BaseBiome biome) { - BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); - if (adapter != null) { - final Biome bukkitBiome = adapter.getBiome(biome.getId()); - return bukkitBiome::name; - } else { - return null; - } + public BiomeData getData(BiomeType biome) { + final Biome bukkitBiome = BukkitAdapter.adapt(biome); + return bukkitBiome == null ? null : bukkitBiome::name; } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCategoryRegistry.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCategoryRegistry.java index 24cbe0f6b..cecec0691 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCategoryRegistry.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCategoryRegistry.java @@ -49,4 +49,4 @@ public class BukkitBlockCategoryRegistry implements BlockCategoryRegistry { public Set getAll(Category category) { return getCategorisedByName(category.getId()); } -} \ No newline at end of file +} diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java index b392c50ac..fa3f2917f 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.bukkit; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.bukkit.util.CommandInspector; import com.sk89q.minecraft.util.commands.CommandLocals; import com.sk89q.worldedit.extension.platform.Actor; @@ -29,12 +27,14 @@ import com.sk89q.worldedit.util.command.Description; import com.sk89q.worldedit.util.command.Dispatcher; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import java.util.logging.Logger; +import static com.google.common.base.Preconditions.checkNotNull; class BukkitCommandInspector implements CommandInspector { - private static final Logger logger = Logger.getLogger(BukkitCommandInspector.class.getCanonicalName()); + private static final Logger logger = LoggerFactory.getLogger(BukkitCommandInspector.class); private final WorldEditPlugin plugin; private final Dispatcher dispatcher; @@ -51,7 +51,7 @@ class BukkitCommandInspector implements CommandInspector { if (mapping != null) { return mapping.getDescription().getDescription(); } else { - logger.warning("BukkitCommandInspector doesn't know how about the command '" + command + "'"); + logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'"); return "Help text not available"; } } @@ -63,7 +63,7 @@ class BukkitCommandInspector implements CommandInspector { Description description = mapping.getDescription(); return "Usage: " + description.getUsage() + (description.getHelp() != null ? "\n" + description.getHelp() : ""); } else { - logger.warning("BukkitCommandInspector doesn't know how about the command '" + command + "'"); + logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'"); return "Help text not available"; } } @@ -76,7 +76,7 @@ class BukkitCommandInspector implements CommandInspector { locals.put(Actor.class, plugin.wrapCommandSender(sender)); return mapping.getCallable().testPermission(locals); } else { - logger.warning("BukkitCommandInspector doesn't know how about the command '" + command + "'"); + logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'"); return false; } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java index 494a464ea..96c755083 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitConfiguration.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.bukkit; import com.sk89q.util.yaml.YAMLProcessor; import com.sk89q.worldedit.util.YAMLConfiguration; import com.sk89q.worldedit.util.report.Unreported; +import org.slf4j.LoggerFactory; import java.io.File; @@ -34,7 +35,7 @@ public class BukkitConfiguration extends YAMLConfiguration { @Unreported private final WorldEditPlugin plugin; public BukkitConfiguration(YAMLProcessor config, WorldEditPlugin plugin) { - super(config, plugin.getLogger()); + super(config, LoggerFactory.getLogger(plugin.getLogger().getName())); this.plugin = plugin; } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitImplementationTester.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitImplementationTester.java deleted file mode 100644 index 1345f6a81..000000000 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitImplementationTester.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.bukkit; - -/** - * Adds methods to test if different API methods are possible based on implementation. - */ -public class BukkitImplementationTester { - - private BukkitImplementationTester() { - } - - /** - * Known Bukkit implementations - */ - public enum BukkitImplementation { - CRAFTBUKKIT, - SPIGOT, - PAPER, - } - - private static final String implementationMessage = "************************************************" + - "* Note: PaperMC (https://papermc.io/) is *" + - "* recommended for optimal performance with *" + - "* WorldEdit, WorldGuard, or CraftBook. *" + - "************************************************"; - - private static BukkitImplementation implementation; - - /** - * Gets the implementation currently in use on the server. - * - * @return The server implementation - */ - public static BukkitImplementation getImplementation() { - if (implementation == null) { - try { - Class.forName("com.destroystokyo.paper.PaperConfig"); - implementation = BukkitImplementation.PAPER; - } catch (Exception e) { - try { - Class.forName("org.spigotmc.SpigotConfig"); - implementation = BukkitImplementation.SPIGOT; - } catch (Exception e2) { - implementation = BukkitImplementation.CRAFTBUKKIT; - } - } - - if (implementation != BukkitImplementation.PAPER) { -// Bukkit.getServer().getConsoleSender().sendMessage(implementationMessage); // TODO Decide if good idea. - } - } - - return implementation; - } - - /** - * Check if this implementation is compatible with Spigot APIs - * - * @return If compatible with Spigot APIs - */ - public static boolean isSpigotCompatible() { - return getImplementation() == BukkitImplementation.SPIGOT || getImplementation() == BukkitImplementation.PAPER; - } - - /** - * Check if this implementation is compatible with Paper APIs - * - * @return If compatible with Paper APIs - */ - public static boolean isPaperCompatible() { - return getImplementation() == BukkitImplementation.PAPER; - } -} diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitItemCategoryRegistry.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitItemCategoryRegistry.java index b5291b4e1..c75c56eb2 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitItemCategoryRegistry.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitItemCategoryRegistry.java @@ -49,4 +49,4 @@ public class BukkitItemCategoryRegistry implements ItemCategoryRegistry { public Set getAll(Category category) { return getCategorisedByName(category.getId()); } -} \ No newline at end of file +} diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index b3674e986..94b616f7b 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -61,6 +61,10 @@ public class BukkitPlayer extends AbstractPlayerActor { private Player player; private WorldEditPlugin plugin; + public BukkitPlayer(Player player) { + this(WorldEditPlugin.getInstance(), player); + } + public BukkitPlayer(WorldEditPlugin plugin, Player player) { this.plugin = plugin; this.player = player; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitRegistries.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitRegistries.java index 962d10d01..12f485bf5 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitRegistries.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitRegistries.java @@ -19,7 +19,11 @@ package com.sk89q.worldedit.bukkit; -import com.sk89q.worldedit.world.registry.*; +import com.sk89q.worldedit.world.registry.BiomeRegistry; +import com.sk89q.worldedit.world.registry.BlockCategoryRegistry; +import com.sk89q.worldedit.world.registry.BlockRegistry; +import com.sk89q.worldedit.world.registry.BundledRegistries; +import com.sk89q.worldedit.world.registry.ItemCategoryRegistry; /** * World data for the Bukkit platform. @@ -44,11 +48,6 @@ class BukkitRegistries extends BundledRegistries { public BlockRegistry getBlockRegistry() { return blockRegistry; } - - @Override - public BlockCategoryRegistry getBlockCategoryRegistry() { - return blockCategoryRegistry; - } @Override public BiomeRegistry getBiomeRegistry() { @@ -59,6 +58,11 @@ class BukkitRegistries extends BundledRegistries { public ItemRegistry getItemRegistry() { return itemRegistry; } + + @Override + public BlockCategoryRegistry getBlockCategoryRegistry() { + return blockCategoryRegistry; + } @Override public ItemCategoryRegistry getItemCategoryRegistry() { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index a199b6069..ca94366da 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -18,7 +18,6 @@ package com.sk89q.worldedit.bukkit; - import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; @@ -33,7 +32,8 @@ import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.world.AbstractWorld; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherTypes; @@ -41,13 +41,13 @@ import com.sk89q.worldedit.world.weather.WeatherTypes; import org.bukkit.Effect; import org.bukkit.TreeType; import org.bukkit.World; -import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Chest; import org.bukkit.entity.Entity; import org.bukkit.inventory.DoubleChestInventory; import org.bukkit.inventory.Inventory; +import org.slf4j.Logger; import javax.annotation.Nullable; import java.lang.ref.WeakReference; @@ -56,8 +56,6 @@ import java.util.EnumMap; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; import static com.google.common.base.Preconditions.checkNotNull; public class BukkitWorld extends AbstractWorld { @@ -118,9 +116,9 @@ public class BukkitWorld extends AbstractWorld { return null; } } catch (Exception e) { - logger.warning("Corrupt entity found when creating: " + entity.getType().getId()); + logger.warn("Corrupt entity found when creating: " + entity.getType().getId()); if (entity.getNbtData() != null) { - logger.warning(entity.getNbtData().toString()); + logger.warn(entity.getNbtData().toString()); } e.printStackTrace(); return null; @@ -183,7 +181,7 @@ public class BukkitWorld extends AbstractWorld { try { getWorld().regenerateChunk(chunk.getBlockX(), chunk.getBlockZ()); } catch (Throwable t) { - logger.log(Level.WARNING, "Chunk generation via Bukkit raised an error", t); + logger.warn("Chunk generation via Bukkit raised an error", t); } // Then restore @@ -280,7 +278,7 @@ public class BukkitWorld extends AbstractWorld { treeTypeMapping.put(TreeGenerator.TreeType.RANDOM_MUSHROOM, TreeType.BROWN_MUSHROOM); for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) { if (treeTypeMapping.get(type) == null) { - WorldEdit.logger.severe("No TreeType mapping for TreeGenerator.TreeType." + type); + WorldEdit.logger.error("No TreeType mapping for TreeGenerator.TreeType." + type); } } } @@ -425,9 +423,9 @@ public class BukkitWorld extends AbstractWorld { try { return adapter.setBlock(BukkitAdapter.adapt(getWorld(), position), block, notifyAndLight); } catch (Exception e) { - if (block instanceof BaseBlock && ((BaseBlock)block).getNbtData() != null) { - logger.warning("Tried to set a corrupt tile entity at " + position.toString()); - logger.warning(((BaseBlock)block).getNbtData().toString()); + if (block instanceof BaseBlock && ((BaseBlock) block).getNbtData() != null) { + logger.warn("Tried to set a corrupt tile entity at " + position.toString()); + logger.warn(((BaseBlock) block).getNbtData().toString()); } e.printStackTrace(); Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ()); @@ -468,25 +466,13 @@ public class BukkitWorld extends AbstractWorld { } @Override - public BaseBiome getBiome(BlockVector2 position) { - BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); - if (adapter != null) { - int id = adapter.getBiomeId(getWorld().getBiome(position.getBlockX(), position.getBlockZ())); - return new BaseBiome(id); - } else { - return new BaseBiome(0); - } + public BiomeType getBiome(BlockVector2 position) { + return BukkitAdapter.adapt(getWorld().getBiome(position.getBlockX(), position.getBlockZ())); } @Override - public boolean setBiome(BlockVector2 position, BaseBiome biome) { - BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); - if (adapter != null) { - Biome bukkitBiome = adapter.getBiome(biome.getId()); - getWorld().setBiome(position.getBlockX(), position.getBlockZ(), bukkitBiome); - return true; - } else { - return false; - } + public boolean setBiome(BlockVector2 position, BiomeType biome) { + getWorld().setBiome(position.getBlockX(), position.getBlockZ(), BukkitAdapter.adapt(biome)); + return true; } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 78f8c8091..b49d9dc96 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -19,6 +19,8 @@ package com.sk89q.worldedit.bukkit; +import com.bekvon.bukkit.residence.commands.message; +import com.bekvon.bukkit.residence.containers.cmd; import com.boydti.fawe.Fawe; import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.adapter.v1_13_1.Spigot_v1_13_R2; @@ -34,32 +36,49 @@ import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader; import com.sk89q.worldedit.event.platform.CommandEvent; import com.sk89q.worldedit.event.platform.PlatformReadyEvent; +import com.sk89q.worldedit.extension.input.InputParseException; +import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.NoCapablePlatformException; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extent.inventory.BlockBag; +import com.sk89q.worldedit.registry.state.Property; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.block.BlockCategory; +import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockType; +import com.sk89q.worldedit.world.block.FuzzyBlockState; +import com.sk89q.worldedit.world.entity.EntityType; +import com.sk89q.worldedit.world.item.ItemCategory; +import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.registry.LegacyMapper; +import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.Tag; +import org.bukkit.block.Biome; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.*; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPluginLoader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.annotation.Nullable; -import java.io.*; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.lang.reflect.Field; -import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; import java.util.jar.JarFile; import java.util.logging.Level; -import java.util.logging.Logger; import java.util.zip.ZipEntry; import static com.google.common.base.Preconditions.checkNotNull; @@ -70,7 +89,7 @@ import static com.google.common.base.Preconditions.checkNotNull; public class WorldEditPlugin extends JavaPlugin //implements TabCompleter { - private static final Logger log = Logger.getLogger("FastAsyncWorldEdit"); + private static final Logger log = LoggerFactory.getLogger(WorldEditPlugin.class); public static final String CUI_PLUGIN_CHANNEL = "worldedit:cui"; private static WorldEditPlugin INSTANCE; @@ -139,13 +158,9 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter return CUI_PLUGIN_CHANNEL; } - /** - * Called on plugin enable. - */ - @SuppressWarnings("AccessStaticViaInstance") @Override - public void onEnable() { - rename(); + public void onLoad() { + rename(); this.INSTANCE = this; FaweBukkit imp = new FaweBukkit(this); @@ -163,6 +178,16 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter loadConfig(); // Load configuration fail(() -> PermissionsResolverManager.initialize(INSTANCE), "Failed to initialize permissions resolver"); + } + + /** + * Called on plugin enable. + */ + @Override + public void onEnable() { + setupTags(); // these have to be done post-world since they rely on MC registries. the other ones just use Bukkit enums + + PermissionsResolverManager.initialize(this); // Setup permission resolver // Register CUI fail(() -> { @@ -178,9 +203,6 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter // platforms to be worried about... at the current time of writing WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent()); - // Setup the BukkitImplementationTester. - BukkitImplementationTester.getImplementation(); - { // Register 1.13 Material ids with LegacyMapper LegacyMapper legacyMapper = LegacyMapper.getInstance(); for (Material m : Material.values()) { @@ -191,6 +213,20 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter } } + private void setupTags() { + // Tags + try { + for (Tag blockTag : Bukkit.getTags(Tag.REGISTRY_BLOCKS, Material.class)) { + BlockCategory.REGISTRY.register(blockTag.getKey().toString(), new BlockCategory(blockTag.getKey().toString())); + } + for (Tag itemTag : Bukkit.getTags(Tag.REGISTRY_ITEMS, Material.class)) { + ItemCategory.REGISTRY.register(itemTag.getKey().toString(), new ItemCategory(itemTag.getKey().toString())); + } + } catch (NoSuchMethodError e) { + getLogger().warning("The version of Spigot/Paper you are using doesn't support Tags. The usage of tags with WorldEdit will not work until you update."); + } + } + private void rename() { // { // PluginDescriptionFile desc = getDescription(); @@ -221,7 +257,7 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter } } { - Logger logger = getLogger(); + java.util.logging.Logger logger = getLogger(); if (logger != null) { try { Field nameField = Logger.class.getDeclaredField("name"); @@ -245,7 +281,7 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter e.printStackTrace(); } } - log.log(Level.INFO, "Please restart the server if you have any plugins which depend on FAWE."); + log.info("Please restart the server if you have any plugins which depend on FAWE."); } } @@ -253,7 +289,7 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter try { run.run(); } catch (Throwable e) { - log.log(Level.SEVERE, message); + log.error(message); e.printStackTrace(); } } @@ -264,7 +300,7 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config-legacy.yml"), true), this); config.load(); } catch (Throwable e) { - log.log(Level.SEVERE, "Failed to load config.yml"); + log.error("Failed to load config.yml"); e.printStackTrace(); } // Create schematics folder @@ -287,30 +323,30 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter try { adapterLoader.addFromPath(getClass().getClassLoader()); } catch (IOException e) { - log.log(Level.WARNING, "Failed to search path for Bukkit adapters"); + log.warn("Failed to search path for Bukkit adapters"); } try { adapterLoader.addFromJar(getFile()); } catch (IOException e) { - log.log(Level.WARNING, "Failed to search " + getFile() + " for Bukkit adapters", e); + log.warn("Failed to search " + getFile() + " for Bukkit adapters", e); } try { bukkitAdapter = adapterLoader.loadAdapter(); - log.log(Level.INFO, "Using " + bukkitAdapter.getClass().getCanonicalName() + " as the Bukkit adapter"); + log.info("Using " + bukkitAdapter.getClass().getCanonicalName() + " as the Bukkit adapter"); } catch (AdapterLoadException e) { try { Platform platform = worldEdit.getPlatformManager().queryCapability(Capability.WORLD_EDITING); if (platform instanceof BukkitServerInterface) { - log.log(Level.WARNING, e.getMessage()); + log.warn(e.getMessage()); return; } else { - log.log(Level.INFO, "WorldEdit could not find a Bukkit adapter for this MC version, " + + log.info("WorldEdit could not find a Bukkit adapter for this MC version, " + "but it seems that you have another implementation of WorldEdit installed (" + platform.getPlatformName() + ") " + "that handles the world editing."); } } catch (NoCapablePlatformException ignore) {} - log.log(Level.INFO, "WorldEdit could not find a Bukkit adapter for this MC version"); + log.info("WorldEdit could not find a Bukkit adapter for this MC version"); } } @@ -425,7 +461,7 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter EditSession editSession = WorldEdit.getInstance().getEditSessionFactory() .getEditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag, wePlayer); - editSession.enableQueue(); + editSession.enableStandardMode(); return editSession; } @@ -441,7 +477,7 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter LocalSession session = WorldEdit.getInstance().getSessionManager().get(wePlayer); session.remember(editSession); - editSession.flushQueue(); + editSession.flushSession(); WorldEdit.getInstance().flushBlockBag(wePlayer, editSession); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java index 33c2e51e0..b8af14175 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java @@ -19,20 +19,18 @@ package com.sk89q.worldedit.bukkit.adapter; -import com.sk89q.jnbt.Tag; -import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.Property; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.registry.BlockMaterial; import org.bukkit.Chunk; import org.bukkit.Location; -import org.bukkit.block.Biome; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -45,26 +43,6 @@ import javax.annotation.Nullable; */ public interface BukkitImplAdapter extends IBukkitAdapter { - /** - * Get the biome ID for the given biome. - * - *

Returns 0 if it is not known or it doesn't exist.

- * - * @param biome biome - * @return the biome ID - */ - int getBiomeId(Biome biome); - - /** - * Get the biome ID for the given biome ID.. - * - *

Returns {@link Biome#OCEAN} if it is not known or it doesn't exist.

- * - * @param id the biome ID - * @return the biome - */ - Biome getBiome(int id); - /** * Get the block at the given location. * diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java index 9d65cf46b..8d99181d6 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java @@ -20,6 +20,8 @@ package com.sk89q.worldedit.bukkit.adapter; import com.sk89q.worldedit.util.io.Closer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; @@ -29,15 +31,13 @@ import java.util.Enumeration; import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarFile; -import java.util.logging.Level; -import java.util.logging.Logger; /** * Loads Bukkit implementation adapters. */ public class BukkitImplLoader { - private static final Logger log = Logger.getLogger(BukkitImplLoader.class.getCanonicalName()); + private static final Logger log = LoggerFactory.getLogger(BukkitImplLoader.class); private final List adapterCandidates = new ArrayList<>(); private String customCandidate; @@ -73,7 +73,7 @@ public class BukkitImplLoader { if (className != null) { customCandidate = className; adapterCandidates.add(className); - log.log(Level.INFO, "-Dworldedit.bukkit.adapter used to add " + className + " to the list of available Bukkit adapters"); + log.info("-Dworldedit.bukkit.adapter used to add " + className + " to the list of available Bukkit adapters"); } } @@ -93,7 +93,7 @@ public class BukkitImplLoader { try { Enumeration entries = jar.entries(); while (entries.hasMoreElements()) { - JarEntry jarEntry = (JarEntry) entries.nextElement(); + JarEntry jarEntry = entries.nextElement(); String className = jarEntry.getName().replaceAll("[/\\\\]+", "."); @@ -157,22 +157,23 @@ public class BukkitImplLoader { for (String className : adapterCandidates) { try { Class cls = Class.forName(className); + if (cls.isSynthetic()) continue; if (BukkitImplAdapter.class.isAssignableFrom(cls)) { return (BukkitImplAdapter) cls.newInstance(); } else { - log.log(Level.WARNING, "Failed to load the Bukkit adapter class '" + className + + log.warn("Failed to load the Bukkit adapter class '" + className + "' because it does not implement " + BukkitImplAdapter.class.getCanonicalName()); } } catch (ClassNotFoundException e) { - log.log(Level.WARNING, "Failed to load the Bukkit adapter class '" + className + + log.warn("Failed to load the Bukkit adapter class '" + className + "' that is not supposed to be missing", e); } catch (IllegalAccessException e) { - log.log(Level.WARNING, "Failed to load the Bukkit adapter class '" + className + + log.warn("Failed to load the Bukkit adapter class '" + className + "' that is not supposed to be raising this error", e); } catch (Throwable e) { e.printStackTrace(); if (className.equals(customCandidate)) { - log.log(Level.WARNING, "Failed to load the Bukkit adapter class '" + className + "'", e); + log.warn("Failed to load the Bukkit adapter class '" + className + "'", e); } } } diff --git a/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_13_R1$1.class b/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_13_R1$1.class new file mode 100644 index 000000000..efa78dacc Binary files /dev/null and b/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_13_R1$1.class differ diff --git a/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_13_R2$1.class b/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_13_R2$1.class new file mode 100644 index 000000000..97a809b53 Binary files /dev/null and b/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_13_R2$1.class differ diff --git a/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_13_R2_2$1.class b/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_13_R2_2$1.class new file mode 100644 index 000000000..e294143a7 Binary files /dev/null and b/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_13_R2_2$1.class differ diff --git a/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_13_R2_2.class b/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_13_R2_2.class new file mode 100644 index 000000000..5377fe96c Binary files /dev/null and b/worldedit-bukkit/src/main/resources/com/sk89q/worldedit/bukkit/adapter/impl/Spigot_v1_13_R2_2.class differ diff --git a/worldedit-bukkit/src/main/resources/defaults/config-legacy.yml b/worldedit-bukkit/src/main/resources/defaults/config-legacy.yml index 4b8d14715..624b7dc7d 100644 --- a/worldedit-bukkit/src/main/resources/defaults/config-legacy.yml +++ b/worldedit-bukkit/src/main/resources/defaults/config-legacy.yml @@ -17,7 +17,6 @@ # limits: - allow-extra-data-values: false max-blocks-changed: default: -1 maximum: -1 @@ -77,9 +76,16 @@ history: size: 15 expiration: 10 +calculation: + timeout: 100 + +debugging: + trace-unflushed-sessions: false + wand-item: minecraft:wooden_axe shell-save-type: no-double-slash: false no-op-permissions: false debug: false show-help-on-first-use: true +server-side-cui: true diff --git a/worldedit-core/build.gradle b/worldedit-core/build.gradle index 89a595b92..6ac2c5455 100644 --- a/worldedit-core/build.gradle +++ b/worldedit-core/build.gradle @@ -13,6 +13,8 @@ dependencies { compile 'com.google.code.gson:gson:2.8.0' compile 'com.sk89q.lib:jlibnoise:1.0.0' compile 'com.googlecode.json-simple:json-simple:1.1.1' + compile 'org.slf4j:slf4j-api:1.7.26' + //compile 'net.sf.trove4j:trove4j:3.0.3' testCompile 'org.mockito:mockito-core:1.9.0-rc1' // Fawe depends diff --git a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java index a8f49678b..df3b0806b 100644 --- a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java +++ b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java @@ -20,6 +20,8 @@ package com.sk89q.minecraft.util.commands; import com.sk89q.util.StringUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -30,8 +32,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; /** * Manager for handling commands. This allows you to easily process commands, @@ -63,7 +63,7 @@ import java.util.logging.Logger; public abstract class CommandsManager { protected static final Logger logger = - Logger.getLogger(CommandsManager.class.getCanonicalName()); + LoggerFactory.getLogger(CommandsManager.class); /** * Mapping of commands (including aliases) with a description. Root @@ -142,7 +142,7 @@ public abstract class CommandsManager { return registerMethods(cls, parent, obj); } } catch (InvocationTargetException | InstantiationException | IllegalAccessException e) { - logger.log(Level.SEVERE, "Failed to register commands", e); + logger.error("Failed to register commands", e); } return null; } @@ -523,7 +523,7 @@ public abstract class CommandsManager { try { method.invoke(instance, methodArgs); } catch (IllegalArgumentException | IllegalAccessException e) { - logger.log(Level.SEVERE, "Failed to execute command", e); + logger.error("Failed to execute command", e); } catch (InvocationTargetException e) { if (e.getCause() instanceof CommandException) { throw (CommandException) e.getCause(); diff --git a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java index eb6097512..652c69a5d 100644 --- a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java +++ b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java @@ -19,14 +19,15 @@ package com.sk89q.minecraft.util.commands; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.util.logging.Level; -import java.util.logging.Logger; public class SimpleInjector implements Injector { - private static final Logger log = Logger.getLogger(SimpleInjector.class.getCanonicalName()); + private static final Logger log = LoggerFactory.getLogger(SimpleInjector.class); private Object[] args; private Class[] argClasses; @@ -45,7 +46,7 @@ public class SimpleInjector implements Injector { ctr.setAccessible(true); return ctr.newInstance(args); } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { - log.log(Level.SEVERE, "Error initializing commands class " + clazz, e); + log.error("Error initializing commands class " + clazz, e); return null; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 452fbe70d..b1779c154 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -28,18 +28,45 @@ import com.boydti.fawe.jnbt.anvil.MCAQueue; import com.boydti.fawe.jnbt.anvil.MCAWorld; import com.boydti.fawe.logging.LoggingChangeSet; import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory; -import com.boydti.fawe.object.*; +import com.boydti.fawe.object.FaweLimit; +import com.boydti.fawe.object.FawePlayer; +import com.boydti.fawe.object.FaweQueue; +import com.boydti.fawe.object.HasFaweQueue; +import com.boydti.fawe.object.HistoryExtent; +import com.boydti.fawe.object.NullChangeSet; +import com.boydti.fawe.object.RegionWrapper; +import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.brush.visualization.VirtualWorld; -import com.boydti.fawe.object.changeset.*; +import com.boydti.fawe.object.changeset.BlockBagChangeSet; +import com.boydti.fawe.object.changeset.CPUOptimizedChangeSet; +import com.boydti.fawe.object.changeset.DiskStorageHistory; +import com.boydti.fawe.object.changeset.FaweChangeSet; +import com.boydti.fawe.object.changeset.MemoryOptimizedHistory; +import com.boydti.fawe.object.collection.BlockVectorSet; import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.boydti.fawe.object.exception.FaweException; -import com.boydti.fawe.object.extent.*; +import com.boydti.fawe.object.extent.FastWorldEditExtent; +import com.boydti.fawe.object.extent.FaweRegionExtent; +import com.boydti.fawe.object.extent.HeightBoundExtent; +import com.boydti.fawe.object.extent.MultiRegionExtent; +import com.boydti.fawe.object.extent.NullExtent; +import com.boydti.fawe.object.extent.ResettableExtent; +import com.boydti.fawe.object.extent.SingleRegionExtent; +import com.boydti.fawe.object.extent.SlowExtent; +import com.boydti.fawe.object.extent.SourceMaskExtent; +import com.boydti.fawe.object.extent.StripNBTExtent; import com.boydti.fawe.object.function.SurfaceRegionFunction; import com.boydti.fawe.object.mask.ResettableMask; import com.boydti.fawe.object.pattern.ExistingPattern; import com.boydti.fawe.object.progress.ChatProgressTracker; import com.boydti.fawe.object.progress.DefaultProgressTracker; -import com.boydti.fawe.util.*; +import com.boydti.fawe.util.ExtentTraverser; +import com.boydti.fawe.util.MaskTraverser; +import com.boydti.fawe.util.MathMan; +import com.boydti.fawe.util.MemUtil; +import com.boydti.fawe.util.Perm; +import com.boydti.fawe.util.SetQueue; +import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.wrappers.WorldWrapper; import com.google.common.base.Supplier; import com.sk89q.jnbt.CompoundTag; @@ -51,37 +78,79 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.ChangeSetExtent; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.MaskingExtent; +import com.sk89q.worldedit.extent.cache.LastAccessExtentCache; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBagExtent; +import com.sk89q.worldedit.extent.reorder.ChunkBatchingExtent; +import com.sk89q.worldedit.extent.reorder.MultiStageReorder; +import com.sk89q.worldedit.extent.validation.BlockChangeLimiter; +import com.sk89q.worldedit.extent.validation.DataValidatorExtent; +import com.sk89q.worldedit.extent.world.BlockQuirkExtent; +import com.sk89q.worldedit.extent.world.ChunkLoadingExtent; +import com.sk89q.worldedit.extent.world.FastModeExtent; import com.sk89q.worldedit.extent.world.SurvivalModeExtent; import com.sk89q.worldedit.function.GroundFunction; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.RegionMaskingFilter; +import com.sk89q.worldedit.function.block.BlockDistributionCounter; import com.sk89q.worldedit.function.block.BlockReplace; import com.sk89q.worldedit.function.block.Naturalizer; +import com.sk89q.worldedit.function.generator.ForestGenerator; import com.sk89q.worldedit.function.generator.GardenPatchGenerator; -import com.sk89q.worldedit.function.mask.*; +import com.sk89q.worldedit.function.mask.BlockMask; +import com.sk89q.worldedit.function.mask.BlockMaskBuilder; +import com.sk89q.worldedit.function.mask.BlockStateMask; +import com.sk89q.worldedit.function.mask.BlockTypeMask; +import com.sk89q.worldedit.function.mask.BoundedHeightMask; +import com.sk89q.worldedit.function.mask.ExistingBlockMask; +import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.function.mask.MaskIntersection; +import com.sk89q.worldedit.function.mask.MaskUnion; +import com.sk89q.worldedit.function.mask.Masks; +import com.sk89q.worldedit.function.mask.NoiseFilter2D; +import com.sk89q.worldedit.function.mask.RegionMask; import com.sk89q.worldedit.function.operation.ChangeSetExecutor; import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; +import com.sk89q.worldedit.function.pattern.WaterloggedRemover; import com.sk89q.worldedit.function.util.RegionOffset; -import com.sk89q.worldedit.function.visitor.*; +import com.sk89q.worldedit.function.visitor.DirectionalVisitor; +import com.sk89q.worldedit.function.visitor.DownwardVisitor; +import com.sk89q.worldedit.function.visitor.FlatRegionVisitor; +import com.sk89q.worldedit.function.visitor.LayerVisitor; +import com.sk89q.worldedit.function.visitor.NonRisingVisitor; +import com.sk89q.worldedit.function.visitor.RecursiveVisitor; +import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.history.change.BlockChange; +import com.sk89q.worldedit.history.changeset.BlockOptimizedHistory; import com.sk89q.worldedit.history.changeset.ChangeSet; import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.runtime.EvaluationException; import com.sk89q.worldedit.internal.expression.runtime.RValue; -import com.sk89q.worldedit.math.*; +import com.sk89q.worldedit.internal.expression.runtime.ExpressionTimeoutException; +import com.sk89q.worldedit.internal.expression.runtime.RValue; +import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.MathUtils; +import com.sk89q.worldedit.math.MutableBlockVector2; +import com.sk89q.worldedit.math.MutableBlockVector3; +import com.sk89q.worldedit.math.Vector2; +import com.sk89q.worldedit.math.Vector3; +import com.sk89q.worldedit.math.interpolation.Interpolation; import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation; import com.sk89q.worldedit.math.interpolation.Node; import com.sk89q.worldedit.math.noise.RandomNoise; import com.sk89q.worldedit.math.transform.AffineTransform; -import com.sk89q.worldedit.regions.*; +import com.sk89q.worldedit.regions.CuboidRegion; +import com.sk89q.worldedit.regions.EllipsoidRegion; +import com.sk89q.worldedit.regions.FlatRegion; +import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.regions.Regions; import com.sk89q.worldedit.regions.shape.ArbitraryBiomeShape; import com.sk89q.worldedit.regions.shape.ArbitraryShape; import com.sk89q.worldedit.regions.shape.RegionShape; @@ -89,12 +158,18 @@ import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment; import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.TreeGenerator; +import com.sk89q.worldedit.util.collection.DoubleArrayList; import com.sk89q.worldedit.util.eventbus.EventBus; +import com.sk89q.worldedit.world.NullWorld; import com.sk89q.worldedit.world.SimpleWorld; import com.sk89q.worldedit.world.World; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.*; +import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.weather.WeatherType; +import javafx.stage.Stage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -103,7 +178,9 @@ import java.util.concurrent.ThreadLocalRandom; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; -import static com.sk89q.worldedit.regions.Regions.*; +import static com.sk89q.worldedit.regions.Regions.asFlatRegion; +import static com.sk89q.worldedit.regions.Regions.maximumBlockY; +import static com.sk89q.worldedit.regions.Regions.minimumBlockY; /** * An {@link Extent} that handles history, {@link BlockBag}s, change limits, @@ -114,13 +191,8 @@ import static com.sk89q.worldedit.regions.Regions.*; * using the {@link ChangeSetExtent}.

*/ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, SimpleWorld, AutoCloseable { - /** - * Used by {@link EditSession#setBlock(BlockVector3, BlockStateHolder, Stage)} to - * determine which {@link Extent}s should be bypassed. - */ - public enum Stage { - BEFORE_HISTORY, BEFORE_REORDER, BEFORE_CHANGE - } + + private static final Logger log = LoggerFactory.getLogger(EditSession.class); private World world; private String worldName; @@ -144,9 +216,14 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, private final int maxY; public static final UUID CONSOLE = UUID.fromString("1-1-3-3-7"); - public static final BaseBiome nullBiome = new BaseBiome(0); public static final BlockState nullBlock = BlockTypes.AIR.getDefaultState(); + public enum Stage { + BEFORE_HISTORY, + BEFORE_REORDER, + BEFORE_CHANGE + } + @Deprecated public EditSession(@Nonnull World world, @Nullable FaweQueue queue, @Nullable FawePlayer player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable RegionWrapper[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) { this(null, world, queue, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, bus, event); @@ -340,6 +417,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, this(WorldEdit.getInstance().getEventBus(), world, maxBlocks, blockBag, new EditSessionEvent(world, null, maxBlocks, null)); } + private ReorderMode reorderMode = ReorderMode.MULTI_STAGE; + private Mask oldMask; /** @@ -370,6 +449,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, if (find != null && find.get() != null) { find.get().setLimit(this.limit); } + + setReorderMode(this.reorderMode); } /** @@ -400,7 +481,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } /** - * The region extent restricts block placements to allowed regions + * The region extent restricts block placements to allowmaxYed regions * * @return FaweRegionExtent (may be null) */ @@ -536,6 +617,29 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, return extent; } + // pkg private for TracedEditSession only, may later become public API + boolean commitRequired() { + if (reorderExtent != null && reorderExtent.commitRequired()) { + return true; + } + if (chunkBatchingExtent != null && chunkBatchingExtent.commitRequired()) { + return true; + } + if (fastModeExtent != null && fastModeExtent.commitRequired()) { + return true; + } + return false; + } + + /** + * Turns on specific features for a normal WorldEdit session, such as + * {@link #setBatchingChunks(boolean) + * chunk batching}. + */ + public void enableStandardMode() { + setBatchingChunks(true); + } + /** * Get the world. * @@ -610,6 +714,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * Returns queue status. * * @return whether the queue is enabled + * @deprecated Use {@link EditSession#getReorderMode()} with MULTI_STAGE instead. */ @Deprecated public boolean isQueueEnabled() { @@ -618,6 +723,9 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, /** * Queue certain types of block for better reproduction of those blocks. + * + * Uses {@link ReorderMode#MULTI_STAGE} + * @deprecated Use {@link EditSession#setReorderMode(ReorderMode)} with MULTI_STAGE instead. */ @Deprecated public void enableQueue() { @@ -880,6 +988,27 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, return new HashMap<>(); } + /** + * Returns chunk batching status. + * + * @return whether chunk batching is enabled + */ + public boolean isBatchingChunks() { + return false; + } + + /** + * Enable or disable chunk batching. Disabling will + * {@linkplain #flushSession() flush the session}. + * + * @param batchingChunks {@code true} to enable, {@code false} to disable + */ + public void setBatchingChunks(boolean batchingChunks) { + } + + public void disableBuffering() { + } + /** * Get the number of blocks changed, including repeated block changes. *

@@ -892,18 +1021,18 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } @Override - public BaseBiome getBiome(final BlockVector2 position) { + public BiomeType getBiome(final BlockVector2 position) { return this.extent.getBiome(position); } @Override - public boolean setBiome(final BlockVector2 position, final BaseBiome biome) { + public boolean setBiome(final BlockVector2 position, final BiomeType biome) { this.changes++; return this.extent.setBiome(position, biome); } @Override - public boolean setBiome(int x, int y, int z, BaseBiome biome) { + public boolean setBiome(int x, int y, int z, BiomeType biome) { this.changes++; return this.extent.setBiome(x, y, z, biome); } @@ -968,8 +1097,24 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, return getBlockType(position.getBlockX(), position.getBlockY(), position.getBlockZ()); } + /** + * Returns the highest solid 'terrain' block. + * + * @param x the X coordinate + * @param z the Z coordinate + * @param minY minimal height + * @param maxY maximal height + * @param filter a mask of blocks to consider, or null to consider any solid (movement-blocking) block + * @return height of highest block found or 'minY' + */ public int getHighestTerrainBlock(int x, int z, int minY, int maxY) { - return getHighestTerrainBlock(x, z, minY, maxY, null); + for (int y = maxY; y >= minY; --y) { + BlockVector3 pt = BlockVector3.at(x, y, z); + if (getBlock(pt).getBlockType().getMaterial().isMovementBlocker()) { + return y; + } + } + return minY; } /** @@ -985,9 +1130,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) { for (int y = maxY; y >= minY; --y) { BlockVector3 pt = BlockVector3.at(x, y, z); - if (filter == null - ? getBlock(pt).getBlockType().getMaterial().isMovementBlocker() - : filter.test(pt)) { + if (filter.test(pt)) { return y; } } @@ -1033,6 +1176,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return whether the block changed */ public > boolean rawSetBlock(BlockVector3 position, B block) { + this.changes++; try { return this.bypassAll.setBlock(position, block); } catch (WorldEditException e) { @@ -1048,6 +1192,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return whether the block changed */ public > boolean smartSetBlock(BlockVector3 position, B block) { + this.changes++; try { return setBlock(position, block, Stage.BEFORE_REORDER); } catch (WorldEditException e) { @@ -1450,8 +1595,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return number of blocks affected * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - public int fillXZ(final BlockVector3 origin, BaseBlock block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException { - return fillXZ(origin, (Pattern) block, radius, depth, recursive); + public > int fillXZ(BlockVector3 origin, B block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException { + return fillXZ(origin, new BlockPattern(block), radius, depth, recursive); } /** * Fills an area recursively in the X/Z directions. @@ -1471,12 +1616,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, checkArgument(depth >= 1, "depth >= 1"); final MaskIntersection mask = new MaskIntersection(new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), new BoundedHeightMask(Math.max( (origin.getBlockY() - depth) + 1, getMinimumPoint().getBlockY()), Math.min(getMaximumPoint().getBlockY(), origin.getBlockY())), Masks.negate(new ExistingBlockMask(EditSession.this))); -// MaskIntersection mask = new MaskIntersection( -// new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), -// new BoundedHeightMask( -// Math.max(origin.getBlockY() - depth + 1, 0), -// Math.min(getWorld().getMaxY(), origin.getBlockY())), -// Masks.negate(new ExistingBlockMask(this))); // Want to replace blocks BlockReplace replace = new BlockReplace(this, pattern); @@ -1588,6 +1727,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, public boolean hasExtraExtents() { return wrapped || getMask() != null || getSourceMask() != null || history != null; } + public int removeNear(BlockVector3 position, BlockType blockType, int apothem) throws MaxChangedBlocksException { checkNotNull(position); checkArgument(apothem >= 1, "apothem >= 1"); @@ -1670,7 +1810,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return number of blocks affected * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - public > int replaceBlocks(Region region, Set filter, B replacement) throws MaxChangedBlocksException { + public > int replaceBlocks(Region region, Set filter, B replacement) throws MaxChangedBlocksException { return replaceBlocks(region, filter, new BlockPattern(replacement)); } @@ -1684,8 +1824,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return number of blocks affected * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - public int replaceBlocks(Region region, Set filter, Pattern pattern) throws MaxChangedBlocksException { - Mask mask = filter == null ? new ExistingBlockMask(this) : new BlockMaskBuilder().addBlocks(filter).build(this); + public int replaceBlocks(Region region, Set filter, Pattern pattern) throws MaxChangedBlocksException { + Mask mask = filter == null ? new ExistingBlockMask(this) : new BlockMask(this, filter); return replaceBlocks(region, mask, pattern); } @@ -1887,12 +2027,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, FlatRegionVisitor visitor = new FlatRegionVisitor(asFlatRegion(region), surface, this); Operations.completeBlindly(visitor); return this.changes = visitor.getAffected(); -// BlockReplace replace = new BlockReplace(this, pattern); -// RegionOffset offset = new RegionOffset(BlockVector3.at(0, 1, 0), replace); -// GroundFunction ground = new GroundFunction(new ExistingBlockMask(this), offset); -// LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground); -// Operations.completeLegacy(visitor); -// return ground.getAffected(); } /** @@ -2031,6 +2165,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @throws MaxChangedBlocksException thrown if too many blocks are changed */ public int drainArea(final BlockVector3 origin, final double radius) { + return drainArea(origin, radius, false); + } + + public int drainArea(final BlockVector3 origin, final double radius, boolean waterLogged) { checkNotNull(origin); checkArgument(radius >= 0, "radius >= 0 required"); Mask liquidMask; @@ -2053,20 +2191,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, // Around the origin in a 3x3 block for (final BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) { -// public int drainArea(BlockVector3 origin, double radius) throws MaxChangedBlocksException { -// checkNotNull(origin); -// checkArgument(radius >= 0, "radius >= 0 required"); -// -// MaskIntersection mask = new MaskIntersection( -// new BoundedHeightMask(0, getWorld().getMaxY()), -// new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))), -// getWorld().createLiquidMask()); -// -// BlockReplace replace = new BlockReplace(this, new BlockPattern(BlockTypes.AIR.getDefaultState())); -// RecursiveVisitor visitor = new RecursiveVisitor(mask, replace); -// -// // Around the origin in a 3x3 block -// for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) { if (mask.test(position)) { visitor.visit(position); } @@ -2349,7 +2473,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return number of blocks changed * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - public int makeSphere(final BlockVector3 pos, final Pattern block, final double radius, final boolean filled) { + public int makeSphere(BlockVector3 pos, Pattern block, double radius, boolean filled) { return makeSphere(pos, block, radius, radius, radius, filled); } @@ -2595,7 +2719,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, */ public int green(final BlockVector3 position, final double radius) { return this.green(position, radius, false); -} + } + public int green(BlockVector3 position, double radius, boolean onlyNormalDirt) throws MaxChangedBlocksException { int affected = 0; @@ -2619,6 +2744,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, for (int y = maxY; y >= 1; --y) { BlockType block = getBlockType(x, y, z); switch (block.getResource().toUpperCase()) { + // TODO onlyNormalDirt case "DIRT": this.setBlock(x, y, z, BlockTypes.GRASS_BLOCK.getDefaultState()); break loop; @@ -2629,26 +2755,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, if (block.getMaterial().isMovementBlocker()) { break loop; } -// for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) { -// for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) { -// if ((BlockVector3.at(x, oy, z)).distanceSq(position) > radiusSq) { -// continue; -// } -// -// for (int y = world.getMaxY(); y >= 1; --y) { -// final BlockVector3 pt = BlockVector3.at(x, y, z); -// final BlockState block = getBlock(pt); -// -// if (block.getBlockType() == BlockTypes.DIRT || -// (!onlyNormalDirt && block.getBlockType() == BlockTypes.COARSE_DIRT)) { -// if (setBlock(pt, grass)) { -// ++affected; -// } -// break; -// } else if (block.getBlockType() == BlockTypes.WATER || block.getBlockType() == BlockTypes.LAVA) { -// break; -// } else if (block.getBlockType().getMaterial().isMovementBlocker()) { -// break; } } } @@ -2727,48 +2833,39 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } else if (type.getMaterial().isAir()) { continue; } -// public int makeForest(BlockVector3 basePosition, int size, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException { -// int affected = 0; -// -// for (int x = basePosition.getBlockX() - size; x <= basePosition.getBlockX() -// + size; ++x) { -// for (int z = basePosition.getBlockZ() - size; z <= basePosition.getBlockZ() -// + size; ++z) { -// // Don't want to be in the ground -// if (!getBlock(BlockVector3.at(x, basePosition.getBlockY(), z)).getBlockType().getMaterial().isAir()) { -// continue; -// } -// // The gods don't want a tree here -// if (Math.random() >= density) { -// continue; -// } // def 0.05 -// -// for (int y = basePosition.getBlockY(); y >= basePosition.getBlockY() - 10; --y) { -// // Check if we hit the ground -// BlockType t = getBlock(BlockVector3.at(x, y, z)).getBlockType(); -// if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) { -// treeType.generate(this, BlockVector3.at(x, y + 1, z)); -// ++affected; -// break; -// } else if (t == BlockTypes.SNOW) { -// setBlock(BlockVector3.at(x, y, z), BlockTypes.AIR.getDefaultState()); -// } else if (!t.getMaterial().isAir()) { // Trees won't grow on this! -// break; } } } - } catch (MaxChangedBlocksException ignore) { - } + } catch (MaxChangedBlocksException ignore) {} return this.changes; } + /** + * Makes a forest. + * + * @param region the region to generate trees in + * @param density between 0 and 1, inclusive + * @param treeType the tree type + * @return number of trees created + * @throws MaxChangedBlocksException thrown if too many blocks are changed + */ + public int makeForest(Region region, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException { + ForestGenerator generator = new ForestGenerator(this, treeType); + GroundFunction ground = new GroundFunction(new ExistingBlockMask(this), generator); + LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground); + visitor.setMask(new NoiseFilter2D(new RandomNoise(), density)); + Operations.completeLegacy(visitor); + return ground.getAffected(); + } + /** * Get the block distribution inside a region. * * @param region a region * @return the results */ - public List> getBlockDistribution(final Region region) { + public List> getBlockDistribution(Region region, boolean separateStates) { + if (separateStates) return getBlockDistributionWithData(region); int[] counter = new int[BlockTypes.size()]; if (region instanceof CuboidRegion) { @@ -2810,10 +2907,17 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } /** - * Get the block distribution (with data values) inside a region. + * Generate a shape for the given expression. * - * @param region a region - * @return the results + * @param region the region to generate the shape in + * @param zero the coordinate origin for x/y/z variables + * @param unit the scale of the x/y/z/ variables + * @param pattern the default material to make the shape from + * @param expressionString the expression defining the shape + * @param hollow whether the shape should be hollow + * @return number of blocks changed + * @throws ExpressionException + * @throws MaxChangedBlocksException */ public List> getBlockDistributionWithData(final Region region) { int[][] counter = new int[BlockTypes.size()][]; @@ -2884,6 +2988,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, final WorldEditExpressionEnvironment environment = new WorldEditExpressionEnvironment(this, unit, zero); expression.setEnvironment(environment); + final int[] timedOut = {0}; final ArbitraryShape shape = new ArbitraryShape(region) { @Override public BaseBlock getMaterial(final int x, final int y, final int z, final BaseBlock defaultMaterial) { @@ -2907,12 +3012,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } } }; - - try { - return shape.generate(this, pattern, hollow); - } catch (WorldEditException e) { - throw new RuntimeException(e); + int changed = shape.generate(this, pattern, hollow); + if (timedOut[0] > 0) { + throw new ExpressionTimeoutException( + String.format("%d blocks changed. %d blocks took too long to evaluate (increase with //timeout).", + changed, timedOut[0])); } + return changed; } public int deformRegion(final Region region, final Vector3 zero, final Vector3 unit, final String expressionString) throws ExpressionException, MaxChangedBlocksException { @@ -2926,18 +3032,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, final Vector3 zero2 = zero.add(0.5, 0.5, 0.5); RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() { -// final DoubleArrayList queue = new DoubleArrayList<>(false); -// -// for (BlockVector3 position : region) { -// // offset, scale -// final Vector3 scaled = position.subtract(zero).divide(unit); -// -// // transform -// expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ()); -// -// final BlockVector3 sourcePosition = environment.toWorld(x.getValue(), y.getValue(), z.getValue()); - - private MutableBlockVector3 mutable = new MutableBlockVector3(); + private MutableBlockVector3 mutable = new MutableBlockVector3(); @Override public boolean apply(BlockVector3 position) throws WorldEditException { @@ -2956,18 +3051,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } catch (EvaluationException e) { throw new RuntimeException(e); } -// // queue operation -// queue.put(position, material); -// } -// -// int affected = 0; -// for (Map.Entry entry : queue) { -// BlockVector3 position = entry.getKey(); -// BaseBlock material = entry.getValue(); -// -// // set at new position -// if (setBlock(position, material)) { -// ++affected; } }, this); Operations.completeBlindly(visitor); @@ -3249,9 +3332,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, return returnset; } - public void recurseHollow(final Region region, final BlockVector3 origin, final Set outside) { - //TODO FIXME Optimize - avoid vector creation - final ArrayDeque queue = new ArrayDeque<>(); + private void recurseHollow(Region region, BlockVector3 origin, Set outside) { + final BlockVectorSet queue = new BlockVectorSet<>(); queue.addLast(origin); while (!queue.isEmpty()) { @@ -3272,10 +3354,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, for (BlockVector3 recurseDirection : recurseDirections) { queue.addLast(current.add(recurseDirection)); } - } // while + } } - public int makeBiomeShape(final Region region, final Vector3 zero, final Vector3 unit, final BaseBiome biomeType, final String expressionString, final boolean hollow) throws ExpressionException, MaxChangedBlocksException { + public int makeBiomeShape(final Region region, final Vector3 zero, final Vector3 unit, final BiomeType biomeType, final String expressionString, final boolean hollow) throws ExpressionException, MaxChangedBlocksException { final Vector2 zero2D = zero.toVector2(); final Vector2 unit2D = unit.toVector2(); @@ -3288,7 +3370,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, final ArbitraryBiomeShape shape = new ArbitraryBiomeShape(region) { @Override - protected BaseBiome getBiome(final int x, final int z, final BaseBiome defaultBiomeType) { + protected BiomeType getBiome(final int x, final int z, final BiomeType defaultBiomeType) { environment.setCurrentBlock(x, 0, z); double scaledX = (x - zero2D.getX()) / unit2D.getX(); double scaledZ = (z - zero2D.getZ()) / unit2D.getZ(); @@ -3305,8 +3387,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } } }; - - return shape.generate(this, biomeType, hollow); + int changed = shape.generate(this, biomeType, hollow); + if (timedOut[0] > 0) { + throw new ExpressionTimeoutException( + String.format("%d blocks changed. %d blocks took too long to evaluate (increase time with //timeout)", + changed, timedOut[0])); + } + return changed; } private static final BlockVector3[] recurseDirections = { Direction.NORTH.toBlockVector(), @@ -3374,7 +3461,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } } - public boolean regenerate(final Region region, final BaseBiome biome, final Long seed) { + public boolean regenerate(final Region region, final BiomeType biome, final Long seed) { //TODO Optimize - avoid Vector2D creation (make mutable) final FaweQueue queue = this.getQueue(); queue.setChangeTask(null); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionFactory.java index 094da742e..9b288271f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionFactory.java @@ -152,21 +152,24 @@ public class EditSessionFactory { @Override public EditSession getEditSession(World world, int maxBlocks) { - return new EditSession(eventBus, world, maxBlocks, null, new EditSessionEvent(world, null, maxBlocks, null)); + return getEditSession(world, maxBlocks, null, null); } @Override public EditSession getEditSession(World world, int maxBlocks, Player player) { - return new EditSession(eventBus, world, maxBlocks, null, new EditSessionEvent(world, player, maxBlocks, null)); + return getEditSession(world, maxBlocks, null, player); } @Override public EditSession getEditSession(World world, int maxBlocks, BlockBag blockBag) { - return new EditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, null, maxBlocks, null)); + return getEditSession(world, maxBlocks, blockBag, null); } @Override public EditSession getEditSession(World world, int maxBlocks, BlockBag blockBag, Player player) { + if (WorldEdit.getInstance().getConfiguration().traceUnflushedSessions) { + return new TracedEditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, player, maxBlocks, null)); + } return new EditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, player, maxBlocks, null)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java index d1902be8b..d88f23e4b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java @@ -38,6 +38,7 @@ import java.util.Set; public abstract class LocalConfiguration { public boolean profile = false; + public boolean traceUnflushedSessions = false; public Set disallowedBlocks = new HashSet<>(); public int defaultChangeLimit = -1; public int maxChangeLimit = -1; @@ -65,6 +66,8 @@ public abstract class LocalConfiguration { public String navigationWand = "minecraft:compass"; public int navigationWandMaxDistance = 50; public int scriptTimeout = 3000; + public int calculationTimeout = 100; + public int maxCalculationTimeout = 300; public Set allowedDataCycleBlocks = new HashSet<>(); public String saveDir = "schematics"; public String scriptsDir = "craftscripts"; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index a4cefa188..a1a56f980 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -67,11 +67,16 @@ import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.snapshot.Snapshot; -import java.io.*; -import java.util.*; -import java.util.concurrent.atomic.AtomicBoolean; -import javax.annotation.Nonnull; + import javax.annotation.Nullable; +import java.util.Calendar; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.TimeZone; +import java.util.concurrent.atomic.AtomicBoolean; + +import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull; @@ -118,6 +123,7 @@ public class LocalSession implements TextureHolder { private transient Tool[] tools = new Tool[ItemTypes.size()]; private transient int maxBlocksChanged = -1; + private transient int maxTimeoutTime; private transient boolean useInventory; private transient Snapshot snapshot; private transient boolean hasCUISupport = false; @@ -830,6 +836,24 @@ public class LocalSession implements TextureHolder { this.maxBlocksChanged = maxBlocksChanged; } + /** + * Get the maximum time allowed for certain executions to run before cancelling them, such as expressions. + * + * @return timeout time, in milliseconds + */ + public int getTimeout() { + return maxTimeoutTime; + } + + /** + * Set the maximum number of blocks that can be changed. + * + * @param timeout the time, in milliseconds, to limit certain executions to, or -1 to disable + */ + public void setTimeout(int timeout) { + this.maxTimeoutTime = timeout; + } + /** * Checks whether the super pick axe is enabled. * @@ -1260,7 +1284,7 @@ public class LocalSession implements TextureHolder { String msg = e.getMessage(); if (msg != null && msg.length() > 256) msg = msg.substring(0, 256); this.failedCuiAttempts++; - WorldEdit.logger.warning("Error while reading CUI init message for player " + uuid + ": " + msg); + WorldEdit.logger.warn("Error while reading CUI init message for player " + uuid + ": " + msg); } } @@ -1375,6 +1399,24 @@ public class LocalSession implements TextureHolder { this.fastMode = fastMode; } + /** + * Gets the reorder mode of the session. + * + * @return The reorder mode + */ + public EditSession.ReorderMode getReorderMode() { + return reorderMode; + } + + /** + * Sets the reorder mode of the session. + * + * @param reorderMode The reorder mode + */ + public void setReorderMode(EditSession.ReorderMode reorderMode) { + this.reorderMode = reorderMode; + } + /** * Get the mask. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/TracedEditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/TracedEditSession.java new file mode 100644 index 000000000..9832d084d --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/TracedEditSession.java @@ -0,0 +1,45 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit; + +import com.sk89q.worldedit.event.extent.EditSessionEvent; +import com.sk89q.worldedit.extent.inventory.BlockBag; +import com.sk89q.worldedit.util.eventbus.EventBus; +import com.sk89q.worldedit.world.World; + +public class TracedEditSession extends EditSession { + + TracedEditSession(EventBus eventBus, World world, int maxBlocks, BlockBag blockBag, EditSessionEvent event) { + super(eventBus, world, maxBlocks, blockBag, event); + } + + private final Throwable stacktrace = new Throwable("Creation trace."); + + @Override + protected void finalize() throws Throwable { + super.finalize(); + + if (commitRequired()) { + WorldEdit.logger.warn("####### LEFTOVER BUFFER BLOCKS DETECTED #######"); + WorldEdit.logger.warn("This means that some code did not flush their EditSession."); + WorldEdit.logger.warn("Here is a stacktrace from the creation of this EditSession:", stacktrace); + } + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java index 3ec352d07..2404d8f2a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -37,15 +37,11 @@ import com.sk89q.worldedit.extension.platform.PlatformManager; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.internal.expression.Expression; -import com.sk89q.worldedit.internal.expression.runtime.Constant; -import com.sk89q.worldedit.internal.expression.runtime.RValue; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.scripting.CraftScriptContext; import com.sk89q.worldedit.scripting.CraftScriptEngine; import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine; import com.sk89q.worldedit.session.SessionManager; -import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.eventbus.EventBus; @@ -53,7 +49,6 @@ import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException; import com.sk89q.worldedit.util.io.file.FilenameException; import com.sk89q.worldedit.util.io.file.FilenameResolutionException; import com.sk89q.worldedit.util.io.file.InvalidFilenameException; -import com.sk89q.worldedit.util.logging.WorldEditPrefixHandler; import com.sk89q.worldedit.util.task.SimpleSupervisor; import com.sk89q.worldedit.util.task.Supervisor; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -61,6 +56,8 @@ import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.registry.BundledBlockData; import com.sk89q.worldedit.world.registry.BundledItemData; import com.sk89q.worldedit.world.registry.LegacyMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.annotation.Nullable; import javax.script.ScriptException; @@ -97,9 +94,9 @@ import static com.sk89q.worldedit.event.platform.Interaction.OPEN; */ public final class WorldEdit { - public static final Logger logger = Logger.getLogger(WorldEdit.class.getCanonicalName()); + public static final Logger logger = LoggerFactory.getLogger(WorldEdit.class); - private final static WorldEdit instance = new WorldEdit(); + private static final WorldEdit instance = new WorldEdit(); private static String version; private final EventBus eventBus = new EventBus(); @@ -114,7 +111,6 @@ public final class WorldEdit { private final PatternFactory patternFactory = new PatternFactory(this); static { - WorldEditPrefixHandler.register("com.sk89q.worldedit"); getVersion(); } @@ -670,16 +666,16 @@ public final class WorldEdit { } catch (ScriptException e) { player.printError("Failed to execute:"); player.printRaw(e.getMessage()); - logger.log(Level.WARNING, "Failed to execute script", e); + logger.warn("Failed to execute script", e); } catch (NumberFormatException | WorldEditException e) { throw e; } catch (Throwable e) { player.printError("Failed to execute (see console):"); player.printRaw(e.getClass().getCanonicalName()); - logger.log(Level.WARNING, "Failed to execute script", e); + logger.warn("Failed to execute script", e); } finally { for (EditSession editSession : scriptContext.getEditSessions()) { - editSession.flushQueue(); + editSession.flushSession(); session.remember(editSession); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseItem.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseItem.java index 47283f582..c4dc6dac8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseItem.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseItem.java @@ -27,6 +27,8 @@ import com.sk89q.worldedit.world.item.ItemTypes; import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Represents an item, without an amount value. See {@link BaseItemStack} * for an instance with stack amount information. @@ -34,7 +36,7 @@ import javax.annotation.Nullable; *

This class may be removed in the future.

*/ public class BaseItem implements NbtValued { - + private ItemType itemType; @Nullable private CompoundTag nbtData; @@ -45,6 +47,7 @@ public class BaseItem implements NbtValued { * @param itemType Type of the item */ public BaseItem(ItemType itemType) { + checkNotNull(itemType); this.itemType = itemType; } @@ -54,7 +57,8 @@ public class BaseItem implements NbtValued { * @param itemType Type of the item * @param tag NBT Compound tag */ - public BaseItem(ItemType itemType, CompoundTag tag) { + public BaseItem(ItemType itemType, @Nullable CompoundTag tag) { + checkNotNull(itemType); this.itemType = itemType; this.nbtData = tag; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java index 83ebddc85..1f65c6a19 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java @@ -19,14 +19,13 @@ package com.sk89q.worldedit.blocks; -import com.sk89q.worldedit.world.block.BlockCategories; +import com.google.common.collect.Maps; +import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; import java.util.Collection; -import java.util.HashSet; -import java.util.Set; +import java.util.Map; /** * Block-related utility methods. @@ -36,143 +35,6 @@ public final class Blocks { private Blocks() { } - /** - * HashSet for shouldPlaceLate. - */ - private static final Set shouldPlaceLate = new HashSet<>(); - static { - shouldPlaceLate.add(BlockTypes.WATER); - shouldPlaceLate.add(BlockTypes.LAVA); - shouldPlaceLate.add(BlockTypes.GRAVEL); - shouldPlaceLate.add(BlockTypes.SAND); - } - /** - * Checks to see whether a block should be placed in the final queue. - * - * This applies to blocks that can be attached to other blocks that have an attachment. - * - * @param type the type of the block - * @return whether the block is in the late queue - */ - public static boolean shouldPlaceLate(BlockType type) { - return shouldPlaceLate.contains(type); - } - - /** - * HashSet for shouldPlaceLast. - */ - private static final Set shouldPlaceLast = new HashSet<>(); - static { - shouldPlaceLast.addAll(BlockCategories.SAPLINGS.getAll()); - shouldPlaceLast.addAll(BlockCategories.FLOWER_POTS.getAll()); - shouldPlaceLast.addAll(BlockCategories.BUTTONS.getAll()); - shouldPlaceLast.addAll(BlockCategories.ANVIL.getAll()); // becomes relevant with asynchronous placement - shouldPlaceLast.addAll(BlockCategories.WOODEN_PRESSURE_PLATES.getAll()); - shouldPlaceLast.addAll(BlockCategories.CARPETS.getAll()); - shouldPlaceLast.addAll(BlockCategories.RAILS.getAll()); - shouldPlaceLast.add(BlockTypes.BLACK_BED); - shouldPlaceLast.add(BlockTypes.BLUE_BED); - shouldPlaceLast.add(BlockTypes.BROWN_BED); - shouldPlaceLast.add(BlockTypes.CYAN_BED); - shouldPlaceLast.add(BlockTypes.GRAY_BED); - shouldPlaceLast.add(BlockTypes.GREEN_BED); - shouldPlaceLast.add(BlockTypes.LIGHT_BLUE_BED); - shouldPlaceLast.add(BlockTypes.LIGHT_GRAY_BED); - shouldPlaceLast.add(BlockTypes.LIME_BED); - shouldPlaceLast.add(BlockTypes.MAGENTA_BED); - shouldPlaceLast.add(BlockTypes.ORANGE_BED); - shouldPlaceLast.add(BlockTypes.PINK_BED); - shouldPlaceLast.add(BlockTypes.PURPLE_BED); - shouldPlaceLast.add(BlockTypes.RED_BED); - shouldPlaceLast.add(BlockTypes.WHITE_BED); - shouldPlaceLast.add(BlockTypes.YELLOW_BED); - shouldPlaceLast.add(BlockTypes.GRASS); - shouldPlaceLast.add(BlockTypes.TALL_GRASS); - shouldPlaceLast.add(BlockTypes.ROSE_BUSH); - shouldPlaceLast.add(BlockTypes.DANDELION); - shouldPlaceLast.add(BlockTypes.BROWN_MUSHROOM); - shouldPlaceLast.add(BlockTypes.RED_MUSHROOM); - shouldPlaceLast.add(BlockTypes.FERN); - shouldPlaceLast.add(BlockTypes.LARGE_FERN); - shouldPlaceLast.add(BlockTypes.OXEYE_DAISY); - shouldPlaceLast.add(BlockTypes.AZURE_BLUET); - shouldPlaceLast.add(BlockTypes.TORCH); - shouldPlaceLast.add(BlockTypes.WALL_TORCH); - shouldPlaceLast.add(BlockTypes.FIRE); - shouldPlaceLast.add(BlockTypes.REDSTONE_WIRE); - shouldPlaceLast.add(BlockTypes.CARROTS); - shouldPlaceLast.add(BlockTypes.POTATOES); - shouldPlaceLast.add(BlockTypes.WHEAT); - shouldPlaceLast.add(BlockTypes.BEETROOTS); - shouldPlaceLast.add(BlockTypes.COCOA); - shouldPlaceLast.add(BlockTypes.LADDER); - shouldPlaceLast.add(BlockTypes.LEVER); - shouldPlaceLast.add(BlockTypes.REDSTONE_TORCH); - shouldPlaceLast.add(BlockTypes.REDSTONE_WALL_TORCH); - shouldPlaceLast.add(BlockTypes.SNOW); - shouldPlaceLast.add(BlockTypes.NETHER_PORTAL); - shouldPlaceLast.add(BlockTypes.END_PORTAL); - shouldPlaceLast.add(BlockTypes.REPEATER); - shouldPlaceLast.add(BlockTypes.VINE); - shouldPlaceLast.add(BlockTypes.LILY_PAD); - shouldPlaceLast.add(BlockTypes.NETHER_WART); - shouldPlaceLast.add(BlockTypes.PISTON); - shouldPlaceLast.add(BlockTypes.STICKY_PISTON); - shouldPlaceLast.add(BlockTypes.TRIPWIRE_HOOK); - shouldPlaceLast.add(BlockTypes.TRIPWIRE); - shouldPlaceLast.add(BlockTypes.STONE_PRESSURE_PLATE); - shouldPlaceLast.add(BlockTypes.HEAVY_WEIGHTED_PRESSURE_PLATE); - shouldPlaceLast.add(BlockTypes.LIGHT_WEIGHTED_PRESSURE_PLATE); - shouldPlaceLast.add(BlockTypes.COMPARATOR); - shouldPlaceLast.add(BlockTypes.IRON_TRAPDOOR); - shouldPlaceLast.add(BlockTypes.ACACIA_TRAPDOOR); - shouldPlaceLast.add(BlockTypes.BIRCH_TRAPDOOR); - shouldPlaceLast.add(BlockTypes.DARK_OAK_TRAPDOOR); - shouldPlaceLast.add(BlockTypes.JUNGLE_TRAPDOOR); - shouldPlaceLast.add(BlockTypes.OAK_TRAPDOOR); - shouldPlaceLast.add(BlockTypes.SPRUCE_TRAPDOOR); - shouldPlaceLast.add(BlockTypes.DAYLIGHT_DETECTOR); - } - - /** - * Checks to see whether a block should be placed last (when reordering - * blocks that are placed). - * - * @param type the block type - * @return true if the block should be placed last - */ - public static boolean shouldPlaceLast(BlockType type) { - return shouldPlaceLast.contains(type); - } - - /** - * HashSet for shouldPlaceLast. - */ - private static final Set shouldPlaceFinal = new HashSet<>(); - static { - shouldPlaceFinal.addAll(BlockCategories.DOORS.getAll()); - shouldPlaceFinal.addAll(BlockCategories.BANNERS.getAll()); - shouldPlaceFinal.add(BlockTypes.SIGN); - shouldPlaceFinal.add(BlockTypes.WALL_SIGN); - shouldPlaceFinal.add(BlockTypes.CACTUS); - shouldPlaceFinal.add(BlockTypes.SUGAR_CANE); - shouldPlaceFinal.add(BlockTypes.CAKE); - shouldPlaceFinal.add(BlockTypes.PISTON_HEAD); - shouldPlaceFinal.add(BlockTypes.MOVING_PISTON); - } - - /** - * Checks to see whether a block should be placed in the final queue. - * - * This applies to blocks that can be attached to other blocks that have an attachment. - * - * @param type the type of the block - * @return whether the block is in the final queue - */ - public static boolean shouldPlaceFinal(BlockType type) { - return shouldPlaceFinal.contains(type); - } - /** * Checks whether a given block is in a list of base blocks. * @@ -190,4 +52,28 @@ public final class Blocks { return false; } + /** + * Parses a string->string map to find the matching Property and values for the given BlockType. + * + * @param states the desired states and values + * @param type the block type to get properties and values for + * @return a property->value map + */ + public static Map, Object> resolveProperties(Map states, BlockType type) { + Map> existing = type.getPropertyMap(); + Map, Object> newMap = Maps.newHashMap(); + states.forEach((key, value) -> { + @SuppressWarnings("unchecked") + Property prop = (Property) existing.get(key); + if (prop == null) return; + Object val = null; + try { + val = prop.getValueFor(value); + } catch (IllegalArgumentException ignored) { + } + if (val == null) return; + newMap.put(prop, val); + }); + return newMap; + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java index 8c14f4614..2bffb1ac6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java @@ -53,15 +53,17 @@ import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.command.binding.Switch; import com.sk89q.worldedit.world.World; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeData; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.registry.BiomeRegistry; + import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.List; - - -import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION; +import java.util.Set; /** * Implements biome-related commands such as "/biomelist". @@ -102,11 +104,11 @@ public class BiomeCommands extends MethodCommands { } BiomeRegistry biomeRegistry = getBiomeRegistry(); - List biomes = biomeRegistry.getBiomes(); + List biomes = biomeRegistry.getBiomes(); int totalPages = biomes.size() / 19 + 1; Message msg = BBC.BIOME_LIST_HEADER.m(page, totalPages); String setBiome = Commands.getAlias(BiomeCommands.class, "/setbiome"); - for (BaseBiome biome : biomes) { + for (BiomeType biome : biomes) { if (offset > 0) { offset--; } else { @@ -150,12 +152,12 @@ public class BiomeCommands extends MethodCommands { return; } - BaseBiome biome = player.getWorld().getBiome(blockPosition.toBlockPoint().toBlockVector2()); - biomes[biome.getId()]++; + BiomeType biome = player.getWorld().getBiome(blockPosition.toBlockPoint().toBlockVector2()); + biomes[biome.getInternalId()]++; size = 1; } else if (args.hasFlag('p')) { - BaseBiome biome = player.getWorld().getBiome(player.getLocation().toBlockPoint().toBlockVector2()); - biomes[biome.getId()]++; + BiomeType biome = player.getWorld().getBiome(player.getLocation().toBlockPoint().toBlockVector2()); + biomes[biome.getInternalId()]++; size = 1; } else { World world = player.getWorld(); @@ -181,15 +183,15 @@ public class BiomeCommands extends MethodCommands { BBC.BIOME_LIST_HEADER.send(player, 1, 1); - List> distribution = new ArrayList<>(); + List> distribution = new ArrayList<>(); for (int i = 0; i < biomes.length; i++) { int count = biomes[i]; if (count != 0) { - distribution.add(new Countable<>(new BaseBiome(i), count)); + distribution.add(new Countable<>(new BiomeType(i), count)); } } Collections.sort(distribution); - for (Countable c : distribution) { + for (Countable c : distribution) { BiomeData data = biomeRegistry.getData(c.getID()); String str = String.format("%-7s (%.3f%%) %s #%d", String.valueOf(c.getAmount()), @@ -212,7 +214,7 @@ public class BiomeCommands extends MethodCommands { ) @Logging(REGION) @CommandPermissions("worldedit.biome.set") - public void setBiome(Player player, LocalSession session, EditSession editSession, BaseBiome target, @Switch('p') boolean atPosition) throws WorldEditException { + public void setBiome(Player player, LocalSession session, EditSession editSession, BiomeType target, @Switch('p') boolean atPosition) throws WorldEditException { World world = player.getWorld(); Region region; Mask mask = editSession.getMask(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index 030395cb1..9559d35e1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -37,8 +37,6 @@ import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.minecraft.util.commands.Step; -import com.sk89q.worldedit.*; -import com.sk89q.worldedit.command.tool.brush.*; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; @@ -633,7 +631,7 @@ public class BrushCommands extends BrushProcessor { ) @CommandPermissions("worldedit.brush.smooth") public BrushSettings smoothBrush(Player player, LocalSession session, EditSession editSession, - @Optional("2") Expression radius, @Optional("4") int iterations, CommandContext context) throws WorldEditException { + @Optional("2") Expression radius, @Optional("4") int iterations, @Optional Mask mask, CommandContext context) throws WorldEditException { getWorldEdit().checkMaxBrushRadius(radius); @@ -642,7 +640,7 @@ public class BrushCommands extends BrushProcessor { iterations = Math.min(limit.MAX_ITERATIONS, iterations); return set(session, context, - new SmoothBrush(iterations)) + new SmoothBrush(iterations, mask)) .setSize(radius); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java index 542aef756..91c4c9684 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java @@ -21,7 +21,6 @@ package com.sk89q.worldedit.command; import com.boydti.fawe.config.BBC; import com.sk89q.minecraft.util.commands.Command; -import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.minecraft.util.commands.Logging; import com.sk89q.worldedit.EditSession; @@ -106,7 +105,7 @@ public class ChunkCommands { ) @CommandPermissions("worldedit.delchunks") @Logging(REGION) - public void deleteChunks(Player player, LocalSession session, CommandContext args) throws WorldEditException { + public void deleteChunks(Player player, LocalSession session) throws WorldEditException { player.print(BBC.getPrefix() + "Note that this command does not yet support the mcregion format."); LocalConfiguration config = worldEdit.getConfiguration(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index d5e63ba85..b8fe7c06f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -579,7 +579,7 @@ public class ClipboardCommands extends MethodCommands { max = 1 ) @CommandPermissions("worldedit.clipboard.flip") - public void flip(Player player, LocalSession session, EditSession editSession, + public void flip(Player player, LocalSession session, @Optional(Direction.AIM) @Direction BlockVector3 direction) throws WorldEditException { ClipboardHolder holder = session.getClipboard(); AffineTransform transform = new AffineTransform(); @@ -597,7 +597,7 @@ public class ClipboardCommands extends MethodCommands { max = 0 ) @CommandPermissions("worldedit.clipboard.clear") - public void clearClipboard(Player player, LocalSession session, EditSession editSession) throws WorldEditException { + public void clearClipboard(Player player, LocalSession session) throws WorldEditException { session.setClipboard(null); BBC.CLIPBOARD_CLEARED.send(player); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java index 01784ee81..83780a342 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java @@ -26,8 +26,6 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.transform.BlockTransformExtent; import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.Operation; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.CombinedTransform; @@ -96,20 +94,18 @@ public class FlattenedClipboardTransform { MutableVector3 newMinimum = new MutableVector3(corners[0]); MutableVector3 newMaximum = new MutableVector3(corners[0]); -// MutableVector3 cbv = new MutableVector3(); for (int i = 1; i < corners.length; i++) { - MutableVector3 cbv = new MutableVector3(corners[i]); + Vector3 cbv = corners[i]; newMinimum = newMinimum.setComponents(newMinimum.getMinimum(cbv)); newMaximum = newMaximum.setComponents(newMaximum.getMaximum(cbv)); } // After transformation, the points may not really sit on a block, // so we should expand the region for edge cases - newMinimum.mutX(Math.ceil(Math.floor(newMinimum.getX()))); - newMinimum.mutY(Math.ceil(Math.floor(newMinimum.getY()))); - newMinimum.mutZ(Math.ceil(Math.floor(newMinimum.getZ()))); + newMinimum = newMinimum.floor(); + newMaximum = newMaximum.ceil(); - return new CuboidRegion(BlockVector3.at(newMinimum.getX(), newMinimum.getY(), newMinimum.getZ()), BlockVector3.at(newMaximum.getX(), newMaximum.getY(), newMaximum.getZ())); + return new CuboidRegion(newMinimum.toBlockPoint(), newMaximum.toBlockPoint()); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java index c2754a935..acb8e4970 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java @@ -59,7 +59,7 @@ public class GeneralCommands { max = 1 ) @CommandPermissions("worldedit.limit") - public void limit(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + public void limit(Player player, LocalSession session, CommandContext args) throws WorldEditException { LocalConfiguration config = worldEdit.getConfiguration(); boolean mayDisable = player.hasPermission("worldedit.limit.unrestricted"); @@ -74,13 +74,43 @@ public class GeneralCommands { session.setBlockChangeLimit(limit); - if (limit != -1) { - player.print("Block change limit set to " + limit + ". (Use //limit -1 to go back to the default.)"); + if (limit != config.defaultChangeLimit) { + player.print("Block change limit set to " + limit + ". (Use //limit to go back to the default.)"); } else { player.print("Block change limit set to " + limit + "."); } } + @Command( + aliases = { "/timeout" }, + usage = "[time]", + desc = "Modify evaluation timeout time.", + min = 0, + max = 1 + ) + @CommandPermissions("worldedit.timeout") + public void timeout(Player player, LocalSession session, CommandContext args) throws WorldEditException { + + LocalConfiguration config = worldEdit.getConfiguration(); + boolean mayDisable = player.hasPermission("worldedit.timeout.unrestricted"); + + int limit = args.argsLength() == 0 ? config.calculationTimeout : Math.max(-1, args.getInteger(0)); + if (!mayDisable && config.maxCalculationTimeout > -1) { + if (limit > config.maxCalculationTimeout) { + player.printError("Your maximum allowable timeout is " + config.maxCalculationTimeout + " ms."); + return; + } + } + + session.setTimeout(limit); + + if (limit != config.calculationTimeout) { + player.print("Timeout time set to " + limit + " ms. (Use //timeout to go back to the default.)"); + } else { + player.print("Timeout time set to " + limit + " ms."); + } + } + @Command( aliases = { "/fast" }, usage = "[on|off]", @@ -89,7 +119,7 @@ public class GeneralCommands { max = 1 ) @CommandPermissions("worldedit.fast") - public void fast(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + public void fast(Player player, LocalSession session, CommandContext args) throws WorldEditException { String newState = args.getString(0, null); if (session.hasFastMode()) { @@ -111,6 +141,41 @@ public class GeneralCommands { } } + @Command( + aliases = { "/drawsel" }, + usage = "[on|off]", + desc = "Toggle drawing the current selection", + min = 0, + max = 1 + ) + @CommandPermissions("worldedit.drawsel") + public void drawSelection(Player player, LocalSession session, CommandContext args) throws WorldEditException { + + if (!WorldEdit.getInstance().getConfiguration().serverSideCUI) { + throw new DisallowedUsageException("This functionality is disabled in the configuration!"); + } + String newState = args.getString(0, null); + if (session.shouldUseServerCUI()) { + if ("on".equals(newState)) { + player.printError("Server CUI already enabled."); + return; + } + + session.setUseServerCUI(false); + session.updateServerCUI(player); + player.print("Server CUI disabled."); + } else { + if ("off".equals(newState)) { + player.printError("Server CUI already disabled."); + return; + } + + session.setUseServerCUI(true); + session.updateServerCUI(player); + player.print("Server CUI enabled. This only supports cuboid regions, with a maximum size of 32x32x32."); + } + } + @Command( aliases = { "/gmask", "gmask" }, usage = "[mask]", @@ -119,7 +184,7 @@ public class GeneralCommands { max = -1 ) @CommandPermissions("worldedit.global-mask") - public void gmask(Player player, LocalSession session, EditSession editSession, @Optional Mask mask) throws WorldEditException { + public void gmask(Player player, LocalSession session, @Optional Mask mask) throws WorldEditException { if (mask == null) { session.setMask((Mask) null); player.print("Global mask disabled."); @@ -136,7 +201,7 @@ public class GeneralCommands { min = 0, max = 0 ) - public void togglePlace(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + public void togglePlace(Player player, LocalSession session) throws WorldEditException { if (session.togglePlacementPosition()) { player.print("Now placing at pos #1."); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index 3e76b61c4..de77d60bb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -54,19 +54,7 @@ import com.sk89q.worldedit.util.command.binding.Range; import com.sk89q.worldedit.util.command.binding.Switch; import com.sk89q.worldedit.util.command.binding.Text; import com.sk89q.worldedit.util.command.parametric.Optional; -import com.sk89q.worldedit.util.command.parametric.ParameterException; -import com.sk89q.worldedit.world.biome.BaseBiome; -import com.sk89q.worldedit.world.block.BlockType; - -import java.awt.RenderingHints; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.net.URL; - - -import static com.sk89q.minecraft.util.commands.Logging.LogMode.ALL; -import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT; -import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION; +import com.sk89q.worldedit.world.biome.BiomeType; /** * Commands for the generation of shapes and other objects. @@ -287,7 +275,7 @@ public class GenerationCommands extends MethodCommands { @CommandPermissions("worldedit.generation.forest") @Logging(POSITION) @SuppressWarnings("deprecation") - public void forestGen(Player player, LocalSession session, EditSession editSession, @Optional("10") int size, @Optional("tree") TreeType type, @Optional("5") double density) throws WorldEditException, ParameterException { + public void forestGen(Player player, LocalSession session, EditSession editSession, @Optional("10") int size, @Optional("tree") TreeType type, @Optional("5") @Range(min = 0, max = 100) double density) throws WorldEditException, ParameterException { density = density / 100; int affected = editSession.makeForest(session.getPlacementPosition(player), size, density, type); player.print(BBC.getPrefix() + affected + " trees created."); @@ -430,16 +418,16 @@ public class GenerationCommands extends MethodCommands { min = 2, max = -1 ) - @CommandPermissions({"worldedit.generation.shape", "worldedit.biome.set"}) + @CommandPermissions("worldedit.generation.shape.biome") @Logging(ALL) public void generateBiome(FawePlayer fp, Player player, LocalSession session, EditSession editSession, @Selection Region region, - BaseBiome target, + BiomeType target, @Text String expression, @Switch('h') boolean hollow, @Switch('r') boolean useRawCoords, @Switch('o') boolean offset, - @Switch('c') boolean offsetCenter, CommandContext context) throws WorldEditException { + @Switch('c') boolean offsetCenter) throws WorldEditException { final Vector3 zero; Vector3 unit; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java index af5716eb4..a545e2513 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/HistoryCommands.java @@ -265,7 +265,6 @@ public class HistoryCommands extends MethodCommands { ) @CommandPermissions("worldedit.history.redo") public void redo(Player player, LocalSession session, CommandContext args) throws WorldEditException { - int times = Math.max(1, args.getInteger(0, 1)); EditSession redone = null; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java index af2d20284..91c0c29a3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java @@ -27,7 +27,6 @@ import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.minecraft.util.commands.Logging; import com.sk89q.worldedit.LocalConfiguration; -import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.Player; @@ -134,7 +133,7 @@ public class NavigationCommands { ) @CommandPermissions("worldedit.navigation.ceiling") @Logging(POSITION) - public void ceiling(Player player, LocalSession session, CommandContext args) throws WorldEditException { + public void ceiling(Player player, CommandContext args) throws WorldEditException { final int clearance = args.argsLength() > 0 ? Math.max(0, args.getInteger(0)) : 0; @@ -155,7 +154,7 @@ public class NavigationCommands { max = 0 ) @CommandPermissions("worldedit.navigation.thru.command") - public void thru(Player player, LocalSession session, CommandContext args) throws WorldEditException { + public void thru(Player player) throws WorldEditException { if (player.passThroughForwardWall(6)) { BBC.WHOOSH.send(player); } else { @@ -207,7 +206,7 @@ public class NavigationCommands { ) @CommandPermissions("worldedit.navigation.up") @Logging(POSITION) - public void up(Player player, LocalSession session, CommandContext args) throws WorldEditException { + public void up(Player player, CommandContext args) throws WorldEditException { final int distance = args.getInteger(0); final boolean alwaysGlass = getAlwaysGlass(args); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 64d3f250c..5d6774da6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -53,7 +53,6 @@ import com.sk89q.worldedit.function.visitor.LayerVisitor; import com.sk89q.worldedit.internal.annotation.Direction; import com.sk89q.worldedit.internal.annotation.Selection; import com.sk89q.worldedit.internal.expression.ExpressionException; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.convolution.GaussianKernel; @@ -67,10 +66,6 @@ import com.sk89q.worldedit.util.command.binding.Range; import com.sk89q.worldedit.util.command.binding.Switch; import com.sk89q.worldedit.util.command.binding.Text; import com.sk89q.worldedit.util.command.parametric.Optional; -import com.sk89q.worldedit.world.biome.BaseBiome; -import com.sk89q.worldedit.world.biome.Biomes; -import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.registry.BiomeRegistry; import java.util.ArrayList; import java.util.Iterator; @@ -454,20 +449,19 @@ public class RegionCommands extends MethodCommands { } @Command( - aliases = {"/smooth"}, - usage = "[iterations]", - flags = "n", - desc = "Smooth the elevation in the selection", - help = - "Smooths the elevation in the selection.\n" + - "The -n flag makes it only consider naturally occuring blocks.\n" + - "The -s flag makes it only consider snow.", - min = 0, - max = 2 + aliases = { "/smooth" }, + usage = "[iterations] [filter]", + desc = "Smooth the elevation in the selection", + help = + "Smooths the elevation in the selection.\n" + + "Optionally, restricts the height map to a set of blocks specified with mask syntax.\n" + + "For example, '//smooth 1 grass_block,dirt,stone' would only smooth natural surface terrain.", + min = 0, + max = 2 ) @CommandPermissions("worldedit.region.smoothsnow") @Logging(REGION) - public void smooth(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Switch('n') boolean affectNatural, @Switch('s') boolean snow, CommandContext context) throws WorldEditException { + public void smooth(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Optional Mask mask, @Switch('s') boolean snow, CommandContext context) throws WorldEditException { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); @@ -477,8 +471,8 @@ public class RegionCommands extends MethodCommands { } player.checkConfirmationRegion(() -> { try { - HeightMap heightMap = new HeightMap(editSession, region, affectNatural, snow); - HeightMapFilter filter = (HeightMapFilter) HeightMapFilter.class.getConstructors()[0].newInstance(GaussianKernel.class.getConstructors()[0].newInstance(5, 1)); + HeightMap heightMap = new HeightMap(editSession, region, mask, snow); + HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0)); int affected = heightMap.applyFilter(filter, iterations); BBC.VISITOR_BLOCK.send(player, affected); } catch (Throwable e) { @@ -523,7 +517,7 @@ public class RegionCommands extends MethodCommands { @Command( aliases = {"/move"}, usage = "[count] [direction] [leave-id]", - flags = "s", + flags = "sbea", desc = "Move the contents of the selection", help = "Moves the contents of the selection.\n" + @@ -707,10 +701,10 @@ public class RegionCommands extends MethodCommands { Mask sourceMask = session.getSourceMask(); session.setMask((Mask) null); session.setSourceMask((Mask) null); - BaseBiome biome = null; + BiomeType biome = null; if (context.argsLength() >= 1) { BiomeRegistry biomeRegistry = worldEdit.getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); - List knownBiomes = biomeRegistry.getBiomes(); + List knownBiomes = biomeRegistry.getBiomes(); biome = Biomes.findBiomeByName(knownBiomes, context.getString(0), biomeRegistry); } Long seed = context.argsLength() != 2 || !MathMan.isInteger(context.getString(1)) ? null : Long.parseLong(context.getString(1)); @@ -766,19 +760,10 @@ public class RegionCommands extends MethodCommands { ) @CommandPermissions("worldedit.region.forest") @Logging(REGION) - public void forest(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("tree") TreeType type, - @Optional("5") @Range(min = 0, max = 100) double density, - CommandContext context) throws WorldEditException { - player.checkConfirmationRegion(() -> { - ForestGenerator generator = new ForestGenerator(editSession, type); - GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator); - LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground); - visitor.setMask(new NoiseFilter2D(new RandomNoise(), density / 100)); - Operations.completeLegacy(visitor); - - BBC.COMMAND_TREE.send(player, ground.getAffected()); - }, getArguments(context), region, context); - + public void forest(Player player, EditSession editSession, @Selection Region region, @Optional("tree") TreeType type, + @Optional("5") @Range(min = 0, max = 100) double density) throws WorldEditException { + int affected = editSession.makeForest(region, density / 100, type); + player.print(affected + " trees created."); } @Command( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index 2ce053148..1392e22af 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -32,6 +32,7 @@ import com.boydti.fawe.object.schematic.StructureFormat; import com.boydti.fawe.object.schematic.visualizer.SchemVis; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.chat.Message; +import com.google.common.collect.Multimap; import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandException; @@ -55,23 +56,30 @@ import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.command.binding.Switch; import com.sk89q.worldedit.util.command.parametric.Optional; import com.sk89q.worldedit.util.io.file.FilenameException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import javax.annotation.Nullable; -import java.io.*; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; import java.nio.file.Files; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.UUID; import java.util.concurrent.atomic.LongAdder; -import java.util.logging.Level; -import java.util.logging.Logger; import java.util.regex.Pattern; - -import static com.boydti.fawe.util.ReflectionUtils.as; +import static com.google.common.base.Preconditions.checkNotNull; /** * Commands that work with schematic files. @@ -79,7 +87,12 @@ import static com.boydti.fawe.util.ReflectionUtils.as; @Command(aliases = {"schematic", "schem", "/schematic", "/schem", "clipboard", "/clipboard"}, desc = "Commands that work with schematic files") public class SchematicCommands extends MethodCommands { - private static final Logger log = Logger.getLogger(SchematicCommands.class.getCanonicalName()); + /** + * 9 schematics per page fits in the MC chat window. + */ + private static final int SCHEMATICS_PER_PAGE = 9; + private static final Logger log = LoggerFactory.getLogger(SchematicCommands.class); + private final WorldEdit worldEdit; /** * Create a new instance. @@ -280,7 +293,7 @@ public class SchematicCommands extends MethodCommands { @Command(aliases = {"save"}, usage = "[format] ", desc = "Save a schematic into your clipboard", help = "The default format for 1.13 is schem") @Deprecated @CommandPermissions({"worldedit.clipboard.save", "worldedit.schematic.save", "worldedit.schematic.save.other"}) - public void save(final Player player, final LocalSession session, @Optional("schem") final String formatName, String filename, @Switch('g') boolean global) throws CommandException, WorldEditException { + public void save(final Player player, final LocalSession session, @Optional("schem") final String formatName, String filename, @Switch('g') boolean global, @Switch('f') boolean allowOverwrite) throws CommandException, WorldEditException { final LocalConfiguration config = this.worldEdit.getConfiguration(); final ClipboardFormat format = ClipboardFormats.findByAlias(formatName); if (format == null) { @@ -324,6 +337,8 @@ public class SchematicCommands extends MethodCommands { try { if (!f.exists()) { f.createNewFile(); + } else if (!allowOverwrite) { + BBC.SCHEMATIC_MOVE_EXISTS.send(player, f.getName()); } try (FileOutputStream fos = new FileOutputStream(f)) { final ClipboardHolder holder = session.getClipboard(); @@ -363,7 +378,7 @@ public class SchematicCommands extends MethodCommands { } catch (IOException e) { e.printStackTrace(); player.printError("Schematic could not written: " + e.getMessage()); - log.log(Level.WARNING, "Failed to write a saved clipboard", e); + log.warn("Failed to write a saved clipboard", e); } } @@ -645,6 +660,4 @@ public class SchematicCommands extends MethodCommands { } }); } - - } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ScriptingCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ScriptingCommands.java index a8e9e911f..602a019c9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ScriptingCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ScriptingCommands.java @@ -192,8 +192,9 @@ public class ScriptingCommands { @Command(aliases = {".s"}, usage = "[args...]", desc = "Execute last CraftScript", min = 0, max = -1) @CommandPermissions("worldedit.scripting.execute") @Logging(ALL) - public void executeLast(final Player player, final LocalSession session, final CommandContext args) throws WorldEditException { - final String lastScript = session.getLastScript(); + public void executeLast(Player player, LocalSession session, CommandContext args) throws WorldEditException { + + String lastScript = session.getLastScript(); if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) { player.printError("You don't have permission to use that script."); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java index c00ac21f0..40669c6bc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java @@ -42,6 +42,9 @@ import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.function.block.BlockDistributionCounter; +import com.sk89q.worldedit.function.operation.Operations; +import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; @@ -63,6 +66,8 @@ import com.sk89q.worldedit.util.formatting.Style; import com.sk89q.worldedit.util.formatting.StyledFragment; import com.sk89q.worldedit.util.formatting.component.CommandListBox; import com.sk89q.worldedit.world.World; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.storage.ChunkStore; import java.io.File; @@ -96,8 +101,9 @@ public class SelectionCommands { ) @Logging(POSITION) @CommandPermissions("worldedit.selection.pos") - public void pos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { - BlockVector3 pos; + public void pos1(Player player, LocalSession session, CommandContext args) throws WorldEditException { + + Location pos; if (args.argsLength() == 1) { if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) { @@ -128,8 +134,9 @@ public class SelectionCommands { ) @Logging(POSITION) @CommandPermissions("worldedit.selection.pos") - public void pos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { - BlockVector3 pos; + public void pos2(Player player, LocalSession session, CommandContext args) throws WorldEditException { + + Location pos; if (args.argsLength() == 1) { if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) { String[] coords = args.getString(0).split(","); @@ -161,7 +168,7 @@ public class SelectionCommands { max = 0 ) @CommandPermissions("worldedit.selection.hpos") - public void hpos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + public void hpos1(Player player, LocalSession session, CommandContext args) throws WorldEditException { BlockVector3 pos = player.getBlockTrace(300).toBlockPoint(); if (pos != null) { @@ -185,7 +192,7 @@ public class SelectionCommands { max = 0 ) @CommandPermissions("worldedit.selection.hpos") - public void hpos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + public void hpos2(Player player, LocalSession session, CommandContext args) throws WorldEditException { BlockVector3 pos = player.getBlockTrace(300).toBlockPoint(); if (pos != null) { @@ -219,7 +226,7 @@ public class SelectionCommands { ) @Logging(POSITION) @CommandPermissions("worldedit.selection.chunk") - public void chunk(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + public void chunk(Player player, LocalSession session, CommandContext args) throws WorldEditException { final BlockVector3 min; final BlockVector3 max; final World world = player.getWorld(); @@ -278,7 +285,7 @@ public class SelectionCommands { max = 0 ) @CommandPermissions("worldedit.wand") - public void wand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + public void wand(Player player) throws WorldEditException { player.giveItem(new BaseItemStack(ItemTypes.parse(we.getConfiguration().wandItem), 1)); BBC.SELECTION_WAND.send(player); if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) @@ -294,6 +301,7 @@ public class SelectionCommands { ) @CommandPermissions("worldedit.wand.toggle") public void toggleWand(Player player, LocalSession session, CommandContext args) throws WorldEditException { + session.setToolControl(!session.isToolControlEnabled()); if (session.isToolControlEnabled()) { @@ -312,7 +320,8 @@ public class SelectionCommands { ) @Logging(REGION) @CommandPermissions("worldedit.selection.expand") - public void expand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + public void expand(Player player, LocalSession session, CommandContext args) throws WorldEditException { + // Special syntax (//expand vert) to expand the selection between // sky and bedrock. if (args.getString(0).equalsIgnoreCase("vert") || args.getString(0).equalsIgnoreCase("vertical")) { @@ -402,7 +411,7 @@ public class SelectionCommands { ) @Logging(REGION) @CommandPermissions("worldedit.selection.contract") - public void contract(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + public void contract(Player player, LocalSession session, CommandContext args) throws WorldEditException { List dirs = new ArrayList<>(); int change = args.getInteger(0); @@ -476,7 +485,7 @@ public class SelectionCommands { ) @Logging(REGION) @CommandPermissions("worldedit.selection.shift") - public void shift(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + public void shift(Player player, LocalSession session, CommandContext args) throws WorldEditException { List dirs = new ArrayList<>(); int change = args.getInteger(0); @@ -523,7 +532,7 @@ public class SelectionCommands { ) @Logging(REGION) @CommandPermissions("worldedit.selection.outset") - public void outset(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + public void outset(Player player, LocalSession session, CommandContext args) throws WorldEditException { Region region = session.getSelection(player.getWorld()); region.expand(getChangesForEachDir(args)); session.getRegionSelector(player.getWorld()).learnChanges(); @@ -546,7 +555,7 @@ public class SelectionCommands { ) @Logging(REGION) @CommandPermissions("worldedit.selection.inset") - public void inset(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + public void inset(Player player, LocalSession session, CommandContext args) throws WorldEditException { Region region = session.getSelection(player.getWorld()); region.contract(getChangesForEachDir(args)); session.getRegionSelector(player.getWorld()).learnChanges(); @@ -726,7 +735,7 @@ public class SelectionCommands { min = 0, max = 1 ) - public void select(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + public void select(Player player, LocalSession session, CommandContext args) throws WorldEditException { final World world = player.getWorld(); if (args.argsLength() == 0) { session.getRegionSelector(world).clear(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java index 0a433ac82..ad87b11ec 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java @@ -39,7 +39,6 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.List; -import java.util.logging.Logger; /** * Snapshot commands. @@ -47,7 +46,6 @@ import java.util.logging.Logger; @Command(aliases = {"snapshot", "snap"}, desc = "List, load and view information related to snapshots") public class SnapshotCommands { - private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit"); private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); private final WorldEdit we; @@ -64,7 +62,7 @@ public class SnapshotCommands { max = 1 ) @CommandPermissions("worldedit.snapshots.list") - public void list(Player player, LocalSession session, CommandContext args) throws WorldEditException { + public void list(Player player, CommandContext args) throws WorldEditException { LocalConfiguration config = we.getConfiguration(); @@ -93,10 +91,10 @@ public class SnapshotCommands { File dir = config.snapshotRepo.getDirectory(); try { - logger.info("WorldEdit found no snapshots: looked in: " + WorldEdit.logger.info("WorldEdit found no snapshots: looked in: " + dir.getCanonicalPath()); } catch (IOException e) { - logger.info("WorldEdit found no snapshots: looked in " + WorldEdit.logger.info("WorldEdit found no snapshots: looked in " + "(NON-RESOLVABLE PATH - does it exist?): " + dir.getPath()); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java index 53df86c15..1224926fd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java @@ -39,7 +39,6 @@ import com.sk89q.worldedit.world.storage.ChunkStore; import com.sk89q.worldedit.world.storage.MissingWorldException; import java.io.File; import java.io.IOException; -import java.util.logging.Logger; import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION; @@ -47,8 +46,6 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION; @Command(aliases = {}, desc = "[More Info](http://wiki.sk89q.com/wiki/WorldEdit/Snapshots)") public class SnapshotUtilCommands { - private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit"); - private final WorldEdit we; public SnapshotUtilCommands(WorldEdit we) { @@ -99,10 +96,10 @@ public class SnapshotUtilCommands { File dir = config.snapshotRepo.getDirectory(); try { - logger.info("FAWE found no snapshots: looked in: " + WorldEdit.logger.info("FAWE found no snapshots: looked in: " + dir.getCanonicalPath()); } catch (IOException e) { - logger.info("FAWE found no snapshots: looked in " + WorldEdit.logger.info("FAWE found no snapshots: looked in " + "(NON-RESOLVABLE PATH - does it exist?): " + dir.getPath()); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SuperPickaxeCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SuperPickaxeCommands.java index 71387fbf4..ce5f0054f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SuperPickaxeCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SuperPickaxeCommands.java @@ -48,7 +48,7 @@ public class SuperPickaxeCommands { max = 0 ) @CommandPermissions("worldedit.superpickaxe") - public void single(Player player, LocalSession session, CommandContext args) throws WorldEditException { + public void single(Player player, LocalSession session) throws WorldEditException { session.setSuperPickaxe(new SinglePickaxe()); session.enableSuperPickAxe(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java index 3056036fc..8e756271b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java @@ -24,7 +24,6 @@ import com.boydti.fawe.object.brush.InspectBrush; import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; -import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; @@ -67,7 +66,7 @@ public class ToolCommands { max = 0 ) @CommandPermissions("worldedit.tool.info") - public void info(Player player, LocalSession session, CommandContext args) throws WorldEditException { + public void info(Player player, LocalSession session) throws WorldEditException { session.setTool(new QueryTool(), player); BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); BBC.TOOL_INFO.send(player, itemStack.getType().getName()); @@ -123,7 +122,7 @@ public class ToolCommands { max = 0 ) @CommandPermissions("worldedit.tool.data-cycler") - public void cycler(Player player, LocalSession session, CommandContext args) throws WorldEditException { + public void cycler(Player player, LocalSession session) throws WorldEditException { session.setTool(new BlockDataCyler(), player); BBC.TOOL_CYCLER.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java index 1c1d715fe..0da33de8a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java @@ -22,7 +22,9 @@ package com.sk89q.worldedit.command; import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; -import com.sk89q.worldedit.*; +import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.pattern.Pattern; @@ -48,7 +50,7 @@ public class ToolUtilCommands { max = 1 ) @CommandPermissions("worldedit.superpickaxe") - public void togglePickaxe(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + public void togglePickaxe(Player player, LocalSession session, CommandContext args) throws WorldEditException { String newState = args.getString(0, null); if (session.hasSuperPickAxe()) { @@ -78,7 +80,7 @@ public class ToolUtilCommands { max = -1 ) @CommandPermissions("worldedit.brush.options.mask") - public void mask(Player player, LocalSession session, EditSession editSession, @Optional Mask mask) throws WorldEditException { + public void mask(Player player, LocalSession session, @Optional Mask mask) throws WorldEditException { if (mask == null) { session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setMask(null); player.print("Brush mask disabled."); @@ -96,7 +98,7 @@ public class ToolUtilCommands { max = 1 ) @CommandPermissions("worldedit.brush.options.material") - public void material(Player player, LocalSession session, EditSession editSession, Pattern pattern) throws WorldEditException { + public void material(Player player, LocalSession session, Pattern pattern) throws WorldEditException { session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setFill(pattern); player.print("Brush material set."); } @@ -109,7 +111,7 @@ public class ToolUtilCommands { max = 1 ) @CommandPermissions("worldedit.brush.options.range") - public void range(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { + public void range(Player player, LocalSession session, CommandContext args) throws WorldEditException { int range = args.getInteger(0); session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setRange(range); player.print("Brush range set."); @@ -123,7 +125,9 @@ public class ToolUtilCommands { max = 1 ) @CommandPermissions("worldedit.brush.options.size") - public void size(Player player, LocalSession session, EditSession editSession, Expression radius) throws WorldEditException { + public void size(Player player, LocalSession session, CommandContext args) throws WorldEditException { + + int radius = args.getInteger(0); we.checkMaxBrushRadius(radius); session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setSize(radius); player.print("Brush size set."); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java index ad3314995..d111b86f8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java @@ -77,8 +77,12 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CylinderRegion; import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.util.command.*; import com.sk89q.worldedit.util.command.binding.Range; +import com.sk89q.worldedit.session.SessionOwner; +import com.sk89q.worldedit.util.command.CommandCallable; +import com.sk89q.worldedit.util.command.CommandMapping; +import com.sk89q.worldedit.util.command.Dispatcher; +import com.sk89q.worldedit.util.command.PrimaryAliasComparator; import com.sk89q.worldedit.util.command.binding.Text; import com.sk89q.worldedit.util.command.parametric.Optional; import com.sk89q.worldedit.util.command.parametric.ParameterData; @@ -283,28 +287,6 @@ public class UtilityCommands extends MethodCommands { if (depth == -1) depth = Integer.MAX_VALUE; int affected = editSession.fillXZ(pos, pattern, radius, (int) depth, true); player.print(BBC.getPrefix() + affected + " block(s) have been created."); -//======= -// public void fillr(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { -// -// ParserContext context = new ParserContext(); -// context.setActor(player); -// context.setWorld(player.getWorld()); -// context.setSession(session); -// Pattern pattern = we.getPatternFactory().parseFromInput(args.getString(0), context); -// -// double radius = Math.max(1, args.getDouble(1)); -// we.checkMaxRadius(radius); -// int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : Integer.MAX_VALUE; -// -// BlockVector3 pos = session.getPlacementPosition(player); -// int affected = 0; -// if (pattern instanceof BlockPattern) { -// affected = editSession.fillXZ(pos, ((BlockPattern) pattern).getBlock(), radius, depth, true); -// } else { -// affected = editSession.fillXZ(pos, pattern, radius, depth, true); -// } -// player.print(affected + " block(s) have been created."); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Command( @@ -435,8 +417,8 @@ public class UtilityCommands extends MethodCommands { @CommandPermissions("worldedit.snow") @Logging(PLACEMENT) public void snow(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { - double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10; + we.checkMaxRadius(size); int affected = editSession.simulateSnow(session.getPlacementPosition(player), size); player.print(BBC.getPrefix() + affected + " surfaces covered. Let it snow~"); @@ -452,8 +434,8 @@ public class UtilityCommands extends MethodCommands { @CommandPermissions("worldedit.thaw") @Logging(PLACEMENT) public void thaw(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { - double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10; + we.checkMaxRadius(size); int affected = editSession.thaw(session.getPlacementPosition(player), size); player.print(BBC.getPrefix() + affected + " surfaces thawed."); @@ -463,6 +445,7 @@ public class UtilityCommands extends MethodCommands { aliases = {"/green", "green"}, usage = "[radius]", desc = "Greens the area", + help = "Converts dirt to grass blocks. -f also converts coarse dirt.", flags = "f", min = 0, max = 1 @@ -470,8 +453,8 @@ public class UtilityCommands extends MethodCommands { @CommandPermissions("worldedit.green") @Logging(PLACEMENT) public void green(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { - final double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10; + we.checkMaxRadius(size); final boolean onlyNormalDirt = !args.hasFlag('f'); final int affected = editSession.green(session.getPlacementPosition(player), size); @@ -559,11 +542,7 @@ public class UtilityCommands extends MethodCommands { List entities; if (radius >= 0) { CylinderRegion region = CylinderRegion.createRadius(editSession, center, radius); - entities = editSession.getEntities(region); } else { - entities = editSession.getEntities(); - } - visitors.add(new EntityVisitor(entities.iterator(), flags.createFunction())); } else { Platform platform = worldEdit.getPlatformManager().queryCapability(Capability.WORLD_EDITING); for (World world : platform.getWorlds()) { @@ -582,7 +561,7 @@ public class UtilityCommands extends MethodCommands { if (editSession != null) { session.remember(editSession); - editSession.flushQueue(); + editSession.flushSession(); } } @@ -642,7 +621,7 @@ public class UtilityCommands extends MethodCommands { if (editSession != null) { session.remember(editSession); - editSession.flushQueue(); + editSession.flushSession(); } } @@ -674,10 +653,10 @@ public class UtilityCommands extends MethodCommands { actor.print(BBC.getPrefix() + "= " + result); } catch (EvaluationException e) { actor.printError(String.format( - "'%s' could not be parsed as a valid expression", input)); + "'%s' could not be evaluated (error: %s)", input, e.getMessage())); } catch (ExpressionException e) { actor.printError(String.format( - "'%s' could not be evaluated (error: %s)", input, e.getMessage())); + "'%s' could not be parsed as a valid expression", input)); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index 301640c03..67c4e6a21 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -124,6 +124,31 @@ public class WorldEditCommands { actor.print(BBC.getPrefix() + "Reloaded WorldEdit " + we.getVersion() + " and FAWE (" + Fawe.get().getVersion() + ")"); } + @Command(aliases = {"report"}, desc = "Writes a report on WorldEdit", flags = "p", max = 0) + @CommandPermissions({"worldedit.report"}) + public void report(Actor actor, CommandContext args) throws WorldEditException { + ReportList report = new ReportList("Report"); + report.add(new SystemInfoReport()); + report.add(new ConfigReport()); + String result = report.toString(); + + try { + File dest = new File(we.getWorkingDirectoryFile(we.getConfiguration().saveDir), "report.txt"); + Files.write(result, dest, Charset.forName("UTF-8")); + actor.print("WorldEdit report written to " + dest.getAbsolutePath()); + } catch (IOException e) { + actor.printError("Failed to write report: " + e.getMessage()); + } + + if (args.hasFlag('p')) { + actor.checkPermission("worldedit.report.pastebin"); + ActorCallbackPaste.pastebin( + we.getSupervisor(), actor, result, "WorldEdit report: %s.report", + WorldEdit.getInstance().getPlatformManager().getCommandManager().getExceptionConverter() + ); + } + } + @Command( aliases = {"update"}, usage = "", @@ -252,7 +277,7 @@ public class WorldEditCommands { min = 0, max = 0 ) - public void cui(Player player, LocalSession session, CommandContext args) throws WorldEditException { + public void cui(Player player, LocalSession session) throws WorldEditException { session.setCUISupport(true); session.dispatchCUISetup(player); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/SelectionCommand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/SelectionCommand.java index 645d1f232..e1425c3e1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/SelectionCommand.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/SelectionCommand.java @@ -89,12 +89,14 @@ public class SelectionCommand extends SimpleCommand { LocalSession session = WorldEdit.getInstance().getSessionManager().get(player); Region selection = session.getSelection(player.getWorld()); EditSession editSession = session.createEditSession(player); - editSession.enableQueue(); + editSession.enableStandardMode(); locals.put(EditSession.class, editSession); session.tellVersion(player); EditContext editContext = new EditContext(); editContext.setDestination(locals.get(EditSession.class)); editContext.setRegion(selection); + editContext.setSession(session); + Operation operation = operationFactory.createFromContext(editContext); // Shortcut if (selection instanceof CuboidRegion && editSession.hasFastMode() && operation instanceof RegionVisitor) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ShapedBrushCommand.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ShapedBrushCommand.java index 35a8734b6..f22fceb4e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ShapedBrushCommand.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/composition/ShapedBrushCommand.java @@ -76,7 +76,8 @@ public class ShapedBrushCommand extends SimpleCommand { WorldEdit.getInstance().checkMaxBrushRadius(radius); BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()); tool.setSize(radius); - tool.setBrush(new OperationFactoryBrush(factory, regionFactory), permission); + tool.setFill(null); + tool.setBrush(new OperationFactoryBrush(factory, regionFactory, session), permission); } catch (MaxBrushRadiusException | InvalidToolBindException e) { WorldEdit.getInstance().getPlatformManager().getCommandManager().getExceptionConverter().convert(e); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java index 58abbcd0d..ac1d0de52 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java @@ -6,6 +6,9 @@ import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; +import com.sk89q.worldedit.MaxChangedBlocksException; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -40,33 +43,21 @@ public class AreaPickaxe implements BlockTool { return true; } - EditSession editSession = session.createEditSession(player); - editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop); + try (EditSession editSession = session.createEditSession(player)) { + editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop); for (int x = ox - range; x <= ox + range; ++x) { for (int z = oz - range; z <= oz + range; ++z) { for (int y = oy + range; y >= oy - range; --y) { if (initialType.equals(editSession.getLazyBlock(x, y, z))) { continue; -// try (EditSession editSession = session.createEditSession(player)) { -// editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop); -// -// try { -// for (int x = ox - range; x <= ox + range; ++x) { -// for (int y = oy - range; y <= oy + range; ++y) { -// for (int z = oz - range; z <= oz + range; ++z) { -// BlockVector3 pos = new BlockVector3(x, y, z); -// if (editSession.getBlock(pos).getBlockType() != initialType) { -// continue; -// } -// -// ((World) clicked.getExtent()).queueBlockBreakEffect(server, pos, initialType, clicked.toBlockPoint().distanceSq(pos)); -// -// editSession.setBlock(pos, BlockTypes.AIR.getDefaultState()); -// } } editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState()); } + } catch (MaxChangedBlocksException e) { + player.printError("Max blocks change limit reached."); + } finally { + session.remember(editSession); } } editSession.flushQueue(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java index 0a7b63e6c..ba2ef06f8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java @@ -25,13 +25,15 @@ import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extent.inventory.BlockBag; +import com.sk89q.worldedit.function.pattern.BlockPattern; +import com.sk89q.worldedit.world.block.BlockState; /** - * A mode that replaces one block. */ public class BlockReplacer implements DoubleActionBlockTool { @@ -58,7 +60,6 @@ public class BlockReplacer implements DoubleActionBlockTool { if (bag != null) { bag.flushChanges(); } - session.remember(editSession); } return true; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java index 221d71eb5..269d9b7b5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java @@ -472,14 +472,6 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool MaskIntersection newMask = new MaskIntersection(existingMask); newMask.add(mask); editSession.setMask(newMask); -//======= -// try { -// brush.build(editSession, target.toBlockPoint(), material, size); -// } catch (MaxChangedBlocksException e) { -// player.printError("Max blocks change limit reached."); -// } finally { -// session.remember(editSession); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } } Mask sourceMask = current.getSourceMask(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java index aa3d91b7f..3d12dc1d7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.command.tool; +import com.boydti.fawe.object.collection.BlockVectorSet; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; @@ -75,80 +76,26 @@ public class FloatingTreeRemover implements BlockTool { player.printError("That's not a tree."); return true; } - final EditSession editSession = session.createEditSession(player); - try /*(EditSession editSession = session.createEditSession(player))*/ { - final Set blockSet = bfs(world, clicked.toBlockPoint()); - if (blockSet == null) { - player.printError("That's not a floating tree."); - return true; - } - for (BlockVector3 blockVector : blockSet) { - final BlockState otherState = editSession.getBlock(blockVector); - if (isTreeBlock(otherState.getBlockType())) { - editSession.setBlock(blockVector, BlockTypes.AIR.getDefaultState()); - } - } - } catch (MaxChangedBlocksException e) { - player.printError("Max blocks change limit reached."); - } finally { - session.remember(editSession); + try (EditSession editSession = session.createEditSession(player)) { + try { + Pattern replace = BlockTypes.AIR; + RecursiveVisitor visitor = new RecursiveVisitor(new BlockMask(editSession, logs, leaves), replace, 64, editSession); + visitor.visit(pos); + Operations.completeBlindly(visitor); + } finally { + session.remember(editSession); + } } return true; } private BlockVector3[] recurseDirections = { - Direction.NORTH.toBlockVector(), Direction.EAST.toBlockVector(), Direction.SOUTH.toBlockVector(), Direction.WEST.toBlockVector(), Direction.UP.toBlockVector(), Direction.DOWN.toBlockVector(), }; - - /** - * Helper method. - * - * @param world the world that contains the tree - * @param origin any point contained in the floating tree - * @return a set containing all blocks in the tree/shroom or null if this is not a floating tree/shroom. - */ - private Set bfs(World world, BlockVector3 origin) throws MaxChangedBlocksException { - final Set visited = new HashSet<>(); - final LinkedList queue = new LinkedList<>(); - - queue.addLast(origin); - visited.add(origin); - - while (!queue.isEmpty()) { - final BlockVector3 current = queue.removeFirst(); - for (BlockVector3 recurseDirection : recurseDirections) { - final BlockVector3 next = current.add(recurseDirection); - if (origin.distanceSq(next) > rangeSq) { - // Maximum range exceeded => stop walking - continue; - } - - if (visited.add(next)) { - BlockState state = world.getBlock(next); - if (state.getBlockType().getMaterial().isAir() || state.getBlockType() == BlockTypes.SNOW) { - continue; - } - if (isTreeBlock(state.getBlockType())) { - queue.addLast(next); - } else { - // we hit something solid - evaluate where we came from - final BlockType currentType = world.getBlock(current).getBlockType(); - if (!BlockCategories.LEAVES.contains(currentType) && currentType != BlockTypes.VINE) { - // log/shroom touching a wall/the ground => this is not a floating tree, bail out - return null; - } - } - } - } - } - - return visited; - } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java index ee08812ad..541e9056f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java @@ -69,17 +69,16 @@ public class FloodFillTool implements BlockTool { return true; } - EditSession editSession = session.createEditSession(player); - try { - recurse(editSession, origin, origin, range, initialType, new HashSet<>()); - } catch (MaxChangedBlocksException e) { - player.printError("Max blocks change limit reached."); - } finally { - session.remember(editSession); + try (EditSession editSession = session.createEditSession(player)) { + try { + TODO fillDirection (but replace) + recurse(editSession, origin, origin, range, initialType, new HashSet<>()); + } catch (MaxChangedBlocksException e) { + player.printError("Max blocks change limit reached."); + } finally { + session.remember(editSession); + } } - - editSession.flushQueue(); - session.remember(editSession); return true; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java index 4137e1efd..b902a39b8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java @@ -55,10 +55,8 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) { Location pos = getTargetFace(player); if (pos == null) return false; - EditSession eS = session.createEditSession(player); - try { -// eS.disableBuffering(); - BlockVector3 blockPoint = pos.toBlockPoint(); + try (EditSession eS = session.createEditSession(player)) { + BlockVector3 blockPoint = pos.toVector().toBlockPoint(); BaseBlock applied = secondary.apply(blockPoint); if (applied.getBlockType().getMaterial().isAir()) { eS.setBlock(blockPoint, secondary); @@ -74,12 +72,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo @Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) { - Location pos = getTargetFace(player); - if (pos == null) return false; - EditSession eS = session.createEditSession(player); - - try { -// eS.disableBuffering(); + try (EditSession eS = session.createEditSession(player)) { BlockVector3 blockPoint = pos.toBlockPoint(); BaseBlock applied = primary.apply(blockPoint); if (applied.getBlockType().getMaterial().isAir()) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java index f794882d7..be256f239 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java @@ -53,7 +53,6 @@ public class RecursivePickaxe implements BlockTool { editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop); -//<<<<<<< HEAD final int radius = (int) range; final BlockReplace replace = new BlockReplace(editSession, (editSession.nullBlock)); editSession.setMask((Mask) null); @@ -63,51 +62,6 @@ public class RecursivePickaxe implements BlockTool { editSession.flushQueue(); session.remember(editSession); -//======= -// try { -// recurse(server, editSession, world, clicked.toBlockPoint(), -// clicked.toBlockPoint(), range, initialType, new HashSet<>()); -// } catch (MaxChangedBlocksException e) { -// player.printError("Max blocks change limit reached."); -// } finally { -// session.remember(editSession); -// } -// } -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner - return true; } - -// private static void recurse(Platform server, EditSession editSession, World world, BlockVector3 pos, -// BlockVector3 origin, double size, BlockType initialType, Set visited) throws MaxChangedBlocksException { -// -// final double distanceSq = origin.distanceSq(pos); -// if (distanceSq > size*size || visited.contains(pos)) { -// return; -// } -// -// visited.add(pos); -// -// if (editSession.getBlock(pos).getBlockType() != initialType) { -// return; -// } -// -// world.queueBlockBreakEffect(server, pos, initialType, distanceSq); -// -// editSession.setBlock(pos, BlockTypes.AIR.getDefaultState()); -// -// recurse(server, editSession, world, pos.add(1, 0, 0), -// origin, size, initialType, visited); -// recurse(server, editSession, world, pos.add(-1, 0, 0), -// origin, size, initialType, visited); -// recurse(server, editSession, world, pos.add(0, 0, 1), -// origin, size, initialType, visited); -// recurse(server, editSession, world, pos.add(0, 0, -1), -// origin, size, initialType, visited); -// recurse(server, editSession, world, pos.add(0, 1, 0), -// origin, size, initialType, visited); -// recurse(server, editSession, world, pos.add(0, -1, 0), -// origin, size, initialType, visited); -// } - } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java index 9ac871ad3..2d865550b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/SinglePickaxe.java @@ -50,24 +50,12 @@ public class SinglePickaxe implements BlockTool { && !player.canDestroyBedrock()) { return true; } - final EditSession editSession = session.createEditSession(player); - try { + + try (EditSession editSession = session.createEditSession(player)) { editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop); editSession.setBlock(blockPoint, BlockTypes.AIR.getDefaultState()); - } catch (MaxChangedBlocksException e) { - player.printError("Max blocks change limit reached."); - } - - try { - if (editSession.setBlock(clicked.getBlockX(), clicked.getBlockY(), clicked.getBlockZ(), EditSession.nullBlock)) { - // TODO FIXME play effect -// world.playEffect(clicked, 2001, blockType); - } - } finally { - editSession.flushQueue(); session.remember(editSession); } - return true; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java index 41353b0ad..2eafbb4d5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java @@ -48,16 +48,15 @@ public class TreePlanter implements BlockTool { @Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { - EditSession editSession = session.createEditSession(player); - - try { + try (EditSession editSession = session.createEditSession(player)) { boolean successful = false; - for (int i = 0; i < 10; i++) { - if (treeType.generate(editSession, clicked.add(0, 1, 0).toBlockPoint())) { - successful = true; - break; - } + + for (int i = 0; i < 10; i++) { + if (treeType.generate(editSession, clicked.add(0, 1, 0).toBlockPoint())) { + successful = true; + break; } + } if (!successful) { player.printError("A tree can't go there."); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java index cfebeaf17..12a663ed3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java @@ -21,10 +21,10 @@ package com.sk89q.worldedit.command.tool.brush; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.world.block.BlockTypes; public class CylinderBrush implements Brush { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java index 2c67b3fdc..aaafefdc7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java @@ -21,12 +21,14 @@ package com.sk89q.worldedit.command.tool.brush; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; - -import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockTypes; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public class GravityBrush implements Brush { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java index 54247c107..ed7b23d55 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java @@ -24,6 +24,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockTypes; public class HollowCylinderBrush implements Brush { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowSphereBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowSphereBrush.java index 9763a621a..e76173174 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowSphereBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowSphereBrush.java @@ -24,6 +24,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockTypes; public class HollowSphereBrush implements Brush { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/OperationFactoryBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/OperationFactoryBrush.java index 6a323f14b..1d7c5e7ce 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/OperationFactoryBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/OperationFactoryBrush.java @@ -20,6 +20,7 @@ package com.sk89q.worldedit.command.tool.brush; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.function.Contextual; import com.sk89q.worldedit.function.EditContext; @@ -33,10 +34,16 @@ public class OperationFactoryBrush implements Brush { private final Contextual operationFactory; private final RegionFactory regionFactory; + private final LocalSession session; public OperationFactoryBrush(Contextual operationFactory, RegionFactory regionFactory) { + this(operationFactory, regionFactory, null); + } + + public OperationFactoryBrush(Contextual operationFactory, RegionFactory regionFactory, LocalSession session) { this.operationFactory = operationFactory; this.regionFactory = regionFactory; + this.session = session; } @Override @@ -45,6 +52,7 @@ public class OperationFactoryBrush implements Brush { context.setDestination(editSession); context.setRegion(regionFactory.createCenteredAt(position, size)); context.setFill(pattern); + context.setSession(session); Operation operation = operationFactory.createFromContext(context); Operations.completeLegacy(operation); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SmoothBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SmoothBrush.java index a2c2750b6..66a73112b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SmoothBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SmoothBrush.java @@ -21,9 +21,10 @@ package com.sk89q.worldedit.command.tool.brush; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; +import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; -import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.convolution.GaussianKernel; import com.sk89q.worldedit.math.convolution.HeightMap; import com.sk89q.worldedit.math.convolution.HeightMapFilter; @@ -31,12 +32,20 @@ import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; +import javax.annotation.Nullable; + public class SmoothBrush implements Brush { + private final Mask mask; private int iterations; public SmoothBrush(int iterations) { + this(iterations, null); + } + + public SmoothBrush(int iterations, @Nullable Mask mask) { this.iterations = iterations; + this.mask = mask; } @Override @@ -45,7 +54,7 @@ public class SmoothBrush implements Brush { Location min = new Location(editSession.getWorld(), posDouble.subtract(size, size, size)); BlockVector3 max = posDouble.add(size, size + 10, size).toBlockPoint(); Region region = new CuboidRegion(editSession.getWorld(), min.toBlockPoint(), max); - HeightMap heightMap = new HeightMap(editSession, region); + HeightMap heightMap = new HeightMap(editSession, region, mask); HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0)); heightMap.applyFilter(filter, iterations); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java index 7c38382de..d8028f2ae 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java @@ -21,9 +21,9 @@ package com.sk89q.worldedit.command.tool.brush; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockTypes; public class SphereBrush implements Brush { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/EditSessionEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/EditSessionEvent.java index e6364bbec..c58ae7ce1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/EditSessionEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/EditSessionEvent.java @@ -20,9 +20,6 @@ package com.sk89q.worldedit.event.extent; import com.sk89q.worldedit.EditSession; - -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.event.Cancellable; import com.sk89q.worldedit.event.Event; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.Extent; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java index 8ee07c223..235f0ae3e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java @@ -21,7 +21,6 @@ package com.sk89q.worldedit.extension.factory; import com.sk89q.util.StringUtil; import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.extension.factory.parser.DefaultBlockParser; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java index 0f9f04fde..cc326cc46 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java @@ -55,14 +55,7 @@ public final class MaskFactory extends AbstractFactory { */ public MaskFactory(WorldEdit worldEdit) { super(worldEdit); - - register(new ExistingMaskParser(worldEdit)); - register(new SolidMaskParser(worldEdit)); - register(new LazyRegionMaskParser(worldEdit)); - register(new RegionMaskParser(worldEdit)); register(new BlockCategoryMaskParser(worldEdit)); - register(new NoiseMaskParser(worldEdit)); - register(new NegateMaskParser(worldEdit)); register(new DefaultMaskParser(worldEdit)); } @@ -90,7 +83,7 @@ public final class MaskFactory extends AbstractFactory { case 1: return masks.get(0); default: - return new MaskIntersection(masks); + return new MaskIntersection(masks).optimize(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/PatternFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/PatternFactory.java index 7b93c0d61..c9d43f011 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/PatternFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/PatternFactory.java @@ -22,9 +22,10 @@ package com.sk89q.worldedit.extension.factory; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.factory.parser.pattern.BlockCategoryPatternParser; import com.sk89q.worldedit.extension.factory.parser.pattern.ClipboardPatternParser; -import com.sk89q.worldedit.extension.factory.parser.pattern.DefaultPatternParser; import com.sk89q.worldedit.extension.factory.parser.pattern.RandomPatternParser; +import com.sk89q.worldedit.extension.factory.parser.pattern.RandomStatePatternParser; import com.sk89q.worldedit.extension.factory.parser.pattern.SingleBlockPatternParser; +import com.sk89q.worldedit.extension.factory.parser.pattern.TypeOrStateApplyingPatternParser; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.internal.registry.AbstractFactory; @@ -44,10 +45,6 @@ public final class PatternFactory extends AbstractFactory { */ public PatternFactory(WorldEdit worldEdit) { super(worldEdit); - -// register(new ClipboardPatternParser(worldEdit)); -// register(new SingleBlockPatternParser(worldEdit)); -// register(new RandomPatternParser(worldEdit)); register(new BlockCategoryPatternParser(worldEdit)); register(new DefaultPatternParser(worldEdit)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java index 904c67d95..0f346352c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java @@ -24,12 +24,6 @@ import com.boydti.fawe.jnbt.JSON2NBT; import com.boydti.fawe.jnbt.NBTException; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.StringMan; -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.worldedit.*; - -import com.sk89q.worldedit.extension.platform.Platform; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.NotABlockException; import com.sk89q.worldedit.WorldEdit; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BiomeMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BiomeMaskParser.java new file mode 100644 index 000000000..11b8bb54c --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BiomeMaskParser.java @@ -0,0 +1,65 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.extension.factory.parser.mask; + +import com.google.common.base.Splitter; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.input.InputParseException; +import com.sk89q.worldedit.extension.input.ParserContext; +import com.sk89q.worldedit.extension.platform.Capability; +import com.sk89q.worldedit.function.mask.BiomeMask2D; +import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.function.mask.Masks; +import com.sk89q.worldedit.internal.registry.InputParser; +import com.sk89q.worldedit.session.request.RequestExtent; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.biome.Biomes; +import com.sk89q.worldedit.world.registry.BiomeRegistry; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +public class BiomeMaskParser extends InputParser { + + public BiomeMaskParser(WorldEdit worldEdit) { + super(worldEdit); + } + + @Override + public Mask parseFromInput(String input, ParserContext context) throws InputParseException { + if (!input.startsWith("$")) { + return null; + } + + Set biomes = new HashSet<>(); + BiomeRegistry biomeRegistry = worldEdit.getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); + Collection knownBiomes = BiomeType.REGISTRY.values(); + for (String biomeName : Splitter.on(",").split(input.substring(1))) { + BiomeType biome = Biomes.findBiomeByName(knownBiomes, biomeName, biomeRegistry); + if (biome == null) { + throw new InputParseException("Unknown biome '" + biomeName + '\''); + } + biomes.add(biome); + } + + return Masks.asMask(new BiomeMask2D(new RequestExtent(), biomes)); + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockCategoryMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockCategoryMaskParser.java index 478ba22e6..ec3c65b5c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockCategoryMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockCategoryMaskParser.java @@ -22,12 +22,10 @@ package com.sk89q.worldedit.extension.factory.parser.mask; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.BlockCategoryMask; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.internal.registry.InputParser; -import com.sk89q.worldedit.session.request.Request; -import com.sk89q.worldedit.world.block.BlockCategories; +import com.sk89q.worldedit.session.request.RequestExtent; import com.sk89q.worldedit.world.block.BlockCategory; public class BlockCategoryMaskParser extends InputParser { @@ -38,18 +36,16 @@ public class BlockCategoryMaskParser extends InputParser { @Override public Mask parseFromInput(String input, ParserContext context) throws InputParseException { - if (input.startsWith("##")) { - Extent extent = Request.request().getEditSession(); - - // This means it's a tag mask. - BlockCategory category = BlockCategories.get(input.substring(2).toLowerCase()); - if (category == null) { - throw new InputParseException("Unrecognised tag '" + input.substring(2) + '\''); - } else { - return new BlockCategoryMask(extent, category); - } + if (!input.startsWith("##")) { + return null; } - return null; + // This means it's a tag mask. + BlockCategory category = BlockCategory.REGISTRY.get(input.substring(2).toLowerCase()); + if (category == null) { + throw new InputParseException("Unrecognised tag '" + input.substring(2) + '\''); + } else { + return new BlockCategoryMask(new RequestExtent(), category); + } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockStateMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockStateMaskParser.java new file mode 100644 index 000000000..0a2bd6e56 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlockStateMaskParser.java @@ -0,0 +1,53 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.extension.factory.parser.mask; + +import com.google.common.base.Splitter; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.input.InputParseException; +import com.sk89q.worldedit.extension.input.ParserContext; +import com.sk89q.worldedit.function.mask.BlockStateMask; +import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.internal.registry.InputParser; +import com.sk89q.worldedit.session.request.RequestExtent; + +public class BlockStateMaskParser extends InputParser { + + public BlockStateMaskParser(WorldEdit worldEdit) { + super(worldEdit); + } + + @Override + public Mask parseFromInput(String input, ParserContext context) throws InputParseException { + if (!(input.startsWith("^[") || input.startsWith("^=[")) || !input.endsWith("]")) { + return null; + } + + boolean strict = input.charAt(1) == '='; + String states = input.substring(2 + (strict ? 1 : 0), input.length() - 1); + try { + return new BlockStateMask(new RequestExtent(), + Splitter.on(',').omitEmptyStrings().trimResults().withKeyValueSeparator('=').split(states), + strict); + } catch (Exception e) { + throw new InputParseException("Invalid states.", e); + } + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlocksMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlocksMaskParser.java new file mode 100644 index 000000000..e67a7e8b1 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlocksMaskParser.java @@ -0,0 +1,59 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.extension.factory.parser.mask; + +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.input.InputParseException; +import com.sk89q.worldedit.extension.input.NoMatchException; +import com.sk89q.worldedit.extension.input.ParserContext; +import com.sk89q.worldedit.function.mask.BlockMask; +import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.internal.registry.InputParser; +import com.sk89q.worldedit.session.request.RequestExtent; +import com.sk89q.worldedit.world.block.BaseBlock; + +import java.util.Set; + +/** + * Parses mask input strings. + */ +public class BlocksMaskParser extends InputParser { + + public BlocksMaskParser(WorldEdit worldEdit) { + super(worldEdit); + } + + @Override + public Mask parseFromInput(String component, ParserContext context) throws InputParseException { + ParserContext tempContext = new ParserContext(context); + tempContext.setRestricted(false); + tempContext.setPreferringWildcard(true); + try { + Set holders = worldEdit.getBlockFactory().parseFromListInput(component, tempContext); + if (holders.isEmpty()) { + return null; + } + return new BlockMask(new RequestExtent(), holders); + } catch (NoMatchException e) { + return null; + } + } + +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ExistingMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ExistingMaskParser.java index a1dea6f48..5249d47ad 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ExistingMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ExistingMaskParser.java @@ -21,13 +21,11 @@ package com.sk89q.worldedit.extension.factory.parser.mask; import com.google.common.collect.Lists; import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.internal.registry.SimpleInputParser; -import com.sk89q.worldedit.session.request.Request; +import com.sk89q.worldedit.session.request.RequestExtent; import java.util.List; @@ -43,9 +41,7 @@ public class ExistingMaskParser extends SimpleInputParser { } @Override - public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException { - Extent extent = Request.request().getEditSession(); - - return new ExistingBlockMask(extent); + public Mask parseFromSimpleInput(String input, ParserContext context) { + return new ExistingBlockMask(new RequestExtent()); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ExpressionMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ExpressionMaskParser.java new file mode 100644 index 000000000..4e254109c --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ExpressionMaskParser.java @@ -0,0 +1,65 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.extension.factory.parser.mask; + +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.input.InputParseException; +import com.sk89q.worldedit.extension.input.ParserContext; +import com.sk89q.worldedit.function.mask.ExpressionMask; +import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.internal.expression.Expression; +import com.sk89q.worldedit.internal.expression.ExpressionException; +import com.sk89q.worldedit.internal.registry.InputParser; +import com.sk89q.worldedit.math.Vector3; +import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment; +import com.sk89q.worldedit.session.SessionOwner; +import com.sk89q.worldedit.session.request.Request; +import com.sk89q.worldedit.session.request.RequestExtent; + +import java.util.function.IntSupplier; + +public class ExpressionMaskParser extends InputParser { + + public ExpressionMaskParser(WorldEdit worldEdit) { + super(worldEdit); + } + + @Override + public Mask parseFromInput(String input, ParserContext context) throws InputParseException { + if (!input.startsWith("=")) { + return null; + } + + try { + Expression exp = Expression.compile(input.substring(1), "x", "y", "z"); + WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment( + new RequestExtent(), Vector3.ONE, Vector3.ZERO); + exp.setEnvironment(env); + if (context.getActor() instanceof SessionOwner) { + SessionOwner owner = (SessionOwner) context.getActor(); + IntSupplier timeout = () -> WorldEdit.getInstance().getSessionManager().get(owner).getTimeout(); + return new ExpressionMask(exp, timeout); + } + return new ExpressionMask(exp); + } catch (ExpressionException e) { + throw new InputParseException("Invalid expression: " + e.getMessage()); + } + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/OffsetMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/OffsetMaskParser.java new file mode 100644 index 000000000..ab4882e00 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/OffsetMaskParser.java @@ -0,0 +1,56 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.extension.factory.parser.mask; + +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.input.InputParseException; +import com.sk89q.worldedit.extension.input.ParserContext; +import com.sk89q.worldedit.function.mask.ExistingBlockMask; +import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.function.mask.MaskIntersection; +import com.sk89q.worldedit.function.mask.Masks; +import com.sk89q.worldedit.function.mask.OffsetMask; +import com.sk89q.worldedit.internal.registry.InputParser; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.session.request.RequestExtent; + +public class OffsetMaskParser extends InputParser { + + public OffsetMaskParser(WorldEdit worldEdit) { + super(worldEdit); + } + + @Override + public Mask parseFromInput(String input, ParserContext context) throws InputParseException { + final char firstChar = input.charAt(0); + if (firstChar != '>' && firstChar != '<') { + return null; + } + + Mask submask; + if (input.length() > 1) { + submask = worldEdit.getMaskFactory().parseFromInput(input.substring(1), context); + } else { + submask = new ExistingBlockMask(new RequestExtent()); + } + OffsetMask offsetMask = new OffsetMask(submask, BlockVector3.at(0, firstChar == '>' ? -1 : 1, 0)); + return new MaskIntersection(offsetMask, Masks.negate(submask)); + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/SolidMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/SolidMaskParser.java index 84df2fec8..44e2f07a2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/SolidMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/SolidMaskParser.java @@ -21,13 +21,11 @@ package com.sk89q.worldedit.extension.factory.parser.mask; import com.google.common.collect.Lists; import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.SolidBlockMask; import com.sk89q.worldedit.internal.registry.SimpleInputParser; -import com.sk89q.worldedit.session.request.Request; +import com.sk89q.worldedit.session.request.RequestExtent; import java.util.List; @@ -43,9 +41,7 @@ public class SolidMaskParser extends SimpleInputParser { } @Override - public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException { - Extent extent = Request.request().getEditSession(); - - return new SolidBlockMask(extent); + public Mask parseFromSimpleInput(String input, ParserContext context) { + return new SolidBlockMask(new RequestExtent()); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/BlockCategoryPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/BlockCategoryPatternParser.java index 3b89b3cef..b2e9672f5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/BlockCategoryPatternParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/BlockCategoryPatternParser.java @@ -26,11 +26,11 @@ import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.RandomPattern; import com.sk89q.worldedit.internal.registry.InputParser; -import com.sk89q.worldedit.world.block.BlockCategories; import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockType; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; public class BlockCategoryPatternParser extends InputParser { @@ -46,17 +46,34 @@ public class BlockCategoryPatternParser extends InputParser { @Override public Pattern parseFromInput(String input, ParserContext context) throws InputParseException { - if(!input.startsWith("##")) { + if (!input.startsWith("##")) { return null; } - BlockCategory category = BlockCategories.get(input.substring(2).toLowerCase()); + String tag = input.substring(2).toLowerCase(); + boolean anyState = false; + if (tag.startsWith("*")) { + tag = tag.substring(1); + anyState = true; + } + + BlockCategory category = BlockCategory.REGISTRY.get(tag); if (category == null) { - throw new InputParseException("Unknown block tag: " + input.substring(2)); + throw new InputParseException("Unknown block tag: " + tag); } RandomPattern randomPattern = new RandomPattern(); - for (BlockType blockType : category.getAll()) { - randomPattern.add(new BlockPattern(blockType.getDefaultState()), 1.0 / category.getAll().size()); + Set blocks = category.getAll(); + if (blocks.isEmpty()) { + throw new InputParseException("Block tag " + category.getId() + " had no blocks!"); + } + + if (anyState) { + blocks.stream().flatMap(blockType -> blockType.getAllStates().stream()).forEach(state -> + randomPattern.add(new BlockPattern(state), 1.0)); + } else { + for (BlockType blockType : blocks) { + randomPattern.add(new BlockPattern(blockType.getDefaultState()), 1.0); + } } return randomPattern; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/ClipboardPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/ClipboardPatternParser.java index 720bf8956..1aee6c2a6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/ClipboardPatternParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/ClipboardPatternParser.java @@ -19,189 +19,68 @@ package com.sk89q.worldedit.extension.factory.parser.pattern; -import com.boydti.fawe.command.FaweParser; -import com.boydti.fawe.command.SuggestInputParseException; -import com.boydti.fawe.config.BBC; -import com.boydti.fawe.object.random.TrueRandom; -import com.boydti.fawe.util.StringMan; -import com.sk89q.minecraft.util.commands.CommandException; -import com.sk89q.minecraft.util.commands.CommandLocals; - import com.google.common.collect.Lists; import com.sk89q.worldedit.EmptyClipboardException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.command.PatternCommands; import com.sk89q.worldedit.extension.input.InputParseException; -import com.sk89q.worldedit.extension.input.NoMatchException; import com.sk89q.worldedit.extension.input.ParserContext; -import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.function.pattern.ClipboardPattern; import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.function.pattern.RandomPattern; -import com.sk89q.worldedit.internal.command.ActorAuthorizer; -import com.sk89q.worldedit.internal.command.WorldEditBinding; -import com.sk89q.worldedit.internal.expression.Expression; -import com.sk89q.worldedit.internal.expression.ExpressionException; -import com.sk89q.worldedit.util.command.Dispatcher; -import com.sk89q.worldedit.util.command.SimpleDispatcher; -import com.sk89q.worldedit.util.command.parametric.ParametricBuilder; -import com.sk89q.worldedit.world.block.BlockTypes; +import com.sk89q.worldedit.internal.registry.InputParser; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.session.ClipboardHolder; -import java.util.ArrayList; import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; -public class ClipboardPatternParser extends FaweParser { - private final Dispatcher dispatcher; +public class ClipboardPatternParser extends InputParser { public ClipboardPatternParser(WorldEdit worldEdit) { super(worldEdit); - this.dispatcher = new SimpleDispatcher(); - this.register(new PatternCommands(worldEdit)); } @Override - public Dispatcher getDispatcher() { - return dispatcher; - } - - public void register(Object clazz) { - ParametricBuilder builder = new ParametricBuilder(); - builder.setAuthorizer(new ActorAuthorizer()); - builder.addBinding(new WorldEditBinding(worldEdit)); - builder.registerMethodsAsCommands(dispatcher, clazz); + public List getSuggestions() { + return Lists.newArrayList("#clipboard", "#copy"); } @Override public Pattern parseFromInput(String input, ParserContext context) throws InputParseException { - if (input.isEmpty()) { - throw new SuggestInputParseException("No input provided", "", () -> Stream.concat(Stream.of("#", ",", "&"), BlockTypes.getNameSpaces().stream().map(n -> n + ":")).collect(Collectors.toList())); - } - List chances = new ArrayList<>(); - List patterns = new ArrayList<>(); - final CommandLocals locals = new CommandLocals(); - Actor actor = context != null ? context.getActor() : null; - if (actor != null) { - locals.put(Actor.class, actor); - } - try { - for (Map.Entry> entry : parse(input)) { - ParseEntry pe = entry.getKey(); - final String command = pe.input; - String full = pe.full; - Pattern pattern = null; - double chance = 1; - if (command.isEmpty()) { - pattern = parseFromInput(StringMan.join(entry.getValue(), ','), context); - } else if (dispatcher.get(command) == null) { - // Legacy patterns - char char0 = command.charAt(0); - boolean charMask = input.length() > 1 && input.charAt(1) != '['; - if (charMask && input.charAt(0) == '=') { - return parseFromInput(char0 + "[" + input.substring(1) + "]", context); - } - if (char0 == '#') { - throw new SuggestInputParseException(new NoMatchException("Unknown pattern: " + full + ", See: //patterns"), full, - () -> { - if (full.length() == 1) return new ArrayList<>(dispatcher.getPrimaryAliases()); - return dispatcher.getAliases().stream().filter( - s -> s.startsWith(command.toLowerCase()) - ).collect(Collectors.toList()); - } - ); - } - - - if (charMask) { - switch (char0) { - case '$': { - String value = command.substring(1) + ((entry.getValue().isEmpty()) ? "" : "[" + StringMan.join(entry.getValue(), "][") + "]"); - if (value.contains(":")) { - if (value.charAt(0) == ':') value.replaceFirst(":", ""); - value = value.replaceAll(":", "]["); - } - pattern = parseFromInput(char0 + "[" + value + "]", context); - break; - } - } - } - if (pattern == null) { - if (command.startsWith("[")) { - int end = command.lastIndexOf(']'); - pattern = parseFromInput(command.substring(1, end == -1 ? command.length() : end), context); - } else { - int percentIndex = command.indexOf('%'); - if (percentIndex != -1) { // Legacy percent pattern - chance = Expression.compile(command.substring(0, percentIndex)).evaluate(); - String value = command.substring(percentIndex + 1); - if (!entry.getValue().isEmpty()) { - if (!value.isEmpty()) value += " "; - value += StringMan.join(entry.getValue(), " "); - } - pattern = parseFromInput(value, context); - } else { // legacy block pattern - try { - pattern = worldEdit.getBlockFactory().parseFromInput(pe.full, context); - } catch (NoMatchException e) { - throw new NoMatchException(e.getMessage() + " See: //patterns"); - } - } - } - } - } else { - List args = entry.getValue(); - String cmdArgs = ((args.isEmpty()) ? "" : " " + StringMan.join(args, " ")); - try { - pattern = (Pattern) dispatcher.call(command + cmdArgs, locals, new String[0]); - } catch (SuggestInputParseException rethrow) { - throw rethrow; - } catch (Throwable e) { - throw SuggestInputParseException.of(e, full, () -> { - try { - List suggestions = dispatcher.get(command).getCallable().getSuggestions(cmdArgs, locals); - if (suggestions.size() <= 2) { - for (int i = 0; i < suggestions.size(); i++) { - String suggestion = suggestions.get(i); - if (suggestion.indexOf(' ') != 0) { - String[] split = suggestion.split(" "); - suggestion = BBC.color("[" + StringMan.join(split, "][") + "]"); - suggestions.set(i, suggestion); - } - } - } - return suggestions; - } catch (CommandException e1) { - throw new InputParseException(e1.getMessage()); - } catch (Throwable e2) { - e2.printStackTrace(); - throw new InputParseException(e2.getMessage()); - } - }); - } - } - if (pattern != null) { - patterns.add(pattern); - chances.add(chance); - } - } - } catch (InputParseException rethrow) { - throw rethrow; - } catch (Throwable e) { - e.printStackTrace(); - throw new InputParseException(e.getMessage(), e); - } - if (patterns.isEmpty()) { + String[] offsetParts = input.split("@", 2); + if (!offsetParts[0].equalsIgnoreCase("#clipboard") && !offsetParts[0].equalsIgnoreCase("#copy")) { return null; - } else if (patterns.size() == 1) { - return patterns.get(0); + } + LocalSession session = context.requireSession(); + + BlockVector3 offset = BlockVector3.ZERO; + if (offsetParts.length == 2) { + String coords = offsetParts[1]; + if (coords.length() < 7 // min length of `[x,y,z]` + || coords.charAt(0) != '[' || coords.charAt(coords.length() - 1) != ']') { + throw new InputParseException("Offset specified with @ but no offset given. Use '#copy@[x,y,z]'."); + } + String[] offsetSplit = coords.substring(1, coords.length() - 1).split(","); + if (offsetSplit.length != 3) { + throw new InputParseException("Clipboard offset needs x,y,z coordinates."); + } + offset = BlockVector3.at( + Integer.valueOf(offsetSplit[0]), + Integer.valueOf(offsetSplit[1]), + Integer.valueOf(offsetSplit[2]) + ); + } + + if (session != null) { + try { + ClipboardHolder holder = session.getClipboard(); + Clipboard clipboard = holder.getClipboard(); + return new ClipboardPattern(clipboard, offset); + } catch (EmptyClipboardException e) { + throw new InputParseException("To use #clipboard, please first copy something to your clipboard"); + } } else { - RandomPattern random = new RandomPattern(new TrueRandom()); - for (int i = 0; i < patterns.size(); i++) { - random.add(patterns.get(i), chances.get(i)); - } - return random; - } + throw new InputParseException("No session is available, so no clipboard is available"); + } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomPatternParser.java index f9a05c9e3..a836c1615 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomPatternParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomPatternParser.java @@ -24,11 +24,11 @@ import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.factory.BlockFactory; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; -import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.RandomPattern; import com.sk89q.worldedit.internal.registry.InputParser; -import com.sk89q.worldedit.world.block.BaseBlock; + +import java.util.List; public class RandomPatternParser extends InputParser { @@ -38,14 +38,16 @@ public class RandomPatternParser extends InputParser { @Override public Pattern parseFromInput(String input, ParserContext context) throws InputParseException { - BlockFactory blockRegistry = worldEdit.getBlockFactory(); RandomPattern randomPattern = new RandomPattern(); String[] splits = input.split(","); - for (String token : StringUtil.parseListInQuotes(splits, ',', '[', ']')) { - BaseBlock block; - + List patterns = StringUtil.parseListInQuotes(splits, ',', '[', ']'); + if (patterns.size() == 1) { + return null; // let a 'single'-pattern parser handle it + } + for (String token : patterns) { double chance; + Pattern innerPattern; // Parse special percentage syntax if (token.matches("[0-9]+(\\.[0-9]*)?%.*")) { @@ -55,14 +57,14 @@ public class RandomPatternParser extends InputParser { throw new InputParseException("Missing the type after the % symbol for '" + input + "'"); } else { chance = Double.parseDouble(p[0]); - block = blockRegistry.parseFromInput(p[1], context); + innerPattern = worldEdit.getPatternFactory().parseFromInput(p[1], context); } } else { chance = 1; - block = blockRegistry.parseFromInput(token, context); + innerPattern = worldEdit.getPatternFactory().parseFromInput(token, context); } - randomPattern.add(block, chance); + randomPattern.add(innerPattern, chance); } return randomPattern; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomStatePatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomStatePatternParser.java new file mode 100644 index 000000000..27423f59e --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomStatePatternParser.java @@ -0,0 +1,56 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.extension.factory.parser.pattern; + +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.input.InputParseException; +import com.sk89q.worldedit.extension.input.ParserContext; +import com.sk89q.worldedit.function.pattern.BlockPattern; +import com.sk89q.worldedit.function.pattern.Pattern; +import com.sk89q.worldedit.function.pattern.RandomStatePattern; +import com.sk89q.worldedit.internal.registry.InputParser; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.FuzzyBlockState; + +public class RandomStatePatternParser extends InputParser { + public RandomStatePatternParser(WorldEdit worldEdit) { + super(worldEdit); + } + + @Override + public Pattern parseFromInput(String input, ParserContext context) throws InputParseException { + if (!input.startsWith("*")) { + return null; + } + + boolean wasFuzzy = context.isPreferringWildcard(); + context.setPreferringWildcard(true); + BaseBlock block = worldEdit.getBlockFactory().parseFromInput(input.substring(1), context); + context.setPreferringWildcard(wasFuzzy); + if (block.getStates().size() == block.getBlockType().getPropertyMap().size()) { + // they requested random with *, but didn't leave any states empty - simplify + return new BlockPattern(block); + } else if (block.toImmutableState() instanceof FuzzyBlockState) { + return new RandomStatePattern((FuzzyBlockState) block.toImmutableState()); + } else { + return null; // only should happen if parseLogic changes + } + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SingleBlockPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SingleBlockPatternParser.java index 960983780..e71530a2e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SingleBlockPatternParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SingleBlockPatternParser.java @@ -34,13 +34,7 @@ public class SingleBlockPatternParser extends InputParser { @Override public Pattern parseFromInput(String input, ParserContext context) throws InputParseException { - String[] items = input.split(","); - - if (items.length == 1) { - return new BlockPattern(worldEdit.getBlockFactory().parseFromInput(items[0], context)); - } else { - return null; - } + return new BlockPattern(worldEdit.getBlockFactory().parseFromInput(input, context)); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/TypeOrStateApplyingPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/TypeOrStateApplyingPatternParser.java new file mode 100644 index 000000000..db0ee8c38 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/TypeOrStateApplyingPatternParser.java @@ -0,0 +1,79 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.extension.factory.parser.pattern; + +import com.google.common.base.Splitter; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.input.InputParseException; +import com.sk89q.worldedit.extension.input.ParserContext; +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.extent.buffer.ExtentBuffer; +import com.sk89q.worldedit.function.pattern.ExtentBufferedCompositePattern; +import com.sk89q.worldedit.function.pattern.Pattern; +import com.sk89q.worldedit.function.pattern.StateApplyingPattern; +import com.sk89q.worldedit.function.pattern.TypeApplyingPattern; +import com.sk89q.worldedit.internal.registry.InputParser; +import com.sk89q.worldedit.world.block.BlockState; + +import java.util.Map; +import java.util.Set; + + +public class TypeOrStateApplyingPatternParser extends InputParser { + + public TypeOrStateApplyingPatternParser(WorldEdit worldEdit) { + super(worldEdit); + } + + @Override + public Pattern parseFromInput(String input, ParserContext context) throws InputParseException { + if (!input.startsWith("^")) { + return null; + } + Extent extent = context.requireExtent(); + input = input.substring(1); + + String[] parts = input.split("\\[", 2); + String type = parts[0]; + + if (parts.length == 1) { + return new TypeApplyingPattern(extent, + worldEdit.getBlockFactory().parseFromInput(type, context).getBlockType().getDefaultState()); + } else { + // states given + if (!parts[1].endsWith("]")) throw new InputParseException("Invalid state format."); + Map statesToSet = Splitter.on(',') + .omitEmptyStrings().trimResults().withKeyValueSeparator('=') + .split(parts[1].substring(0, parts[1].length() - 1)); + if (type.isEmpty()) { + return new StateApplyingPattern(extent, statesToSet); + } else { + Extent buffer = new ExtentBuffer(extent); + Pattern typeApplier = new TypeApplyingPattern(buffer, + worldEdit.getBlockFactory().parseFromInput(type, context).getBlockType().getDefaultState()); + Pattern stateApplier = new StateApplyingPattern(buffer, statesToSet); + return new ExtentBufferedCompositePattern(buffer, typeApplier, stateApplier); + } + } + } + +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index 66fb43d85..8992ac465 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -19,8 +19,8 @@ package com.sk89q.worldedit.extension.platform; +import com.sk89q.worldedit.NotABlockException; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.internal.cui.CUIEvent; @@ -31,6 +31,7 @@ import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.TargetBlock; import com.sk89q.worldedit.util.auth.AuthorizationException; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; @@ -118,7 +119,6 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { final BlockVector3 pos = BlockVector3.at(x, y - 2, z); final BlockStateHolder state = world.getBlock(pos); setPosition(Vector3.at(x + 0.5, y - 2 + BlockTypeUtil.centralTopLimit(state), z + 0.5)); -// setPosition(Vector3.at(x + 0.5, y - 2 + 1, z + 0.5)); } return; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java index 8ecbef23c..4a65ccd30 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java @@ -43,9 +43,10 @@ import com.sk89q.worldedit.command.composition.ApplyCommand; import com.sk89q.worldedit.command.composition.DeformCommand; import com.sk89q.worldedit.command.composition.PaintCommand; import com.sk89q.worldedit.command.composition.ShapedBrushCommand; -import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.event.platform.CommandEvent; import com.sk89q.worldedit.event.platform.CommandSuggestionEvent; +import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.factory.Deform; import com.sk89q.worldedit.function.factory.Deform.Mode; import com.sk89q.worldedit.internal.command.*; @@ -60,6 +61,9 @@ import com.sk89q.worldedit.util.command.parametric.*; import com.sk89q.worldedit.util.eventbus.Subscribe; import com.sk89q.worldedit.util.logging.DynamicStreamHandler; import com.sk89q.worldedit.util.logging.LogFormat; +import com.sk89q.worldedit.world.World; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.annotation.Nullable; import java.io.File; @@ -72,7 +76,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.function.Supplier; import java.util.logging.FileHandler; import java.util.logging.Level; -import java.util.logging.Logger; import java.util.regex.Pattern; import static com.google.common.base.Preconditions.checkNotNull; @@ -86,8 +89,9 @@ import static com.sk89q.worldedit.util.command.composition.LegacyCommandAdapter. public final class CommandManager { public static final Pattern COMMAND_CLEAN_PATTERN = Pattern.compile("^[/]+"); - private static final Logger log = Logger.getLogger(CommandManager.class.getCanonicalName()); - private static final Logger commandLog = Logger.getLogger(CommandManager.class.getCanonicalName() + ".CommandLog"); + private static final Logger log = LoggerFactory.getLogger(CommandManager.class); + private static final java.util.logging.Logger commandLog = + java.util.logging.Logger.getLogger(CommandManager.class.getCanonicalName() + ".CommandLog"); private static final Pattern numberFormatExceptionPattern = Pattern.compile("^For input string: \"(.*)\"$"); private final WorldEdit worldEdit; @@ -297,7 +301,7 @@ public final class CommandManager { } public void register(Platform platform) { - log.log(Level.FINE, "Registering commands with " + platform.getClass().getCanonicalName()); + log.info("Registering commands with " + platform.getClass().getCanonicalName()); this.platform = null; try { @@ -318,12 +322,12 @@ public final class CommandManager { File file = new File(config.getWorkingDirectory(), path); commandLog.setLevel(Level.ALL); - log.log(Level.INFO, "Logging WorldEdit commands to " + file.getAbsolutePath()); + log.info("Logging WorldEdit commands to " + file.getAbsolutePath()); try { dynamicHandler.setHandler(new FileHandler(file.getAbsolutePath(), true)); } catch (IOException e) { - log.log(Level.WARNING, "Could not use command log file " + path + ": " + e.getMessage()); + log.warn("Could not use command log file " + path + ": " + e.getMessage()); } } @@ -371,6 +375,13 @@ public final class CommandManager { actor = FakePlayer.wrap(actor.getName(), actor.getUniqueId(), actor); } final LocalSession session = worldEdit.getSessionManager().get(actor); + Request.request().setSession(session); + if (actor instanceof Entity) { + Extent extent = ((Entity) actor).getExtent(); + if (extent instanceof World) { + Request.request().setWorld(((World) extent)); + } + } LocalConfiguration config = worldEdit.getConfiguration(); final CommandLocals locals = new CommandLocals(); final FawePlayer fp = FawePlayer.wrap(actor); @@ -497,8 +508,8 @@ public final class CommandManager { if (time > 1000) { BBC.ACTION_COMPLETE.send(actor, (time / 1000d)); } - Request.reset(); } + Request.reset(); } return null; } @@ -552,7 +563,7 @@ public final class CommandManager { return dispatcher; } - public static Logger getLogger() { + public static java.util.logging.Logger getLogger() { return commandLog; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java index 38f4654cd..b0cd5c41d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java @@ -28,14 +28,10 @@ import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper; import com.boydti.fawe.wrappers.PlayerWrapper; import com.boydti.fawe.wrappers.WorldWrapper; -import com.sk89q.worldedit.command.tool.*; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.command.tool.BlockTool; -import com.sk89q.worldedit.command.tool.DoubleActionBlockTool; import com.sk89q.worldedit.command.tool.DoubleActionTraceTool; import com.sk89q.worldedit.command.tool.Tool; import com.sk89q.worldedit.command.tool.TraceTool; @@ -43,31 +39,29 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.platform.*; import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.session.request.Request; -import com.sk89q.worldedit.util.HandSide; -import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.eventbus.Subscribe; -import com.sk89q.worldedit.world.World; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.annotation.Nullable; -import java.util.*; -import java.util.Map.Entry; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.logging.Level; -import java.util.logging.Logger; - +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import static com.google.common.base.Preconditions.checkNotNull; /** * Manages registered {@link Platform}s for WorldEdit. Platforms are * implementations of WorldEdit. - *

*

This class is thread-safe.

*/ public class PlatformManager { - private static final Logger logger = Logger.getLogger(PlatformManager.class.getCanonicalName()); + private static final Logger logger = LoggerFactory.getLogger(PlatformManager.class); private final WorldEdit worldEdit; private final CommandManager commandManager; @@ -99,7 +93,7 @@ public class PlatformManager { public synchronized void register(Platform platform) { checkNotNull(platform); - logger.log(Level.FINE, "Got request to register " + platform.getClass() + " with WorldEdit [" + super.toString() + "]"); + logger.info("Got request to register " + platform.getClass() + " with WorldEdit [" + super.toString() + "]"); // Just add the platform to the list of platforms: we'll pick favorites // once all the platforms have been loaded @@ -108,7 +102,7 @@ public class PlatformManager { // Make sure that versions are in sync if (firstSeenVersion != null) { if (!firstSeenVersion.equals(platform.getVersion())) { - logger.log(Level.WARNING, "Multiple ports of WorldEdit are installed but they report different versions ({0} and {1}). " + + logger.warn("Multiple ports of WorldEdit are installed but they report different versions ({0} and {1}). " + "If these two versions are truly different, then you may run into unexpected crashes and errors.", new Object[]{firstSeenVersion, platform.getVersion()}); } @@ -131,7 +125,7 @@ public class PlatformManager { boolean removed = platforms.remove(platform); if (removed) { - logger.log(Level.FINE, "Unregistering " + platform.getClass().getCanonicalName() + " from WorldEdit"); + logger.info("Unregistering " + platform.getClass().getCanonicalName() + " from WorldEdit"); boolean choosePreferred = false; @@ -356,7 +350,6 @@ public class PlatformManager { return; } } -//<<<<<<< HEAD final Tool tool = session.getTool(playerActor); if (tool != null && tool instanceof DoubleActionBlockTool) { if (tool.canUse(playerActor)) { @@ -371,14 +364,6 @@ public class PlatformManager { event.setCancelled(true); return; } -//======= -// -// RegionSelector selector = session.getRegionSelector(player.getWorld()); -// -// BlockVector3 blockPoint = vector.toBlockPoint(); -// if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) { -// selector.explainPrimarySelection(actor, session, blockPoint); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } } else if (event.getType() == Interaction.OPEN) { if (session.isToolControlEnabled() && playerActor.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) { @@ -402,7 +387,6 @@ public class PlatformManager { return; } -//<<<<<<< HEAD final Tool tool = session.getTool(playerActor); if (tool != null && tool instanceof BlockTool) { if (tool.canUse(playerActor)) { @@ -423,25 +407,10 @@ public class PlatformManager { return; } } -//======= -// RegionSelector selector = session.getRegionSelector(player.getWorld()); -// BlockVector3 blockPoint = vector.toBlockPoint(); -// if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) { -// selector.explainSecondarySelection(actor, session, blockPoint); -// } -// -// event.setCancelled(true); -// return; -// } -// -// Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType()); -// if (tool instanceof BlockTool) { -// if (tool.canUse(player)) { -// ((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location); -// event.setCancelled(true); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } } + } finally { + Request.reset(); } } catch (Throwable e) { handleThrowable(e, actor); @@ -559,6 +528,8 @@ public class PlatformManager { player.printRaw(e.getClass().getName() + ": " + e.getMessage()); MainUtil.handleError(e); } + } finally { + Request.reset(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java index 1aa31fdd8..a366b42df 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java @@ -22,11 +22,9 @@ package com.sk89q.worldedit.extent; import com.boydti.fawe.jnbt.anvil.generator.GenBase; import com.boydti.fawe.jnbt.anvil.generator.Resource; import com.boydti.fawe.object.extent.LightingExtent; -import com.sk89q.worldedit.WorldEditException; - -import com.sk89q.worldedit.world.block.BlockState; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.world.block.BaseBlock; + +import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.function.mask.Mask; @@ -38,16 +36,13 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.registry.BundledBlockData; import java.util.List; import javax.annotation.Nullable; -/** - * A base class for {@link Extent}s that merely passes extents onto another. - */ public class AbstractDelegateExtent implements LightingExtent { private transient final Extent extent; @@ -126,10 +121,7 @@ public class AbstractDelegateExtent implements LightingExtent { @Override public BlockState getLazyBlock(int x, int y, int z) { -// mutable.mutX(x); -// mutable.mutY(y); -// mutable.mutZ(z); - return extent.getLazyBlock(BlockVector3.at(x, y, z)); + return extent.getLazyBlock(mutable.setComponents(x, y, z)); } @Override @@ -139,20 +131,22 @@ public class AbstractDelegateExtent implements LightingExtent { @Override public > boolean setBlock(int x, int y, int z, T block) throws WorldEditException { -// mutable.mutX(x); -// mutable.mutY(y); -// mutable.mutZ(z); - return setBlock(BlockVector3.at(x, y, z), block); + return setBlock(mutable.setComponents(x, y, z), block); + } + + public BlockState getBlock(BlockVector3 position) { + return extent.getBlock(position); + } + + @Override + public BaseBlock getFullBlock(BlockVector3 position) { + return extent.getFullBlock(position); } @Override public > boolean setBlock(BlockVector3 location, T block) throws WorldEditException { return extent.setBlock(location, block); } - - public BlockState getBlock(BlockVector3 position) { - return extent.getBlock(position); - } @Override @Nullable @@ -171,17 +165,17 @@ public class AbstractDelegateExtent implements LightingExtent { } @Override - public BaseBiome getBiome(BlockVector2 position) { + public BiomeType getBiome(BlockVector2 position) { return extent.getBiome(position); } @Override - public boolean setBiome(BlockVector2 position, BaseBiome biome) { + public boolean setBiome(BlockVector2 position, BiomeType biome) { return extent.setBiome(position, biome); } @Override - public boolean setBiome(int x, int y, int z, BaseBiome biome) { + public boolean setBiome(int x, int y, int z, BiomeType biome) { return extent.setBiome(x, y, z, biome); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java index a53638f3b..284cf044a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java @@ -25,7 +25,6 @@ import com.sk89q.worldedit.world.block.BlockState; import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.history.change.BiomeChange; @@ -37,9 +36,7 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; - -import javax.annotation.Nullable; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -69,15 +66,15 @@ public class ChangeSetExtent extends AbstractDelegateExtent { @Override public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { - BlockStateHolder previous = getBlock(location); + BaseBlock previous = getFullBlock(location); changeSet.add(new BlockChange(location, previous, block)); return super.setBlock(location, block); } @Override - public boolean setBiome(BlockVector2 position, BaseBiome biome) { - BaseBiome previous = getBiome(position); - changeSet.add(new BiomeChange(position, previous, new BaseBiome(biome))); + public boolean setBiome(BlockVector2 position, BiomeType biome) { + BiomeType previous = getBiome(position); + changeSet.add(new BiomeChange(position, previous, biome)); return super.setBiome(position, biome); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java index cca0e4075..0a5a951e0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java @@ -22,25 +22,12 @@ package com.sk89q.worldedit.extent; import com.boydti.fawe.jnbt.anvil.generator.*; import com.boydti.fawe.object.PseudoRandom; import com.boydti.fawe.object.clipboard.WorldCopyClipboard; -import com.sk89q.worldedit.*; - -import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; -import com.sk89q.worldedit.regions.CuboidRegion; -import com.sk89q.worldedit.util.Countable; -import com.sk89q.worldedit.world.block.*; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; -import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.function.operation.Operation; -import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.registry.state.PropertyGroup; -import com.sk89q.worldedit.session.ClipboardHolder; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockState; import javax.annotation.Nullable; @@ -134,7 +121,7 @@ public interface Extent extends InputExtent, OutputExtent { return setBlock(BlockVector3.at(x, y, z), state); } - default boolean setBiome(int x, int y, int z, BaseBiome biome) { + default boolean setBiome(int x, int y, int z, BiomeType biome) { return setBiome(BlockVector2.at(x, z), biome); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/InputExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/InputExtent.java index 34a0994fa..8ce3dc1fa 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/InputExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/InputExtent.java @@ -19,12 +19,12 @@ package com.sk89q.worldedit.extent; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.biome.BaseBiome; -import com.sk89q.worldedit.world.block.BlockType; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockState; /** * Provides the current state of blocks, entities, and so on. @@ -91,6 +91,6 @@ public interface InputExtent { * @param position the (x, z) location to check the biome at * @return the biome at the location */ - BaseBiome getBiome(BlockVector2 position); + BiomeType getBiome(BlockVector2 position); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java index 787073d21..4fd83e2da 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java @@ -25,8 +25,6 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.world.biome.BaseBiome; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -78,12 +76,12 @@ public class MaskingExtent extends AbstractDelegateExtent { } @Override - public boolean setBiome(BlockVector2 position, BaseBiome biome) { + public boolean setBiome(BlockVector2 position, BiomeType biome) { return mask.test(position.toBlockVector3()) && super.setBiome(position, biome); } @Override - public boolean setBiome(int x, int y, int z, BaseBiome biome) { + public boolean setBiome(int x, int y, int z, BiomeType biome) { return mask.test(BlockVector3.at(x, y, z)) && super.setBiome(x, y, z, biome); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java index 074bf9dff..ec4c276a7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java @@ -20,16 +20,6 @@ package com.sk89q.worldedit.extent; import com.sk89q.worldedit.WorldEditException; - -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.blocks.LazyBlock; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.entity.BaseEntity; -import com.sk89q.worldedit.entity.Entity; -import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.function.operation.Operation; @@ -37,8 +27,9 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.biome.BiomeTypes; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; @@ -53,8 +44,6 @@ import java.util.List; */ public class NullExtent implements Extent { - private final BlockVector3 nullPoint = BlockVector3.at(0, 0, 0); - public static final NullExtent INSTANCE = new NullExtent(); @Override @@ -93,29 +82,22 @@ public class NullExtent implements Extent { } @Override - public BaseBlock getFullBlock(BlockVector3 position) { return getBlock(position).toBaseBlock(); } - @Nullable @Override - public BaseBiome getBiome(BlockVector2 position) { - return null; + public BiomeType getBiome(BlockVector2 position) { + return BiomeTypes.THE_VOID; } @Override public > boolean setBlock(BlockVector3 position, B block) throws WorldEditException { return false; } - - @Override - public > boolean setBlock(int x, int y, int z, B block) throws WorldEditException { - return false; - } @Override - public boolean setBiome(BlockVector2 position, BaseBiome biome) { + public boolean setBiome(BlockVector2 position, BiomeType biome) { return false; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java index 18f7f1675..53351e0b0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java @@ -23,7 +23,7 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; import javax.annotation.Nullable; @@ -50,7 +50,7 @@ public interface OutputExtent { * @return true if the block was successfully set (return value may not be accurate) * @throws WorldEditException thrown on an error */ - > boolean setBlock(BlockVector3 position, T block) throws WorldEditException; + > boolean setBlock(BlockVector3 position, T block) throws WorldEditException; /** * Set the biome. @@ -59,7 +59,7 @@ public interface OutputExtent { * @param biome the biome to set to * @return true if the biome was successfully set (return value may not be accurate) */ - boolean setBiome(BlockVector2 position, BaseBiome biome); + boolean setBiome(BlockVector2 position, BiomeType biome); /** * Return an {@link Operation} that should be called to tie up loose ends diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ExtentBuffer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ExtentBuffer.java new file mode 100644 index 000000000..562f094e5 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ExtentBuffer.java @@ -0,0 +1,97 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.extent.buffer; + +import com.google.common.collect.Maps; +import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.extent.AbstractDelegateExtent; +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.function.mask.Masks; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockStateHolder; + +import java.util.Map; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Buffers changes to an {@link Extent} and allows retrieval of the changed blocks, + * without modifying the underlying extent. + */ +public class ExtentBuffer extends AbstractDelegateExtent { + + private final Map buffer = Maps.newHashMap(); + private final Mask mask; + + /** + * Create a new extent buffer that will buffer every change. + * + * @param delegate the delegate extent for {@link Extent#getBlock(BlockVector3)}, etc. calls + */ + public ExtentBuffer(Extent delegate) { + this(delegate, Masks.alwaysTrue()); + } + + /** + * Create a new extent buffer that will buffer changes that meet the criteria + * of the given mask. + * + * @param delegate the delegate extent for {@link Extent#getBlock(BlockVector3)}, etc. calls + * @param mask the mask + */ + public ExtentBuffer(Extent delegate, Mask mask) { + super(delegate); + checkNotNull(delegate); + checkNotNull(mask); + this.mask = mask; + } + + @Override + public BlockState getBlock(BlockVector3 position) { + if (mask.test(position)) { + return getOrDefault(position).toImmutableState(); + } + return super.getBlock(position); + } + + @Override + public BaseBlock getFullBlock(BlockVector3 position) { + if (mask.test(position)) { + return getOrDefault(position); + } + return super.getFullBlock(position); + } + + private BaseBlock getOrDefault(BlockVector3 position) { + return buffer.computeIfAbsent(position, (pos -> getExtent().getFullBlock(pos))); + } + + @Override + public > boolean setBlock(BlockVector3 location, T block) throws WorldEditException { + if (mask.test(location)) { + buffer.put(location, block.toBaseBlock()); + return true; + } + return false; + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java index 3c1ffa4f5..7b98adbd0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java @@ -40,7 +40,6 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.block.BlockStateHolder; import java.io.Closeable; @@ -138,7 +137,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable @Override public Region getRegion() { - return region.clone(); + return region; } public void setRegion(Region region) { @@ -209,20 +208,9 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable } @Override -//<<<<<<< HEAD public BlockState getLazyBlock(BlockVector3 position) { return getBlock(position); } -//======= -// public BaseBlock getFullBlock(BlockVector3 position) { -// if (region.contains(position)) { -// BlockVector3 v = position.subtract(region.getMinimumPoint()); -// BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()]; -// if (block != null) { -// return block.toBaseBlock(); -// } -// } -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner @Override public BaseBlock getFullBlock(BlockVector3 position) { @@ -262,17 +250,17 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable } @Override - public BaseBiome getBiome(BlockVector2 position) { + public BiomeType getBiome(BlockVector2 position) { int x = position.getBlockX() - mx; int z = position.getBlockZ() - mz; return IMP.getBiome(x, z); } @Override - public boolean setBiome(BlockVector2 position, BaseBiome biome) { + public boolean setBiome(BlockVector2 position, BiomeType biome) { int x = position.getBlockX() - mx; int z = position.getBlockZ() - mz; - IMP.setBiome(x, z, biome.getId()); + IMP.setBiome(x, z, biome); return true; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java index e2598b3f8..4336a16f3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java @@ -58,7 +58,7 @@ import java.util.regex.Pattern; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; public class ClipboardFormats { @@ -74,7 +74,7 @@ public class ClipboardFormats { ClipboardFormat old = aliasMap.put(lowKey, format); if (old != null) { aliasMap.put(lowKey, old); - WorldEdit.logger.warning(format.getClass().getName() + " cannot override existing alias '" + lowKey + "' used by " + old.getClass().getName()); + WorldEdit.logger.warn(format.getClass().getName() + " cannot override existing alias '" + lowKey + "' used by " + old.getClass().getName()); } } for (String ext : format.getFileExtensions()) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java index 94b67a3db..00e52e902 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.extent.clipboard.io; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.jnbt.ByteArrayTag; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.IntTag; @@ -46,14 +44,16 @@ import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityTypes; import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.storage.NBTConversions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; + +import static com.google.common.base.Preconditions.checkNotNull; /** * Reads schematic files that are compatible with MCEdit and other editors. @@ -67,7 +67,7 @@ public class MCEditSchematicReader extends NBTSchematicReader { // TODO Add a handler for skulls, flower pots, note blocks, etc. } - private static final Logger log = Logger.getLogger(MCEditSchematicReader.class.getCanonicalName()); + private static final Logger log = LoggerFactory.getLogger(MCEditSchematicReader.class); private final NBTInputStream inputStream; /** @@ -231,15 +231,15 @@ public class MCEditSchematicReader extends NBTSchematicReader { clipboard.setBlock(region.getMinimumPoint().add(pt), state); } } else { - log.warning("Unknown block when pasting schematic: " + blocks[index] + ":" + blockData[index] + ". Please report this issue."); + log.warn("Unknown block when pasting schematic: " + blocks[index] + ":" + blockData[index] + ". Please report this issue."); } } catch (WorldEditException e) { switch (failedBlockSets) { case 0: - log.log(Level.WARNING, "Failed to set block on a Clipboard", e); + log.warn("Failed to set block on a Clipboard", e); break; case 1: - log.log(Level.WARNING, "Failed to set block on a Clipboard (again) -- no more messages will be logged", e); + log.warn("Failed to set block on a Clipboard (again) -- no more messages will be logged", e); break; default: } @@ -254,9 +254,8 @@ public class MCEditSchematicReader extends NBTSchematicReader { // Entities // ==================================================================== - try { - List entityTags = requireTag(schematic, "Entities", ListTag.class).getValue(); - + List entityTags = getTag(schematic, "Entities", ListTag.class).getValue(); + if (entityTags != null) { for (Tag tag : entityTags) { if (tag instanceof CompoundTag) { CompoundTag compound = (CompoundTag) tag; @@ -269,12 +268,11 @@ public class MCEditSchematicReader extends NBTSchematicReader { BaseEntity state = new BaseEntity(entityType, compound); clipboard.createEntity(location, state); } else { - log.warning("Unknown entity when pasting schematic: " + id.toLowerCase()); + log.warn("Unknown entity when pasting schematic: " + id.toLowerCase()); } } } } - } catch (IOException ignored) { // No entities? No problem } return clipboard; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/NBTSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/NBTSchematicReader.java index 424dffcc6..12f1f1b41 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/NBTSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/NBTSchematicReader.java @@ -46,9 +46,7 @@ public abstract class NBTSchematicReader implements ClipboardReader { } @Nullable - protected static T getTag(CompoundTag tag, Class expected, String key) { - Map items = tag.getValue(); - + protected static T getTag(Map items, String key, Class expected) { if (!items.containsKey(key)) { return null; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java index a7661ed9b..1aa22a9e5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java @@ -86,7 +86,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { // If NBT Compat handlers are needed - add them here. } - private static final Logger log = Logger.getLogger(SpongeSchematicReader.class.getCanonicalName()); + private static final Logger log = LoggerFactory.getLogger(SpongeSchematicReader.class); private final NBTInputStream inputStream; /** @@ -108,12 +108,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { public Clipboard read(UUID uuid) throws IOException { return readVersion1(uuid); } -// private Clipboard readVersion1(Map schematic) throws IOException { -// BlockVector3 origin; -// Region region; -// -// Map metadata = requireTag(schematic, "Metadata", CompoundTag.class).getValue(); -// } + private int width, height, length; private int offsetX, offsetY, offsetZ; private char[] palette; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/ChunkBatchingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/ChunkBatchingExtent.java index 6a2686483..b8f6082c4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/ChunkBatchingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/ChunkBatchingExtent.java @@ -72,6 +72,10 @@ public class ChunkBatchingExtent extends AbstractDelegateExtent { this.enabled = enabled; } + public boolean commitRequired() { + return enabled; + } + @Override public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { if (!enabled) { @@ -84,7 +88,7 @@ public class ChunkBatchingExtent extends AbstractDelegateExtent { @Override protected Operation commitBefore() { - if (!enabled) { + if (!commitRequired()) { return null; } return new Operation() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java index 918a03fbf..845444ef8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java @@ -20,43 +20,136 @@ package com.sk89q.worldedit.extent.reorder; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.blocks.Blocks; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.OperationQueue; -import com.sk89q.worldedit.function.operation.RunContext; import com.sk89q.worldedit.function.operation.SetLocatedBlocks; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.registry.state.Property; -import com.sk89q.worldedit.util.LocatedBlock; import com.sk89q.worldedit.util.collection.LocatedBlockList; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockCategories; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import java.util.ArrayList; -import java.util.Deque; import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; /** * Re-orders blocks into several stages. */ public class MultiStageReorder extends AbstractDelegateExtent implements ReorderingExtent { - private static final int STAGE_COUNT = 4; + private static final Map priorityMap = new HashMap<>(); - private List stages = new ArrayList<>(); + static { + // Late + priorityMap.put(BlockTypes.WATER, PlacementPriority.LATE); + priorityMap.put(BlockTypes.LAVA, PlacementPriority.LATE); + priorityMap.put(BlockTypes.SAND, PlacementPriority.LATE); + priorityMap.put(BlockTypes.GRAVEL, PlacementPriority.LATE); + + // Late + BlockCategories.SAPLINGS.getAll().forEach(type -> priorityMap.put(type, PlacementPriority.LAST)); + BlockCategories.FLOWER_POTS.getAll().forEach(type -> priorityMap.put(type, PlacementPriority.LAST)); + BlockCategories.BUTTONS.getAll().forEach(type -> priorityMap.put(type, PlacementPriority.LAST)); + BlockCategories.ANVIL.getAll().forEach(type -> priorityMap.put(type, PlacementPriority.LAST)); + BlockCategories.WOODEN_PRESSURE_PLATES.getAll().forEach(type -> priorityMap.put(type, PlacementPriority.LAST)); + BlockCategories.CARPETS.getAll().forEach(type -> priorityMap.put(type, PlacementPriority.LAST)); + BlockCategories.RAILS.getAll().forEach(type -> priorityMap.put(type, PlacementPriority.LAST)); + priorityMap.put(BlockTypes.BLACK_BED, PlacementPriority.LAST); + priorityMap.put(BlockTypes.BLUE_BED, PlacementPriority.LAST); + priorityMap.put(BlockTypes.BROWN_BED, PlacementPriority.LAST); + priorityMap.put(BlockTypes.CYAN_BED, PlacementPriority.LAST); + priorityMap.put(BlockTypes.GRAY_BED, PlacementPriority.LAST); + priorityMap.put(BlockTypes.GREEN_BED, PlacementPriority.LAST); + priorityMap.put(BlockTypes.LIGHT_BLUE_BED, PlacementPriority.LAST); + priorityMap.put(BlockTypes.LIGHT_GRAY_BED, PlacementPriority.LAST); + priorityMap.put(BlockTypes.LIME_BED, PlacementPriority.LAST); + priorityMap.put(BlockTypes.MAGENTA_BED, PlacementPriority.LAST); + priorityMap.put(BlockTypes.ORANGE_BED, PlacementPriority.LAST); + priorityMap.put(BlockTypes.PINK_BED, PlacementPriority.LAST); + priorityMap.put(BlockTypes.PURPLE_BED, PlacementPriority.LAST); + priorityMap.put(BlockTypes.RED_BED, PlacementPriority.LAST); + priorityMap.put(BlockTypes.WHITE_BED, PlacementPriority.LAST); + priorityMap.put(BlockTypes.YELLOW_BED, PlacementPriority.LAST); + priorityMap.put(BlockTypes.GRASS, PlacementPriority.LAST); + priorityMap.put(BlockTypes.TALL_GRASS, PlacementPriority.LAST); + priorityMap.put(BlockTypes.ROSE_BUSH, PlacementPriority.LAST); + priorityMap.put(BlockTypes.DANDELION, PlacementPriority.LAST); + priorityMap.put(BlockTypes.BROWN_MUSHROOM, PlacementPriority.LAST); + priorityMap.put(BlockTypes.RED_MUSHROOM, PlacementPriority.LAST); + priorityMap.put(BlockTypes.FERN, PlacementPriority.LAST); + priorityMap.put(BlockTypes.LARGE_FERN, PlacementPriority.LAST); + priorityMap.put(BlockTypes.OXEYE_DAISY, PlacementPriority.LAST); + priorityMap.put(BlockTypes.AZURE_BLUET, PlacementPriority.LAST); + priorityMap.put(BlockTypes.TORCH, PlacementPriority.LAST); + priorityMap.put(BlockTypes.WALL_TORCH, PlacementPriority.LAST); + priorityMap.put(BlockTypes.FIRE, PlacementPriority.LAST); + priorityMap.put(BlockTypes.REDSTONE_WIRE, PlacementPriority.LAST); + priorityMap.put(BlockTypes.CARROTS, PlacementPriority.LAST); + priorityMap.put(BlockTypes.POTATOES, PlacementPriority.LAST); + priorityMap.put(BlockTypes.WHEAT, PlacementPriority.LAST); + priorityMap.put(BlockTypes.BEETROOTS, PlacementPriority.LAST); + priorityMap.put(BlockTypes.COCOA, PlacementPriority.LAST); + priorityMap.put(BlockTypes.LADDER, PlacementPriority.LAST); + priorityMap.put(BlockTypes.LEVER, PlacementPriority.LAST); + priorityMap.put(BlockTypes.REDSTONE_TORCH, PlacementPriority.LAST); + priorityMap.put(BlockTypes.REDSTONE_WALL_TORCH, PlacementPriority.LAST); + priorityMap.put(BlockTypes.SNOW, PlacementPriority.LAST); + priorityMap.put(BlockTypes.NETHER_PORTAL, PlacementPriority.LAST); + priorityMap.put(BlockTypes.END_PORTAL, PlacementPriority.LAST); + priorityMap.put(BlockTypes.REPEATER, PlacementPriority.LAST); + priorityMap.put(BlockTypes.VINE, PlacementPriority.LAST); + priorityMap.put(BlockTypes.LILY_PAD, PlacementPriority.LAST); + priorityMap.put(BlockTypes.NETHER_WART, PlacementPriority.LAST); + priorityMap.put(BlockTypes.PISTON, PlacementPriority.LAST); + priorityMap.put(BlockTypes.STICKY_PISTON, PlacementPriority.LAST); + priorityMap.put(BlockTypes.TRIPWIRE_HOOK, PlacementPriority.LAST); + priorityMap.put(BlockTypes.TRIPWIRE, PlacementPriority.LAST); + priorityMap.put(BlockTypes.STONE_PRESSURE_PLATE, PlacementPriority.LAST); + priorityMap.put(BlockTypes.HEAVY_WEIGHTED_PRESSURE_PLATE, PlacementPriority.LAST); + priorityMap.put(BlockTypes.LIGHT_WEIGHTED_PRESSURE_PLATE, PlacementPriority.LAST); + priorityMap.put(BlockTypes.COMPARATOR, PlacementPriority.LAST); + priorityMap.put(BlockTypes.IRON_TRAPDOOR, PlacementPriority.LAST); + priorityMap.put(BlockTypes.ACACIA_TRAPDOOR, PlacementPriority.LAST); + priorityMap.put(BlockTypes.BIRCH_TRAPDOOR, PlacementPriority.LAST); + priorityMap.put(BlockTypes.DARK_OAK_TRAPDOOR, PlacementPriority.LAST); + priorityMap.put(BlockTypes.JUNGLE_TRAPDOOR, PlacementPriority.LAST); + priorityMap.put(BlockTypes.OAK_TRAPDOOR, PlacementPriority.LAST); + priorityMap.put(BlockTypes.SPRUCE_TRAPDOOR, PlacementPriority.LAST); + priorityMap.put(BlockTypes.DAYLIGHT_DETECTOR, PlacementPriority.LAST); + priorityMap.put(BlockTypes.CAKE, PlacementPriority.LAST); + + // Final + BlockCategories.DOORS.getAll().forEach(type -> priorityMap.put(type, PlacementPriority.FINAL)); + BlockCategories.BANNERS.getAll().forEach(type -> priorityMap.put(type, PlacementPriority.FINAL)); + priorityMap.put(BlockTypes.SIGN, PlacementPriority.FINAL); + priorityMap.put(BlockTypes.WALL_SIGN, PlacementPriority.FINAL); + priorityMap.put(BlockTypes.CACTUS, PlacementPriority.FINAL); + priorityMap.put(BlockTypes.SUGAR_CANE, PlacementPriority.FINAL); + priorityMap.put(BlockTypes.PISTON_HEAD, PlacementPriority.FINAL); + priorityMap.put(BlockTypes.MOVING_PISTON, PlacementPriority.FINAL); + } + + private Map stages = new HashMap<>(); private boolean enabled; + public enum PlacementPriority { + CLEAR_FINAL, + CLEAR_LAST, + CLEAR_LATE, + FIRST, + LATE, + LAST, + FINAL + } + /** * Create a new instance when the re-ordering is enabled. * @@ -75,9 +168,8 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder public MultiStageReorder(Extent extent, boolean enabled) { super(extent); this.enabled = enabled; - - for (int i = 0; i < STAGE_COUNT; ++i) { - stages.add(new LocatedBlockList()); + for (PlacementPriority priority : PlacementPriority.values()) { + stages.put(priority, new LocatedBlockList()); } } @@ -100,7 +192,7 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder } public boolean commitRequired() { - return stages.stream().anyMatch(stage -> stage.size() > 0); + return enabled; } /** @@ -109,18 +201,8 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder * @param block The block * @return The priority */ - public > int getPlacementPriority(B block) { - if (Blocks.shouldPlaceLate(block.getBlockType())) { - return 1; - } else if (Blocks.shouldPlaceLast(block.getBlockType())) { - // Place torches, etc. last - return 2; - } else if (Blocks.shouldPlaceFinal(block.getBlockType())) { - // Place signs, reed, etc even later - return 3; - } else { - return 0; - } + private > PlacementPriority getPlacementPriority(B block) { + return priorityMap.getOrDefault(block.getBlockType(), PlacementPriority.FIRST); } @Override @@ -130,13 +212,28 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder } BlockState existing = getBlock(location); - int priority = getPlacementPriority(block); - int srcPriority = getPlacementPriority(existing); + PlacementPriority priority = getPlacementPriority(block); + PlacementPriority srcPriority = getPlacementPriority(existing); - if (srcPriority == 1 || srcPriority == 2) { - // Destroy torches, etc. first - super.setBlock(location, BlockTypes.AIR.getDefaultState()); - return super.setBlock(location, block); + if (srcPriority != PlacementPriority.FIRST) { + BaseBlock replacement = (block.getBlockType().getMaterial().isAir() ? block : BlockTypes.AIR.getDefaultState()).toBaseBlock(); + + switch (srcPriority) { + case FINAL: + stages.get(PlacementPriority.CLEAR_FINAL).add(location, replacement); + break; + case LATE: + stages.get(PlacementPriority.CLEAR_LATE).add(location, replacement); + break; + case LAST: + stages.get(PlacementPriority.CLEAR_LAST).add(location, replacement); + break; + } + } + + if (block.getBlockType().getMaterial().isAir()) { + return !existing.equalsFuzzy(block); + } } stages.get(priority).add(location, block); @@ -145,104 +242,14 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder @Override public Operation commitBefore() { + if (!commitRequired()) { + return null; + } List operations = new ArrayList<>(); - for (int i = 0; i < stages.size() - 1; ++i) { - operations.add(new SetLocatedBlocks(getExtent(), stages.get(i))); + for (PlacementPriority priority : PlacementPriority.values()) { + operations.add(new SetLocatedBlocks(getExtent(), stages.get(priority))); } - operations.add(new FinalStageCommitter()); return new OperationQueue(operations); } - - private class FinalStageCommitter implements Operation { - private Extent extent = getExtent(); - - private final Set blocks = new HashSet<>(); - private final Map blockTypes = new HashMap<>(); - - public FinalStageCommitter() { - for (LocatedBlock entry : stages.get(stages.size() - 1)) { - final BlockVector3 pt = entry.getLocation(); - blocks.add(pt); - blockTypes.put(pt, entry.getBlock()); - } - } - - @Override - public Operation resume(RunContext run) throws WorldEditException { - while (!blocks.isEmpty()) { - BlockVector3 current = blocks.iterator().next(); - if (!blocks.contains(current)) { - continue; - } - - final Deque walked = new LinkedList<>(); - - while (true) { - walked.addFirst(current); - - assert (blockTypes.containsKey(current)); - - final BlockStateHolder blockStateHolder = blockTypes.get(current); - - if (BlockCategories.DOORS.contains(blockStateHolder.getBlockType())) { - Property halfProperty = blockStateHolder.getBlockType().getProperty("half"); - if (blockStateHolder.getState(halfProperty).equals("lower")) { - // Deal with lower door halves being attached to the floor AND the upper half - BlockVector3 upperBlock = current.add(0, 1, 0); - if (blocks.contains(upperBlock) && !walked.contains(upperBlock)) { - walked.addFirst(upperBlock); - } - } - } else if (BlockCategories.RAILS.contains(blockStateHolder.getBlockType())) { - BlockVector3 lowerBlock = current.add(0, -1, 0); - if (blocks.contains(lowerBlock) && !walked.contains(lowerBlock)) { - walked.addFirst(lowerBlock); - } - } - - if (!blockStateHolder.getBlockType().getMaterial().isFragileWhenPushed()) { - // Block is not attached to anything => we can place it - break; - } - -// current = current.add(attachment.vector()).toBlockVector(); -// -// if (!blocks.contains(current)) { -// // We ran outside the remaining set => assume we can place blocks on this -// break; -// } -// - if (walked.contains(current)) { - // Cycle detected => This will most likely go wrong, but there's nothing we can do about it. - break; - } - } - - for (BlockVector3 pt : walked) { - extent.setBlock(pt, blockTypes.get(pt)); - blocks.remove(pt); - } - } - - if (blocks.isEmpty()) { - for (LocatedBlockList stage : stages) { - stage.clear(); - } - return null; - } - - return this; - } - - @Override - public void cancel() { - } - - @Override - public void addStatusMessages(List messages) { - } - - } - -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java index 93a526377..0d7e4393c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java @@ -41,13 +41,12 @@ import com.sk89q.worldedit.registry.state.EnumProperty; import com.sk89q.worldedit.registry.state.IntegerProperty; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.util.Direction; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.OptionalInt; @@ -62,7 +61,7 @@ import javax.annotation.Nullable; */ public class BlockTransformExtent extends ResettableExtent { - private Transform transform; + private final Transform transform; public BlockTransformExtent(Extent parent) { @@ -121,7 +120,7 @@ public class BlockTransformExtent extends ResettableExtent { @Override public BlockState getBlock(BlockVector3 position) { - return transformBlock(super.getBlock(position), false).toImmutableState(); + return transformBlock(super.getBlock(position), false); } @Override @@ -142,6 +141,7 @@ public class BlockTransformExtent extends ResettableExtent { private static final Set directionNames = Sets.newHashSet("north", "south", "east", "west"); + private static final Set directionNames = Sets.newHashSet("north", "south", "east", "west"); /** * Transform the given block using the given transform. @@ -155,6 +155,7 @@ public class BlockTransformExtent extends ResettableExtent { public static > B transform(B block, Transform transform) { checkNotNull(block); checkNotNull(transform); + B result = block; List> properties = block.getBlockType().getProperties(); @@ -240,6 +241,7 @@ public class BlockTransformExtent extends ResettableExtent { result = result.with(block.getBlockType().getProperty(directionName), directionalProperties.contains(directionName)); } } + return result; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java index 637ccd821..7e89fa721 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java @@ -22,10 +22,10 @@ package com.sk89q.worldedit.extent.validation; import static com.google.common.base.Preconditions.checkArgument; import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java index 9bc9aaf43..63ca586e6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java @@ -21,10 +21,10 @@ package com.sk89q.worldedit.extent.validation; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java index 9631f53ae..50f2a9a30 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java @@ -21,10 +21,10 @@ package com.sk89q.worldedit.extent.world; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java index 31ff6f840..de5ae4378 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java @@ -21,10 +21,10 @@ package com.sk89q.worldedit.extent.world; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -62,7 +62,6 @@ public class ChunkLoadingExtent extends AbstractDelegateExtent { @Override public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { - world.checkLoadedChunk(location); if (enabled) { world.checkLoadedChunk(location); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java index a83a4c615..54d72df19 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java @@ -21,12 +21,12 @@ package com.sk89q.worldedit.extent.world; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.BlockVector2; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.RunContext; +import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; @@ -104,7 +104,7 @@ public class FastModeExtent extends AbstractDelegateExtent { dirtyChunks.add(BlockVector2.at(location.getBlockX() >> 4, location.getBlockZ() >> 4)); if (world.setBlock(location, block, false)) { - if (postEditSimulation) { + if (!enabled && postEditSimulation) { positions.add(location); } return true; @@ -117,11 +117,14 @@ public class FastModeExtent extends AbstractDelegateExtent { } public boolean commitRequired() { - return !dirtyChunks.isEmpty() || !positions.isEmpty(); + return enabled || postEditSimulation; } @Override protected Operation commitBefore() { + if (!commitRequired()) { + return null; + } return new Operation() { @Override public Operation resume(RunContext run) throws WorldEditException { @@ -129,7 +132,7 @@ public class FastModeExtent extends AbstractDelegateExtent { world.fixAfterFastMode(dirtyChunks); } - if (postEditSimulation) { + if (!enabled && postEditSimulation) { Iterator positionIterator = positions.iterator(); while (run.shouldContinue() && positionIterator.hasNext()) { BlockVector3 position = positionIterator.next(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/EditContext.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/EditContext.java index 07c1515ba..b26f8d74f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/EditContext.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/EditContext.java @@ -21,6 +21,7 @@ package com.sk89q.worldedit.function; import static com.google.common.base.Preconditions.checkNotNull; +import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.regions.Region; @@ -32,6 +33,7 @@ public class EditContext { private Extent destination; @Nullable private Region region; @Nullable private Pattern fill; + @Nullable private LocalSession session; public Extent getDestination() { return destination; @@ -60,4 +62,12 @@ public class EditContext { this.fill = fill; } + @Nullable + public LocalSession getSession() { + return session; + } + + public void setSession(@Nullable LocalSession session) { + this.session = session; + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/FlatRegionMaskingFilter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/FlatRegionMaskingFilter.java index acafd1f61..961a5721d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/FlatRegionMaskingFilter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/FlatRegionMaskingFilter.java @@ -21,9 +21,9 @@ package com.sk89q.worldedit.function; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.mask.Mask2D; +import com.sk89q.worldedit.math.BlockVector2; /** * Passes calls to {@link #apply(BlockVector2)} to the diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/GroundFunction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/GroundFunction.java index 630952678..d3162ff13 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/GroundFunction.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/GroundFunction.java @@ -21,9 +21,9 @@ package com.sk89q.worldedit.function; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.math.BlockVector3; /** * Applies a {@link RegionFunction} to the first ground block. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskingFilter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskingFilter.java index 9feb385b5..cea580d8b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskingFilter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionMaskingFilter.java @@ -21,9 +21,9 @@ package com.sk89q.worldedit.function; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.math.BlockVector3; /** * Passes calls to {@link #apply(BlockVector3)} to the diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java index 500408700..efa53f45a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java @@ -21,11 +21,11 @@ package com.sk89q.worldedit.function.biome; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.FlatRegionFunction; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.world.biome.BiomeType; /** * Replaces the biome at the locations that this function is applied to. @@ -33,7 +33,7 @@ import com.sk89q.worldedit.world.biome.BaseBiome; public class BiomeReplace implements FlatRegionFunction { private final Extent extent; - private BaseBiome biome; + private BiomeType biome; /** * Create a new instance. @@ -41,7 +41,7 @@ public class BiomeReplace implements FlatRegionFunction { * @param extent an extent * @param biome a biome */ - public BiomeReplace(Extent extent, BaseBiome biome) { + public BiomeReplace(Extent extent, BiomeType biome) { checkNotNull(extent); checkNotNull(biome); this.extent = extent; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java index b6581203e..eec8a1ed3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java @@ -26,9 +26,6 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.block.BaseBlock; - -import static com.google.common.base.Preconditions.checkNotNull; /** * Replaces blocks with a given pattern. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java index 34a4671c9..8fb81e669 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java @@ -28,7 +28,6 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.jnbt.CompoundTagBuilder; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.internal.helper.MCDirections; @@ -37,13 +36,9 @@ import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction.Flag; -import com.sk89q.worldedit.world.block.BlockStateHolder; - -import java.util.Map; - import static com.google.common.base.Preconditions.checkNotNull; -//import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BaseBlock; /** * Copies blocks from one extent to another. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java index 14d3124b4..30f55258a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/Naturalizer.java @@ -29,11 +29,11 @@ import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.function.LayerFunction; import com.sk89q.worldedit.function.mask.BlockTypeMask; import com.sk89q.worldedit.function.mask.Mask; - -import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockTypes; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Makes a layer of grass on top, three layers of dirt below, and smooth stone * only below that for all layers that originally consist of grass, dirt, diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java index fca42f721..643f4593e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java @@ -26,6 +26,7 @@ import com.sk89q.jnbt.FloatTag; import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.Tag; +import com.sk89q.jnbt.CompoundTagBuilder; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; @@ -101,19 +102,6 @@ public class ExtentEntityCopy implements EntityFunction { Location newLocation; Location location = entity.getLocation(); -//<<<<<<< HEAD -// Vector pivot = from.round().add(0.5, 0.5, 0.5); -// Vector newPosition = transform.apply(location.subtract(pivot)); -// Vector newDirection; -// if (transform.isIdentity()) { -// newDirection = entity.getLocation().getDirection(); -// newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection); -// } else { -// newDirection = new Vector(transform.apply(location.getDirection())).subtract(transform.apply(Vector.ZERO)).normalize(); -// newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection); -// state = transformNbtData(state); -// } -//======= Vector3 pivot = from.round().add(0.5, 0.5, 0.5); Vector3 newPosition = transform.apply(location.subtract(pivot)); Vector3 newDirection; @@ -123,9 +111,7 @@ public class ExtentEntityCopy implements EntityFunction { : transform.apply(location.getDirection()).subtract(transform.apply(Vector3.ZERO)).normalize(); newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection); - // Some entities store their position data in NBT state = transformNbtData(state); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner boolean success = destination.createEntity(newLocation, state) != null; @@ -163,14 +149,9 @@ public class ExtentEntityCopy implements EntityFunction { boolean hasFacing = tag.containsKey("Facing"); if (hasTilePosition) { -//<<<<<<< HEAD changed = true; -// Vector tilePosition = new Vector(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ")); -// Vector newTilePosition = transform.apply(tilePosition.subtract(from)).add(to); -//======= Vector3 tilePosition = Vector3.at(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ")); BlockVector3 newTilePosition = transform.apply(tilePosition.subtract(from)).add(to).toBlockPoint(); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner values.put("TileX", new IntTag(newTilePosition.getBlockX())); values.put("TileY", new IntTag(newTilePosition.getBlockY())); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java index ac52933be..8793ae00d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/factory/Deform.java @@ -23,6 +23,8 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.NullExtent; @@ -147,7 +149,9 @@ public class Deform implements Contextual { unit = Vector3.ONE; } - return new DeformOperation(context.getDestination(), region, zero, unit, expression); + LocalSession session = context.getSession(); + return new DeformOperation(context.getDestination(), region, zero, unit, expression, + session == null ? WorldEdit.getInstance().getConfiguration().calculationTimeout : session.getTimeout()); } private static final class DeformOperation implements Operation { @@ -156,6 +160,7 @@ public class Deform implements Contextual { private final Vector3 zero; private final Vector3 unit; private final String expression; + private final int timeout; private DeformOperation(Extent destination, Region region, Vector3 zero, Vector3 unit, String expression) { this.destination = destination; @@ -163,6 +168,7 @@ public class Deform implements Contextual { this.zero = zero; this.unit = unit; this.expression = expression; + this.timeout = timeout; } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java index e1ab41b03..602c07f56 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit.function.generator; import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.pattern.BlockPattern; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/ForestGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/ForestGenerator.java index e0332d550..f6ddf7086 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/ForestGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/ForestGenerator.java @@ -20,9 +20,9 @@ package com.sk89q.worldedit.function.generator; import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; @@ -58,11 +58,14 @@ public class ForestGenerator implements RegionFunction { return true; } else if (t == BlockTypes.TALL_GRASS || t == BlockTypes.DEAD_BUSH || t == BlockTypes.POPPY || t == BlockTypes.DANDELION) { // TODO: This list needs to be moved editSession.setBlock(position, BlockTypes.AIR.getDefaultState()); - treeType.generate(editSession, position); - return true; - } else if (t == BlockTypes.SNOW) { - editSession.setBlock(position, BlockTypes.AIR.getDefaultState()); - return false; + // and then trick the generator here by directly setting into the world + editSession.getWorld().setBlock(position, BlockTypes.AIR.getDefaultState()); + // so that now the generator can generate the tree + boolean success = treeType.generate(editSession, position); + if (!success) { + editSession.setBlock(position, block); // restore on failure + } + return success; } else { // Trees won't grow on this! return false; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java index 0cc3266df..cec89ca16 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java @@ -21,11 +21,11 @@ package com.sk89q.worldedit.function.generator; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask2D.java index c590a211a..633159acb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BiomeMask2D.java @@ -21,9 +21,9 @@ package com.sk89q.worldedit.function.mask; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.world.biome.BiomeType; import java.util.Arrays; import java.util.Collection; @@ -36,7 +36,7 @@ import java.util.Set; public class BiomeMask2D extends AbstractMask2D { private final Extent extent; - private final Set biomes = new HashSet<>(); + private final Set biomes = new HashSet<>(); /** * Create a new biome mask. @@ -44,7 +44,7 @@ public class BiomeMask2D extends AbstractMask2D { * @param extent the extent * @param biomes a list of biomes to match */ - public BiomeMask2D(Extent extent, Collection biomes) { + public BiomeMask2D(Extent extent, Collection biomes) { checkNotNull(extent); checkNotNull(biomes); this.extent = extent; @@ -57,7 +57,7 @@ public class BiomeMask2D extends AbstractMask2D { * @param extent the extent * @param biome an array of biomes to match */ - public BiomeMask2D(Extent extent, BaseBiome... biome) { + public BiomeMask2D(Extent extent, BiomeType... biome) { this(extent, Arrays.asList(checkNotNull(biome))); } @@ -66,7 +66,7 @@ public class BiomeMask2D extends AbstractMask2D { * * @param biomes a list of biomes */ - public void add(Collection biomes) { + public void add(Collection biomes) { checkNotNull(biomes); this.biomes.addAll(biomes); } @@ -76,7 +76,7 @@ public class BiomeMask2D extends AbstractMask2D { * * @param biome an array of biomes */ - public void add(BaseBiome... biome) { + public void add(BiomeType... biome) { add(Arrays.asList(checkNotNull(biome))); } @@ -85,13 +85,13 @@ public class BiomeMask2D extends AbstractMask2D { * * @return a list of biomes */ - public Collection getBiomes() { + public Collection getBiomes() { return biomes; } @Override public boolean test(BlockVector2 vector) { - BaseBiome biome = extent.getBiome(vector); + BiomeType biome = extent.getBiome(vector); return biomes.contains(biome); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java index c3530fd47..4100ca98c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java @@ -129,12 +129,6 @@ public class BlockMask extends AbstractExtentMask { return mask; } } -// public boolean test(BlockVector3 vector) { -// BlockStateHolder block = getExtent().getBlock(vector); -// for (BlockStateHolder testBlock : blocks) { -// if (testBlock.equalsFuzzy(block)) { -// return true; - private Mask getOptimizedMask(BlockType type, long[] bitSet) { boolean single = true; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockStateMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockStateMask.java new file mode 100644 index 000000000..69e47039d --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockStateMask.java @@ -0,0 +1,70 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.function.mask; + +import com.google.common.collect.Maps; +import com.sk89q.worldedit.blocks.Blocks; +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.registry.state.Property; +import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockType; + +import javax.annotation.Nullable; +import java.util.Map; + +public class BlockStateMask extends AbstractExtentMask { + + private final Map states; + private final boolean strict; + private Map, Object>> cache = Maps.newHashMap(); + + /** + * Creates a mask that checks if a given block has the desired properties set to the desired value. + * + * @param extent the extent to get blocks from + * @param states the desired states (property -> value) that a block should have to match the mask + * @param strict true to only match blocks that have all properties and values, false to also match blocks that + * do not have the properties (but only fail blocks with the properties but wrong values) + */ + public BlockStateMask(Extent extent, Map states, boolean strict) { + super(extent); + this.states = states; + this.strict = strict; + } + + @Override + public boolean test(BlockVector3 vector) { + BlockState block = getExtent().getBlock(vector); + final Map, Object> checkProps = cache + .computeIfAbsent(block.getBlockType(), (b -> Blocks.resolveProperties(states, b))); + if (strict && checkProps.isEmpty()) { + return false; + } + return checkProps.entrySet().stream() + .allMatch(entry -> block.getState(entry.getKey()) == entry.getValue()); + } + + @Nullable + @Override + public Mask2D toMask2D() { + return null; + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java index 4c2b44ce9..ac4d24452 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java @@ -19,8 +19,8 @@ package com.sk89q.worldedit.function.mask; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; import javax.annotation.Nullable; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java index 2c4017559..52e0f345d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask.java @@ -21,13 +21,15 @@ package com.sk89q.worldedit.function.mask; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.runtime.EvaluationException; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment; import javax.annotation.Nullable; +import java.util.function.IntSupplier; /** * A mask that evaluates an expression. @@ -38,6 +40,7 @@ import javax.annotation.Nullable; public class ExpressionMask extends AbstractMask { private final Expression expression; + private final IntSupplier timeout; /** * Create a new instance. @@ -46,8 +49,7 @@ public class ExpressionMask extends AbstractMask { * @throws ExpressionException thrown if there is an error with the expression */ public ExpressionMask(String expression) throws ExpressionException { - checkNotNull(expression); - this.expression = Expression.compile(expression, "x", "y", "z"); + this(Expression.compile(checkNotNull(expression), "x", "y", "z")); } /** @@ -56,8 +58,13 @@ public class ExpressionMask extends AbstractMask { * @param expression the expression */ public ExpressionMask(Expression expression) { + this(expression, null); + } + + public ExpressionMask(Expression expression, @Nullable IntSupplier timeout) { checkNotNull(expression); this.expression = expression; + this.timeout = timeout; } @Override @@ -75,7 +82,7 @@ public class ExpressionMask extends AbstractMask { @Nullable @Override public Mask2D toMask2D() { - return new ExpressionMask2D(expression); + return new ExpressionMask2D(expression, timeout); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java index 0afefab0c..0f4d9b198 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExpressionMask2D.java @@ -21,14 +21,19 @@ package com.sk89q.worldedit.function.mask; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.runtime.EvaluationException; +import com.sk89q.worldedit.math.BlockVector2; + +import javax.annotation.Nullable; +import java.util.function.IntSupplier; public class ExpressionMask2D extends AbstractMask2D { private final Expression expression; + private final IntSupplier timeout; /** * Create a new instance. @@ -37,8 +42,7 @@ public class ExpressionMask2D extends AbstractMask2D { * @throws ExpressionException thrown if there is an error with the expression */ public ExpressionMask2D(String expression) throws ExpressionException { - checkNotNull(expression); - this.expression = Expression.compile(expression, "x", "z"); + this(Expression.compile(checkNotNull(expression), "x", "z")); } /** @@ -47,14 +51,23 @@ public class ExpressionMask2D extends AbstractMask2D { * @param expression the expression */ public ExpressionMask2D(Expression expression) { + this(expression, null); + } + + public ExpressionMask2D(Expression expression, @Nullable IntSupplier timeout) { checkNotNull(expression); this.expression = expression; + this.timeout = timeout; } @Override public boolean test(BlockVector2 vector) { try { - return expression.evaluate(vector.getX(), 0, vector.getZ()) > 0; + if (timeout != null) { + return expression.evaluate(vector.getX(), 0, vector.getZ()) > 0; + } else { + return expression.evaluate(new double[]{vector.getX(), 0, vector.getZ()}, timeout.getAsInt()) > 0; + } } catch (EvaluationException e) { return false; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java index 9321ec5cd..f89d67c8e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java @@ -21,8 +21,6 @@ package com.sk89q.worldedit.function.mask; import com.google.common.base.Function; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.math.BlockVector3; import javax.annotation.Nullable; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java index 4279d2fde..1a70e02b2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Masks.java @@ -55,33 +55,6 @@ public final class Masks { //<<<<<<< HEAD public static Mask negate(final Mask finalMask) { return finalMask.inverse(); -//======= -// public static Mask negate(final Mask mask) { -// if (mask instanceof AlwaysTrue) { -// return ALWAYS_FALSE; -// } else if (mask instanceof AlwaysFalse) { -// return ALWAYS_TRUE; -// } -// -// checkNotNull(mask); -// return new AbstractMask() { -// @Override -// public boolean test(BlockVector3 vector) { -// return !mask.test(vector); -// } -// -// @Nullable -// @Override -// public Mask2D toMask2D() { -// Mask2D mask2d = mask.toMask2D(); -// if (mask2d != null) { -// return negate(mask2d); -// } else { -// return null; -// } -// } -// }; -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java index 8ba70fc5d..19afced40 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java @@ -1,6 +1,5 @@ package com.sk89q.worldedit.function.mask; - import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BlockMapEntryPlacer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BlockMapEntryPlacer.java deleted file mode 100644 index 44e33a3af..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/BlockMapEntryPlacer.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.function.operation; - -import com.sk89q.worldedit.WorldEditException; - -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.math.BlockVector3; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Sets block from an iterator of {@link Map.Entry} containing a - * {@link BlockVector} as the key and a {@link BaseBlock} as the value. - */ -public class BlockMapEntryPlacer implements Operation { - - private final Extent extent; - private final Iterator> iterator; - - /** - * Create a new instance. - * - * @param extent the extent to set the blocks on - * @param iterator the iterator - */ - public BlockMapEntryPlacer(Extent extent, Iterator> iterator) { - checkNotNull(extent); - checkNotNull(iterator); - this.extent = extent; - this.iterator = iterator; - } - - @Override - public Operation resume(RunContext run) throws WorldEditException { - while (iterator.hasNext()) { - Map.Entry entry = iterator.next(); - extent.setBlock(entry.getKey(), entry.getValue()); - } - - return null; - } - - @Override - public void cancel() { - } - - @Override - public void addStatusMessages(List messages) { - } - -} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/SetLocatedBlocks.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/SetLocatedBlocks.java index cf644af7a..1e418bb04 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/SetLocatedBlocks.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/SetLocatedBlocks.java @@ -53,4 +53,4 @@ public class SetLocatedBlocks implements Operation { public void addStatusMessages(List messages) { } -} \ No newline at end of file +} diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/gui/GuiHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/AbstractExtentPattern.java similarity index 56% rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/gui/GuiHandler.java rename to worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/AbstractExtentPattern.java index d88b97379..de18b4802 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/gui/GuiHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/AbstractExtentPattern.java @@ -17,29 +17,23 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.forge.gui; +package com.sk89q.worldedit.function.pattern; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; -import net.minecraftforge.fml.common.network.IGuiHandler; +import com.sk89q.worldedit.extent.Extent; -public class GuiHandler implements IGuiHandler { +import static com.google.common.base.Preconditions.checkNotNull; - public static final int REFERENCE_ID = 0; +public abstract class AbstractExtentPattern extends AbstractPattern implements ExtentPattern { - @Override - public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - return null; + private final Extent extent; + + public AbstractExtentPattern(Extent extent) { + this.extent = extent; + checkNotNull(extent); } @Override - public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - switch (id) { - case REFERENCE_ID: - return new GuiReferenceCard(); - } - - return null; + public Extent getExtent() { + return extent; } - -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java index cbfa5dbf6..e686f454d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java @@ -1,25 +1,12 @@ package com.sk89q.worldedit.function.pattern; - -import com.sk89q.worldedit.world.block.BlockState; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.block.BaseBlock; - - -import static com.google.common.base.Preconditions.checkNotNull; /** * A pattern that reads from {@link Clipboard}. */ -public class ClipboardPattern extends AbstractPattern { - - private final Clipboard clipboard; - private final int sx, sy, sz; - private final BlockVector3 min; -// private final BlockVector3 size; +public class ClipboardPattern extends RepeatingExtentPattern { /** * Create a new clipboard pattern. @@ -27,25 +14,16 @@ public class ClipboardPattern extends AbstractPattern { * @param clipboard the clipboard */ public ClipboardPattern(Clipboard clipboard) { - checkNotNull(clipboard); - this.clipboard = clipboard; - BlockVector3 size = clipboard.getMaximumPoint().subtract(clipboard.getMinimumPoint()).add(1, 1, 1); - this.sx = size.getBlockX(); - this.sy = size.getBlockY(); - this.sz = size.getBlockZ(); - this.min = clipboard.getMinimumPoint(); + this(clipboard, BlockVector3.ZERO); } - @Override - public BaseBlock apply(BlockVector3 position) { - int xp = position.getBlockX() % sx; - int yp = position.getBlockY() % sy; - int zp = position.getBlockZ() % sz; - if (xp < 0) xp += sx; - if (yp < 0) yp += sy; - if (zp < 0) zp += sz; - return clipboard.getFullBlock(BlockVector3.at(min.getX() + xp, min.getY() + yp, min.getZ() + zp)); + /** + * Create a new clipboard pattern. + * + * @param clipboard the clipboard + * @param offset the offset + */ + public ClipboardPattern(Clipboard clipboard, BlockVector3 offset) { + super(clipboard, clipboard.getMinimumPoint(), offset); } - - -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ExtentBufferedCompositePattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ExtentBufferedCompositePattern.java new file mode 100644 index 000000000..b95351e3f --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ExtentBufferedCompositePattern.java @@ -0,0 +1,66 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.function.pattern; + +import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.extent.buffer.ExtentBuffer; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.world.block.BaseBlock; + +import static com.google.common.base.Preconditions.checkArgument; + +/** + * A pattern that composes multiple patterns consecutively, ensuring that changes from one + * pattern are realized by the subsequent one(s). For best results, use an {@link ExtentBuffer} + * to avoid changing blocks in an underlying extent (e.g. the world). + */ +public class ExtentBufferedCompositePattern extends AbstractExtentPattern { + + private final Pattern[] patterns; + + /** + * Construct a new instance of this pattern. + * + *

Note that all patterns passed which are ExtentPatterns should use the same extent as the one + * passed to this constructor, or block changes may not be realized by those patterns.

+ * + * @param extent the extent to buffer changes to + * @param patterns the patterns to apply, in order + */ + public ExtentBufferedCompositePattern(Extent extent, Pattern... patterns) { + super(extent); + checkArgument(patterns.length != 0, "patterns cannot be empty"); + this.patterns = patterns; + } + + @Override + public BaseBlock apply(BlockVector3 position) { + BaseBlock lastBlock = null; + for (Pattern pattern : patterns) { + lastBlock = pattern.apply(position); + try { + getExtent().setBlock(position, lastBlock); + } catch (WorldEditException ignored) { // buffer doesn't throw + } + } + return lastBlock; + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ExtentPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ExtentPattern.java new file mode 100644 index 000000000..c0dec41ee --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ExtentPattern.java @@ -0,0 +1,32 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.function.pattern; + +import com.sk89q.worldedit.extent.Extent; + +public interface ExtentPattern extends Pattern { + + /** + * Get the extent associated with this pattern. + * + * @return the extent for this pattern + */ + public Extent getExtent(); +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java index a2419df27..a91354fe2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java @@ -19,14 +19,6 @@ package com.sk89q.worldedit.function.pattern; -import com.sk89q.minecraft.util.commands.Link; -import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.command.UtilityCommands; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.extent.NullExtent; -import com.sk89q.worldedit.internal.expression.runtime.Return; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java index 2acf60bf0..18b7b8033 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java @@ -12,12 +12,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - - import static com.google.common.base.Preconditions.checkNotNull; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomStatePattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomStatePattern.java new file mode 100644 index 000000000..f2e2870a9 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomStatePattern.java @@ -0,0 +1,45 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.function.pattern; + +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.FuzzyBlockState; + +import java.util.List; +import java.util.Random; +import java.util.stream.Collectors; + +public class RandomStatePattern implements Pattern { + + private final Random rand = new Random(); + private final List blocks; + + public RandomStatePattern(FuzzyBlockState state) { + blocks = state.getBlockType().getAllStates().stream().filter(state::equalsFuzzy) + .map(BlockState::toBaseBlock).collect(Collectors.toList()); + } + + @Override + public BaseBlock apply(BlockVector3 position) { + return blocks.get(rand.nextInt(blocks.size())); + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java index d7b799840..28d6362aa 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java @@ -28,9 +28,10 @@ import com.sk89q.worldedit.world.block.BaseBlock; /** * Returns the blocks from {@link Extent}, repeating when out of bounds. */ -public class RepeatingExtentPattern extends AbstractPattern { +public class RepeatingExtentPattern extends AbstractExtentPattern { - private Extent extent; + private final BlockVector3 size; + private BlockVector3 origin; private BlockVector3 offset; /** @@ -39,28 +40,11 @@ public class RepeatingExtentPattern extends AbstractPattern { * @param extent the extent * @param offset the offset */ - public RepeatingExtentPattern(Extent extent, BlockVector3 offset) { - setExtent(extent); + public RepeatingExtentPattern(Extent extent, BlockVector3 origin, BlockVector3 offset) { + super(extent); + setOrigin(origin); setOffset(offset); - } - - /** - * Get the extent. - * - * @return the extent - */ - public Extent getExtent() { - return extent; - } - - /** - * Set the extent. - * - * @param extent the extent - */ - public void setExtent(Extent extent) { - checkNotNull(extent); - this.extent = extent; + size = extent.getMaximumPoint().subtract(extent.getMinimumPoint()).add(1, 1, 1); } /** @@ -82,13 +66,31 @@ public class RepeatingExtentPattern extends AbstractPattern { this.offset = offset; } + /** + * Get the origin. + * + * @return the origin + */ + public BlockVector3 getOrigin() { + return origin; + } + + /** + * Set the origin. + * + * @param origin the origin + */ + public void setOrigin(BlockVector3 origin) { + checkNotNull(origin); + this.origin = origin; + } + @Override public BaseBlock apply(BlockVector3 position) { BlockVector3 base = position.add(offset); - BlockVector3 size = extent.getMaximumPoint().subtract(extent.getMinimumPoint()).add(1, 1, 1); - int x = base.getBlockX() % size.getBlockX(); - int y = base.getBlockY() % size.getBlockY(); - int z = base.getBlockZ() % size.getBlockZ(); - return extent.getFullBlock(BlockVector3.at(x, y, z)); + int x = Math.abs(base.getBlockX()) % size.getBlockX(); + int y = Math.abs(base.getBlockY()) % size.getBlockY(); + int z = Math.abs(base.getBlockZ()) % size.getBlockZ(); + return getExtent().getFullBlock(BlockVector3.at(x, y, z).add(origin)); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/StateApplyingPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/StateApplyingPattern.java new file mode 100644 index 000000000..1ed40bffb --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/StateApplyingPattern.java @@ -0,0 +1,54 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.function.pattern; + +import com.google.common.collect.Maps; +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.registry.state.Property; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockType; + +import java.util.Map; +import java.util.Map.Entry; + +import static com.sk89q.worldedit.blocks.Blocks.resolveProperties; + +public class StateApplyingPattern extends AbstractExtentPattern { + + private final Map states; + private Map, Object>> cache = Maps.newHashMap(); + + public StateApplyingPattern(Extent extent, Map statesToSet) { + super(extent); + this.states = statesToSet; + } + + @Override + public BaseBlock apply(BlockVector3 position) { + BlockState block = getExtent().getBlock(position); + for (Entry, Object> entry : cache + .computeIfAbsent(block.getBlockType(), (b -> resolveProperties(states, b))).entrySet()) { + block = block.with(entry.getKey(), entry.getValue()); + } + return block.toBaseBlock(); + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/TypeApplyingPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/TypeApplyingPattern.java new file mode 100644 index 000000000..dc9951805 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/TypeApplyingPattern.java @@ -0,0 +1,52 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.function.pattern; + +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.registry.state.Property; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockState; + +import java.util.Map.Entry; + +/** + * Applies a block type while retaining all possible states. + */ +public class TypeApplyingPattern extends AbstractExtentPattern { + private final BlockState blockState; + + public TypeApplyingPattern(Extent extent, BlockState blockState) { + super(extent); + this.blockState = blockState; + } + + @Override + public BaseBlock apply(BlockVector3 position) { + BlockState oldBlock = getExtent().getBlock(position); + BlockState newBlock = blockState; + for (Entry, Object> entry : oldBlock.getStates().entrySet()) { + @SuppressWarnings("unchecked") + Property prop = (Property) entry.getKey(); + newBlock = newBlock.with(prop, entry.getValue()); + } + return newBlock.toBaseBlock(); + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/WaterloggedRemover.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/WaterloggedRemover.java new file mode 100644 index 000000000..51f8c0f67 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/WaterloggedRemover.java @@ -0,0 +1,47 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.function.pattern; + +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.registry.state.Property; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockTypes; + +/** + * Removes the waterlogged state from blocks if possible. If not possible, returns air. + */ +public class WaterloggedRemover extends AbstractExtentPattern { + + public WaterloggedRemover(Extent extent) { + super(extent); + } + + @Override + public BaseBlock apply(BlockVector3 position) { + BaseBlock block = getExtent().getFullBlock(position); + @SuppressWarnings("unchecked") + Property prop = (Property) block.getBlockType().getPropertyMap().getOrDefault("waterlogged", null); + if (prop != null) { + return block.with(prop, false); + } + return BlockTypes.AIR.getDefaultState().toBaseBlock(); + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/FlatRegionOffset.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/FlatRegionOffset.java index b53b75619..9682ff378 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/FlatRegionOffset.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/FlatRegionOffset.java @@ -21,9 +21,9 @@ package com.sk89q.worldedit.function.util; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.FlatRegionFunction; +import com.sk89q.worldedit.math.BlockVector2; /** * Offsets the position parameter by adding a given offset vector. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/RegionOffset.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/RegionOffset.java index a9e123fcf..7ac57da1f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/RegionOffset.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/util/RegionOffset.java @@ -21,9 +21,9 @@ package com.sk89q.worldedit.function.util; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; +import com.sk89q.worldedit.math.BlockVector3; /** * Offsets the position parameter by adding a given offset vector. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java index b31ea0d85..859110b77 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java @@ -264,17 +264,6 @@ public abstract class BreadthFirstSearch implements Operation { } } } -//======= -// BlockVector3 position; -// -// while ((position = queue.poll()) != null) { -// if (function.apply(position)) { -// affected++; -// } -// -// for (BlockVector3 dir : directions) { -// visit(position, position.add(dir)); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } if (currentDepth == maxDepth) { break; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java index 5d86ad0c9..cc1b15c8c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/FlatRegionVisitor.java @@ -32,7 +32,6 @@ import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.RunContext; import com.sk89q.worldedit.math.BlockVector2; -import com.sk89q.worldedit.math.Vector2; import com.sk89q.worldedit.regions.FlatRegion; import java.util.List; @@ -81,7 +80,6 @@ public class FlatRegionVisitor implements Operation { } @Override -//<<<<<<< HEAD public Operation resume(final RunContext run) throws WorldEditException { if (this.queue != null) { for (final BlockVector2 pt : new Fast2DIterator(this.iterator, queue)) { @@ -90,12 +88,6 @@ public class FlatRegionVisitor implements Operation { } else { for (final BlockVector2 pt : this.iterator) { if (this.function.apply(pt)) affected++; -//======= -// public Operation resume(RunContext run) throws WorldEditException { -// for (BlockVector2 pt : flatRegion.asFlatRegion()) { -// if (function.apply(pt)) { -// affected++; -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } } return null; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java index 7293d2b26..586d27d0f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java @@ -103,7 +103,7 @@ public class LayerVisitor implements Operation { // Abort if we are underground if (function.isGround(column.toBlockVector3(maxY + 1))) { - return null; + continue; } boolean found = false; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RecursiveVisitor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RecursiveVisitor.java index be44fb32b..72c294441 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RecursiveVisitor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/visitor/RecursiveVisitor.java @@ -26,9 +26,6 @@ import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; - -import static com.google.common.base.Preconditions.checkNotNull; - /** * An implementation of an {@link BreadthFirstSearch} that uses a mask to * determine where a block should be visited. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BiomeChange.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BiomeChange.java index 133f38f7f..f8c0ef597 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BiomeChange.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BiomeChange.java @@ -25,7 +25,7 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.math.BlockVector2; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; /** * Represents a biome change that may be undone or replayed. @@ -37,8 +37,8 @@ import com.sk89q.worldedit.world.biome.BaseBiome; public class BiomeChange implements Change { private final BlockVector2 position; - private final BaseBiome previous; - private final BaseBiome current; + private final BiomeType previous; + private final BiomeType current; /** * Create a new biome change. @@ -47,7 +47,7 @@ public class BiomeChange implements Change { * @param previous the previous biome * @param current the current biome */ - public BiomeChange(BlockVector2 position, BaseBiome previous, BaseBiome current) { + public BiomeChange(BlockVector2 position, BiomeType previous, BiomeType current) { checkNotNull(position); checkNotNull(previous); checkNotNull(current); @@ -70,7 +70,7 @@ public class BiomeChange implements Change { * * @return the previous biome */ - public BaseBiome getPrevious() { + public BiomeType getPrevious() { return previous; } @@ -79,7 +79,7 @@ public class BiomeChange implements Change { * * @return the current biome */ - public BaseBiome getCurrent() { + public BiomeType getCurrent() { return current; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java index d4613b277..ce7c26926 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java @@ -21,10 +21,10 @@ package com.sk89q.worldedit.history.change; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.history.UndoContext; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java index 256f891ec..ed65dc8fb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java @@ -19,17 +19,15 @@ package com.sk89q.worldedit.internal.command; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandException; import com.sk89q.minecraft.util.commands.Logging; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.command.parametric.AbstractInvokeListener; import com.sk89q.worldedit.util.command.parametric.InvokeHandler; import com.sk89q.worldedit.util.command.parametric.ParameterData; @@ -40,6 +38,8 @@ import java.lang.reflect.Method; import java.util.logging.Handler; import java.util.logging.Logger; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Logs called commands to a logger. */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java index ead5cd02b..937a9d79a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java @@ -27,9 +27,6 @@ import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.UnknownDirectionException; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; - -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.input.NoMatchException; @@ -51,15 +48,15 @@ import com.sk89q.worldedit.util.command.parametric.BindingHelper; import com.sk89q.worldedit.util.command.parametric.BindingMatch; import com.sk89q.worldedit.util.command.parametric.ParameterException; import com.sk89q.worldedit.world.World; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.Biomes; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.registry.BiomeRegistry; -import java.util.Arrays; -import java.util.List; +import java.util.Collection; /** * Binds standard WorldEdit classes such as {@link Player} and {@link LocalSession}. @@ -107,7 +104,7 @@ public class WorldEditBinding { Player sender = getPlayer(context); LocalSession session = worldEdit.getSessionManager().get(sender); EditSession editSession = session.createEditSession(sender); - editSession.enableQueue(); + editSession.enableStandardMode(); context.getContext().getLocals().put(EditSession.class, editSession); session.tellVersion(sender); return editSession; @@ -338,7 +335,8 @@ public BaseBlock getBaseBlock(ArgumentStack context) throws ParameterException, return type; } else { throw new ParameterException( - String.format("Can't recognize tree type '%s' -- choose from: %s", input, Arrays.toString(TreeType.values()))); + String.format("Can't recognize tree type '%s' -- choose from: %s", input, + TreeType.getPrimaryAliases())); } } else { return TreeType.TREE; @@ -346,24 +344,26 @@ public BaseBlock getBaseBlock(ArgumentStack context) throws ParameterException, } /** - * Gets an {@link BaseBiome} from a {@link ArgumentStack}. + * Gets an {@link BiomeType} from a {@link ArgumentStack}. * * @param context the context * @return a pattern * @throws ParameterException on error * @throws WorldEditException on error */ - @BindingMatch(type = BaseBiome.class, - behavior = BindingBehavior.CONSUMES, - consumedCount = 1) - public BaseBiome getBiomeType(ArgumentStack context) throws ParameterException, WorldEditException { + @BindingMatch(type = BiomeType.class, + behavior = BindingBehavior.CONSUMES, + consumedCount = 1) + public BiomeType getBiomeType(ArgumentStack context) throws ParameterException, WorldEditException { String input = context.next(); if (input != null) { - if (MathMan.isInteger(input)) return new BaseBiome(Integer.parseInt(input)); + + if (MathMan.isInteger(input)) return new BiomeType(Integer.parseInt(input)); TODO FIXME + BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager() .queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); - List knownBiomes = biomeRegistry.getBiomes(); - BaseBiome biome = Biomes.findBiomeByName(knownBiomes, input, biomeRegistry); + Collection knownBiomes = BiomeType.REGISTRY.values(); + BiomeType biome = Biomes.findBiomeByName(knownBiomes, input, biomeRegistry); if (biome != null) { return biome; } else { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java index 17460fc1f..3237eb686 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java @@ -19,12 +19,15 @@ package com.sk89q.worldedit.internal.expression; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.internal.expression.lexer.Lexer; import com.sk89q.worldedit.internal.expression.lexer.tokens.Token; import com.sk89q.worldedit.internal.expression.parser.Parser; import com.sk89q.worldedit.internal.expression.runtime.Constant; import com.sk89q.worldedit.internal.expression.runtime.EvaluationException; import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment; +import com.sk89q.worldedit.internal.expression.runtime.ExpressionTimeoutException; import com.sk89q.worldedit.internal.expression.runtime.Functions; import com.sk89q.worldedit.internal.expression.runtime.RValue; import com.sk89q.worldedit.internal.expression.runtime.ReturnException; @@ -33,6 +36,12 @@ import java.util.ArrayDeque; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; /** * Compiles and evaluates expressions. @@ -68,6 +77,11 @@ import java.util.Map; public class Expression { private static final ThreadLocal> instance = ThreadLocal.withInitial(ArrayDeque::new); + private static final ExecutorService evalThread = Executors.newCachedThreadPool( + new ThreadFactoryBuilder() + .setDaemon(true) + .setNameFormat("worldedit-expression-eval-%d") + .build()); private final Map variables = new HashMap<>(); private final String[] variableNames; @@ -119,10 +133,55 @@ public class Expression { var.value = values[i]; } pushInstance(); + return evaluate(values, WorldEdit.getInstance().getConfiguration().calculationTimeout); + } + + public double evaluate(double[] values, int timeout) throws EvaluationException { + for (int i = 0; i < values.length; ++i) { + final String variableName = variableNames[i]; + final RValue invokable = variables.get(variableName); + if (!(invokable instanceof Variable)) { + throw new EvaluationException(invokable.getPosition(), "Tried to assign constant " + variableName + "."); + } + + ((Variable) invokable).value = values[i]; + } try { - return root.getValue(); + if (timeout < 0) { + return evaluateRoot(); + } + return evaluateRootTimed(timeout); } catch (ReturnException e) { return e.getValue(); + } // other evaluation exceptions are thrown out of this method + } + + private double evaluateRootTimed(int timeout) throws EvaluationException { + Future result = evalThread.submit(this::evaluateRoot); + try { + return result.get(timeout, TimeUnit.MILLISECONDS); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeException(e); + } catch (TimeoutException e) { + result.cancel(true); + throw new ExpressionTimeoutException("Calculations exceeded time limit."); + } catch (ExecutionException e) { + Throwable cause = e.getCause(); + if (cause instanceof EvaluationException) { + throw (EvaluationException) cause; + } + if (cause instanceof RuntimeException) { + throw (RuntimeException) cause; + } + throw new RuntimeException(cause); + } + } + + private Double evaluateRoot() throws EvaluationException { + pushInstance(); + try { + return root.getValue(); } finally { popInstance(); } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/CommonProxy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/ExpressionTimeoutException.java similarity index 73% rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/CommonProxy.java rename to worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/ExpressionTimeoutException.java index 18a7de68f..ce7d55140 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/CommonProxy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/ExpressionTimeoutException.java @@ -17,15 +17,13 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.forge; +package com.sk89q.worldedit.internal.expression.runtime; -import com.sk89q.worldedit.forge.gui.GuiHandler; -import net.minecraftforge.fml.common.network.NetworkRegistry; - -public class CommonProxy { - - public void registerHandlers() { - NetworkRegistry.INSTANCE.registerGuiHandler(ForgeWorldEdit.inst, new GuiHandler()); +/** + * Thrown when an evaluation exceeds the timeout time. + */ +public class ExpressionTimeoutException extends EvaluationException { + public ExpressionTimeoutException(String message) { + super(-1, message); } - } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/For.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/For.java index 3250da3ed..e660daacd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/For.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/For.java @@ -29,10 +29,9 @@ public class For extends Node { throw new EvaluationException(this.getPosition(), "Loop exceeded 256 iterations."); } - if(Thread.currentThread().isInterrupted()){ + if(Thread.interrupted()){ throw new EvaluationException(this.getPosition(), "Thread has been interrupted."); } - ++iterations; try { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/SimpleFor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/SimpleFor.java index 0faf0c3eb..1576c3484 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/SimpleFor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/SimpleFor.java @@ -53,8 +53,8 @@ public class SimpleFor extends Node { if (iterations > 256) { throw new EvaluationException(getPosition(), "Loop exceeded 256 iterations."); } - if(Thread.currentThread().isInterrupted()){ - throw new EvaluationException(this.getPosition(), "Thread has been interrupted."); + if (Thread.interrupted()) { + throw new EvaluationException(getPosition(), "Calculations exceeded time limit."); } ++iterations; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/While.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/While.java index 5eb3ed5f6..5da3dae01 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/While.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/runtime/While.java @@ -49,8 +49,8 @@ public class While extends Node { if (iterations > 256) { throw new EvaluationException(getPosition(), "Loop exceeded 256 iterations."); } - if(Thread.currentThread().isInterrupted()){ - throw new EvaluationException(this.getPosition(), "Thread has been interrupted."); + if (Thread.interrupted()) { + throw new EvaluationException(getPosition(), "Calculations exceeded time limit."); } ++iterations; @@ -69,8 +69,8 @@ public class While extends Node { if (iterations > 256) { throw new EvaluationException(getPosition(), "Loop exceeded 256 iterations."); } - if(Thread.currentThread().isInterrupted()){ - throw new EvaluationException(this.getPosition(), "Thread has been interrupted."); + if (Thread.interrupted()) { + throw new EvaluationException(getPosition(), "Calculations exceeded time limit."); } ++iterations; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/InputParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/InputParser.java index ee40fa3b9..c96a1d183 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/InputParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/InputParser.java @@ -24,6 +24,7 @@ import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; +import java.util.Collections; import java.util.List; /** @@ -48,6 +49,6 @@ public abstract class InputParser { * @return a list of suggestions */ public List getSuggestions() { - return Lists.newArrayList(); + return Collections.emptyList(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java index 1950ff9e2..001fe15ce 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java @@ -485,7 +485,7 @@ public class Vector2 { } Vector2 other = (Vector2) obj; - return other.getX() == this.getX() && other.getZ() == this.getZ(); + return other.x == this.x && other.z == this.z; } @@ -496,7 +496,7 @@ public class Vector2 { @Override public String toString() { - return "(" + getX() + ", " + getZ() + ")"; + return "(" + x + ", " + z + ")"; } } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java index 172a75687..275dff135 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java @@ -622,13 +622,12 @@ public class Vector3 { @Override public boolean equals(Object obj) { - if (obj == this) return true; if (!(obj instanceof Vector3)) { return false; } Vector3 other = (Vector3) obj; - return other.getX() == this.getX() && other.getZ() == this.getZ() && other.getY() == this.getY(); + return other.x == this.x && other.y == this.y && other.z == this.z; } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java index 34f757b44..f3cb35c9b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java @@ -5,6 +5,7 @@ import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.block.BlockState; @@ -18,6 +19,8 @@ import java.util.Iterator; import static com.google.common.base.Preconditions.checkNotNull; +import javax.annotation.Nullable; + /** * Allows applications of Kernels onto the region's height map. *

@@ -44,11 +47,11 @@ public class HeightMap { this(session, region, false); } - public HeightMap(EditSession session, Region region, boolean naturalOnly) { - this(session, region, naturalOnly, false); + public HeightMap(EditSession session, Region region, Mask mask) { + this(session, region, mask, false); } - public HeightMap(EditSession session, Region region, boolean naturalOnly, boolean layers) { + public HeightMap(EditSession session, Region region, Mask mask, boolean layers) { checkNotNull(session); checkNotNull(region); @@ -80,35 +83,27 @@ public class HeightMap { BlockVector2 pos = iter.next(); int x = pos.getBlockX(); int z = pos.getBlockZ(); - layer = session.getNearestSurfaceLayer(x, z, (layer + 7) >> 3, 0, maxY); + layer = session.getNearestSurfaceLayer(x, z, (layer + 7) >> 3, 0, maxY, mask); data[(z - bz) * width + (x - bx)] = layer; } } else { // Store current heightmap data int index = 0; - if (naturalOnly) { - for (int z = 0; z < height; ++z) { - for (int x = 0; x < width; ++x, index++) { - data[index] = session.getHighestTerrainBlock(x + minX, z + minZ, minY, maxY); - } - } - } else { - int yTmp = 255; - for (int z = 0; z < height; ++z) { - for (int x = 0; x < width; ++x, index++) { - yTmp = session.getNearestSurfaceTerrainBlock(x + minX, z + minZ, yTmp, minY, maxY, Integer.MIN_VALUE, Integer.MAX_VALUE); - switch (yTmp) { - case Integer.MIN_VALUE: - yTmp = minY; - invalid[index] = true; - break; - case Integer.MAX_VALUE: - yTmp = maxY; - invalid[index] = true; - break; - } - data[index] = yTmp; + int yTmp = 255; + for (int z = 0; z < height; ++z) { + for (int x = 0; x < width; ++x, index++) { + yTmp = session.getNearestSurfaceTerrainBlock(x + minX, z + minZ, yTmp, minY, maxY, Integer.MIN_VALUE, Integer.MAX_VALUE, mask); + switch (yTmp) { + case Integer.MIN_VALUE: + yTmp = minY; + invalid[index] = true; + break; + case Integer.MAX_VALUE: + yTmp = maxY; + invalid[index] = true; + break; } + data[index] = yTmp; } } } @@ -180,7 +175,6 @@ public class HeightMap { // Depending on growing or shrinking we need to start at the bottom or top if (newHeight > curHeight) { // Set the top block of the column to be the same type (this might go wrong with rounding) -//<<<<<<< HEAD BlockStateHolder existing = session.getBlock(xr, curBlock, zr); // Skip water/lava @@ -200,34 +194,13 @@ public class HeightMap { } else { existing = PropertyGroup.LEVEL.set(existing, 15); session.setBlock(xr, newBlock, zr, existing); - -//======= -// BlockState existing = session.getBlock(BlockVector3.at(xr, curHeight, zr)); -// -// // Skip water/lava -// if (existing.getBlockType() != BlockTypes.WATER && existing.getBlockType() != BlockTypes.LAVA) { -// session.setBlock(BlockVector3.at(xr, newHeight, zr), existing); -// ++blocksChanged; -// -// // Grow -- start from 1 below top replacing airblocks -// for (int y = newHeight - 1 - originY; y >= 0; --y) { -// int copyFrom = (int) (y * scale); -// session.setBlock(BlockVector3.at(xr, originY + y, zr), session.getBlock(BlockVector3.at(xr, originY + copyFrom, zr))); -//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching ++blocksChanged; } } } else if (curHeight > newHeight) { -//<<<<<<< HEAD // Fill rest with air for (int y = newBlock + 1; y <= ((curHeight + 15) >> 4); ++y) { session.setBlock(xr, y, zr, fillerAir); -//======= -// // Shrink -- start from bottom -// for (int y = 0; y < newHeight - originY; ++y) { -// int copyFrom = (int) (y * scale); -// session.setBlock(BlockVector3.at(xr, originY + y, zr), session.getBlock(BlockVector3.at(xr, originY + copyFrom, zr))); -//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching ++blocksChanged; } // Set the top block of the column to be the same type diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java index 29a3ee5ee..23680f2bc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java @@ -21,14 +21,15 @@ package com.sk89q.worldedit.math.interpolation; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.math.Vector3; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.List; import java.util.Map.Entry; import java.util.TreeMap; -import java.util.logging.Logger; + +import static com.google.common.base.Preconditions.checkNotNull; /** * Reparametrises another interpolation function by arc length. @@ -38,7 +39,7 @@ import java.util.logging.Logger; */ public class ReparametrisingInterpolation implements Interpolation { - private static final Logger log = Logger.getLogger(ReparametrisingInterpolation.class.getCanonicalName()); + private static final Logger log = LoggerFactory.getLogger(ReparametrisingInterpolation.class); private final Interpolation baseInterpolation; private double totalArcLength; @@ -102,7 +103,7 @@ public class ReparametrisingInterpolation implements Interpolation { Entry ceilingEntry = cache.ceilingEntry(arc); if (ceilingEntry == null) { - log.warning("Error in arcToParameter: no ceiling entry for " + arc + " found!"); + log.warn("Error in arcToParameter: no ceiling entry for " + arc + " found!"); return 0; } final double rightArc = ceilingEntry.getKey(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java index 5223ca718..e31f3cd86 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java @@ -3,9 +3,9 @@ package com.sk89q.worldedit.math.transform; import java.io.IOException; import java.io.Serializable; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MathUtils; -import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.Vector3; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java index 521f23c62..66b3028e5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractRegion.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.regions; -import com.sk89q.worldedit.*; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 5ead3a841..77bd47f7e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -346,16 +346,10 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { }; } -//<<<<<<< HEAD @Override public int size() { return size; } -//======= -// for (int x = min.getBlockX() >> ChunkStore.CHUNK_SHIFTS; x <= max.getBlockX() >> ChunkStore.CHUNK_SHIFTS; ++x) { -// for (int z = min.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; z <= max.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; ++z) { -// chunks.add(BlockVector2.at(x, z)); -//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching @Override @@ -394,27 +388,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { } -// private int ly = Integer.MIN_VALUE; -// private int lz = Integer.MIN_VALUE; -// private boolean lr, lry, lrz; - @Override public boolean contains(int x, int y, int z) { return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ && y >= this.minY && y <= this.maxY; -// if (z != lz) { -// lz = z; -// lrz = z >= this.minZ && z <= this.maxZ; -// if (y != ly) { -// ly = y; -// lry = y >= this.minY && y <= this.maxY; -// } -// lr = lrz && lry; -// } else if (y != ly) { -// ly = y; -// lry = y >= this.minY && y <= this.maxY; -// lr = lrz && lry; -// } -// return lr && (x >= this.minX && x <= this.maxX); } @Override @@ -467,7 +443,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { @Override public BlockVector3 next() { -//<<<<<<< HEAD mutable.mutX(x); mutable.mutY(y); mutable.mutZ(z); @@ -503,17 +478,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { } else { x = cbx; z = cbz; -//======= -// if (!hasNext()) throw new NoSuchElementException(); -// BlockVector3 answer = BlockVector3.at(nextX, nextY, nextZ); -// if (++nextX > max.getBlockX()) { -// nextX = min.getBlockX(); -// if (++nextY > max.getBlockY()) { -// nextY = min.getBlockY(); -// if (++nextZ > max.getBlockZ()) { -// nextX = Integer.MIN_VALUE; -//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching - } } else { x = cbx; } @@ -540,16 +504,10 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { } @Override -//<<<<<<< HEAD public BlockVector3 next() { mutable.mutX(nextX); mutable.mutY(nextY); mutable.mutZ(nextZ); -//======= -// public BlockVector2 next() { -// if (!hasNext()) throw new NoSuchElementException(); -// BlockVector2 answer = BlockVector2.at(nextX, nextZ); -//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching if (++nextX > max.getBlockX()) { nextX = min.getBlockX(); if (++nextZ > max.getBlockZ()) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java index 9524874f2..90892ed12 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java @@ -105,7 +105,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { hasY = region.hasY; } - @Override + @Override public Vector3 getCenter() { return center.toVector3((maxY + minY) / 2); } @@ -306,7 +306,6 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { double dz = Math.abs(pz - center.getBlockZ()) * radiusInverse.getZ(); return dx * dx + dz * dz <= 1; -// return position.subtract(center).toVector2().divide(radius).lengthSq() <= 1; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java index f7c209a14..415f92244 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java @@ -117,10 +117,10 @@ public class EllipsoidRegion extends AbstractRegion { return diff.divide(2).floor(); } - private BlockVector3 calculateChanges(BlockVector3... changes) { - BlockVector3 total = BlockVector3.ZERO; + private Vector3 calculateChanges(BlockVector3... changes) { + Vector3 total = Vector3.ZERO; for (BlockVector3 change : changes) { - total = total.add(change.abs()); + total = total.add(change.abs().toVector3()); } return total.divide(2).floor(); @@ -135,8 +135,8 @@ public class EllipsoidRegion extends AbstractRegion { @Override public void contract(BlockVector3... changes) throws RegionOperationException { center = center.subtract(calculateDiff(changes)); - Vector3 newRadius = radius.subtract(calculateChanges(changes).toVector3()); - setRadius(Vector3.at(1.5, 1.5, 1.5).getMaximum(newRadius)); + Vector3 newRadius = radius.subtract(calculateChanges(changes)); + radius = Vector3.at(1.5, 1.5, 1.5).getMaximum(newRadius); } @Override @@ -214,31 +214,29 @@ public class EllipsoidRegion extends AbstractRegion { } @Override -// public boolean contains(Vector position) { -// int cx = position.getBlockX() - center.getBlockX(); -// int cx2 = cx * cx; -// if (cx2 > radiusSqr.getBlockX()) { -// return false; -// } -// int cz = position.getBlockZ() - center.getBlockZ(); -// int cz2 = cz * cz; -// if (cz2 > radiusSqr.getBlockZ()) { -// return false; -// } -// int cy = position.getBlockY() - center.getBlockY(); -// int cy2 = cy * cy; -// if (radiusSqr.getBlockY() < 255 && cy2 > radiusSqr.getBlockY()) { -// return false; -// } -// if (sphere) { -// return cx2 + cy2 + cz2 <= radiusLengthSqr; -// } -// double cxd = (double) cx / radius.getBlockX(); -// double cyd = (double) cy / radius.getBlockY(); -// double czd = (double) cz / radius.getBlockZ(); -// return cxd * cxd + cyd * cyd + czd * czd <= 1; - public boolean contains(BlockVector3 position) { - return position.subtract(center).divide(radius.toBlockPoint()).lengthSq() <= 1; + public boolean contains(BlockVector3 position) { + int cx = position.getBlockX() - center.getBlockX(); + int cx2 = cx * cx; + if (cx2 > radiusSqr.getBlockX()) { + return false; + } + int cz = position.getBlockZ() - center.getBlockZ(); + int cz2 = cz * cz; + if (cz2 > radiusSqr.getBlockZ()) { + return false; + } + int cy = position.getBlockY() - center.getBlockY(); + int cy2 = cy * cy; + if (radiusSqr.getBlockY() < 255 && cy2 > radiusSqr.getBlockY()) { + return false; + } + if (sphere) { + return cx2 + cy2 + cz2 <= radiusLengthSqr; + } + double cxd = (double) cx / radius.getBlockX(); + double cyd = (double) cy / radius.getBlockY(); + double czd = (double) cz / radius.getBlockZ(); + return cxd * cxd + cyd * cyd + czd * czd <= 1; } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/NullRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/NullRegion.java index 570f0a80d..de2a3dea0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/NullRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/NullRegion.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.regions; -import com.sk89q.worldedit.*; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java index 96d0bfa63..8c4c75a48 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java @@ -108,7 +108,6 @@ public interface Region extends Iterable, Cloneable { */ void shift(BlockVector3 change) throws RegionOperationException; - default boolean contains(int x, int y, int z) { return contains(BlockVector3.at(x, y, z)); } @@ -128,6 +127,12 @@ public interface Region extends Iterable, Cloneable { * @param position the position * @return true if contained */ + /** + * Returns true based on whether the region contains the point. + * + * @param position the position + * @return true if contained + */ boolean contains(BlockVector3 position); /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java index 0a61610b3..6a7a06780 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java @@ -21,8 +21,8 @@ package com.sk89q.worldedit.regions.iterator; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.FlatRegion; import java.util.Iterator; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java index 1c28566f4..8bd0a48dc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java @@ -21,11 +21,12 @@ package com.sk89q.worldedit.regions.iterator; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import java.util.Iterator; +import java.util.NoSuchElementException; public class FlatRegionIterator implements Iterator { @@ -72,7 +73,7 @@ public class FlatRegionIterator implements Iterator { @Override public BlockVector2 next() { if (!hasNext()) { - throw new java.util.NoSuchElementException(); + throw new NoSuchElementException(); } BlockVector2 answer = BlockVector2.at(nextX, nextZ); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java index afe54c996..aa6f48da3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java @@ -174,7 +174,6 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion { @Override public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) { BBC.SELECTOR_CENTER.send(player, pos, 0); - session.describeCUI(player); } @@ -182,7 +181,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion { public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) { Vector3 center = region.getCenter(); - if (!center.equals(BlockVector3.ZERO)) { + if (!center.equals(Vector3.ZERO)) { BBC.SELECTOR_RADIUS.send(player, NUMBER_FORMAT.format(region.getRadius().getX()) + "/" + NUMBER_FORMAT.format(region.getRadius().getZ()), region.getArea()); } else { BBC.SELECTION_WAND.send(player); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java index 0ebdc7393..de1324852 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java @@ -24,7 +24,8 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.FlatRegion; import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.biome.BiomeTypes; /** * Generates solid and hollow shapes according to materials returned by the @@ -54,10 +55,10 @@ public abstract class ArbitraryBiomeShape { cacheOffsetX = min.getBlockX() - 1; cacheOffsetZ = min.getBlockZ() - 1; - cacheSizeX = (int) (max.getX() - cacheOffsetX + 2); - cacheSizeZ = (int) (max.getZ() - cacheOffsetZ + 2); + cacheSizeX = max.getX() - cacheOffsetX + 2; + cacheSizeZ = max.getZ() - cacheOffsetZ + 2; - cache = new BaseBiome[cacheSizeX * cacheSizeZ]; + cache = new BiomeType[cacheSizeX * cacheSizeZ]; } protected Iterable getExtent() { @@ -71,7 +72,7 @@ public abstract class ArbitraryBiomeShape { * OUTSIDE = outside * else = inside */ - private final BaseBiome[] cache; + private final BiomeType[] cache; /** * Override this function to specify the shape to generate. @@ -81,17 +82,17 @@ public abstract class ArbitraryBiomeShape { * @param defaultBaseBiome The default biome for the current column. * @return material to place or null to not place anything. */ - protected abstract BaseBiome getBiome(int x, int z, BaseBiome defaultBaseBiome); + protected abstract BiomeType getBiome(int x, int z, BiomeType defaultBaseBiome); - private BaseBiome getBiomeCached(int x, int z, BaseBiome baseBiome) { + private BiomeType getBiomeCached(int x, int z, BiomeType baseBiome) { final int index = (z - cacheOffsetZ) + (x - cacheOffsetX) * cacheSizeZ; - final BaseBiome cacheEntry = cache[index]; + final BiomeType cacheEntry = cache[index]; if (cacheEntry == null) {// unknown, fetch material - final BaseBiome material = getBiome(x, z, baseBiome); + final BiomeType material = getBiome(x, z, baseBiome); if (material == null) { // outside - cache[index] = OUTSIDE; + cache[index] = BiomeTypes.THE_VOID; return null; } @@ -99,7 +100,7 @@ public abstract class ArbitraryBiomeShape { return material; } - if (cacheEntry == OUTSIDE) { + if (cacheEntry == BiomeTypes.THE_VOID) { // outside return null; } @@ -107,16 +108,16 @@ public abstract class ArbitraryBiomeShape { return cacheEntry; } - private boolean isInsideCached(int x, int z, BaseBiome baseBiome) { + private boolean isInsideCached(int x, int z, BiomeType baseBiome) { final int index = (z - cacheOffsetZ) + (x - cacheOffsetX) * cacheSizeZ; - final BaseBiome cacheEntry = cache[index]; + final BiomeType cacheEntry = cache[index]; if (cacheEntry == null) { // unknown block, meaning they must be outside the extent at this stage, but might still be inside the shape return getBiomeCached(x, z, baseBiome) != null; } - return cacheEntry != OUTSIDE; + return cacheEntry != BiomeTypes.THE_VOID; } /** @@ -127,7 +128,7 @@ public abstract class ArbitraryBiomeShape { * @param hollow Specifies whether to generate a hollow shape. * @return number of affected blocks. */ - public int generate(EditSession editSession, BaseBiome baseBiome, boolean hollow) { + public int generate(EditSession editSession, BiomeType baseBiome, boolean hollow) { int affected = 0; for (BlockVector2 position : getExtent()) { @@ -135,8 +136,8 @@ public abstract class ArbitraryBiomeShape { int z = position.getBlockZ(); if (!hollow) { - final BaseBiome material = getBiome(x, z, baseBiome); - if (material != null && material != OUTSIDE) { + final BiomeType material = getBiome(x, z, baseBiome); + if (material != null && material != BiomeTypes.THE_VOID) { editSession.getWorld().setBiome(position, material); ++affected; } @@ -144,7 +145,7 @@ public abstract class ArbitraryBiomeShape { continue; } - final BaseBiome material = getBiomeCached(x, z, baseBiome); + final BiomeType material = getBiomeCached(x, z, baseBiome); if (material == null) { continue; } @@ -180,16 +181,4 @@ public abstract class ArbitraryBiomeShape { return affected; } - private static final BaseBiome OUTSIDE = new BaseBiome(0) { - @Override - public int hashCode() { - return 0; - } - - @Override - public boolean equals(Object o) { - return this == o; - } - }; - } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java index 142fbb481..b9eed1bee 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java @@ -34,8 +34,36 @@ public abstract class ArbitraryShape { protected final Region extent; + private int cacheOffsetX; + private int cacheOffsetY; + private int cacheOffsetZ; + private int cacheSizeX; + private int cacheSizeY; + private int cacheSizeZ; + + /** + * Cache entires: + * 0 = unknown + * -1 = outside + * 1 = inside + */ + private final byte[] cache; + public ArbitraryShape(Region extent) { this.extent = extent; + + BlockVector3 min = extent.getMinimumPoint(); + BlockVector3 max = extent.getMaximumPoint(); + + cacheOffsetX = min.getBlockX() - 1; + cacheOffsetY = min.getBlockY() - 1; + cacheOffsetZ = min.getBlockZ() - 1; + + cacheSizeX = max.getX() - cacheOffsetX + 2; + cacheSizeY = max.getY() - cacheOffsetY + 2; + cacheSizeZ = max.getZ() - cacheOffsetZ + 2; + + cache = new byte[cacheSizeX * cacheSizeY * cacheSizeZ]; } protected Region getExtent() { @@ -81,6 +109,40 @@ public abstract class ArbitraryShape { BaseBlock material = getMaterial(x, y, z, pattern.apply(position)); if (material == null) { + final int index = (y - cacheOffsetY) + (z - cacheOffsetZ) * cacheSizeY + (x - cacheOffsetX) * cacheSizeY * cacheSizeZ; + cache[index] = -1; + continue; + } + + boolean draw = false; + do { + if (!isInsideCached(x + 1, y, z, pattern)) { + draw = true; + break; + } + if (!isInsideCached(x - 1, y, z, pattern)) { + draw = true; + break; + } + if (!isInsideCached(x, y, z + 1, pattern)) { + draw = true; + break; + } + if (!isInsideCached(x, y, z - 1, pattern)) { + draw = true; + break; + } + if (!isInsideCached(x, y + 1, z, pattern)) { + draw = true; + break; + } + if (!isInsideCached(x, y - 1, z, pattern)) { + draw = true; + break; + } + } while (false); + + if (!draw) { continue; } @@ -92,4 +154,27 @@ public abstract class ArbitraryShape { return affected; } + private boolean isInsideCached(int x, int y, int z, Pattern pattern) { + final int index = (y - cacheOffsetY) + (z - cacheOffsetZ) * cacheSizeY + (x - cacheOffsetX) * cacheSizeY * cacheSizeZ; + + switch (cache[index]) { + case 0: + BaseBlock mat = getMaterial(x, y, z, pattern.apply(BlockVector3.at(x, y, z))); + if (mat == null) { + cache[index] = -1; + return false; + } + cache[index] = 1; + return true; + + case -1: + // outside + return false; + + default: + // inside + return true; + } + } + } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/CraftScriptContext.java b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/CraftScriptContext.java index 1307508f5..e97e7ebf6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/CraftScriptContext.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/CraftScriptContext.java @@ -28,6 +28,7 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.function.pattern.Pattern; +import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.util.io.file.FilenameException; import com.sk89q.worldedit.world.block.BaseBlock; @@ -62,7 +63,8 @@ public class CraftScriptContext extends CraftScriptEnvironment { EditSession editSession = controller.getEditSessionFactory() .getEditSession(player.getWorld(), session.getBlockChangeLimit(), session.getBlockBag(player), player); - editSession.enableQueue(); + Request.request().setEditSession(editSession); + editSession.enableStandardMode(); editSessions.add(editSession); return editSession; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java index 5339db01d..4e5edd5f2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/SessionManager.java @@ -19,7 +19,8 @@ package com.sk89q.worldedit.session; -import com.boydti.fawe.object.collection.SoftHashMap; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; import com.sk89q.worldedit.LocalConfiguration; @@ -27,50 +28,46 @@ import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent; +import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.session.storage.JsonFileSessionStore; import com.sk89q.worldedit.session.storage.SessionStore; import com.sk89q.worldedit.session.storage.VoidStore; import com.sk89q.worldedit.util.concurrency.EvenMoreExecutors; import com.sk89q.worldedit.util.eventbus.Subscribe; import com.sk89q.worldedit.world.gamemode.GameModes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Nullable; import java.io.File; import java.io.IOException; -import java.lang.ref.Reference; -import java.lang.ref.SoftReference; +import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Timer; +import java.util.TimerTask; import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.annotation.Nullable; - +import java.util.concurrent.Callable; import static com.google.common.base.Preconditions.checkNotNull; /** * Session manager for WorldEdit. - *

+ * *

Get a reference to one from {@link WorldEdit}.

- *

+ * *

While this class is thread-safe, the returned session may not be.

*/ public class SessionManager { - @Deprecated - public static int EXPIRATION_GRACE = 600000; - + public static int EXPIRATION_GRACE = 0; + private static final int FLUSH_PERIOD = 1000 * 60; private static final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 5)); - private static final Logger log = Logger.getLogger(SessionManager.class.getCanonicalName()); + private static final Logger log = LoggerFactory.getLogger(SessionManager.class); private final Timer timer = new Timer(); private final WorldEdit worldEdit; - private final Map sessions = new ConcurrentHashMap<>(8, 0.9f, 1); - private final Map> softSessions = new SoftHashMap<>(); - + private final Map sessions = new HashMap<>(); private SessionStore store = new VoidStore(); - private File path; /** * Create a new session manager. @@ -82,6 +79,7 @@ public class SessionManager { this.worldEdit = worldEdit; worldEdit.getEventBus().register(this); + timer.schedule(new SessionTracker(), FLUSH_PERIOD, FLUSH_PERIOD); } /** @@ -92,7 +90,7 @@ public class SessionManager { */ public synchronized boolean contains(SessionOwner owner) { checkNotNull(owner); - return sessions.containsKey(getKey(owner)) || softSessions.containsKey(owner); + return sessions.containsKey(getKey(owner)); } /** @@ -110,24 +108,7 @@ public class SessionManager { return holder.session; } } - Iterator>> iter = softSessions.entrySet().iterator(); - while (iter.hasNext()) { - Map.Entry> entry = iter.next(); - UUID key = entry.getKey(); - SessionHolder holder = entry.getValue().get(); - if (holder == null) { - iter.remove(); - continue; - } - String test = holder.key.getName(); - if (test != null && name.equals(test)) { -// if (holder.key.isActive()) { - iter.remove(); - sessions.put(key, holder); -// } - return holder.session; - } - } + return null; } @@ -141,24 +122,12 @@ public class SessionManager { @Nullable public synchronized LocalSession getIfPresent(SessionOwner owner) { checkNotNull(owner); - UUID key = getKey(owner); - SessionHolder stored = sessions.get(key); + SessionHolder stored = sessions.get(getKey(owner)); if (stored != null) { return stored.session; } else { - Reference reference = softSessions.get(key); - if (reference != null) { - stored = reference.get(); - if (stored != null) { -// if (stored.key.isActive()) { - softSessions.remove(key); - sessions.put(key, stored); -// } - return stored.session; - } - } + return null; } - return null; } /** @@ -179,36 +148,26 @@ public class SessionManager { try { session = store.load(getKey(sessionKey)); session.postLoad(); - } catch (Throwable e) { - log.log(Level.WARNING, "Failed to load saved session", e); + } catch (IOException e) { + log.warn("Failed to load saved session", e); session = new LocalSession(); } + Request.request().setSession(session); session.setConfiguration(config); session.setBlockChangeLimit(config.defaultChangeLimit); + session.setTimeout(config.calculationTimeout); + // Remember the session regardless of if it's currently active or not. + // And have the SessionTracker FLUSH inactive sessions. sessions.put(getKey(owner), new SessionHolder(sessionKey, session)); } - // Set the limit on the number of blocks that an operation can - // change at once, or don't if the owner has an override or there - // is no limit. There is also a default limit - int currentChangeLimit = session.getBlockChangeLimit(); - - if (!owner.hasPermission("worldedit.limit.unrestricted") && config.maxChangeLimit > -1) { - // If the default limit is infinite but there is a maximum - // limit, make sure to not have it be overridden - if (config.defaultChangeLimit < 0) { - if (currentChangeLimit < 0 || currentChangeLimit > config.maxChangeLimit) { - session.setBlockChangeLimit(config.maxChangeLimit); - } - } else { - // Bound the change limit - int maxChangeLimit = config.maxChangeLimit; - if (currentChangeLimit == -1 || currentChangeLimit > maxChangeLimit) { - session.setBlockChangeLimit(maxChangeLimit); - } - } + if (shouldBoundLimit(owner, "worldedit.limit.unrestricted", session.getBlockChangeLimit(), config.maxChangeLimit)) { + session.setBlockChangeLimit(config.maxChangeLimit); + } + if (shouldBoundLimit(owner, "worldedit.timeout.unrestricted", session.getTimeout(), config.maxCalculationTimeout)) { + session.setTimeout(config.maxCalculationTimeout); } // Have the session use inventory if it's enabled and the owner @@ -221,27 +180,49 @@ public class SessionManager { return session; } - private void save(SessionHolder holder) { - SessionKey key = holder.key; - holder.session.setClipboard(null); - if (key.isPersistent()) { - try { - if (holder.session.compareAndResetDirty()) { - if (holder.session.save()) { - store.save(getKey(key), holder.session); - } else if (path != null) { - File file = new File(path, getKey(key) + ".json"); - if (file.exists()) { - if (!file.delete()) { - file.deleteOnExit(); - } - } + private boolean shouldBoundLimit(SessionOwner owner, String permission, int currentLimit, int maxLimit) { + if (maxLimit > -1) { // if max is finite + return (currentLimit < 0 || currentLimit > maxLimit) // make sure current is finite and less than max + && !owner.hasPermission(permission); // unless user has unlimited permission + } + return false; + } + + /** + * Save a map of sessions to disk. + * + * @param sessions a map of sessions to save + * @return a future that completes on save or error + */ + private ListenableFuture commit(final Map sessions) { + checkNotNull(sessions); + + if (sessions.isEmpty()) { + return Futures.immediateFuture(sessions); + } + + return executorService.submit((Callable) () -> { + Exception exception = null; + + for (Map.Entry entry : sessions.entrySet()) { + SessionKey key = entry.getKey(); + + if (key.isPersistent()) { + try { + store.save(getKey(key), entry.getValue()); + } catch (IOException e) { + log.warn("Failed to write session for UUID " + getKey(key), e); + exception = e; } } - } catch (IOException e) { - log.log(Level.WARNING, "Failed to write session for UUID " + getKey(key), e); } - } + + if (exception != null) { + throw exception; + } + + return sessions; + }); } /** @@ -277,44 +258,65 @@ public class SessionManager { */ public synchronized void remove(SessionOwner owner) { checkNotNull(owner); - SessionHolder session = sessions.remove(getKey(owner)); - if (session != null) { - save(session); - } + sessions.remove(getKey(owner)); } - public synchronized void forget(SessionOwner owner) { - checkNotNull(owner); - UUID key = getKey(owner); - SessionHolder holder = sessions.remove(key); - if (holder != null) { - softSessions.put(key, new SoftReference(holder)); - save(holder); - } + /** + * Called to unload this session manager. + */ + public synchronized void unload() { + clear(); } /** * Remove all sessions. */ public synchronized void clear() { - for (Map.Entry entry : sessions.entrySet()) { - save(entry.getValue()); - } + saveChangedSessions(); sessions.clear(); } + private synchronized void saveChangedSessions() { + long now = System.currentTimeMillis(); + Iterator it = sessions.values().iterator(); + Map saveQueue = new HashMap<>(); + + while (it.hasNext()) { + SessionHolder stored = it.next(); + if (stored.key.isActive()) { + stored.lastActive = now; + + if (stored.session.compareAndResetDirty()) { + // Don't save unless player disconnects +// saveQueue.put(stored.key, stored.session); + } + } else { + if (now - stored.lastActive > EXPIRATION_GRACE) { + if (stored.session.compareAndResetDirty()) { + saveQueue.put(stored.key, stored.session); + } + + it.remove(); + } + } + } + + if (!saveQueue.isEmpty()) { + commit(saveQueue); + } + } + @Subscribe public void onConfigurationLoad(ConfigurationLoadEvent event) { LocalConfiguration config = event.getConfiguration(); File dir = new File(config.getWorkingDirectory(), "sessions"); store = new JsonFileSessionStore(dir); - this.path = dir; } /** * Stores the owner of a session, the session, and the last active time. */ - private static class SessionHolder { + private static final class SessionHolder { private final SessionKey key; private final LocalSession session; private long lastActive = System.currentTimeMillis(); @@ -325,7 +327,17 @@ public class SessionManager { } } - - + /** + * Removes inactive sessions after they have been inactive for a period + * of time. Commits them as well. + */ + private class SessionTracker extends TimerTask { + @Override + public void run() { + synchronized (SessionManager.this) { + saveChangedSessions(); + } + } + } } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/Request.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/Request.java index ef26a05f1..e0786b03e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/Request.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/Request.java @@ -34,21 +34,12 @@ public final class Request { private static final ThreadLocal threadLocal = ThreadLocal.withInitial(Request::new); - private - @Nullable - World world; - private - @Nullable - Actor actor; - private - @Nullable - LocalSession session; - private - @Nullable - EditSession editSession; - private - @Nullable - Extent extent; + private @Nullable World world; + private @Nullable Actor actor; + private @Nullable LocalSession session; + private @Nullable EditSession editSession; + private @Nullable Extent extent; + private boolean valid; private Request() { } @@ -148,8 +139,20 @@ public final class Request { * Reset the current request and clear all fields. */ public static void reset() { + request().invalidate(); threadLocal.remove(); } + /** + * Check if the current request object is still valid. Invalid requests may contain outdated values. + * + * @return true if the request is valid + */ + public boolean isValid() { + return valid; + } + private void invalidate() { + valid = false; + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestExtent.java new file mode 100644 index 000000000..dc5aac815 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestExtent.java @@ -0,0 +1,109 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.session.request; + +import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.entity.BaseEntity; +import com.sk89q.worldedit.entity.Entity; +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.function.operation.Operation; +import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockStateHolder; + +import javax.annotation.Nullable; +import java.util.List; + +public class RequestExtent implements Extent { + + private Request request; + + protected Extent getExtent() { + if (request == null || !request.isValid()) { + request = Request.request(); + } + return request.getEditSession(); + } + + @Override + public BlockVector3 getMinimumPoint() { + return getExtent().getMinimumPoint(); + } + + @Override + public BlockVector3 getMaximumPoint() { + return getExtent().getMaximumPoint(); + } + + @Override + public List getEntities(Region region) { + return getExtent().getEntities(region); + } + + @Override + public List getEntities() { + return getExtent().getEntities(); + } + + @Override + @Nullable + public Entity createEntity(Location location, BaseEntity entity) { + return getExtent().createEntity(location, entity); + } + + @Override + public BlockState getBlock(BlockVector3 position) { + return getExtent().getBlock(position); + } + + @Override + public BaseBlock getFullBlock(BlockVector3 position) { + return getExtent().getFullBlock(position); + } + + @Override + public BiomeType getBiome(BlockVector2 position) { + return getExtent().getBiome(position); + } + + @Override + public > boolean setBlock(BlockVector3 position, T block) throws WorldEditException { + return getExtent().setBlock(position, block); + } + + @Override + public boolean setBiome(BlockVector2 position, BiomeType biome) { + return getExtent().setBiome(position, biome); + } + + @Override + @Nullable + public Operation commit() { + Operation commit = getExtent().commit(); + request = null; + return commit; + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestSelection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestSelection.java index 70d8d2baf..9e37e4da0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestSelection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestSelection.java @@ -19,10 +19,10 @@ package com.sk89q.worldedit.session.request; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.NullRegion; import com.sk89q.worldedit.regions.Region; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/storage/JsonFileSessionStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/storage/JsonFileSessionStore.java index d7b2a9893..ad8e422bf 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/storage/JsonFileSessionStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/storage/JsonFileSessionStore.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.session.storage; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonIOException; @@ -28,6 +26,8 @@ import com.google.gson.JsonParseException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.util.gson.GsonUtil; import com.sk89q.worldedit.util.io.Closer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -37,8 +37,8 @@ import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.UUID; -import java.util.logging.Level; -import java.util.logging.Logger; + +import static com.google.common.base.Preconditions.checkNotNull; /** * Stores sessions as JSON files in a directory. @@ -47,7 +47,7 @@ import java.util.logging.Logger; */ public class JsonFileSessionStore implements SessionStore { - private static final Logger log = Logger.getLogger(JsonFileSessionStore.class.getCanonicalName()); + private static final Logger log = LoggerFactory.getLogger(JsonFileSessionStore.class); private final Gson gson; private final File dir; @@ -61,7 +61,7 @@ public class JsonFileSessionStore implements SessionStore { if (!dir.isDirectory()) { if (!dir.mkdirs()) { - log.log(Level.WARNING, "Failed to create directory '" + dir.getPath() + "' for sessions"); + log.warn("Failed to create directory '" + dir.getPath() + "' for sessions"); } } @@ -111,12 +111,12 @@ public class JsonFileSessionStore implements SessionStore { if (finalFile.exists()) { if (!finalFile.delete()) { - log.log(Level.WARNING, "Failed to delete " + finalFile.getPath() + " so the .tmp file can replace it"); + log.warn("Failed to delete " + finalFile.getPath() + " so the .tmp file can replace it"); } } if (!tempFile.renameTo(finalFile)) { - log.log(Level.WARNING, "Failed to rename temporary session file to " + finalFile.getPath()); + log.warn("Failed to rename temporary session file to " + finalFile.getPath()); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java index 35e228b93..5d3aa84e4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Location.java @@ -208,6 +208,9 @@ public class Location extends Vector3 { * @return the direction vector */ public Vector3 getDirection() { + if (Float.isNaN(getYaw()) && Float.isNaN(getPitch())) { + return Vector3.ZERO; + } double yaw = Math.toRadians(this.getYaw()); double pitch = Math.toRadians(this.getPitch()); double xz = Math.cos(pitch); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java index 18a8cc806..12513b97d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java @@ -1,283 +1,282 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -// $Id$ - -package com.sk89q.worldedit.util; - -import com.google.common.collect.Lists; -import com.sk89q.util.StringUtil; -import com.sk89q.worldedit.LocalConfiguration; -import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.sk89q.worldedit.world.item.ItemTypes; -import com.sk89q.worldedit.world.registry.LegacyMapper; -import com.sk89q.worldedit.world.snapshot.SnapshotRepository; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.stream.Collectors; - -/** - * Simple LocalConfiguration that loads settings using - * {@code java.util.Properties}. - */ -public class PropertiesConfiguration extends LocalConfiguration { - - private static final Logger log = Logger.getLogger(PropertiesConfiguration.class.getCanonicalName()); - - protected Properties properties; - protected File path; - - /** - * Construct the object. The configuration isn't loaded yet. - * - * @param path the path tot he configuration - */ - public PropertiesConfiguration(File path) { - this.path = path; - - properties = new Properties(); - } - - @Override - public void load() { - try (InputStream stream = new FileInputStream(path)) { - properties.load(stream); - } catch (FileNotFoundException ignored) { - } catch (IOException e) { - log.log(Level.WARNING, "Failed to read configuration", e); - } - - loadExtra(); - - profile = getBool("profile", profile); - - disallowedBlocks = - new HashSet<>(getStringSet("limits.disallowed-blocks", getDefaultDisallowedBlocks())); - allowedDataCycleBlocks = - new HashSet<>(getStringSet("limits.allowed-data-cycle-blocks", null)); - defaultChangeLimit = getInt("default-max-changed-blocks", defaultChangeLimit); - maxChangeLimit = getInt("max-changed-blocks", maxChangeLimit); - defaultMaxPolygonalPoints = getInt("default-max-polygon-points", defaultMaxPolygonalPoints); - maxPolygonalPoints = getInt("max-polygon-points", maxPolygonalPoints); - defaultMaxPolyhedronPoints = getInt("default-max-polyhedron-points", defaultMaxPolyhedronPoints); - maxPolyhedronPoints = getInt("max-polyhedron-points", maxPolyhedronPoints); - shellSaveType = getString("shell-save-type", shellSaveType); - maxRadius = getInt("max-radius", maxRadius); - maxSuperPickaxeSize = getInt("max-super-pickaxe-size", maxSuperPickaxeSize); - maxBrushRadius = getInt("max-brush-radius", maxBrushRadius); - logCommands = getBool("log-commands", logCommands); - logFile = getString("log-file", logFile); - logFormat = getString("log-format", logFormat); - registerHelp = getBool("register-help", registerHelp); - wandItem = getString("wand-item", wandItem); - try { - wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).getId(); - } catch (Throwable e) {} - superPickaxeDrop = getBool("super-pickaxe-drop-items", superPickaxeDrop); - superPickaxeManyDrop = getBool("super-pickaxe-many-drop-items", superPickaxeManyDrop); - noDoubleSlash = getBool("no-double-slash", noDoubleSlash); - useInventory = getBool("use-inventory", useInventory); - useInventoryOverride = getBool("use-inventory-override", useInventoryOverride); - useInventoryCreativeOverride = getBool("use-inventory-creative-override", useInventoryCreativeOverride); - navigationWand = getString("nav-wand-item", navigationWand); - try { - navigationWand = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(navigationWand)).getId(); - } catch (Throwable e) {} - navigationWandMaxDistance = getInt("nav-wand-distance", navigationWandMaxDistance); - navigationUseGlass = getBool("nav-use-glass", navigationUseGlass); - scriptTimeout = getInt("scripting-timeout", scriptTimeout); - saveDir = getString("schematic-save-dir", saveDir); - scriptsDir = getString("craftscript-dir", scriptsDir); - butcherDefaultRadius = getInt("butcher-default-radius", butcherDefaultRadius); - butcherMaxRadius = getInt("butcher-max-radius", butcherMaxRadius); - allowSymlinks = getBool("allow-symbolic-links", allowSymlinks); - - LocalSession.MAX_HISTORY_SIZE = Math.max(15, getInt("history-size", 15)); - - String snapshotsDir = getString("snapshots-dir", ""); - if (!snapshotsDir.isEmpty()) { - snapshotRepo = new SnapshotRepository(snapshotsDir); - } - - path.getParentFile().mkdirs(); - try (OutputStream output = new FileOutputStream(path)) { - properties.store(output, "Don't put comments; they get removed"); - } catch (IOException e) { - log.log(Level.WARNING, "Failed to write configuration", e); - } - } - - /** - * Called to load extra configuration. - */ - protected void loadExtra() { - } - - /** - * Get a string value. - * - * @param key the key - * @param def the default value - * @return the value - */ - protected String getString(String key, String def) { - if (def == null) { - def = ""; - } - String val = properties.getProperty(key); - if (val == null) { - properties.setProperty(key, def); - return def; - } else { - return val; - } - } - - /** - * Get a boolean value. - * - * @param key the key - * @param def the default value - * @return the value - */ - protected boolean getBool(String key, boolean def) { - String val = properties.getProperty(key); - if (val == null) { - properties.setProperty(key, def ? "true" : "false"); - return def; - } else { - return val.equalsIgnoreCase("true") - || val.equals("1"); - } - } - - /** - * Get an integer value. - * - * @param key the key - * @param def the default value - * @return the value - */ - protected int getInt(String key, int def) { - String val = properties.getProperty(key); - if (val == null) { - properties.setProperty(key, String.valueOf(def)); - return def; - } else { - try { - return Integer.parseInt(val); - } catch (NumberFormatException e) { - properties.setProperty(key, String.valueOf(def)); - return def; - } - } - } - - /** - * Get a double value. - * - * @param key the key - * @param def the default value - * @return the value - */ - protected double getDouble(String key, double def) { - String val = properties.getProperty(key); - if (val == null) { - properties.setProperty(key, String.valueOf(def)); - return def; - } else { - try { - return Double.parseDouble(val); - } catch (NumberFormatException e) { - properties.setProperty(key, String.valueOf(def)); - return def; - } - } - } - - /** - * Get a double value. - * - * @param key the key - * @param def the default value - * @return the value - */ - protected Set getIntSet(String key, int[] def) { - String val = properties.getProperty(key); - if (val == null) { - properties.setProperty(key, StringUtil.joinString(def, ",", 0)); - Set set = new HashSet<>(); - for (int i : def) { - set.add(i); - } - return set; - } else { - Set set = new HashSet<>(); - String[] parts = val.split(","); - for (String part : parts) { - try { - int v = Integer.parseInt(part.trim()); - set.add(v); - } catch (NumberFormatException ignored) { - } - } - return set; - } - } - - /** - * Get a String set. - * - * @param key the key - * @param def the default value - * @return the value - */ - protected Set getStringSet(String key, String[] def) { - String val = properties.getProperty(key); - if (val == null) { - properties.setProperty(key, StringUtil.joinString(def, ",", 0)); - return new HashSet<>(Arrays.asList(def)); - } else { - Set set = new HashSet<>(); - String[] parts = val.split(","); - for (String part : parts) { - try { - String v = part.trim(); - set.add(v); - } catch (NumberFormatException ignored) { - } - } - return set; - } - } - -} \ No newline at end of file +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +// $Id$ + +package com.sk89q.worldedit.util; + +import com.sk89q.util.StringUtil; +import com.sk89q.worldedit.LocalConfiguration; +import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.util.report.Unreported; +import com.sk89q.worldedit.world.registry.LegacyMapper; +import com.sk89q.worldedit.world.snapshot.SnapshotRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Properties; +import java.util.Set; + +/** + * Simple LocalConfiguration that loads settings using + * {@code java.util.Properties}. + */ +public class PropertiesConfiguration extends LocalConfiguration { + + @Unreported private static final Logger log = LoggerFactory.getLogger(PropertiesConfiguration.class); + + @Unreported protected Properties properties; + @Unreported protected File path; + + /** + * Construct the object. The configuration isn't loaded yet. + * + * @param path the path tot he configuration + */ + public PropertiesConfiguration(File path) { + this.path = path; + + properties = new Properties(); + } + + @Override + public void load() { + try (InputStream stream = new FileInputStream(path)) { + properties.load(stream); + } catch (FileNotFoundException ignored) { + } catch (IOException e) { + log.warn("Failed to read configuration", e); + } + + loadExtra(); + + profile = getBool("profile", profile); + traceUnflushedSessions = getBool("trace-unflushed-sessions", traceUnflushedSessions); + disallowedBlocks = getStringSet("disallowed-blocks", getDefaultDisallowedBlocks()); + defaultChangeLimit = getInt("default-max-changed-blocks", defaultChangeLimit); + maxChangeLimit = getInt("max-changed-blocks", maxChangeLimit); + defaultMaxPolygonalPoints = getInt("default-max-polygon-points", defaultMaxPolygonalPoints); + maxPolygonalPoints = getInt("max-polygon-points", maxPolygonalPoints); + defaultMaxPolyhedronPoints = getInt("default-max-polyhedron-points", defaultMaxPolyhedronPoints); + maxPolyhedronPoints = getInt("max-polyhedron-points", maxPolyhedronPoints); + shellSaveType = getString("shell-save-type", shellSaveType); + maxRadius = getInt("max-radius", maxRadius); + maxSuperPickaxeSize = getInt("max-super-pickaxe-size", maxSuperPickaxeSize); + maxBrushRadius = getInt("max-brush-radius", maxBrushRadius); + logCommands = getBool("log-commands", logCommands); + logFile = getString("log-file", logFile); + logFormat = getString("log-format", logFormat); + registerHelp = getBool("register-help", registerHelp); + wandItem = getString("wand-item", wandItem); + try { + wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).getId(); + } catch (Throwable e) { + } + superPickaxeDrop = getBool("super-pickaxe-drop-items", superPickaxeDrop); + superPickaxeManyDrop = getBool("super-pickaxe-many-drop-items", superPickaxeManyDrop); + noDoubleSlash = getBool("no-double-slash", noDoubleSlash); + useInventory = getBool("use-inventory", useInventory); + useInventoryOverride = getBool("use-inventory-override", useInventoryOverride); + useInventoryCreativeOverride = getBool("use-inventory-creative-override", useInventoryCreativeOverride); + navigationWand = getString("nav-wand-item", navigationWand); + try { + navigationWand = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(navigationWand)).getId(); + } catch (Throwable e) { + } + navigationWandMaxDistance = getInt("nav-wand-distance", navigationWandMaxDistance); + navigationUseGlass = getBool("nav-use-glass", navigationUseGlass); + scriptTimeout = getInt("scripting-timeout", scriptTimeout); + calculationTimeout = getInt("calculation-timeout", calculationTimeout); + maxCalculationTimeout = getInt("max-calculation-timeout", maxCalculationTimeout); + saveDir = getString("schematic-save-dir", saveDir); + scriptsDir = getString("craftscript-dir", scriptsDir); + butcherDefaultRadius = getInt("butcher-default-radius", butcherDefaultRadius); + butcherMaxRadius = getInt("butcher-max-radius", butcherMaxRadius); + allowSymlinks = getBool("allow-symbolic-links", allowSymlinks); + serverSideCUI = getBool("server-side-cui", serverSideCUI); + + LocalSession.MAX_HISTORY_SIZE = Math.max(15, getInt("history-size", 15)); + + String snapshotsDir = getString("snapshots-dir", ""); + if (!snapshotsDir.isEmpty()) { + snapshotRepo = new SnapshotRepository(snapshotsDir); + } + + path.getParentFile().mkdirs(); + try (OutputStream output = new FileOutputStream(path)) { + properties.store(output, "Don't put comments; they get removed"); + } catch (IOException e) { + log.warn("Failed to write configuration", e); + } + } + + /** + * Called to load extra configuration. + */ + protected void loadExtra() { + } + + /** + * Get a string value. + * + * @param key the key + * @param def the default value + * @return the value + */ + protected String getString(String key, String def) { + if (def == null) { + def = ""; + } + String val = properties.getProperty(key); + if (val == null) { + properties.setProperty(key, def); + return def; + } else { + return val; + } + } + + /** + * Get a boolean value. + * + * @param key the key + * @param def the default value + * @return the value + */ + protected boolean getBool(String key, boolean def) { + String val = properties.getProperty(key); + if (val == null) { + properties.setProperty(key, def ? "true" : "false"); + return def; + } else { + return val.equalsIgnoreCase("true") + || val.equals("1"); + } + } + + /** + * Get an integer value. + * + * @param key the key + * @param def the default value + * @return the value + */ + protected int getInt(String key, int def) { + String val = properties.getProperty(key); + if (val == null) { + properties.setProperty(key, String.valueOf(def)); + return def; + } else { + try { + return Integer.parseInt(val); + } catch (NumberFormatException e) { + properties.setProperty(key, String.valueOf(def)); + return def; + } + } + } + + /** + * Get a double value. + * + * @param key the key + * @param def the default value + * @return the value + */ + protected double getDouble(String key, double def) { + String val = properties.getProperty(key); + if (val == null) { + properties.setProperty(key, String.valueOf(def)); + return def; + } else { + try { + return Double.parseDouble(val); + } catch (NumberFormatException e) { + properties.setProperty(key, String.valueOf(def)); + return def; + } + } + } + + /** + * Get a double value. + * + * @param key the key + * @param def the default value + * @return the value + */ + protected Set getIntSet(String key, int[] def) { + String val = properties.getProperty(key); + if (val == null) { + properties.setProperty(key, StringUtil.joinString(def, ",", 0)); + Set set = new HashSet<>(); + for (int i : def) { + set.add(i); + } + return set; + } else { + Set set = new HashSet<>(); + String[] parts = val.split(","); + for (String part : parts) { + try { + int v = Integer.parseInt(part.trim()); + set.add(v); + } catch (NumberFormatException ignored) { + } + } + return set; + } + } + + /** + * Get a String set. + * + * @param key the key + * @param def the default value + * @return the value + */ + protected Set getStringSet(String key, String[] def) { + String val = properties.getProperty(key); + if (val == null) { + properties.setProperty(key, StringUtil.joinString(def, ",", 0)); + return new HashSet<>(Arrays.asList(def)); + } else { + Set set = new HashSet<>(); + String[] parts = val.split(","); + for (String part : parts) { + try { + String v = part.trim(); + set.add(v); + } catch (NumberFormatException ignored) { + } + } + return set; + } + } + +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java index fba4fc67e..5a657584d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java @@ -26,11 +26,10 @@ import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.session.SessionManager; import com.sk89q.worldedit.util.report.Unreported; import com.sk89q.worldedit.world.snapshot.SnapshotRepository; +import org.slf4j.Logger; import java.io.IOException; import java.util.HashSet; -import java.util.logging.Level; -import java.util.logging.Logger; /** * A less simple implementation of {@link LocalConfiguration} @@ -51,10 +50,11 @@ public class YAMLConfiguration extends LocalConfiguration { try { config.load(); } catch (IOException e) { - logger.log(Level.WARNING, "Error loading WorldEdit configuration", e); + logger.warn("Error loading WorldEdit configuration", e); } profile = config.getBoolean("debug", profile); + traceUnflushedSessions = config.getBoolean("debugging.trace-unflushed-sessions", traceUnflushedSessions); wandItem = convertLegacyItem(config.getString("wand-item", wandItem)); defaultChangeLimit = Math.max(-1, config.getInt( @@ -79,8 +79,7 @@ public class YAMLConfiguration extends LocalConfiguration { butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum", butcherMaxRadius)); disallowedBlocks = new HashSet<>(config.getStringList("limits.disallowed-blocks", Lists.newArrayList(getDefaultDisallowedBlocks()))); - allowedDataCycleBlocks = - new HashSet<>(config.getStringList("limits.allowed-data-cycle-blocks", null)); + allowedDataCycleBlocks = new HashSet<>(config.getStringList("limits.allowed-data-cycle-blocks", null)); registerHelp = config.getBoolean("register-help", true); logCommands = config.getBoolean("logging.log-commands", logCommands); @@ -107,6 +106,9 @@ public class YAMLConfiguration extends LocalConfiguration { scriptTimeout = config.getInt("scripting.timeout", scriptTimeout); scriptsDir = config.getString("scripting.dir", scriptsDir); + calculationTimeout = config.getInt("calculation.timeout", calculationTimeout); + maxCalculationTimeout = config.getInt("calculation.max-timeout", maxCalculationTimeout); + saveDir = config.getString("saving.dir", saveDir); allowSymlinks = config.getBoolean("files.allow-symbolic-links", false); @@ -114,6 +116,7 @@ public class YAMLConfiguration extends LocalConfiguration { SessionManager.EXPIRATION_GRACE = config.getInt("history.expiration", 10) * 60 * 1000; showHelpInfo = config.getBoolean("show-help-on-first-use", true); + serverSideCUI = config.getBoolean("server-side-cui", true); String snapshotsDir = config.getString("snapshots.directory", ""); if (!snapshotsDir.isEmpty()) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/FastListIterator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/FastListIterator.java deleted file mode 100644 index 3182502f6..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/FastListIterator.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.util.collection; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; - -/** - * A fast iterator for lists that uses an internal index integer - * and caches the size of the list. The size of the list cannot change - * during iteration and {@link Iterator#remove()} is not supported. - * - *

The iterator in Java, at least in older Java versions, is very slow, - * causing a significant amount of time in operations in WorldEdit - * being spent on {@link Iterator#hasNext()}. In contrast, the iterator - * implemented by this class is very quick, as long as - * {@link List#get(int)} is fast.

- * - * @param the element - */ -public class FastListIterator implements Iterator { - - private final List list; - private int index; - private final int size; - private final int increment; - - /** - * Create a new fast iterator. - * - * @param list the list - * @param index the index to start from - * @param size the size of the list - * @param increment the increment amount (i.e. 1 or -1) - */ - private FastListIterator(List list, int index, int size, int increment) { - checkNotNull(list); - checkArgument(size >= 0, "size >= 0 required"); - checkArgument(index >= 0, "index >= 0 required"); - this.list = list; - this.index = index; - this.size = size; - this.increment = increment; - } - - @Override - public boolean hasNext() { - return index >= 0 && index < size; - } - - @Override - public E next() { - if (hasNext()) { - E entry = list.get(index); - index += increment; - return entry; - } else { - throw new NoSuchElementException(); - } - } - - @Override - public void remove() { - throw new UnsupportedOperationException("Not supported"); - } - - /** - * Create a new forward iterator for the given list. - * - * @param list the list - * @param the element - * @return an iterator - */ - public static Iterator forwardIterator(List list) { - return new FastListIterator<>(list, 0, list.size(), 1); - } - - /** - * Create a new reverse iterator for the given list. - * - * @param list the list - * @param the element - * @return an iterator - */ - public static Iterator reverseIterator(List list) { - if (!list.isEmpty()) { - return new FastListIterator<>(list, list.size() - 1, list.size(), -1); - } else { - return new FastListIterator<>(list, 0, 0, -1); - } - } - -} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/TupleArrayList.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/TupleArrayList.java deleted file mode 100644 index 8247607f1..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/TupleArrayList.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.util.collection; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Map; - -/** - * An {@link ArrayList} that takes {@link Map.Entry}-like tuples. This class - * exists for legacy reasons. - * - * @param the first type in the tuple - * @param the second type in the tuple - */ -public class TupleArrayList extends ArrayList> { - - /** - * Add an item to the list. - * - * @param a the 'key' - * @param b the 'value' - */ - public void put(A a, B b) { - add(new Tuple<>(a, b)); - } - - /** - * Return an entry iterator that traverses in the reverse direction. - * - * @param reverse true to return the reverse iterator - * @return an entry iterator - */ - public Iterator> iterator(boolean reverse) { - return reverse ? reverseIterator() : iterator(); - } - - @Override - public Iterator> iterator() { - return FastListIterator.forwardIterator(this); - } - - /** - * Return an entry iterator that traverses in the reverse direction. - * - * @return an entry iterator - */ - public Iterator> reverseIterator() { - return FastListIterator.reverseIterator(this); - } - - private static class Tuple implements Map.Entry { - private A key; - private B value; - - private Tuple(A key, B value) { - this.key = key; - this.value = value; - } - - @Override - public A getKey() { - return key; - } - - @Override - public B getValue() { - return value; - } - - @Override - public B setValue(B value) { - throw new UnsupportedOperationException(); - } - } - -} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/EventBus.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/EventBus.java index d8cbe8b20..d97c090ea 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/EventBus.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/eventbus/EventBus.java @@ -19,13 +19,13 @@ package com.sk89q.worldedit.util.eventbus; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import com.google.common.collect.SetMultimap; import com.google.common.eventbus.DeadEvent; import com.sk89q.worldedit.internal.annotation.RequiresNewerGuava; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; @@ -36,8 +36,8 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; + +import static com.google.common.base.Preconditions.checkNotNull; /** * Dispatches events to listeners, and provides ways for listeners to register @@ -53,7 +53,7 @@ import java.util.logging.Logger; */ public class EventBus { - private final Logger logger = Logger.getLogger(EventBus.class.getCanonicalName()); + private final Logger logger = LoggerFactory.getLogger(EventBus.class); private final SetMultimap, EventHandler> handlersByType = Multimaps.newSetMultimap(new HashMap<>(), this::newHandlerSet); @@ -186,8 +186,7 @@ public class EventBus { try { handler.handleEvent(event); } catch (InvocationTargetException e) { - logger.log(Level.SEVERE, - "Could not dispatch event: " + event + " to handler " + handler, e); + logger.error("Could not dispatch event: " + event + " to handler " + handler, e); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/Closer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/Closer.java index 26ef6a0f9..1b7aceda3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/Closer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/Closer.java @@ -19,23 +19,23 @@ package com.sk89q.worldedit.util.io; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Throwables; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.Closeable; import java.io.IOException; import java.lang.reflect.Method; import java.util.ArrayDeque; import java.util.Deque; -import java.util.logging.Level; -import java.util.logging.Logger; import java.util.zip.ZipFile; +import static com.google.common.base.Preconditions.checkNotNull; + public final class Closer implements Closeable { - private static final Logger logger = Logger.getLogger(Closer.class.getCanonicalName()); + private static final Logger logger = LoggerFactory.getLogger(Closer.class); /** * The suppressor implementation to use for the current Java version. @@ -218,7 +218,7 @@ public final class Closer implements Closeable { @Override public void suppress(Object closeable, Throwable thrown, Throwable suppressed) { // log to the same place as Closeables - logger.log(Level.WARNING, "Suppressing exception thrown when closing " + closeable, suppressed); + logger.warn("Suppressing exception thrown when closing " + closeable, suppressed); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java index e87e440bf..e95a45bf9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/ActorCallbackPaste.java @@ -26,14 +26,14 @@ import com.sk89q.worldedit.command.util.AsyncCommandHelper; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.util.command.parametric.ExceptionConverter; import com.sk89q.worldedit.util.task.Supervisor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.net.URL; -import java.util.logging.Level; -import java.util.logging.Logger; public class ActorCallbackPaste { - private static final Logger LOGGER = Logger.getLogger(ActorCallbackPaste.class.getSimpleName()); + private static final Logger LOGGER = LoggerFactory.getLogger(ActorCallbackPaste.class); private ActorCallbackPaste() { } @@ -47,7 +47,7 @@ public class ActorCallbackPaste { * @param content The content * @param successMessage The message, formatted with {@link String#format(String, Object...)} on success */ -public static void pastebin(Supervisor supervisor, final Actor sender, String content, final String successMessage, final ExceptionConverter exceptionConverter) { + public static void pastebin(Supervisor supervisor, final Actor sender, String content, final String successMessage, final ExceptionConverter exceptionConverter) { ListenableFuture future = new IncendoPaste("fastasyncworldedit").paste(content); AsyncCommandHelper.wrap(future, supervisor, sender, exceptionConverter) @@ -62,7 +62,7 @@ public static void pastebin(Supervisor supervisor, final Actor sender, String co @Override public void onFailure(Throwable throwable) { - LOGGER.log(Level.WARNING, "Failed to submit pastebin", throwable); + LOGGER.warn("Failed to submit pastebin", throwable); sender.printError("Failed to submit to a pastebin. Please see console for the error."); } }); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/ShallowObjectReport.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/ShallowObjectReport.java index bb4abb1f3..18085bc0b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/ShallowObjectReport.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/ShallowObjectReport.java @@ -19,16 +19,17 @@ package com.sk89q.worldedit.util.report; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import java.util.logging.Level; -import java.util.logging.Logger; import static com.google.common.base.Preconditions.checkNotNull; public class ShallowObjectReport extends DataReport { - private static final Logger log = Logger.getLogger(ShallowObjectReport.class.getCanonicalName()); + private static final Logger log = LoggerFactory.getLogger(ShallowObjectReport.class); public ShallowObjectReport(String title, Object object) { super(title); @@ -52,7 +53,7 @@ public class ShallowObjectReport extends DataReport { Object value = field.get(object); append(field.getName(), String.valueOf(value)); } catch (IllegalAccessException e) { - log.log(Level.WARNING, "Failed to get value of '" + field.getName() + "' on " + type); + log.warn("Failed to get value of '" + field.getName() + "' on " + type); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/progress/ProgressIterator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/progress/ProgressIterator.java index 447838922..11eb34f32 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/progress/ProgressIterator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/task/progress/ProgressIterator.java @@ -83,7 +83,7 @@ public class ProgressIterator implements Iterator, ProgressObservable { * @return an instance */ public static ProgressIterator create(Iterator iterator, int count) { - return new ProgressIterator<>(iterator, count); + return new ProgressIterator(iterator, count); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java index 80aaa726b..cc5b4be68 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java @@ -93,7 +93,7 @@ public abstract class AbstractWorld implements World { @Override public BlockState getLazyBlock(BlockVector3 position) { - return new BaseBlock(getBlock(position)).toImmutableState(); + return getBlock(position); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java index f21e1660f..fa27b3d17 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java @@ -33,11 +33,14 @@ import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.TreeGenerator.TreeType; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.biome.BiomeTypes; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.weather.WeatherType; +import com.sk89q.worldedit.world.weather.WeatherTypes; import javax.annotation.Nullable; import java.util.Collections; @@ -80,12 +83,12 @@ public class NullWorld extends AbstractWorld { } @Override - public BaseBiome getBiome(BlockVector2 position) { - return null; + public BiomeType getBiome(BlockVector2 position) { + return BiomeTypes.THE_VOID; } @Override - public boolean setBiome(BlockVector2 position, BaseBiome biome) { + public boolean setBiome(BlockVector2 position, BiomeType biome) { return false; } @@ -109,7 +112,7 @@ public class NullWorld extends AbstractWorld { @Override public WeatherType getWeather() { - return null; + return WeatherTypes.CLEAR; } @Override @@ -136,7 +139,6 @@ public class NullWorld extends AbstractWorld { } @Override -//<<<<<<< HEAD public BlockState getLazyBlock(BlockVector3 position) { return getBlock(position); } @@ -145,10 +147,6 @@ public class NullWorld extends AbstractWorld { public BaseBlock getFullBlock(BlockVector3 position) { return getBlock(position).toBaseBlock(); } -//======= -// public BaseBlock getFullBlock(BlockVector3 position) { -// return getBlock(position).toBaseBlock(); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } @Override public List getEntities(Region region) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BaseBiome.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BaseBiome.java deleted file mode 100644 index 5bf051706..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BaseBiome.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.world.biome; - -import com.sk89q.minecraft.util.commands.Link; -import com.sk89q.worldedit.command.BiomeCommands; - - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Basic storage object to represent a given biome. - */ -@Link(clazz = BiomeCommands.class, value = "biomelist") -public class BaseBiome { - - private int id; - - /** - * Create a new biome with the given biome ID. - * - * @param id the biome ID - */ - public BaseBiome(int id) { - this.id = id; - } - - /** - * Create a clone of the given biome. - * - * @param biome the biome to clone - */ - public BaseBiome(BaseBiome biome) { - checkNotNull(biome); - this.id = biome.getId(); - } - - /** - * Get the biome ID. - * - * @return the biome ID - */ - public int getId() { - return id; - } - - /** - * Set the biome id. - * - * @param id the biome ID - */ - public void setId(int id) { - this.id = id; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - BaseBiome baseBiome = (BaseBiome) o; - - return id == baseBiome.id; - } - - @Override - public int hashCode() { - return id; - } -} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeName.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeName.java index 45018ed41..83c3faa58 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeName.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeName.java @@ -29,7 +29,7 @@ import javax.annotation.Nullable; /** * Returns the name of a biome using a given {@code BiomeRegistry}. */ -class BiomeName implements Function { +class BiomeName implements Function { private final BiomeRegistry registry; @@ -45,7 +45,7 @@ class BiomeName implements Function { @Nullable @Override - public String apply(BaseBiome input) { + public String apply(BiomeType input) { BiomeData data = registry.getData(input); if (data != null) { return data.getName(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/logging/WorldEditPrefixHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeType.java similarity index 52% rename from worldedit-core/src/main/java/com/sk89q/worldedit/util/logging/WorldEditPrefixHandler.java rename to worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeType.java index f2c8a0754..7dc155253 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/logging/WorldEditPrefixHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeType.java @@ -17,43 +17,44 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.util.logging; +package com.sk89q.worldedit.world.biome; -import java.util.logging.Handler; -import java.util.logging.LogRecord; -import java.util.logging.Logger; +import com.sk89q.worldedit.registry.NamespacedRegistry; /** - * Adds a WorldEdit prefix to WorldEdit's logger messages using a handler. + * All the types of biomes in the game. */ -public final class WorldEditPrefixHandler extends Handler { +public class BiomeType { - private WorldEditPrefixHandler() { - } + public static final NamespacedRegistry REGISTRY = new NamespacedRegistry<>("biome type"); - @Override - public void publish(LogRecord record) { - String message = record.getMessage(); - if (!message.startsWith("WorldEdit: ") && !message.startsWith("[WorldEdit] ")) { - record.setMessage("[WorldEdit] " + message); - } - } + private String id; - @Override - public void flush() { - } - - @Override - public void close() throws SecurityException { + public BiomeType(String id) { + this.id = id; } /** - * Add the handler to the following logger name. + * Gets the ID of this biome. * - * @param name the logger name + * @return The id */ - public static void register(String name) { - Logger.getLogger(name).addHandler(new WorldEditPrefixHandler()); + public String getId() { + return this.id; } + @Override + public String toString() { + return getId(); + } + + @Override + public int hashCode() { + return this.id.hashCode(); + } + + @Override + public boolean equals(Object obj) { + return obj instanceof BiomeType && this.id.equals(((BiomeType) obj).id); + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java new file mode 100644 index 000000000..a9d07a5fc --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java @@ -0,0 +1,117 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.world.biome; + +import javax.annotation.Nullable; + +/** + * Stores a list of common Biome String IDs. + */ +public class BiomeTypes { + + @Nullable public static final BiomeType BADLANDS = get("minecraft:badlands"); + @Nullable public static final BiomeType BADLANDS_PLATEAU = get("minecraft:badlands_plateau"); + @Nullable public static final BiomeType BEACH = get("minecraft:beach"); + @Nullable public static final BiomeType BIRCH_FOREST = get("minecraft:birch_forest"); + @Nullable public static final BiomeType BIRCH_FOREST_HILLS = get("minecraft:birch_forest_hills"); + @Nullable public static final BiomeType COLD_OCEAN = get("minecraft:cold_ocean"); + @Nullable public static final BiomeType DARK_FOREST = get("minecraft:dark_forest"); + @Nullable public static final BiomeType DARK_FOREST_HILLS = get("minecraft:dark_forest_hills"); + @Nullable public static final BiomeType DEEP_COLD_OCEAN = get("minecraft:deep_cold_ocean"); + @Nullable public static final BiomeType DEEP_FROZEN_OCEAN = get("minecraft:deep_frozen_ocean"); + @Nullable public static final BiomeType DEEP_LUKEWARM_OCEAN = get("minecraft:deep_lukewarm_ocean"); + @Nullable public static final BiomeType DEEP_OCEAN = get("minecraft:deep_ocean"); + @Nullable public static final BiomeType DEEP_WARM_OCEAN = get("minecraft:deep_warm_ocean"); + @Nullable public static final BiomeType DESERT = get("minecraft:desert"); + @Nullable public static final BiomeType DESERT_HILLS = get("minecraft:desert_hills"); + @Nullable public static final BiomeType DESERT_LAKES = get("minecraft:desert_lakes"); + @Nullable public static final BiomeType END_BARRENS = get("minecraft:end_barrens"); + @Nullable public static final BiomeType END_HIGHLANDS = get("minecraft:end_highlands"); + @Nullable public static final BiomeType END_MIDLANDS = get("minecraft:end_midlands"); + @Nullable public static final BiomeType ERODED_BADLANDS = get("minecraft:eroded_badlands"); + @Nullable public static final BiomeType FLOWER_FOREST = get("minecraft:flower_forest"); + @Nullable public static final BiomeType FOREST = get("minecraft:forest"); + @Nullable public static final BiomeType FROZEN_OCEAN = get("minecraft:frozen_ocean"); + @Nullable public static final BiomeType FROZEN_RIVER = get("minecraft:frozen_river"); + @Nullable public static final BiomeType GIANT_SPRUCE_TAIGA = get("minecraft:giant_spruce_taiga"); + @Nullable public static final BiomeType GIANT_SPRUCE_TAIGA_HILLS = get("minecraft:giant_spruce_taiga_hills"); + @Nullable public static final BiomeType GIANT_TREE_TAIGA = get("minecraft:giant_tree_taiga"); + @Nullable public static final BiomeType GIANT_TREE_TAIGA_HILLS = get("minecraft:giant_tree_taiga_hills"); + @Nullable public static final BiomeType GRAVELLY_MOUNTAINS = get("minecraft:gravelly_mountains"); + @Nullable public static final BiomeType ICE_SPIKES = get("minecraft:ice_spikes"); + @Nullable public static final BiomeType JUNGLE = get("minecraft:jungle"); + @Nullable public static final BiomeType JUNGLE_EDGE = get("minecraft:jungle_edge"); + @Nullable public static final BiomeType JUNGLE_HILLS = get("minecraft:jungle_hills"); + @Nullable public static final BiomeType LUKEWARM_OCEAN = get("minecraft:lukewarm_ocean"); + @Nullable public static final BiomeType MODIFIED_BADLANDS_PLATEAU = get("minecraft:modified_badlands_plateau"); + @Nullable public static final BiomeType MODIFIED_GRAVELLY_MOUNTAINS = get("minecraft:modified_gravelly_mountains"); + @Nullable public static final BiomeType MODIFIED_JUNGLE = get("minecraft:modified_jungle"); + @Nullable public static final BiomeType MODIFIED_JUNGLE_EDGE = get("minecraft:modified_jungle_edge"); + @Nullable public static final BiomeType MODIFIED_WOODED_BADLANDS_PLATEAU = get("minecraft:modified_wooded_badlands_plateau"); + @Nullable public static final BiomeType MOUNTAIN_EDGE = get("minecraft:mountain_edge"); + @Nullable public static final BiomeType MOUNTAINS = get("minecraft:mountains"); + @Nullable public static final BiomeType MUSHROOM_FIELD_SHORE = get("minecraft:mushroom_field_shore"); + @Nullable public static final BiomeType MUSHROOM_FIELDS = get("minecraft:mushroom_fields"); + @Nullable public static final BiomeType NETHER = get("minecraft:nether"); + @Nullable public static final BiomeType OCEAN = get("minecraft:ocean"); + @Nullable public static final BiomeType PLAINS = get("minecraft:plains"); + @Nullable public static final BiomeType RIVER = get("minecraft:river"); + @Nullable public static final BiomeType SAVANNA = get("minecraft:savanna"); + @Nullable public static final BiomeType SAVANNA_PLATEAU = get("minecraft:savanna_plateau"); + @Nullable public static final BiomeType SHATTERED_SAVANNA = get("minecraft:shattered_savanna"); + @Nullable public static final BiomeType SHATTERED_SAVANNA_PLATEAU = get("minecraft:shattered_savanna_plateau"); + @Nullable public static final BiomeType SMALL_END_ISLANDS = get("minecraft:small_end_islands"); + @Nullable public static final BiomeType SNOWY_BEACH = get("minecraft:snowy_beach"); + @Nullable public static final BiomeType SNOWY_MOUNTAINS = get("minecraft:snowy_mountains"); + @Nullable public static final BiomeType SNOWY_TAIGA = get("minecraft:snowy_taiga"); + @Nullable public static final BiomeType SNOWY_TAIGA_HILLS = get("minecraft:snowy_taiga_hills"); + @Nullable public static final BiomeType SNOWY_TAIGA_MOUNTAINS = get("minecraft:snowy_taiga_mountains"); + @Nullable public static final BiomeType SNOWY_TUNDRA = get("minecraft:snowy_tundra"); + @Nullable public static final BiomeType STONE_SHORE = get("minecraft:stone_shore"); + @Nullable public static final BiomeType SUNFLOWER_PLAINS = get("minecraft:sunflower_plains"); + @Nullable public static final BiomeType SWAMP = get("minecraft:swamp"); + @Nullable public static final BiomeType SWAMP_HILLS = get("minecraft:swamp_hills"); + @Nullable public static final BiomeType TAIGA = get("minecraft:taiga"); + @Nullable public static final BiomeType TAIGA_HILLS = get("minecraft:taiga_hills"); + @Nullable public static final BiomeType TAIGA_MOUNTAINS = get("minecraft:taiga_mountains"); + @Nullable public static final BiomeType TALL_BIRCH_FOREST = get("minecraft:tall_birch_forest"); + @Nullable public static final BiomeType TALL_BIRCH_HILLS = get("minecraft:tall_birch_hills"); + @Nullable public static final BiomeType THE_END = get("minecraft:the_end"); + @Nullable public static final BiomeType THE_VOID = get("minecraft:the_void"); + @Nullable public static final BiomeType WARM_OCEAN = get("minecraft:warm_ocean"); + @Nullable public static final BiomeType WOODED_BADLANDS_PLATEAU = get("minecraft:wooded_badlands_plateau"); + @Nullable public static final BiomeType WOODED_HILLS = get("minecraft:wooded_hills"); + @Nullable public static final BiomeType WOODED_MOUNTAINS = get("minecraft:wooded_mountains"); + + private BiomeTypes() { + } + + private static BiomeType register(final String id) { + return register(new BiomeType(id)); + } + + public static BiomeType register(final BiomeType biome) { + return BiomeType.REGISTRY.register(biome.getId(), biome); + } + + public static @Nullable BiomeType get(final String id) { + return BiomeType.REGISTRY.get(id); + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/Biomes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/Biomes.java index 0282227db..8c73ddf01 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/Biomes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/Biomes.java @@ -50,17 +50,17 @@ public final class Biomes { * @return a biome or null */ @Nullable - public static BaseBiome findBiomeByName(Collection biomes, String name, BiomeRegistry registry) { + public static BiomeType findBiomeByName(Collection biomes, String name, BiomeRegistry registry) { checkNotNull(biomes); checkNotNull(name); checkNotNull(registry); Function compare = new LevenshteinDistance(name, false, LevenshteinDistance.STANDARD_CHARS); - WeightedChoice chooser = new WeightedChoice<>(Functions.compose(compare::apply, new BiomeName(registry)), 0); - for (BaseBiome biome : biomes) { + WeightedChoice chooser = new WeightedChoice<>(Functions.compose(compare::apply, new BiomeName(registry)), 0); + for (BiomeType biome : biomes) { chooser.consider(biome); } - Optional> choice = chooser.getChoice(); + Optional> choice = chooser.getChoice(); if (choice.isPresent() && choice.get().getScore() <= 1) { return choice.get().getValue(); } else { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java index 31b424422..61caf1561 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java @@ -223,11 +223,7 @@ public class BaseBlock implements BlockStateHolder, TileEntityBlock { @Override public int hashCode() { - int ret = toImmutableState().hashCode() << 3; - if (hasNbtData()) { - ret += getNbtData().hashCode(); - } - return ret; + return getOrdinal(); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java index d60c96985..28c3385d5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java @@ -19,58 +19,52 @@ package com.sk89q.worldedit.world.block; -import javax.annotation.Nullable; - /** * Stores a list of categories of Block Types. */ public final class BlockCategories { - public static final BlockCategory ACACIA_LOGS = register("minecraft:acacia_logs"); - public static final BlockCategory ANVIL = register("minecraft:anvil"); - public static final BlockCategory BANNERS = register("minecraft:banners"); - public static final BlockCategory BIRCH_LOGS = register("minecraft:birch_logs"); - public static final BlockCategory BUTTONS = register("minecraft:buttons"); - public static final BlockCategory CARPETS = register("minecraft:carpets"); - public static final BlockCategory CORAL = register("minecraft:coral"); - public static final BlockCategory CORAL_PLANTS = register("minecraft:coral_plants"); - public static final BlockCategory DARK_OAK_LOGS = register("minecraft:dark_oak_logs"); - public static final BlockCategory DOORS = register("minecraft:doors"); - public static final BlockCategory ENDERMAN_HOLDABLE = register("minecraft:enderman_holdable"); - public static final BlockCategory FLOWER_POTS = register("minecraft:flower_pots"); - public static final BlockCategory ICE = register("minecraft:ice"); - public static final BlockCategory JUNGLE_LOGS = register("minecraft:jungle_logs"); - public static final BlockCategory LEAVES = register("minecraft:leaves"); - public static final BlockCategory LOGS = register("minecraft:logs"); - public static final BlockCategory OAK_LOGS = register("minecraft:oak_logs"); - public static final BlockCategory PLANKS = register("minecraft:planks"); - public static final BlockCategory RAILS = register("minecraft:rails"); - public static final BlockCategory SAND = register("minecraft:sand"); - public static final BlockCategory SAPLINGS = register("minecraft:saplings"); - public static final BlockCategory SLABS = register("minecraft:slabs"); - public static final BlockCategory SPRUCE_LOGS = register("minecraft:spruce_logs"); - public static final BlockCategory STAIRS = register("minecraft:stairs"); - public static final BlockCategory STONE_BRICKS = register("minecraft:stone_bricks"); - public static final BlockCategory VALID_SPAWN = register("minecraft:valid_spawn"); - public static final BlockCategory WOODEN_BUTTONS = register("minecraft:wooden_buttons"); - public static final BlockCategory WOODEN_DOORS = register("minecraft:wooden_doors"); - public static final BlockCategory WOODEN_PRESSURE_PLATES = register("minecraft:wooden_pressure_plates"); - public static final BlockCategory WOODEN_SLABS = register("minecraft:wooden_slabs"); - public static final BlockCategory WOODEN_STAIRS = register("minecraft:wooden_stairs"); - public static final BlockCategory WOOL = register("minecraft:wool"); + public static final BlockCategory ACACIA_LOGS = get("minecraft:acacia_logs"); + public static final BlockCategory ANVIL = get("minecraft:anvil"); + public static final BlockCategory BANNERS = get("minecraft:banners"); + public static final BlockCategory BIRCH_LOGS = get("minecraft:birch_logs"); + public static final BlockCategory BUTTONS = get("minecraft:buttons"); + public static final BlockCategory CARPETS = get("minecraft:carpets"); + public static final BlockCategory CORALS = get("minecraft:corals"); + public static final BlockCategory CORAL_BLOCKS = get("minecraft:coral_blocks"); + public static final BlockCategory DARK_OAK_LOGS = get("minecraft:dark_oak_logs"); + public static final BlockCategory DOORS = get("minecraft:doors"); + public static final BlockCategory ENDERMAN_HOLDABLE = get("minecraft:enderman_holdable"); + public static final BlockCategory FLOWER_POTS = get("minecraft:flower_pots"); + public static final BlockCategory ICE = get("minecraft:ice"); + public static final BlockCategory JUNGLE_LOGS = get("minecraft:jungle_logs"); + public static final BlockCategory LEAVES = get("minecraft:leaves"); + public static final BlockCategory LOGS = get("minecraft:logs"); + public static final BlockCategory OAK_LOGS = get("minecraft:oak_logs"); + public static final BlockCategory PLANKS = get("minecraft:planks"); + public static final BlockCategory RAILS = get("minecraft:rails"); + public static final BlockCategory SAND = get("minecraft:sand"); + public static final BlockCategory SAPLINGS = get("minecraft:saplings"); + public static final BlockCategory SLABS = get("minecraft:slabs"); + public static final BlockCategory SPRUCE_LOGS = get("minecraft:spruce_logs"); + public static final BlockCategory STAIRS = get("minecraft:stairs"); + public static final BlockCategory STONE_BRICKS = get("minecraft:stone_bricks"); + public static final BlockCategory VALID_SPAWN = get("minecraft:valid_spawn"); + public static final BlockCategory WOODEN_BUTTONS = get("minecraft:wooden_buttons"); + public static final BlockCategory WOODEN_DOORS = get("minecraft:wooden_doors"); + public static final BlockCategory WOODEN_PRESSURE_PLATES = get("minecraft:wooden_pressure_plates"); + public static final BlockCategory WOODEN_SLABS = get("minecraft:wooden_slabs"); + public static final BlockCategory WOODEN_STAIRS = get("minecraft:wooden_stairs"); + public static final BlockCategory WOOL = get("minecraft:wool"); private BlockCategories() { } - private static BlockCategory register(final String id) { - return register(new BlockCategory(id)); - } - - public static BlockCategory register(final BlockCategory tag) { - return BlockCategory.REGISTRY.register(tag.getId(), tag); - } - - public static @Nullable BlockCategory get(final String id) { - return BlockCategory.REGISTRY.get(id); + private static BlockCategory get(final String id) { + BlockCategory blockCategory = BlockCategory.REGISTRY.get(id); + if (blockCategory == null) { + return new BlockCategory(id); + } + return blockCategory; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java index f007ad5db..a0dc34982 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java @@ -22,8 +22,11 @@ package com.sk89q.worldedit.world.block; import com.boydti.fawe.command.SuggestInputParseException; import com.boydti.fawe.object.string.MutableCharSequence; import com.google.common.base.Function; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.common.collect.Table; import com.sk89q.jnbt.CompoundTag; +import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extent.Extent; @@ -314,15 +317,10 @@ public class BlockState implements BlockStateHolder { return this.blockType; } - @Override - public int hashCode() { - return getOrdinal(); - } - @Override public boolean equalsFuzzy(BlockStateHolder o) { if (this == o) { - // Added a reference equality check for + // Added a reference equality check for speediness return true; } if (!getBlockType().equals(o.getBlockType())) { @@ -359,8 +357,8 @@ public class BlockState implements BlockStateHolder { } @Override - public String toString() { - return getAsString(); + public BaseBlock toBaseBlock() { + return this.emptyBaseBlock; } @Override @@ -375,9 +373,27 @@ public class BlockState implements BlockStateHolder { @Override public int getOrdinal() { - //? - return 0; + get ordinal } + /** + * Internal method used for creating the initial BlockState. + * + * Sets a value. DO NOT USE THIS. + * + * @param property The state + * @param value The value + * @return The blockstate, for chaining + */ + BlockState setState(final Property property, final Object value) { + this.values.put(property, value); + return this; + } + + @Override + public String toString() { + return getAsString(); + } + @Override public boolean equals(Object obj) { if (!(obj instanceof BlockState)) { @@ -386,4 +402,11 @@ public class BlockState implements BlockStateHolder { return equalsFuzzy((BlockState) obj); } + + private Integer hashCodeCache = null; + + @Override + public int hashCode() { + return getOrdinal(); + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java index b87acf092..1c6645d2d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java @@ -39,11 +39,13 @@ import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.registry.BundledBlockData; +import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.LegacyMapper; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.*; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -222,6 +224,10 @@ public class BlockType implements FawePattern { return new FuzzyBlockState(this); } + public FuzzyBlockState getFuzzyMatcher() { + return updateField(emptyFuzzy, () -> new FuzzyBlockState(this)); + } + /** * Slow * @return collection of states @@ -311,7 +317,7 @@ public class BlockType implements FawePattern { @Override public int hashCode() { - return this.id.hashCode(); + return this.getSettings().defaultState.ordinal(); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java index 57ae659ec..903f2a7eb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java @@ -58,623 +58,617 @@ import java.util.stream.Stream; /** * Stores a list of common Block String IDs. */ -@SuppressWarnings("deprecation") -public class BlockTypes{ - /* - ----------------------------------------------------- - Replaced at runtime by the block registry - ----------------------------------------------------- - */ - public static final BlockType __RESERVED__ = register("minecraft:__reserved__"); - public static final BlockType ACACIA_BUTTON = register("minecraft:acacia_button", state -> state.with(state.getBlockType().getProperty("face"), "WALL").with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType ACACIA_DOOR = register("minecraft:acacia_door", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "lower").with(state.getBlockType().getProperty("hinge"), "left").with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType ACACIA_FENCE = register("minecraft:acacia_fence", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType ACACIA_FENCE_GATE = register("minecraft:acacia_fence_gate", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("in_wall"), false).with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType ACACIA_LEAVES = register("minecraft:acacia_leaves", state -> state.with(state.getBlockType().getProperty("distance"), 7).with(state.getBlockType().getProperty("persistent"), false)); - public static final BlockType ACACIA_LOG = register("minecraft:acacia_log", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType ACACIA_PLANKS = register("minecraft:acacia_planks"); - public static final BlockType ACACIA_PRESSURE_PLATE = register("minecraft:acacia_pressure_plate", state -> state.with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType ACACIA_SAPLING = register("minecraft:acacia_sapling", state -> state.with(state.getBlockType().getProperty("stage"), 0)); - public static final BlockType ACACIA_SLAB = register("minecraft:acacia_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType ACACIA_STAIRS = register("minecraft:acacia_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType ACACIA_TRAPDOOR = register("minecraft:acacia_trapdoor", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false).with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType ACACIA_WOOD = register("minecraft:acacia_wood", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType ACTIVATOR_RAIL = register("minecraft:activator_rail", state -> state.with(state.getBlockType().getProperty("powered"), false).with(state.getBlockType().getProperty("shape"), "north_south")); - public static final BlockType AIR = register("minecraft:air"); - public static final BlockType ALLIUM = register("minecraft:allium"); - public static final BlockType ANDESITE = register("minecraft:andesite"); - public static final BlockType ANVIL = register("minecraft:anvil", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType ATTACHED_MELON_STEM = register("minecraft:attached_melon_stem", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType ATTACHED_PUMPKIN_STEM = register("minecraft:attached_pumpkin_stem", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType AZURE_BLUET = register("minecraft:azure_bluet"); - public static final BlockType BARRIER = register("minecraft:barrier"); - public static final BlockType BEACON = register("minecraft:beacon"); - public static final BlockType BEDROCK = register("minecraft:bedrock"); - public static final BlockType BEETROOTS = register("minecraft:beetroots", state -> state.with(state.getBlockType().getProperty("age"), 0)); - public static final BlockType BIRCH_BUTTON = register("minecraft:birch_button", state -> state.with(state.getBlockType().getProperty("face"), "WALL").with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType BIRCH_DOOR = register("minecraft:birch_door", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "lower").with(state.getBlockType().getProperty("hinge"), "left").with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType BIRCH_FENCE = register("minecraft:birch_fence", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType BIRCH_FENCE_GATE = register("minecraft:birch_fence_gate", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("in_wall"), false).with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType BIRCH_LEAVES = register("minecraft:birch_leaves", state -> state.with(state.getBlockType().getProperty("distance"), 7).with(state.getBlockType().getProperty("persistent"), false)); - public static final BlockType BIRCH_LOG = register("minecraft:birch_log", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType BIRCH_PLANKS = register("minecraft:birch_planks"); - public static final BlockType BIRCH_PRESSURE_PLATE = register("minecraft:birch_pressure_plate", state -> state.with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType BIRCH_SAPLING = register("minecraft:birch_sapling", state -> state.with(state.getBlockType().getProperty("stage"), 0)); - public static final BlockType BIRCH_SLAB = register("minecraft:birch_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType BIRCH_STAIRS = register("minecraft:birch_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType BIRCH_TRAPDOOR = register("minecraft:birch_trapdoor", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false).with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType BIRCH_WOOD = register("minecraft:birch_wood", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType BLACK_BANNER = register("minecraft:black_banner", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType BLACK_BED = register("minecraft:black_bed", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("occupied"), false).with(state.getBlockType().getProperty("part"), "foot")); - public static final BlockType BLACK_CARPET = register("minecraft:black_carpet"); - public static final BlockType BLACK_CONCRETE = register("minecraft:black_concrete"); - public static final BlockType BLACK_CONCRETE_POWDER = register("minecraft:black_concrete_powder"); - public static final BlockType BLACK_GLAZED_TERRACOTTA = register("minecraft:black_glazed_terracotta", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType BLACK_SHULKER_BOX = register("minecraft:black_shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType BLACK_STAINED_GLASS = register("minecraft:black_stained_glass"); - public static final BlockType BLACK_STAINED_GLASS_PANE = register("minecraft:black_stained_glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType BLACK_TERRACOTTA = register("minecraft:black_terracotta"); - public static final BlockType BLACK_WALL_BANNER = register("minecraft:black_wall_banner", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType BLACK_WOOL = register("minecraft:black_wool"); - public static final BlockType BLUE_BANNER = register("minecraft:blue_banner", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType BLUE_BED = register("minecraft:blue_bed", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("occupied"), false).with(state.getBlockType().getProperty("part"), "foot")); - public static final BlockType BLUE_CARPET = register("minecraft:blue_carpet"); - public static final BlockType BLUE_CONCRETE = register("minecraft:blue_concrete"); - public static final BlockType BLUE_CONCRETE_POWDER = register("minecraft:blue_concrete_powder"); - public static final BlockType BLUE_GLAZED_TERRACOTTA = register("minecraft:blue_glazed_terracotta", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType BLUE_ICE = register("minecraft:blue_ice"); - public static final BlockType BLUE_ORCHID = register("minecraft:blue_orchid"); - public static final BlockType BLUE_SHULKER_BOX = register("minecraft:blue_shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType BLUE_STAINED_GLASS = register("minecraft:blue_stained_glass"); - public static final BlockType BLUE_STAINED_GLASS_PANE = register("minecraft:blue_stained_glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType BLUE_TERRACOTTA = register("minecraft:blue_terracotta"); - public static final BlockType BLUE_WALL_BANNER = register("minecraft:blue_wall_banner", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType BLUE_WOOL = register("minecraft:blue_wool"); - public static final BlockType BONE_BLOCK = register("minecraft:bone_block", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType BOOKSHELF = register("minecraft:bookshelf"); - public static final BlockType BRAIN_CORAL = register("minecraft:brain_coral", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType BRAIN_CORAL_BLOCK = register("minecraft:brain_coral_block"); - public static final BlockType BRAIN_CORAL_FAN = register("minecraft:brain_coral_fan", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType BRAIN_CORAL_WALL_FAN = register("minecraft:brain_coral_wall_fan", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType BREWING_STAND = register("minecraft:brewing_stand", state -> state.with(state.getBlockType().getProperty("has_bottle_0"), false).with(state.getBlockType().getProperty("has_bottle_1"), false).with(state.getBlockType().getProperty("has_bottle_2"), false)); - public static final BlockType BRICK_SLAB = register("minecraft:brick_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType BRICK_STAIRS = register("minecraft:brick_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType BRICKS = register("minecraft:bricks"); - public static final BlockType BROWN_BANNER = register("minecraft:brown_banner", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType BROWN_BED = register("minecraft:brown_bed", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("occupied"), false).with(state.getBlockType().getProperty("part"), "foot")); - public static final BlockType BROWN_CARPET = register("minecraft:brown_carpet"); - public static final BlockType BROWN_CONCRETE = register("minecraft:brown_concrete"); - public static final BlockType BROWN_CONCRETE_POWDER = register("minecraft:brown_concrete_powder"); - public static final BlockType BROWN_GLAZED_TERRACOTTA = register("minecraft:brown_glazed_terracotta", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType BROWN_MUSHROOM = register("minecraft:brown_mushroom"); - public static final BlockType BROWN_MUSHROOM_BLOCK = register("minecraft:brown_mushroom_block", state -> state.with(state.getBlockType().getProperty("down"), true).with(state.getBlockType().getProperty("east"), true).with(state.getBlockType().getProperty("north"), true).with(state.getBlockType().getProperty("south"), true).with(state.getBlockType().getProperty("up"), true).with(state.getBlockType().getProperty("west"), true)); - public static final BlockType BROWN_SHULKER_BOX = register("minecraft:brown_shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType BROWN_STAINED_GLASS = register("minecraft:brown_stained_glass"); - public static final BlockType BROWN_STAINED_GLASS_PANE = register("minecraft:brown_stained_glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType BROWN_TERRACOTTA = register("minecraft:brown_terracotta"); - public static final BlockType BROWN_WALL_BANNER = register("minecraft:brown_wall_banner", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType BROWN_WOOL = register("minecraft:brown_wool"); - public static final BlockType BUBBLE_COLUMN = register("minecraft:bubble_column", state -> state.with(state.getBlockType().getProperty("drag"), true)); - public static final BlockType BUBBLE_CORAL = register("minecraft:bubble_coral", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType BUBBLE_CORAL_BLOCK = register("minecraft:bubble_coral_block"); - public static final BlockType BUBBLE_CORAL_FAN = register("minecraft:bubble_coral_fan", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType BUBBLE_CORAL_WALL_FAN = register("minecraft:bubble_coral_wall_fan", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType CACTUS = register("minecraft:cactus", state -> state.with(state.getBlockType().getProperty("age"), 0)); - public static final BlockType CAKE = register("minecraft:cake", state -> state.with(state.getBlockType().getProperty("bites"), 0)); - public static final BlockType CARROTS = register("minecraft:carrots", state -> state.with(state.getBlockType().getProperty("age"), 0)); - public static final BlockType CARVED_PUMPKIN = register("minecraft:carved_pumpkin", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType CAULDRON = register("minecraft:cauldron", state -> state.with(state.getBlockType().getProperty("level"), 0)); - public static final BlockType CAVE_AIR = register("minecraft:cave_air"); - public static final BlockType CHAIN_COMMAND_BLOCK = register("minecraft:chain_command_block", state -> state.with(state.getBlockType().getProperty("conditional"), false).with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType CHEST = register("minecraft:chest", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("type"), "SINGLE").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType CHIPPED_ANVIL = register("minecraft:chipped_anvil", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType CHISELED_QUARTZ_BLOCK = register("minecraft:chiseled_quartz_block"); - public static final BlockType CHISELED_RED_SANDSTONE = register("minecraft:chiseled_red_sandstone"); - public static final BlockType CHISELED_SANDSTONE = register("minecraft:chiseled_sandstone"); - public static final BlockType CHISELED_STONE_BRICKS = register("minecraft:chiseled_stone_bricks"); - public static final BlockType CHORUS_FLOWER = register("minecraft:chorus_flower", state -> state.with(state.getBlockType().getProperty("age"), 0)); - public static final BlockType CHORUS_PLANT = register("minecraft:chorus_plant", state -> state.with(state.getBlockType().getProperty("down"), false).with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("up"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType CLAY = register("minecraft:clay"); - public static final BlockType COAL_BLOCK = register("minecraft:coal_block"); - public static final BlockType COAL_ORE = register("minecraft:coal_ore"); - public static final BlockType COARSE_DIRT = register("minecraft:coarse_dirt"); - public static final BlockType COBBLESTONE = register("minecraft:cobblestone"); - public static final BlockType COBBLESTONE_SLAB = register("minecraft:cobblestone_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType COBBLESTONE_STAIRS = register("minecraft:cobblestone_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType COBBLESTONE_WALL = register("minecraft:cobblestone_wall", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("up"), true).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType COBWEB = register("minecraft:cobweb"); - public static final BlockType COCOA = register("minecraft:cocoa", state -> state.with(state.getBlockType().getProperty("age"), 0).with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType COMMAND_BLOCK = register("minecraft:command_block", state -> state.with(state.getBlockType().getProperty("conditional"), false).with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType COMPARATOR = register("minecraft:comparator", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("mode"), "compare").with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType CONDUIT = register("minecraft:conduit", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType CRACKED_STONE_BRICKS = register("minecraft:cracked_stone_bricks"); - public static final BlockType CRAFTING_TABLE = register("minecraft:crafting_table"); - public static final BlockType CREEPER_HEAD = register("minecraft:creeper_head", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType CREEPER_WALL_HEAD = register("minecraft:creeper_wall_head", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType CUT_RED_SANDSTONE = register("minecraft:cut_red_sandstone"); - public static final BlockType CUT_SANDSTONE = register("minecraft:cut_sandstone"); - public static final BlockType CYAN_BANNER = register("minecraft:cyan_banner", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType CYAN_BED = register("minecraft:cyan_bed", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("occupied"), false).with(state.getBlockType().getProperty("part"), "foot")); - public static final BlockType CYAN_CARPET = register("minecraft:cyan_carpet"); - public static final BlockType CYAN_CONCRETE = register("minecraft:cyan_concrete"); - public static final BlockType CYAN_CONCRETE_POWDER = register("minecraft:cyan_concrete_powder"); - public static final BlockType CYAN_GLAZED_TERRACOTTA = register("minecraft:cyan_glazed_terracotta", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType CYAN_SHULKER_BOX = register("minecraft:cyan_shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType CYAN_STAINED_GLASS = register("minecraft:cyan_stained_glass"); - public static final BlockType CYAN_STAINED_GLASS_PANE = register("minecraft:cyan_stained_glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType CYAN_TERRACOTTA = register("minecraft:cyan_terracotta"); - public static final BlockType CYAN_WALL_BANNER = register("minecraft:cyan_wall_banner", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType CYAN_WOOL = register("minecraft:cyan_wool"); - public static final BlockType DAMAGED_ANVIL = register("minecraft:damaged_anvil", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType DANDELION = register("minecraft:dandelion"); - public static final BlockType DARK_OAK_BUTTON = register("minecraft:dark_oak_button", state -> state.with(state.getBlockType().getProperty("face"), "WALL").with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType DARK_OAK_DOOR = register("minecraft:dark_oak_door", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "lower").with(state.getBlockType().getProperty("hinge"), "left").with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType DARK_OAK_FENCE = register("minecraft:dark_oak_fence", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType DARK_OAK_FENCE_GATE = register("minecraft:dark_oak_fence_gate", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("in_wall"), false).with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType DARK_OAK_LEAVES = register("minecraft:dark_oak_leaves", state -> state.with(state.getBlockType().getProperty("distance"), 7).with(state.getBlockType().getProperty("persistent"), false)); - public static final BlockType DARK_OAK_LOG = register("minecraft:dark_oak_log", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType DARK_OAK_PLANKS = register("minecraft:dark_oak_planks"); - public static final BlockType DARK_OAK_PRESSURE_PLATE = register("minecraft:dark_oak_pressure_plate", state -> state.with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType DARK_OAK_SAPLING = register("minecraft:dark_oak_sapling", state -> state.with(state.getBlockType().getProperty("stage"), 0)); - public static final BlockType DARK_OAK_SLAB = register("minecraft:dark_oak_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType DARK_OAK_STAIRS = register("minecraft:dark_oak_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType DARK_OAK_TRAPDOOR = register("minecraft:dark_oak_trapdoor", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false).with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType DARK_OAK_WOOD = register("minecraft:dark_oak_wood", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType DARK_PRISMARINE = register("minecraft:dark_prismarine"); - public static final BlockType DARK_PRISMARINE_SLAB = register("minecraft:dark_prismarine_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType DARK_PRISMARINE_STAIRS = register("minecraft:dark_prismarine_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType DAYLIGHT_DETECTOR = register("minecraft:daylight_detector", state -> state.with(state.getBlockType().getProperty("inverted"), false).with(state.getBlockType().getProperty("power"), 0)); - public static final BlockType DEAD_BRAIN_CORAL = register("minecraft:dead_brain_coral", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType DEAD_BRAIN_CORAL_BLOCK = register("minecraft:dead_brain_coral_block"); - public static final BlockType DEAD_BRAIN_CORAL_FAN = register("minecraft:dead_brain_coral_fan", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType DEAD_BRAIN_CORAL_WALL_FAN = register("minecraft:dead_brain_coral_wall_fan", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType DEAD_BUBBLE_CORAL = register("minecraft:dead_bubble_coral", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType DEAD_BUBBLE_CORAL_BLOCK = register("minecraft:dead_bubble_coral_block"); - public static final BlockType DEAD_BUBBLE_CORAL_FAN = register("minecraft:dead_bubble_coral_fan", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType DEAD_BUBBLE_CORAL_WALL_FAN = register("minecraft:dead_bubble_coral_wall_fan", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType DEAD_BUSH = register("minecraft:dead_bush"); - public static final BlockType DEAD_FIRE_CORAL = register("minecraft:dead_fire_coral", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType DEAD_FIRE_CORAL_BLOCK = register("minecraft:dead_fire_coral_block"); - public static final BlockType DEAD_FIRE_CORAL_FAN = register("minecraft:dead_fire_coral_fan", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType DEAD_FIRE_CORAL_WALL_FAN = register("minecraft:dead_fire_coral_wall_fan", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType DEAD_HORN_CORAL = register("minecraft:dead_horn_coral", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType DEAD_HORN_CORAL_BLOCK = register("minecraft:dead_horn_coral_block"); - public static final BlockType DEAD_HORN_CORAL_FAN = register("minecraft:dead_horn_coral_fan", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType DEAD_HORN_CORAL_WALL_FAN = register("minecraft:dead_horn_coral_wall_fan", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType DEAD_TUBE_CORAL = register("minecraft:dead_tube_coral", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType DEAD_TUBE_CORAL_BLOCK = register("minecraft:dead_tube_coral_block"); - public static final BlockType DEAD_TUBE_CORAL_FAN = register("minecraft:dead_tube_coral_fan", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType DEAD_TUBE_CORAL_WALL_FAN = register("minecraft:dead_tube_coral_wall_fan", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType DETECTOR_RAIL = register("minecraft:detector_rail", state -> state.with(state.getBlockType().getProperty("powered"), false).with(state.getBlockType().getProperty("shape"), "north_south")); - public static final BlockType DIAMOND_BLOCK = register("minecraft:diamond_block"); - public static final BlockType DIAMOND_ORE = register("minecraft:diamond_ore"); - public static final BlockType DIORITE = register("minecraft:diorite"); - public static final BlockType DIRT = register("minecraft:dirt"); - public static final BlockType DISPENSER = register("minecraft:dispenser", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("triggered"), false)); - public static final BlockType DRAGON_EGG = register("minecraft:dragon_egg"); - public static final BlockType DRAGON_HEAD = register("minecraft:dragon_head", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType DRAGON_WALL_HEAD = register("minecraft:dragon_wall_head", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType DRIED_KELP_BLOCK = register("minecraft:dried_kelp_block"); - public static final BlockType DROPPER = register("minecraft:dropper", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("triggered"), false)); - public static final BlockType EMERALD_BLOCK = register("minecraft:emerald_block"); - public static final BlockType EMERALD_ORE = register("minecraft:emerald_ore"); - public static final BlockType ENCHANTING_TABLE = register("minecraft:enchanting_table"); - public static final BlockType END_GATEWAY = register("minecraft:end_gateway"); - public static final BlockType END_PORTAL = register("minecraft:end_portal"); - public static final BlockType END_PORTAL_FRAME = register("minecraft:end_portal_frame", state -> state.with(state.getBlockType().getProperty("eye"), false).with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType END_ROD = register("minecraft:end_rod", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType END_STONE = register("minecraft:end_stone"); - public static final BlockType END_STONE_BRICKS = register("minecraft:end_stone_bricks"); - public static final BlockType ENDER_CHEST = register("minecraft:ender_chest", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType FARMLAND = register("minecraft:farmland", state -> state.with(state.getBlockType().getProperty("moisture"), 0)); - public static final BlockType FERN = register("minecraft:fern"); - public static final BlockType FIRE = register("minecraft:fire", state -> state.with(state.getBlockType().getProperty("age"), 0).with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("up"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType FIRE_CORAL = register("minecraft:fire_coral", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType FIRE_CORAL_BLOCK = register("minecraft:fire_coral_block"); - public static final BlockType FIRE_CORAL_FAN = register("minecraft:fire_coral_fan", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType FIRE_CORAL_WALL_FAN = register("minecraft:fire_coral_wall_fan", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType FLOWER_POT = register("minecraft:flower_pot"); - public static final BlockType FROSTED_ICE = register("minecraft:frosted_ice", state -> state.with(state.getBlockType().getProperty("age"), 0)); - public static final BlockType FURNACE = register("minecraft:furnace", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("lit"), false)); - public static final BlockType GLASS = register("minecraft:glass"); - public static final BlockType GLASS_PANE = register("minecraft:glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType GLOWSTONE = register("minecraft:glowstone"); - public static final BlockType GOLD_BLOCK = register("minecraft:gold_block"); - public static final BlockType GOLD_ORE = register("minecraft:gold_ore"); - public static final BlockType GRANITE = register("minecraft:granite"); - public static final BlockType GRASS = register("minecraft:grass"); - public static final BlockType GRASS_BLOCK = register("minecraft:grass_block", state -> state.with(state.getBlockType().getProperty("snowy"), false)); - public static final BlockType GRASS_PATH = register("minecraft:grass_path"); - public static final BlockType GRAVEL = register("minecraft:gravel"); - public static final BlockType GRAY_BANNER = register("minecraft:gray_banner", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType GRAY_BED = register("minecraft:gray_bed", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("occupied"), false).with(state.getBlockType().getProperty("part"), "foot")); - public static final BlockType GRAY_CARPET = register("minecraft:gray_carpet"); - public static final BlockType GRAY_CONCRETE = register("minecraft:gray_concrete"); - public static final BlockType GRAY_CONCRETE_POWDER = register("minecraft:gray_concrete_powder"); - public static final BlockType GRAY_GLAZED_TERRACOTTA = register("minecraft:gray_glazed_terracotta", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType GRAY_SHULKER_BOX = register("minecraft:gray_shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType GRAY_STAINED_GLASS = register("minecraft:gray_stained_glass"); - public static final BlockType GRAY_STAINED_GLASS_PANE = register("minecraft:gray_stained_glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType GRAY_TERRACOTTA = register("minecraft:gray_terracotta"); - public static final BlockType GRAY_WALL_BANNER = register("minecraft:gray_wall_banner", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType GRAY_WOOL = register("minecraft:gray_wool"); - public static final BlockType GREEN_BANNER = register("minecraft:green_banner", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType GREEN_BED = register("minecraft:green_bed", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("occupied"), false).with(state.getBlockType().getProperty("part"), "foot")); - public static final BlockType GREEN_CARPET = register("minecraft:green_carpet"); - public static final BlockType GREEN_CONCRETE = register("minecraft:green_concrete"); - public static final BlockType GREEN_CONCRETE_POWDER = register("minecraft:green_concrete_powder"); - public static final BlockType GREEN_GLAZED_TERRACOTTA = register("minecraft:green_glazed_terracotta", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType GREEN_SHULKER_BOX = register("minecraft:green_shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType GREEN_STAINED_GLASS = register("minecraft:green_stained_glass"); - public static final BlockType GREEN_STAINED_GLASS_PANE = register("minecraft:green_stained_glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType GREEN_TERRACOTTA = register("minecraft:green_terracotta"); - public static final BlockType GREEN_WALL_BANNER = register("minecraft:green_wall_banner", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType GREEN_WOOL = register("minecraft:green_wool"); - public static final BlockType HAY_BLOCK = register("minecraft:hay_block", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType HEAVY_WEIGHTED_PRESSURE_PLATE = register("minecraft:heavy_weighted_pressure_plate", state -> state.with(state.getBlockType().getProperty("power"), 0)); - public static final BlockType HOPPER = register("minecraft:hopper", state -> state.with(state.getBlockType().getProperty("enabled"), true).with(state.getBlockType().getProperty("facing"), Direction.DOWN)); - public static final BlockType HORN_CORAL = register("minecraft:horn_coral", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType HORN_CORAL_BLOCK = register("minecraft:horn_coral_block"); - public static final BlockType HORN_CORAL_FAN = register("minecraft:horn_coral_fan", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType HORN_CORAL_WALL_FAN = register("minecraft:horn_coral_wall_fan", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType ICE = register("minecraft:ice"); - public static final BlockType INFESTED_CHISELED_STONE_BRICKS = register("minecraft:infested_chiseled_stone_bricks"); - public static final BlockType INFESTED_COBBLESTONE = register("minecraft:infested_cobblestone"); - public static final BlockType INFESTED_CRACKED_STONE_BRICKS = register("minecraft:infested_cracked_stone_bricks"); - public static final BlockType INFESTED_MOSSY_STONE_BRICKS = register("minecraft:infested_mossy_stone_bricks"); - public static final BlockType INFESTED_STONE = register("minecraft:infested_stone"); - public static final BlockType INFESTED_STONE_BRICKS = register("minecraft:infested_stone_bricks"); - public static final BlockType IRON_BARS = register("minecraft:iron_bars", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType IRON_BLOCK = register("minecraft:iron_block"); - public static final BlockType IRON_DOOR = register("minecraft:iron_door", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "lower").with(state.getBlockType().getProperty("hinge"), "left").with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType IRON_ORE = register("minecraft:iron_ore"); - public static final BlockType IRON_TRAPDOOR = register("minecraft:iron_trapdoor", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false).with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType JACK_O_LANTERN = register("minecraft:jack_o_lantern", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType JUKEBOX = register("minecraft:jukebox", state -> state.with(state.getBlockType().getProperty("has_record"), false)); - public static final BlockType JUNGLE_BUTTON = register("minecraft:jungle_button", state -> state.with(state.getBlockType().getProperty("face"), "WALL").with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType JUNGLE_DOOR = register("minecraft:jungle_door", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "lower").with(state.getBlockType().getProperty("hinge"), "left").with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType JUNGLE_FENCE = register("minecraft:jungle_fence", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType JUNGLE_FENCE_GATE = register("minecraft:jungle_fence_gate", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("in_wall"), false).with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType JUNGLE_LEAVES = register("minecraft:jungle_leaves", state -> state.with(state.getBlockType().getProperty("distance"), 7).with(state.getBlockType().getProperty("persistent"), false)); - public static final BlockType JUNGLE_LOG = register("minecraft:jungle_log", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType JUNGLE_PLANKS = register("minecraft:jungle_planks"); - public static final BlockType JUNGLE_PRESSURE_PLATE = register("minecraft:jungle_pressure_plate", state -> state.with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType JUNGLE_SAPLING = register("minecraft:jungle_sapling", state -> state.with(state.getBlockType().getProperty("stage"), 0)); - public static final BlockType JUNGLE_SLAB = register("minecraft:jungle_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType JUNGLE_STAIRS = register("minecraft:jungle_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType JUNGLE_TRAPDOOR = register("minecraft:jungle_trapdoor", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false).with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType JUNGLE_WOOD = register("minecraft:jungle_wood", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType KELP = register("minecraft:kelp", state -> state.with(state.getBlockType().getProperty("age"), 0)); - public static final BlockType KELP_PLANT = register("minecraft:kelp_plant"); - public static final BlockType LADDER = register("minecraft:ladder", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType LAPIS_BLOCK = register("minecraft:lapis_block"); - public static final BlockType LAPIS_ORE = register("minecraft:lapis_ore"); - public static final BlockType LARGE_FERN = register("minecraft:large_fern", state -> state.with(state.getBlockType().getProperty("half"), "lower")); - public static final BlockType LAVA = register("minecraft:lava", state -> state.with(state.getBlockType().getProperty("level"), 0)); - public static final BlockType LEVER = register("minecraft:lever", state -> state.with(state.getBlockType().getProperty("face"), "WALL").with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType LIGHT_BLUE_BANNER = register("minecraft:light_blue_banner", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType LIGHT_BLUE_BED = register("minecraft:light_blue_bed", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("occupied"), false).with(state.getBlockType().getProperty("part"), "foot")); - public static final BlockType LIGHT_BLUE_CARPET = register("minecraft:light_blue_carpet"); - public static final BlockType LIGHT_BLUE_CONCRETE = register("minecraft:light_blue_concrete"); - public static final BlockType LIGHT_BLUE_CONCRETE_POWDER = register("minecraft:light_blue_concrete_powder"); - public static final BlockType LIGHT_BLUE_GLAZED_TERRACOTTA = register("minecraft:light_blue_glazed_terracotta", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType LIGHT_BLUE_SHULKER_BOX = register("minecraft:light_blue_shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType LIGHT_BLUE_STAINED_GLASS = register("minecraft:light_blue_stained_glass"); - public static final BlockType LIGHT_BLUE_STAINED_GLASS_PANE = register("minecraft:light_blue_stained_glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType LIGHT_BLUE_TERRACOTTA = register("minecraft:light_blue_terracotta"); - public static final BlockType LIGHT_BLUE_WALL_BANNER = register("minecraft:light_blue_wall_banner", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType LIGHT_BLUE_WOOL = register("minecraft:light_blue_wool"); - public static final BlockType LIGHT_GRAY_BANNER = register("minecraft:light_gray_banner", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType LIGHT_GRAY_BED = register("minecraft:light_gray_bed", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("occupied"), false).with(state.getBlockType().getProperty("part"), "foot")); - public static final BlockType LIGHT_GRAY_CARPET = register("minecraft:light_gray_carpet"); - public static final BlockType LIGHT_GRAY_CONCRETE = register("minecraft:light_gray_concrete"); - public static final BlockType LIGHT_GRAY_CONCRETE_POWDER = register("minecraft:light_gray_concrete_powder"); - public static final BlockType LIGHT_GRAY_GLAZED_TERRACOTTA = register("minecraft:light_gray_glazed_terracotta", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType LIGHT_GRAY_SHULKER_BOX = register("minecraft:light_gray_shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType LIGHT_GRAY_STAINED_GLASS = register("minecraft:light_gray_stained_glass"); - public static final BlockType LIGHT_GRAY_STAINED_GLASS_PANE = register("minecraft:light_gray_stained_glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType LIGHT_GRAY_TERRACOTTA = register("minecraft:light_gray_terracotta"); - public static final BlockType LIGHT_GRAY_WALL_BANNER = register("minecraft:light_gray_wall_banner", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType LIGHT_GRAY_WOOL = register("minecraft:light_gray_wool"); - public static final BlockType LIGHT_WEIGHTED_PRESSURE_PLATE = register("minecraft:light_weighted_pressure_plate", state -> state.with(state.getBlockType().getProperty("power"), 0)); - public static final BlockType LILAC = register("minecraft:lilac", state -> state.with(state.getBlockType().getProperty("half"), "lower")); - public static final BlockType LILY_PAD = register("minecraft:lily_pad"); - public static final BlockType LIME_BANNER = register("minecraft:lime_banner", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType LIME_BED = register("minecraft:lime_bed", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("occupied"), false).with(state.getBlockType().getProperty("part"), "foot")); - public static final BlockType LIME_CARPET = register("minecraft:lime_carpet"); - public static final BlockType LIME_CONCRETE = register("minecraft:lime_concrete"); - public static final BlockType LIME_CONCRETE_POWDER = register("minecraft:lime_concrete_powder"); - public static final BlockType LIME_GLAZED_TERRACOTTA = register("minecraft:lime_glazed_terracotta", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType LIME_SHULKER_BOX = register("minecraft:lime_shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType LIME_STAINED_GLASS = register("minecraft:lime_stained_glass"); - public static final BlockType LIME_STAINED_GLASS_PANE = register("minecraft:lime_stained_glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType LIME_TERRACOTTA = register("minecraft:lime_terracotta"); - public static final BlockType LIME_WALL_BANNER = register("minecraft:lime_wall_banner", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType LIME_WOOL = register("minecraft:lime_wool"); - public static final BlockType MAGENTA_BANNER = register("minecraft:magenta_banner", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType MAGENTA_BED = register("minecraft:magenta_bed", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("occupied"), false).with(state.getBlockType().getProperty("part"), "foot")); - public static final BlockType MAGENTA_CARPET = register("minecraft:magenta_carpet"); - public static final BlockType MAGENTA_CONCRETE = register("minecraft:magenta_concrete"); - public static final BlockType MAGENTA_CONCRETE_POWDER = register("minecraft:magenta_concrete_powder"); - public static final BlockType MAGENTA_GLAZED_TERRACOTTA = register("minecraft:magenta_glazed_terracotta", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType MAGENTA_SHULKER_BOX = register("minecraft:magenta_shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType MAGENTA_STAINED_GLASS = register("minecraft:magenta_stained_glass"); - public static final BlockType MAGENTA_STAINED_GLASS_PANE = register("minecraft:magenta_stained_glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType MAGENTA_TERRACOTTA = register("minecraft:magenta_terracotta"); - public static final BlockType MAGENTA_WALL_BANNER = register("minecraft:magenta_wall_banner", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType MAGENTA_WOOL = register("minecraft:magenta_wool"); - public static final BlockType MAGMA_BLOCK = register("minecraft:magma_block"); - public static final BlockType MELON = register("minecraft:melon"); - public static final BlockType MELON_STEM = register("minecraft:melon_stem", state -> state.with(state.getBlockType().getProperty("age"), 0)); - public static final BlockType MOSSY_COBBLESTONE = register("minecraft:mossy_cobblestone"); - public static final BlockType MOSSY_COBBLESTONE_WALL = register("minecraft:mossy_cobblestone_wall", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("up"), true).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType MOSSY_STONE_BRICKS = register("minecraft:mossy_stone_bricks"); - public static final BlockType MOVING_PISTON = register("minecraft:moving_piston", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("type"), "normal")); - public static final BlockType MUSHROOM_STEM = register("minecraft:mushroom_stem", state -> state.with(state.getBlockType().getProperty("down"), true).with(state.getBlockType().getProperty("east"), true).with(state.getBlockType().getProperty("north"), true).with(state.getBlockType().getProperty("south"), true).with(state.getBlockType().getProperty("up"), true).with(state.getBlockType().getProperty("west"), true)); - public static final BlockType MYCELIUM = register("minecraft:mycelium", state -> state.with(state.getBlockType().getProperty("snowy"), false)); - public static final BlockType NETHER_BRICK_FENCE = register("minecraft:nether_brick_fence", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType NETHER_BRICK_SLAB = register("minecraft:nether_brick_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType NETHER_BRICK_STAIRS = register("minecraft:nether_brick_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType NETHER_BRICKS = register("minecraft:nether_bricks"); - public static final BlockType NETHER_PORTAL = register("minecraft:nether_portal", state -> state.with(state.getBlockType().getProperty("axis"), "x")); - public static final BlockType NETHER_QUARTZ_ORE = register("minecraft:nether_quartz_ore"); - public static final BlockType NETHER_WART = register("minecraft:nether_wart", state -> state.with(state.getBlockType().getProperty("age"), 0)); - public static final BlockType NETHER_WART_BLOCK = register("minecraft:nether_wart_block"); - public static final BlockType NETHERRACK = register("minecraft:netherrack"); - public static final BlockType NOTE_BLOCK = register("minecraft:note_block", state -> state.with(state.getBlockType().getProperty("instrument"), "HARP").with(state.getBlockType().getProperty("note"), 0).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType OAK_BUTTON = register("minecraft:oak_button", state -> state.with(state.getBlockType().getProperty("face"), "WALL").with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType OAK_DOOR = register("minecraft:oak_door", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "lower").with(state.getBlockType().getProperty("hinge"), "left").with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType OAK_FENCE = register("minecraft:oak_fence", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType OAK_FENCE_GATE = register("minecraft:oak_fence_gate", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("in_wall"), false).with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType OAK_LEAVES = register("minecraft:oak_leaves", state -> state.with(state.getBlockType().getProperty("distance"), 7).with(state.getBlockType().getProperty("persistent"), false)); - public static final BlockType OAK_LOG = register("minecraft:oak_log", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType OAK_PLANKS = register("minecraft:oak_planks"); - public static final BlockType OAK_PRESSURE_PLATE = register("minecraft:oak_pressure_plate", state -> state.with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType OAK_SAPLING = register("minecraft:oak_sapling", state -> state.with(state.getBlockType().getProperty("stage"), 0)); - public static final BlockType OAK_SLAB = register("minecraft:oak_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType OAK_STAIRS = register("minecraft:oak_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType OAK_TRAPDOOR = register("minecraft:oak_trapdoor", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false).with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType OAK_WOOD = register("minecraft:oak_wood", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType OBSERVER = register("minecraft:observer", state -> state.with(state.getBlockType().getProperty("facing"), Direction.SOUTH).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType OBSIDIAN = register("minecraft:obsidian"); - public static final BlockType ORANGE_BANNER = register("minecraft:orange_banner", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType ORANGE_BED = register("minecraft:orange_bed", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("occupied"), false).with(state.getBlockType().getProperty("part"), "foot")); - public static final BlockType ORANGE_CARPET = register("minecraft:orange_carpet"); - public static final BlockType ORANGE_CONCRETE = register("minecraft:orange_concrete"); - public static final BlockType ORANGE_CONCRETE_POWDER = register("minecraft:orange_concrete_powder"); - public static final BlockType ORANGE_GLAZED_TERRACOTTA = register("minecraft:orange_glazed_terracotta", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType ORANGE_SHULKER_BOX = register("minecraft:orange_shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType ORANGE_STAINED_GLASS = register("minecraft:orange_stained_glass"); - public static final BlockType ORANGE_STAINED_GLASS_PANE = register("minecraft:orange_stained_glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType ORANGE_TERRACOTTA = register("minecraft:orange_terracotta"); - public static final BlockType ORANGE_TULIP = register("minecraft:orange_tulip"); - public static final BlockType ORANGE_WALL_BANNER = register("minecraft:orange_wall_banner", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType ORANGE_WOOL = register("minecraft:orange_wool"); - public static final BlockType OXEYE_DAISY = register("minecraft:oxeye_daisy"); - public static final BlockType PACKED_ICE = register("minecraft:packed_ice"); - public static final BlockType PEONY = register("minecraft:peony", state -> state.with(state.getBlockType().getProperty("half"), "lower")); - public static final BlockType PETRIFIED_OAK_SLAB = register("minecraft:petrified_oak_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType PINK_BANNER = register("minecraft:pink_banner", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType PINK_BED = register("minecraft:pink_bed", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("occupied"), false).with(state.getBlockType().getProperty("part"), "foot")); - public static final BlockType PINK_CARPET = register("minecraft:pink_carpet"); - public static final BlockType PINK_CONCRETE = register("minecraft:pink_concrete"); - public static final BlockType PINK_CONCRETE_POWDER = register("minecraft:pink_concrete_powder"); - public static final BlockType PINK_GLAZED_TERRACOTTA = register("minecraft:pink_glazed_terracotta", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType PINK_SHULKER_BOX = register("minecraft:pink_shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType PINK_STAINED_GLASS = register("minecraft:pink_stained_glass"); - public static final BlockType PINK_STAINED_GLASS_PANE = register("minecraft:pink_stained_glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType PINK_TERRACOTTA = register("minecraft:pink_terracotta"); - public static final BlockType PINK_TULIP = register("minecraft:pink_tulip"); - public static final BlockType PINK_WALL_BANNER = register("minecraft:pink_wall_banner", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType PINK_WOOL = register("minecraft:pink_wool"); - public static final BlockType PISTON = register("minecraft:piston", state -> state.with(state.getBlockType().getProperty("extended"), false).with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType PISTON_HEAD = register("minecraft:piston_head", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("short"), false).with(state.getBlockType().getProperty("type"), "normal")); - public static final BlockType PLAYER_HEAD = register("minecraft:player_head", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType PLAYER_WALL_HEAD = register("minecraft:player_wall_head", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType PODZOL = register("minecraft:podzol", state -> state.with(state.getBlockType().getProperty("snowy"), false)); - public static final BlockType POLISHED_ANDESITE = register("minecraft:polished_andesite"); - public static final BlockType POLISHED_DIORITE = register("minecraft:polished_diorite"); - public static final BlockType POLISHED_GRANITE = register("minecraft:polished_granite"); - public static final BlockType POPPY = register("minecraft:poppy"); - public static final BlockType POTATOES = register("minecraft:potatoes", state -> state.with(state.getBlockType().getProperty("age"), 0)); - public static final BlockType POTTED_ACACIA_SAPLING = register("minecraft:potted_acacia_sapling"); - public static final BlockType POTTED_ALLIUM = register("minecraft:potted_allium"); - public static final BlockType POTTED_AZURE_BLUET = register("minecraft:potted_azure_bluet"); - public static final BlockType POTTED_BIRCH_SAPLING = register("minecraft:potted_birch_sapling"); - public static final BlockType POTTED_BLUE_ORCHID = register("minecraft:potted_blue_orchid"); - public static final BlockType POTTED_BROWN_MUSHROOM = register("minecraft:potted_brown_mushroom"); - public static final BlockType POTTED_CACTUS = register("minecraft:potted_cactus"); - public static final BlockType POTTED_DANDELION = register("minecraft:potted_dandelion"); - public static final BlockType POTTED_DARK_OAK_SAPLING = register("minecraft:potted_dark_oak_sapling"); - public static final BlockType POTTED_DEAD_BUSH = register("minecraft:potted_dead_bush"); - public static final BlockType POTTED_FERN = register("minecraft:potted_fern"); - public static final BlockType POTTED_JUNGLE_SAPLING = register("minecraft:potted_jungle_sapling"); - public static final BlockType POTTED_OAK_SAPLING = register("minecraft:potted_oak_sapling"); - public static final BlockType POTTED_ORANGE_TULIP = register("minecraft:potted_orange_tulip"); - public static final BlockType POTTED_OXEYE_DAISY = register("minecraft:potted_oxeye_daisy"); - public static final BlockType POTTED_PINK_TULIP = register("minecraft:potted_pink_tulip"); - public static final BlockType POTTED_POPPY = register("minecraft:potted_poppy"); - public static final BlockType POTTED_RED_MUSHROOM = register("minecraft:potted_red_mushroom"); - public static final BlockType POTTED_RED_TULIP = register("minecraft:potted_red_tulip"); - public static final BlockType POTTED_SPRUCE_SAPLING = register("minecraft:potted_spruce_sapling"); - public static final BlockType POTTED_WHITE_TULIP = register("minecraft:potted_white_tulip"); - public static final BlockType POWERED_RAIL = register("minecraft:powered_rail", state -> state.with(state.getBlockType().getProperty("powered"), false).with(state.getBlockType().getProperty("shape"), "north_south")); - public static final BlockType PRISMARINE = register("minecraft:prismarine"); - public static final BlockType PRISMARINE_BRICK_SLAB = register("minecraft:prismarine_brick_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType PRISMARINE_BRICK_STAIRS = register("minecraft:prismarine_brick_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType PRISMARINE_BRICKS = register("minecraft:prismarine_bricks"); - public static final BlockType PRISMARINE_SLAB = register("minecraft:prismarine_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType PRISMARINE_STAIRS = register("minecraft:prismarine_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType PUMPKIN = register("minecraft:pumpkin"); - public static final BlockType PUMPKIN_STEM = register("minecraft:pumpkin_stem", state -> state.with(state.getBlockType().getProperty("age"), 0)); - public static final BlockType PURPLE_BANNER = register("minecraft:purple_banner", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType PURPLE_BED = register("minecraft:purple_bed", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("occupied"), false).with(state.getBlockType().getProperty("part"), "foot")); - public static final BlockType PURPLE_CARPET = register("minecraft:purple_carpet"); - public static final BlockType PURPLE_CONCRETE = register("minecraft:purple_concrete"); - public static final BlockType PURPLE_CONCRETE_POWDER = register("minecraft:purple_concrete_powder"); - public static final BlockType PURPLE_GLAZED_TERRACOTTA = register("minecraft:purple_glazed_terracotta", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType PURPLE_SHULKER_BOX = register("minecraft:purple_shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType PURPLE_STAINED_GLASS = register("minecraft:purple_stained_glass"); - public static final BlockType PURPLE_STAINED_GLASS_PANE = register("minecraft:purple_stained_glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType PURPLE_TERRACOTTA = register("minecraft:purple_terracotta"); - public static final BlockType PURPLE_WALL_BANNER = register("minecraft:purple_wall_banner", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType PURPLE_WOOL = register("minecraft:purple_wool"); - public static final BlockType PURPUR_BLOCK = register("minecraft:purpur_block"); - public static final BlockType PURPUR_PILLAR = register("minecraft:purpur_pillar", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType PURPUR_SLAB = register("minecraft:purpur_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType PURPUR_STAIRS = register("minecraft:purpur_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType QUARTZ_BLOCK = register("minecraft:quartz_block"); - public static final BlockType QUARTZ_PILLAR = register("minecraft:quartz_pillar", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType QUARTZ_SLAB = register("minecraft:quartz_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType QUARTZ_STAIRS = register("minecraft:quartz_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType RAIL = register("minecraft:rail", state -> state.with(state.getBlockType().getProperty("shape"), "north_south")); - public static final BlockType RED_BANNER = register("minecraft:red_banner", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType RED_BED = register("minecraft:red_bed", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("occupied"), false).with(state.getBlockType().getProperty("part"), "foot")); - public static final BlockType RED_CARPET = register("minecraft:red_carpet"); - public static final BlockType RED_CONCRETE = register("minecraft:red_concrete"); - public static final BlockType RED_CONCRETE_POWDER = register("minecraft:red_concrete_powder"); - public static final BlockType RED_GLAZED_TERRACOTTA = register("minecraft:red_glazed_terracotta", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType RED_MUSHROOM = register("minecraft:red_mushroom"); - public static final BlockType RED_MUSHROOM_BLOCK = register("minecraft:red_mushroom_block", state -> state.with(state.getBlockType().getProperty("down"), true).with(state.getBlockType().getProperty("east"), true).with(state.getBlockType().getProperty("north"), true).with(state.getBlockType().getProperty("south"), true).with(state.getBlockType().getProperty("up"), true).with(state.getBlockType().getProperty("west"), true)); - public static final BlockType RED_NETHER_BRICKS = register("minecraft:red_nether_bricks"); - public static final BlockType RED_SAND = register("minecraft:red_sand"); - public static final BlockType RED_SANDSTONE = register("minecraft:red_sandstone"); - public static final BlockType RED_SANDSTONE_SLAB = register("minecraft:red_sandstone_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType RED_SANDSTONE_STAIRS = register("minecraft:red_sandstone_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType RED_SHULKER_BOX = register("minecraft:red_shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType RED_STAINED_GLASS = register("minecraft:red_stained_glass"); - public static final BlockType RED_STAINED_GLASS_PANE = register("minecraft:red_stained_glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType RED_TERRACOTTA = register("minecraft:red_terracotta"); - public static final BlockType RED_TULIP = register("minecraft:red_tulip"); - public static final BlockType RED_WALL_BANNER = register("minecraft:red_wall_banner", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType RED_WOOL = register("minecraft:red_wool"); - public static final BlockType REDSTONE_BLOCK = register("minecraft:redstone_block"); - public static final BlockType REDSTONE_LAMP = register("minecraft:redstone_lamp", state -> state.with(state.getBlockType().getProperty("lit"), false)); - public static final BlockType REDSTONE_ORE = register("minecraft:redstone_ore", state -> state.with(state.getBlockType().getProperty("lit"), false)); - public static final BlockType REDSTONE_TORCH = register("minecraft:redstone_torch", state -> state.with(state.getBlockType().getProperty("lit"), true)); - public static final BlockType REDSTONE_WALL_TORCH = register("minecraft:redstone_wall_torch", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("lit"), true)); - public static final BlockType REDSTONE_WIRE = register("minecraft:redstone_wire", state -> state.with(state.getBlockType().getProperty("east"), "none").with(state.getBlockType().getProperty("north"), "none").with(state.getBlockType().getProperty("power"), 0).with(state.getBlockType().getProperty("south"), "none").with(state.getBlockType().getProperty("west"), "none")); - public static final BlockType REPEATER = register("minecraft:repeater", state -> state.with(state.getBlockType().getProperty("delay"), 1).with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("locked"), false).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType REPEATING_COMMAND_BLOCK = register("minecraft:repeating_command_block", state -> state.with(state.getBlockType().getProperty("conditional"), false).with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType ROSE_BUSH = register("minecraft:rose_bush", state -> state.with(state.getBlockType().getProperty("half"), "lower")); - public static final BlockType SAND = register("minecraft:sand"); - public static final BlockType SANDSTONE = register("minecraft:sandstone"); - public static final BlockType SANDSTONE_SLAB = register("minecraft:sandstone_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType SANDSTONE_STAIRS = register("minecraft:sandstone_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType SEA_LANTERN = register("minecraft:sea_lantern"); - public static final BlockType SEA_PICKLE = register("minecraft:sea_pickle", state -> state.with(state.getBlockType().getProperty("pickles"), 1).with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType SEAGRASS = register("minecraft:seagrass"); - public static final BlockType SHULKER_BOX = register("minecraft:shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType SIGN = register("minecraft:sign", state -> state.with(state.getBlockType().getProperty("rotation"), 0).with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType SKELETON_SKULL = register("minecraft:skeleton_skull", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType SKELETON_WALL_SKULL = register("minecraft:skeleton_wall_skull", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType SLIME_BLOCK = register("minecraft:slime_block"); - public static final BlockType SMOOTH_QUARTZ = register("minecraft:smooth_quartz"); - public static final BlockType SMOOTH_RED_SANDSTONE = register("minecraft:smooth_red_sandstone"); - public static final BlockType SMOOTH_SANDSTONE = register("minecraft:smooth_sandstone"); - public static final BlockType SMOOTH_STONE = register("minecraft:smooth_stone"); - public static final BlockType SNOW = register("minecraft:snow", state -> state.with(state.getBlockType().getProperty("layers"), 1)); - public static final BlockType SNOW_BLOCK = register("minecraft:snow_block"); - public static final BlockType SOUL_SAND = register("minecraft:soul_sand"); - public static final BlockType SPAWNER = register("minecraft:spawner"); - public static final BlockType SPONGE = register("minecraft:sponge"); - public static final BlockType SPRUCE_BUTTON = register("minecraft:spruce_button", state -> state.with(state.getBlockType().getProperty("face"), "WALL").with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType SPRUCE_DOOR = register("minecraft:spruce_door", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "lower").with(state.getBlockType().getProperty("hinge"), "left").with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType SPRUCE_FENCE = register("minecraft:spruce_fence", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType SPRUCE_FENCE_GATE = register("minecraft:spruce_fence_gate", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("in_wall"), false).with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType SPRUCE_LEAVES = register("minecraft:spruce_leaves", state -> state.with(state.getBlockType().getProperty("distance"), 7).with(state.getBlockType().getProperty("persistent"), false)); - public static final BlockType SPRUCE_LOG = register("minecraft:spruce_log", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType SPRUCE_PLANKS = register("minecraft:spruce_planks"); - public static final BlockType SPRUCE_PRESSURE_PLATE = register("minecraft:spruce_pressure_plate", state -> state.with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType SPRUCE_SAPLING = register("minecraft:spruce_sapling", state -> state.with(state.getBlockType().getProperty("stage"), 0)); - public static final BlockType SPRUCE_SLAB = register("minecraft:spruce_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType SPRUCE_STAIRS = register("minecraft:spruce_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType SPRUCE_TRAPDOOR = register("minecraft:spruce_trapdoor", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("open"), false).with(state.getBlockType().getProperty("powered"), false).with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType SPRUCE_WOOD = register("minecraft:spruce_wood", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType STICKY_PISTON = register("minecraft:sticky_piston", state -> state.with(state.getBlockType().getProperty("extended"), false).with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType STONE = register("minecraft:stone"); - public static final BlockType STONE_BRICK_SLAB = register("minecraft:stone_brick_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType STONE_BRICK_STAIRS = register("minecraft:stone_brick_stairs", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("half"), "bottom").with(state.getBlockType().getProperty("shape"), "straight").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType STONE_BRICKS = register("minecraft:stone_bricks"); - public static final BlockType STONE_BUTTON = register("minecraft:stone_button", state -> state.with(state.getBlockType().getProperty("face"), "WALL").with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType STONE_PRESSURE_PLATE = register("minecraft:stone_pressure_plate", state -> state.with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType STONE_SLAB = register("minecraft:stone_slab", state -> state.with(state.getBlockType().getProperty("type"), "bottom").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType STRIPPED_ACACIA_LOG = register("minecraft:stripped_acacia_log", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType STRIPPED_ACACIA_WOOD = register("minecraft:stripped_acacia_wood", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType STRIPPED_BIRCH_LOG = register("minecraft:stripped_birch_log", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType STRIPPED_BIRCH_WOOD = register("minecraft:stripped_birch_wood", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType STRIPPED_DARK_OAK_LOG = register("minecraft:stripped_dark_oak_log", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType STRIPPED_DARK_OAK_WOOD = register("minecraft:stripped_dark_oak_wood", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType STRIPPED_JUNGLE_LOG = register("minecraft:stripped_jungle_log", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType STRIPPED_JUNGLE_WOOD = register("minecraft:stripped_jungle_wood", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType STRIPPED_OAK_LOG = register("minecraft:stripped_oak_log", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType STRIPPED_OAK_WOOD = register("minecraft:stripped_oak_wood", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType STRIPPED_SPRUCE_LOG = register("minecraft:stripped_spruce_log", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType STRIPPED_SPRUCE_WOOD = register("minecraft:stripped_spruce_wood", state -> state.with(state.getBlockType().getProperty("axis"), "y")); - public static final BlockType STRUCTURE_BLOCK = register("minecraft:structure_block", state -> state.with(state.getBlockType().getProperty("mode"), "SAVE")); - public static final BlockType STRUCTURE_VOID = register("minecraft:structure_void"); - public static final BlockType SUGAR_CANE = register("minecraft:sugar_cane", state -> state.with(state.getBlockType().getProperty("age"), 0)); - public static final BlockType SUNFLOWER = register("minecraft:sunflower", state -> state.with(state.getBlockType().getProperty("half"), "lower")); - public static final BlockType TALL_GRASS = register("minecraft:tall_grass", state -> state.with(state.getBlockType().getProperty("half"), "lower")); - public static final BlockType TALL_SEAGRASS = register("minecraft:tall_seagrass", state -> state.with(state.getBlockType().getProperty("half"), "lower")); - public static final BlockType TERRACOTTA = register("minecraft:terracotta"); - public static final BlockType TNT = register("minecraft:tnt", state -> state.with(state.getBlockType().getProperty("unstable"), false)); - public static final BlockType TORCH = register("minecraft:torch"); - public static final BlockType TRAPPED_CHEST = register("minecraft:trapped_chest", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("type"), "SINGLE").with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType TRIPWIRE = register("minecraft:tripwire", state -> state.with(state.getBlockType().getProperty("attached"), false).with(state.getBlockType().getProperty("disarmed"), false).with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("powered"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType TRIPWIRE_HOOK = register("minecraft:tripwire_hook", state -> state.with(state.getBlockType().getProperty("attached"), false).with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("powered"), false)); - public static final BlockType TUBE_CORAL = register("minecraft:tube_coral", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType TUBE_CORAL_BLOCK = register("minecraft:tube_coral_block"); - public static final BlockType TUBE_CORAL_FAN = register("minecraft:tube_coral_fan", state -> state.with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType TUBE_CORAL_WALL_FAN = register("minecraft:tube_coral_wall_fan", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("waterlogged"), true)); - public static final BlockType TURTLE_EGG = register("minecraft:turtle_egg", state -> state.with(state.getBlockType().getProperty("eggs"), 1).with(state.getBlockType().getProperty("hatch"), 0)); - public static final BlockType VINE = register("minecraft:vine", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("up"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType VOID_AIR = register("minecraft:void_air"); - public static final BlockType WALL_SIGN = register("minecraft:wall_sign", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("waterlogged"), false)); - public static final BlockType WALL_TORCH = register("minecraft:wall_torch", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType WATER = register("minecraft:water", state -> state.with(state.getBlockType().getProperty("level"), 0)); - public static final BlockType WET_SPONGE = register("minecraft:wet_sponge"); - public static final BlockType WHEAT = register("minecraft:wheat", state -> state.with(state.getBlockType().getProperty("age"), 0)); - public static final BlockType WHITE_BANNER = register("minecraft:white_banner", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType WHITE_BED = register("minecraft:white_bed", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("occupied"), false).with(state.getBlockType().getProperty("part"), "foot")); - public static final BlockType WHITE_CARPET = register("minecraft:white_carpet"); - public static final BlockType WHITE_CONCRETE = register("minecraft:white_concrete"); - public static final BlockType WHITE_CONCRETE_POWDER = register("minecraft:white_concrete_powder"); - public static final BlockType WHITE_GLAZED_TERRACOTTA = register("minecraft:white_glazed_terracotta", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType WHITE_SHULKER_BOX = register("minecraft:white_shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType WHITE_STAINED_GLASS = register("minecraft:white_stained_glass"); - public static final BlockType WHITE_STAINED_GLASS_PANE = register("minecraft:white_stained_glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType WHITE_TERRACOTTA = register("minecraft:white_terracotta"); - public static final BlockType WHITE_TULIP = register("minecraft:white_tulip"); - public static final BlockType WHITE_WALL_BANNER = register("minecraft:white_wall_banner", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType WHITE_WOOL = register("minecraft:white_wool"); - public static final BlockType WITHER_SKELETON_SKULL = register("minecraft:wither_skeleton_skull", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType WITHER_SKELETON_WALL_SKULL = register("minecraft:wither_skeleton_wall_skull", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType YELLOW_BANNER = register("minecraft:yellow_banner", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType YELLOW_BED = register("minecraft:yellow_bed", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH).with(state.getBlockType().getProperty("occupied"), false).with(state.getBlockType().getProperty("part"), "foot")); - public static final BlockType YELLOW_CARPET = register("minecraft:yellow_carpet"); - public static final BlockType YELLOW_CONCRETE = register("minecraft:yellow_concrete"); - public static final BlockType YELLOW_CONCRETE_POWDER = register("minecraft:yellow_concrete_powder"); - public static final BlockType YELLOW_GLAZED_TERRACOTTA = register("minecraft:yellow_glazed_terracotta", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType YELLOW_SHULKER_BOX = register("minecraft:yellow_shulker_box", state -> state.with(state.getBlockType().getProperty("facing"), Direction.UP)); - public static final BlockType YELLOW_STAINED_GLASS = register("minecraft:yellow_stained_glass"); - public static final BlockType YELLOW_STAINED_GLASS_PANE = register("minecraft:yellow_stained_glass_pane", state -> state.with(state.getBlockType().getProperty("east"), false).with(state.getBlockType().getProperty("north"), false).with(state.getBlockType().getProperty("south"), false).with(state.getBlockType().getProperty("waterlogged"), false).with(state.getBlockType().getProperty("west"), false)); - public static final BlockType YELLOW_TERRACOTTA = register("minecraft:yellow_terracotta"); - public static final BlockType YELLOW_WALL_BANNER = register("minecraft:yellow_wall_banner", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); - public static final BlockType YELLOW_WOOL = register("minecraft:yellow_wool"); - public static final BlockType ZOMBIE_HEAD = register("minecraft:zombie_head", state -> state.with(state.getBlockType().getProperty("rotation"), 0)); - public static final BlockType ZOMBIE_WALL_HEAD = register("minecraft:zombie_wall_head", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH)); +public final class BlockTypes { + + @Nullable public static final BlockType ACACIA_BUTTON = get("minecraft:acacia_button"); + @Nullable public static final BlockType ACACIA_DOOR = get("minecraft:acacia_door"); + @Nullable public static final BlockType ACACIA_FENCE = get("minecraft:acacia_fence"); + @Nullable public static final BlockType ACACIA_FENCE_GATE = get("minecraft:acacia_fence_gate"); + @Nullable public static final BlockType ACACIA_LEAVES = get("minecraft:acacia_leaves"); + @Nullable public static final BlockType ACACIA_LOG = get("minecraft:acacia_log"); + @Nullable public static final BlockType ACACIA_PLANKS = get("minecraft:acacia_planks"); + @Nullable public static final BlockType ACACIA_PRESSURE_PLATE = get("minecraft:acacia_pressure_plate"); + @Nullable public static final BlockType ACACIA_SAPLING = get("minecraft:acacia_sapling"); + @Nullable public static final BlockType ACACIA_SLAB = get("minecraft:acacia_slab"); + @Nullable public static final BlockType ACACIA_STAIRS = get("minecraft:acacia_stairs"); + @Nullable public static final BlockType ACACIA_TRAPDOOR = get("minecraft:acacia_trapdoor"); + @Nullable public static final BlockType ACACIA_WOOD = get("minecraft:acacia_wood"); + @Nullable public static final BlockType ACTIVATOR_RAIL = get("minecraft:activator_rail"); + @Nullable public static final BlockType AIR = get("minecraft:air"); + @Nullable public static final BlockType ALLIUM = get("minecraft:allium"); + @Nullable public static final BlockType ANDESITE = get("minecraft:andesite"); + @Nullable public static final BlockType ANVIL = get("minecraft:anvil"); + @Nullable public static final BlockType ATTACHED_MELON_STEM = get("minecraft:attached_melon_stem"); + @Nullable public static final BlockType ATTACHED_PUMPKIN_STEM = get("minecraft:attached_pumpkin_stem"); + @Nullable public static final BlockType AZURE_BLUET = get("minecraft:azure_bluet"); + @Nullable public static final BlockType BARRIER = get("minecraft:barrier"); + @Nullable public static final BlockType BEACON = get("minecraft:beacon"); + @Nullable public static final BlockType BEDROCK = get("minecraft:bedrock"); + @Nullable public static final BlockType BEETROOTS = get("minecraft:beetroots"); + @Nullable public static final BlockType BIRCH_BUTTON = get("minecraft:birch_button"); + @Nullable public static final BlockType BIRCH_DOOR = get("minecraft:birch_door"); + @Nullable public static final BlockType BIRCH_FENCE = get("minecraft:birch_fence"); + @Nullable public static final BlockType BIRCH_FENCE_GATE = get("minecraft:birch_fence_gate"); + @Nullable public static final BlockType BIRCH_LEAVES = get("minecraft:birch_leaves"); + @Nullable public static final BlockType BIRCH_LOG = get("minecraft:birch_log"); + @Nullable public static final BlockType BIRCH_PLANKS = get("minecraft:birch_planks"); + @Nullable public static final BlockType BIRCH_PRESSURE_PLATE = get("minecraft:birch_pressure_plate"); + @Nullable public static final BlockType BIRCH_SAPLING = get("minecraft:birch_sapling"); + @Nullable public static final BlockType BIRCH_SLAB = get("minecraft:birch_slab"); + @Nullable public static final BlockType BIRCH_STAIRS = get("minecraft:birch_stairs"); + @Nullable public static final BlockType BIRCH_TRAPDOOR = get("minecraft:birch_trapdoor"); + @Nullable public static final BlockType BIRCH_WOOD = get("minecraft:birch_wood"); + @Nullable public static final BlockType BLACK_BANNER = get("minecraft:black_banner"); + @Nullable public static final BlockType BLACK_BED = get("minecraft:black_bed"); + @Nullable public static final BlockType BLACK_CARPET = get("minecraft:black_carpet"); + @Nullable public static final BlockType BLACK_CONCRETE = get("minecraft:black_concrete"); + @Nullable public static final BlockType BLACK_CONCRETE_POWDER = get("minecraft:black_concrete_powder"); + @Nullable public static final BlockType BLACK_GLAZED_TERRACOTTA = get("minecraft:black_glazed_terracotta"); + @Nullable public static final BlockType BLACK_SHULKER_BOX = get("minecraft:black_shulker_box"); + @Nullable public static final BlockType BLACK_STAINED_GLASS = get("minecraft:black_stained_glass"); + @Nullable public static final BlockType BLACK_STAINED_GLASS_PANE = get("minecraft:black_stained_glass_pane"); + @Nullable public static final BlockType BLACK_TERRACOTTA = get("minecraft:black_terracotta"); + @Nullable public static final BlockType BLACK_WALL_BANNER = get("minecraft:black_wall_banner"); + @Nullable public static final BlockType BLACK_WOOL = get("minecraft:black_wool"); + @Nullable public static final BlockType BLUE_BANNER = get("minecraft:blue_banner"); + @Nullable public static final BlockType BLUE_BED = get("minecraft:blue_bed"); + @Nullable public static final BlockType BLUE_CARPET = get("minecraft:blue_carpet"); + @Nullable public static final BlockType BLUE_CONCRETE = get("minecraft:blue_concrete"); + @Nullable public static final BlockType BLUE_CONCRETE_POWDER = get("minecraft:blue_concrete_powder"); + @Nullable public static final BlockType BLUE_GLAZED_TERRACOTTA = get("minecraft:blue_glazed_terracotta"); + @Nullable public static final BlockType BLUE_ICE = get("minecraft:blue_ice"); + @Nullable public static final BlockType BLUE_ORCHID = get("minecraft:blue_orchid"); + @Nullable public static final BlockType BLUE_SHULKER_BOX = get("minecraft:blue_shulker_box"); + @Nullable public static final BlockType BLUE_STAINED_GLASS = get("minecraft:blue_stained_glass"); + @Nullable public static final BlockType BLUE_STAINED_GLASS_PANE = get("minecraft:blue_stained_glass_pane"); + @Nullable public static final BlockType BLUE_TERRACOTTA = get("minecraft:blue_terracotta"); + @Nullable public static final BlockType BLUE_WALL_BANNER = get("minecraft:blue_wall_banner"); + @Nullable public static final BlockType BLUE_WOOL = get("minecraft:blue_wool"); + @Nullable public static final BlockType BONE_BLOCK = get("minecraft:bone_block"); + @Nullable public static final BlockType BOOKSHELF = get("minecraft:bookshelf"); + @Nullable public static final BlockType BRAIN_CORAL = get("minecraft:brain_coral"); + @Nullable public static final BlockType BRAIN_CORAL_BLOCK = get("minecraft:brain_coral_block"); + @Nullable public static final BlockType BRAIN_CORAL_FAN = get("minecraft:brain_coral_fan"); + @Nullable public static final BlockType BRAIN_CORAL_WALL_FAN = get("minecraft:brain_coral_wall_fan"); + @Nullable public static final BlockType BREWING_STAND = get("minecraft:brewing_stand"); + @Nullable public static final BlockType BRICK_SLAB = get("minecraft:brick_slab"); + @Nullable public static final BlockType BRICK_STAIRS = get("minecraft:brick_stairs"); + @Nullable public static final BlockType BRICKS = get("minecraft:bricks"); + @Nullable public static final BlockType BROWN_BANNER = get("minecraft:brown_banner"); + @Nullable public static final BlockType BROWN_BED = get("minecraft:brown_bed"); + @Nullable public static final BlockType BROWN_CARPET = get("minecraft:brown_carpet"); + @Nullable public static final BlockType BROWN_CONCRETE = get("minecraft:brown_concrete"); + @Nullable public static final BlockType BROWN_CONCRETE_POWDER = get("minecraft:brown_concrete_powder"); + @Nullable public static final BlockType BROWN_GLAZED_TERRACOTTA = get("minecraft:brown_glazed_terracotta"); + @Nullable public static final BlockType BROWN_MUSHROOM = get("minecraft:brown_mushroom"); + @Nullable public static final BlockType BROWN_MUSHROOM_BLOCK = get("minecraft:brown_mushroom_block"); + @Nullable public static final BlockType BROWN_SHULKER_BOX = get("minecraft:brown_shulker_box"); + @Nullable public static final BlockType BROWN_STAINED_GLASS = get("minecraft:brown_stained_glass"); + @Nullable public static final BlockType BROWN_STAINED_GLASS_PANE = get("minecraft:brown_stained_glass_pane"); + @Nullable public static final BlockType BROWN_TERRACOTTA = get("minecraft:brown_terracotta"); + @Nullable public static final BlockType BROWN_WALL_BANNER = get("minecraft:brown_wall_banner"); + @Nullable public static final BlockType BROWN_WOOL = get("minecraft:brown_wool"); + @Nullable public static final BlockType BUBBLE_COLUMN = get("minecraft:bubble_column"); + @Nullable public static final BlockType BUBBLE_CORAL = get("minecraft:bubble_coral"); + @Nullable public static final BlockType BUBBLE_CORAL_BLOCK = get("minecraft:bubble_coral_block"); + @Nullable public static final BlockType BUBBLE_CORAL_FAN = get("minecraft:bubble_coral_fan"); + @Nullable public static final BlockType BUBBLE_CORAL_WALL_FAN = get("minecraft:bubble_coral_wall_fan"); + @Nullable public static final BlockType CACTUS = get("minecraft:cactus"); + @Nullable public static final BlockType CAKE = get("minecraft:cake"); + @Nullable public static final BlockType CARROTS = get("minecraft:carrots"); + @Nullable public static final BlockType CARVED_PUMPKIN = get("minecraft:carved_pumpkin"); + @Nullable public static final BlockType CAULDRON = get("minecraft:cauldron"); + @Nullable public static final BlockType CAVE_AIR = get("minecraft:cave_air"); + @Nullable public static final BlockType CHAIN_COMMAND_BLOCK = get("minecraft:chain_command_block"); + @Nullable public static final BlockType CHEST = get("minecraft:chest"); + @Nullable public static final BlockType CHIPPED_ANVIL = get("minecraft:chipped_anvil"); + @Nullable public static final BlockType CHISELED_QUARTZ_BLOCK = get("minecraft:chiseled_quartz_block"); + @Nullable public static final BlockType CHISELED_RED_SANDSTONE = get("minecraft:chiseled_red_sandstone"); + @Nullable public static final BlockType CHISELED_SANDSTONE = get("minecraft:chiseled_sandstone"); + @Nullable public static final BlockType CHISELED_STONE_BRICKS = get("minecraft:chiseled_stone_bricks"); + @Nullable public static final BlockType CHORUS_FLOWER = get("minecraft:chorus_flower"); + @Nullable public static final BlockType CHORUS_PLANT = get("minecraft:chorus_plant"); + @Nullable public static final BlockType CLAY = get("minecraft:clay"); + @Nullable public static final BlockType COAL_BLOCK = get("minecraft:coal_block"); + @Nullable public static final BlockType COAL_ORE = get("minecraft:coal_ore"); + @Nullable public static final BlockType COARSE_DIRT = get("minecraft:coarse_dirt"); + @Nullable public static final BlockType COBBLESTONE = get("minecraft:cobblestone"); + @Nullable public static final BlockType COBBLESTONE_SLAB = get("minecraft:cobblestone_slab"); + @Nullable public static final BlockType COBBLESTONE_STAIRS = get("minecraft:cobblestone_stairs"); + @Nullable public static final BlockType COBBLESTONE_WALL = get("minecraft:cobblestone_wall"); + @Nullable public static final BlockType COBWEB = get("minecraft:cobweb"); + @Nullable public static final BlockType COCOA = get("minecraft:cocoa"); + @Nullable public static final BlockType COMMAND_BLOCK = get("minecraft:command_block"); + @Nullable public static final BlockType COMPARATOR = get("minecraft:comparator"); + @Nullable public static final BlockType CONDUIT = get("minecraft:conduit"); + @Nullable public static final BlockType CRACKED_STONE_BRICKS = get("minecraft:cracked_stone_bricks"); + @Nullable public static final BlockType CRAFTING_TABLE = get("minecraft:crafting_table"); + @Nullable public static final BlockType CREEPER_HEAD = get("minecraft:creeper_head"); + @Nullable public static final BlockType CREEPER_WALL_HEAD = get("minecraft:creeper_wall_head"); + @Nullable public static final BlockType CUT_RED_SANDSTONE = get("minecraft:cut_red_sandstone"); + @Nullable public static final BlockType CUT_SANDSTONE = get("minecraft:cut_sandstone"); + @Nullable public static final BlockType CYAN_BANNER = get("minecraft:cyan_banner"); + @Nullable public static final BlockType CYAN_BED = get("minecraft:cyan_bed"); + @Nullable public static final BlockType CYAN_CARPET = get("minecraft:cyan_carpet"); + @Nullable public static final BlockType CYAN_CONCRETE = get("minecraft:cyan_concrete"); + @Nullable public static final BlockType CYAN_CONCRETE_POWDER = get("minecraft:cyan_concrete_powder"); + @Nullable public static final BlockType CYAN_GLAZED_TERRACOTTA = get("minecraft:cyan_glazed_terracotta"); + @Nullable public static final BlockType CYAN_SHULKER_BOX = get("minecraft:cyan_shulker_box"); + @Nullable public static final BlockType CYAN_STAINED_GLASS = get("minecraft:cyan_stained_glass"); + @Nullable public static final BlockType CYAN_STAINED_GLASS_PANE = get("minecraft:cyan_stained_glass_pane"); + @Nullable public static final BlockType CYAN_TERRACOTTA = get("minecraft:cyan_terracotta"); + @Nullable public static final BlockType CYAN_WALL_BANNER = get("minecraft:cyan_wall_banner"); + @Nullable public static final BlockType CYAN_WOOL = get("minecraft:cyan_wool"); + @Nullable public static final BlockType DAMAGED_ANVIL = get("minecraft:damaged_anvil"); + @Nullable public static final BlockType DANDELION = get("minecraft:dandelion"); + @Nullable public static final BlockType DARK_OAK_BUTTON = get("minecraft:dark_oak_button"); + @Nullable public static final BlockType DARK_OAK_DOOR = get("minecraft:dark_oak_door"); + @Nullable public static final BlockType DARK_OAK_FENCE = get("minecraft:dark_oak_fence"); + @Nullable public static final BlockType DARK_OAK_FENCE_GATE = get("minecraft:dark_oak_fence_gate"); + @Nullable public static final BlockType DARK_OAK_LEAVES = get("minecraft:dark_oak_leaves"); + @Nullable public static final BlockType DARK_OAK_LOG = get("minecraft:dark_oak_log"); + @Nullable public static final BlockType DARK_OAK_PLANKS = get("minecraft:dark_oak_planks"); + @Nullable public static final BlockType DARK_OAK_PRESSURE_PLATE = get("minecraft:dark_oak_pressure_plate"); + @Nullable public static final BlockType DARK_OAK_SAPLING = get("minecraft:dark_oak_sapling"); + @Nullable public static final BlockType DARK_OAK_SLAB = get("minecraft:dark_oak_slab"); + @Nullable public static final BlockType DARK_OAK_STAIRS = get("minecraft:dark_oak_stairs"); + @Nullable public static final BlockType DARK_OAK_TRAPDOOR = get("minecraft:dark_oak_trapdoor"); + @Nullable public static final BlockType DARK_OAK_WOOD = get("minecraft:dark_oak_wood"); + @Nullable public static final BlockType DARK_PRISMARINE = get("minecraft:dark_prismarine"); + @Nullable public static final BlockType DARK_PRISMARINE_SLAB = get("minecraft:dark_prismarine_slab"); + @Nullable public static final BlockType DARK_PRISMARINE_STAIRS = get("minecraft:dark_prismarine_stairs"); + @Nullable public static final BlockType DAYLIGHT_DETECTOR = get("minecraft:daylight_detector"); + @Nullable public static final BlockType DEAD_BRAIN_CORAL = get("minecraft:dead_brain_coral"); + @Nullable public static final BlockType DEAD_BRAIN_CORAL_BLOCK = get("minecraft:dead_brain_coral_block"); + @Nullable public static final BlockType DEAD_BRAIN_CORAL_FAN = get("minecraft:dead_brain_coral_fan"); + @Nullable public static final BlockType DEAD_BRAIN_CORAL_WALL_FAN = get("minecraft:dead_brain_coral_wall_fan"); + @Nullable public static final BlockType DEAD_BUBBLE_CORAL = get("minecraft:dead_bubble_coral"); + @Nullable public static final BlockType DEAD_BUBBLE_CORAL_BLOCK = get("minecraft:dead_bubble_coral_block"); + @Nullable public static final BlockType DEAD_BUBBLE_CORAL_FAN = get("minecraft:dead_bubble_coral_fan"); + @Nullable public static final BlockType DEAD_BUBBLE_CORAL_WALL_FAN = get("minecraft:dead_bubble_coral_wall_fan"); + @Nullable public static final BlockType DEAD_BUSH = get("minecraft:dead_bush"); + @Nullable public static final BlockType DEAD_FIRE_CORAL = get("minecraft:dead_fire_coral"); + @Nullable public static final BlockType DEAD_FIRE_CORAL_BLOCK = get("minecraft:dead_fire_coral_block"); + @Nullable public static final BlockType DEAD_FIRE_CORAL_FAN = get("minecraft:dead_fire_coral_fan"); + @Nullable public static final BlockType DEAD_FIRE_CORAL_WALL_FAN = get("minecraft:dead_fire_coral_wall_fan"); + @Nullable public static final BlockType DEAD_HORN_CORAL = get("minecraft:dead_horn_coral"); + @Nullable public static final BlockType DEAD_HORN_CORAL_BLOCK = get("minecraft:dead_horn_coral_block"); + @Nullable public static final BlockType DEAD_HORN_CORAL_FAN = get("minecraft:dead_horn_coral_fan"); + @Nullable public static final BlockType DEAD_HORN_CORAL_WALL_FAN = get("minecraft:dead_horn_coral_wall_fan"); + @Nullable public static final BlockType DEAD_TUBE_CORAL = get("minecraft:dead_tube_coral"); + @Nullable public static final BlockType DEAD_TUBE_CORAL_BLOCK = get("minecraft:dead_tube_coral_block"); + @Nullable public static final BlockType DEAD_TUBE_CORAL_FAN = get("minecraft:dead_tube_coral_fan"); + @Nullable public static final BlockType DEAD_TUBE_CORAL_WALL_FAN = get("minecraft:dead_tube_coral_wall_fan"); + @Nullable public static final BlockType DETECTOR_RAIL = get("minecraft:detector_rail"); + @Nullable public static final BlockType DIAMOND_BLOCK = get("minecraft:diamond_block"); + @Nullable public static final BlockType DIAMOND_ORE = get("minecraft:diamond_ore"); + @Nullable public static final BlockType DIORITE = get("minecraft:diorite"); + @Nullable public static final BlockType DIRT = get("minecraft:dirt"); + @Nullable public static final BlockType DISPENSER = get("minecraft:dispenser"); + @Nullable public static final BlockType DRAGON_EGG = get("minecraft:dragon_egg"); + @Nullable public static final BlockType DRAGON_HEAD = get("minecraft:dragon_head"); + @Nullable public static final BlockType DRAGON_WALL_HEAD = get("minecraft:dragon_wall_head"); + @Nullable public static final BlockType DRIED_KELP_BLOCK = get("minecraft:dried_kelp_block"); + @Nullable public static final BlockType DROPPER = get("minecraft:dropper"); + @Nullable public static final BlockType EMERALD_BLOCK = get("minecraft:emerald_block"); + @Nullable public static final BlockType EMERALD_ORE = get("minecraft:emerald_ore"); + @Nullable public static final BlockType ENCHANTING_TABLE = get("minecraft:enchanting_table"); + @Nullable public static final BlockType END_GATEWAY = get("minecraft:end_gateway"); + @Nullable public static final BlockType END_PORTAL = get("minecraft:end_portal"); + @Nullable public static final BlockType END_PORTAL_FRAME = get("minecraft:end_portal_frame"); + @Nullable public static final BlockType END_ROD = get("minecraft:end_rod"); + @Nullable public static final BlockType END_STONE = get("minecraft:end_stone"); + @Nullable public static final BlockType END_STONE_BRICKS = get("minecraft:end_stone_bricks"); + @Nullable public static final BlockType ENDER_CHEST = get("minecraft:ender_chest"); + @Nullable public static final BlockType FARMLAND = get("minecraft:farmland"); + @Nullable public static final BlockType FERN = get("minecraft:fern"); + @Nullable public static final BlockType FIRE = get("minecraft:fire"); + @Nullable public static final BlockType FIRE_CORAL = get("minecraft:fire_coral"); + @Nullable public static final BlockType FIRE_CORAL_BLOCK = get("minecraft:fire_coral_block"); + @Nullable public static final BlockType FIRE_CORAL_FAN = get("minecraft:fire_coral_fan"); + @Nullable public static final BlockType FIRE_CORAL_WALL_FAN = get("minecraft:fire_coral_wall_fan"); + @Nullable public static final BlockType FLOWER_POT = get("minecraft:flower_pot"); + @Nullable public static final BlockType FROSTED_ICE = get("minecraft:frosted_ice"); + @Nullable public static final BlockType FURNACE = get("minecraft:furnace"); + @Nullable public static final BlockType GLASS = get("minecraft:glass"); + @Nullable public static final BlockType GLASS_PANE = get("minecraft:glass_pane"); + @Nullable public static final BlockType GLOWSTONE = get("minecraft:glowstone"); + @Nullable public static final BlockType GOLD_BLOCK = get("minecraft:gold_block"); + @Nullable public static final BlockType GOLD_ORE = get("minecraft:gold_ore"); + @Nullable public static final BlockType GRANITE = get("minecraft:granite"); + @Nullable public static final BlockType GRASS = get("minecraft:grass"); + @Nullable public static final BlockType GRASS_BLOCK = get("minecraft:grass_block"); + @Nullable public static final BlockType GRASS_PATH = get("minecraft:grass_path"); + @Nullable public static final BlockType GRAVEL = get("minecraft:gravel"); + @Nullable public static final BlockType GRAY_BANNER = get("minecraft:gray_banner"); + @Nullable public static final BlockType GRAY_BED = get("minecraft:gray_bed"); + @Nullable public static final BlockType GRAY_CARPET = get("minecraft:gray_carpet"); + @Nullable public static final BlockType GRAY_CONCRETE = get("minecraft:gray_concrete"); + @Nullable public static final BlockType GRAY_CONCRETE_POWDER = get("minecraft:gray_concrete_powder"); + @Nullable public static final BlockType GRAY_GLAZED_TERRACOTTA = get("minecraft:gray_glazed_terracotta"); + @Nullable public static final BlockType GRAY_SHULKER_BOX = get("minecraft:gray_shulker_box"); + @Nullable public static final BlockType GRAY_STAINED_GLASS = get("minecraft:gray_stained_glass"); + @Nullable public static final BlockType GRAY_STAINED_GLASS_PANE = get("minecraft:gray_stained_glass_pane"); + @Nullable public static final BlockType GRAY_TERRACOTTA = get("minecraft:gray_terracotta"); + @Nullable public static final BlockType GRAY_WALL_BANNER = get("minecraft:gray_wall_banner"); + @Nullable public static final BlockType GRAY_WOOL = get("minecraft:gray_wool"); + @Nullable public static final BlockType GREEN_BANNER = get("minecraft:green_banner"); + @Nullable public static final BlockType GREEN_BED = get("minecraft:green_bed"); + @Nullable public static final BlockType GREEN_CARPET = get("minecraft:green_carpet"); + @Nullable public static final BlockType GREEN_CONCRETE = get("minecraft:green_concrete"); + @Nullable public static final BlockType GREEN_CONCRETE_POWDER = get("minecraft:green_concrete_powder"); + @Nullable public static final BlockType GREEN_GLAZED_TERRACOTTA = get("minecraft:green_glazed_terracotta"); + @Nullable public static final BlockType GREEN_SHULKER_BOX = get("minecraft:green_shulker_box"); + @Nullable public static final BlockType GREEN_STAINED_GLASS = get("minecraft:green_stained_glass"); + @Nullable public static final BlockType GREEN_STAINED_GLASS_PANE = get("minecraft:green_stained_glass_pane"); + @Nullable public static final BlockType GREEN_TERRACOTTA = get("minecraft:green_terracotta"); + @Nullable public static final BlockType GREEN_WALL_BANNER = get("minecraft:green_wall_banner"); + @Nullable public static final BlockType GREEN_WOOL = get("minecraft:green_wool"); + @Nullable public static final BlockType HAY_BLOCK = get("minecraft:hay_block"); + @Nullable public static final BlockType HEAVY_WEIGHTED_PRESSURE_PLATE = get("minecraft:heavy_weighted_pressure_plate"); + @Nullable public static final BlockType HOPPER = get("minecraft:hopper"); + @Nullable public static final BlockType HORN_CORAL = get("minecraft:horn_coral"); + @Nullable public static final BlockType HORN_CORAL_BLOCK = get("minecraft:horn_coral_block"); + @Nullable public static final BlockType HORN_CORAL_FAN = get("minecraft:horn_coral_fan"); + @Nullable public static final BlockType HORN_CORAL_WALL_FAN = get("minecraft:horn_coral_wall_fan"); + @Nullable public static final BlockType ICE = get("minecraft:ice"); + @Nullable public static final BlockType INFESTED_CHISELED_STONE_BRICKS = get("minecraft:infested_chiseled_stone_bricks"); + @Nullable public static final BlockType INFESTED_COBBLESTONE = get("minecraft:infested_cobblestone"); + @Nullable public static final BlockType INFESTED_CRACKED_STONE_BRICKS = get("minecraft:infested_cracked_stone_bricks"); + @Nullable public static final BlockType INFESTED_MOSSY_STONE_BRICKS = get("minecraft:infested_mossy_stone_bricks"); + @Nullable public static final BlockType INFESTED_STONE = get("minecraft:infested_stone"); + @Nullable public static final BlockType INFESTED_STONE_BRICKS = get("minecraft:infested_stone_bricks"); + @Nullable public static final BlockType IRON_BARS = get("minecraft:iron_bars"); + @Nullable public static final BlockType IRON_BLOCK = get("minecraft:iron_block"); + @Nullable public static final BlockType IRON_DOOR = get("minecraft:iron_door"); + @Nullable public static final BlockType IRON_ORE = get("minecraft:iron_ore"); + @Nullable public static final BlockType IRON_TRAPDOOR = get("minecraft:iron_trapdoor"); + @Nullable public static final BlockType JACK_O_LANTERN = get("minecraft:jack_o_lantern"); + @Nullable public static final BlockType JUKEBOX = get("minecraft:jukebox"); + @Nullable public static final BlockType JUNGLE_BUTTON = get("minecraft:jungle_button"); + @Nullable public static final BlockType JUNGLE_DOOR = get("minecraft:jungle_door"); + @Nullable public static final BlockType JUNGLE_FENCE = get("minecraft:jungle_fence"); + @Nullable public static final BlockType JUNGLE_FENCE_GATE = get("minecraft:jungle_fence_gate"); + @Nullable public static final BlockType JUNGLE_LEAVES = get("minecraft:jungle_leaves"); + @Nullable public static final BlockType JUNGLE_LOG = get("minecraft:jungle_log"); + @Nullable public static final BlockType JUNGLE_PLANKS = get("minecraft:jungle_planks"); + @Nullable public static final BlockType JUNGLE_PRESSURE_PLATE = get("minecraft:jungle_pressure_plate"); + @Nullable public static final BlockType JUNGLE_SAPLING = get("minecraft:jungle_sapling"); + @Nullable public static final BlockType JUNGLE_SLAB = get("minecraft:jungle_slab"); + @Nullable public static final BlockType JUNGLE_STAIRS = get("minecraft:jungle_stairs"); + @Nullable public static final BlockType JUNGLE_TRAPDOOR = get("minecraft:jungle_trapdoor"); + @Nullable public static final BlockType JUNGLE_WOOD = get("minecraft:jungle_wood"); + @Nullable public static final BlockType KELP = get("minecraft:kelp"); + @Nullable public static final BlockType KELP_PLANT = get("minecraft:kelp_plant"); + @Nullable public static final BlockType LADDER = get("minecraft:ladder"); + @Nullable public static final BlockType LAPIS_BLOCK = get("minecraft:lapis_block"); + @Nullable public static final BlockType LAPIS_ORE = get("minecraft:lapis_ore"); + @Nullable public static final BlockType LARGE_FERN = get("minecraft:large_fern"); + @Nullable public static final BlockType LAVA = get("minecraft:lava"); + @Nullable public static final BlockType LEVER = get("minecraft:lever"); + @Nullable public static final BlockType LIGHT_BLUE_BANNER = get("minecraft:light_blue_banner"); + @Nullable public static final BlockType LIGHT_BLUE_BED = get("minecraft:light_blue_bed"); + @Nullable public static final BlockType LIGHT_BLUE_CARPET = get("minecraft:light_blue_carpet"); + @Nullable public static final BlockType LIGHT_BLUE_CONCRETE = get("minecraft:light_blue_concrete"); + @Nullable public static final BlockType LIGHT_BLUE_CONCRETE_POWDER = get("minecraft:light_blue_concrete_powder"); + @Nullable public static final BlockType LIGHT_BLUE_GLAZED_TERRACOTTA = get("minecraft:light_blue_glazed_terracotta"); + @Nullable public static final BlockType LIGHT_BLUE_SHULKER_BOX = get("minecraft:light_blue_shulker_box"); + @Nullable public static final BlockType LIGHT_BLUE_STAINED_GLASS = get("minecraft:light_blue_stained_glass"); + @Nullable public static final BlockType LIGHT_BLUE_STAINED_GLASS_PANE = get("minecraft:light_blue_stained_glass_pane"); + @Nullable public static final BlockType LIGHT_BLUE_TERRACOTTA = get("minecraft:light_blue_terracotta"); + @Nullable public static final BlockType LIGHT_BLUE_WALL_BANNER = get("minecraft:light_blue_wall_banner"); + @Nullable public static final BlockType LIGHT_BLUE_WOOL = get("minecraft:light_blue_wool"); + @Nullable public static final BlockType LIGHT_GRAY_BANNER = get("minecraft:light_gray_banner"); + @Nullable public static final BlockType LIGHT_GRAY_BED = get("minecraft:light_gray_bed"); + @Nullable public static final BlockType LIGHT_GRAY_CARPET = get("minecraft:light_gray_carpet"); + @Nullable public static final BlockType LIGHT_GRAY_CONCRETE = get("minecraft:light_gray_concrete"); + @Nullable public static final BlockType LIGHT_GRAY_CONCRETE_POWDER = get("minecraft:light_gray_concrete_powder"); + @Nullable public static final BlockType LIGHT_GRAY_GLAZED_TERRACOTTA = get("minecraft:light_gray_glazed_terracotta"); + @Nullable public static final BlockType LIGHT_GRAY_SHULKER_BOX = get("minecraft:light_gray_shulker_box"); + @Nullable public static final BlockType LIGHT_GRAY_STAINED_GLASS = get("minecraft:light_gray_stained_glass"); + @Nullable public static final BlockType LIGHT_GRAY_STAINED_GLASS_PANE = get("minecraft:light_gray_stained_glass_pane"); + @Nullable public static final BlockType LIGHT_GRAY_TERRACOTTA = get("minecraft:light_gray_terracotta"); + @Nullable public static final BlockType LIGHT_GRAY_WALL_BANNER = get("minecraft:light_gray_wall_banner"); + @Nullable public static final BlockType LIGHT_GRAY_WOOL = get("minecraft:light_gray_wool"); + @Nullable public static final BlockType LIGHT_WEIGHTED_PRESSURE_PLATE = get("minecraft:light_weighted_pressure_plate"); + @Nullable public static final BlockType LILAC = get("minecraft:lilac"); + @Nullable public static final BlockType LILY_PAD = get("minecraft:lily_pad"); + @Nullable public static final BlockType LIME_BANNER = get("minecraft:lime_banner"); + @Nullable public static final BlockType LIME_BED = get("minecraft:lime_bed"); + @Nullable public static final BlockType LIME_CARPET = get("minecraft:lime_carpet"); + @Nullable public static final BlockType LIME_CONCRETE = get("minecraft:lime_concrete"); + @Nullable public static final BlockType LIME_CONCRETE_POWDER = get("minecraft:lime_concrete_powder"); + @Nullable public static final BlockType LIME_GLAZED_TERRACOTTA = get("minecraft:lime_glazed_terracotta"); + @Nullable public static final BlockType LIME_SHULKER_BOX = get("minecraft:lime_shulker_box"); + @Nullable public static final BlockType LIME_STAINED_GLASS = get("minecraft:lime_stained_glass"); + @Nullable public static final BlockType LIME_STAINED_GLASS_PANE = get("minecraft:lime_stained_glass_pane"); + @Nullable public static final BlockType LIME_TERRACOTTA = get("minecraft:lime_terracotta"); + @Nullable public static final BlockType LIME_WALL_BANNER = get("minecraft:lime_wall_banner"); + @Nullable public static final BlockType LIME_WOOL = get("minecraft:lime_wool"); + @Nullable public static final BlockType MAGENTA_BANNER = get("minecraft:magenta_banner"); + @Nullable public static final BlockType MAGENTA_BED = get("minecraft:magenta_bed"); + @Nullable public static final BlockType MAGENTA_CARPET = get("minecraft:magenta_carpet"); + @Nullable public static final BlockType MAGENTA_CONCRETE = get("minecraft:magenta_concrete"); + @Nullable public static final BlockType MAGENTA_CONCRETE_POWDER = get("minecraft:magenta_concrete_powder"); + @Nullable public static final BlockType MAGENTA_GLAZED_TERRACOTTA = get("minecraft:magenta_glazed_terracotta"); + @Nullable public static final BlockType MAGENTA_SHULKER_BOX = get("minecraft:magenta_shulker_box"); + @Nullable public static final BlockType MAGENTA_STAINED_GLASS = get("minecraft:magenta_stained_glass"); + @Nullable public static final BlockType MAGENTA_STAINED_GLASS_PANE = get("minecraft:magenta_stained_glass_pane"); + @Nullable public static final BlockType MAGENTA_TERRACOTTA = get("minecraft:magenta_terracotta"); + @Nullable public static final BlockType MAGENTA_WALL_BANNER = get("minecraft:magenta_wall_banner"); + @Nullable public static final BlockType MAGENTA_WOOL = get("minecraft:magenta_wool"); + @Nullable public static final BlockType MAGMA_BLOCK = get("minecraft:magma_block"); + @Nullable public static final BlockType MELON = get("minecraft:melon"); + @Nullable public static final BlockType MELON_STEM = get("minecraft:melon_stem"); + @Nullable public static final BlockType MOSSY_COBBLESTONE = get("minecraft:mossy_cobblestone"); + @Nullable public static final BlockType MOSSY_COBBLESTONE_WALL = get("minecraft:mossy_cobblestone_wall"); + @Nullable public static final BlockType MOSSY_STONE_BRICKS = get("minecraft:mossy_stone_bricks"); + @Nullable public static final BlockType MOVING_PISTON = get("minecraft:moving_piston"); + @Nullable public static final BlockType MUSHROOM_STEM = get("minecraft:mushroom_stem"); + @Nullable public static final BlockType MYCELIUM = get("minecraft:mycelium"); + @Nullable public static final BlockType NETHER_BRICK_FENCE = get("minecraft:nether_brick_fence"); + @Nullable public static final BlockType NETHER_BRICK_SLAB = get("minecraft:nether_brick_slab"); + @Nullable public static final BlockType NETHER_BRICK_STAIRS = get("minecraft:nether_brick_stairs"); + @Nullable public static final BlockType NETHER_BRICKS = get("minecraft:nether_bricks"); + @Nullable public static final BlockType NETHER_PORTAL = get("minecraft:nether_portal"); + @Nullable public static final BlockType NETHER_QUARTZ_ORE = get("minecraft:nether_quartz_ore"); + @Nullable public static final BlockType NETHER_WART = get("minecraft:nether_wart"); + @Nullable public static final BlockType NETHER_WART_BLOCK = get("minecraft:nether_wart_block"); + @Nullable public static final BlockType NETHERRACK = get("minecraft:netherrack"); + @Nullable public static final BlockType NOTE_BLOCK = get("minecraft:note_block"); + @Nullable public static final BlockType OAK_BUTTON = get("minecraft:oak_button"); + @Nullable public static final BlockType OAK_DOOR = get("minecraft:oak_door"); + @Nullable public static final BlockType OAK_FENCE = get("minecraft:oak_fence"); + @Nullable public static final BlockType OAK_FENCE_GATE = get("minecraft:oak_fence_gate"); + @Nullable public static final BlockType OAK_LEAVES = get("minecraft:oak_leaves"); + @Nullable public static final BlockType OAK_LOG = get("minecraft:oak_log"); + @Nullable public static final BlockType OAK_PLANKS = get("minecraft:oak_planks"); + @Nullable public static final BlockType OAK_PRESSURE_PLATE = get("minecraft:oak_pressure_plate"); + @Nullable public static final BlockType OAK_SAPLING = get("minecraft:oak_sapling"); + @Nullable public static final BlockType OAK_SLAB = get("minecraft:oak_slab"); + @Nullable public static final BlockType OAK_STAIRS = get("minecraft:oak_stairs"); + @Nullable public static final BlockType OAK_TRAPDOOR = get("minecraft:oak_trapdoor"); + @Nullable public static final BlockType OAK_WOOD = get("minecraft:oak_wood"); + @Nullable public static final BlockType OBSERVER = get("minecraft:observer"); + @Nullable public static final BlockType OBSIDIAN = get("minecraft:obsidian"); + @Nullable public static final BlockType ORANGE_BANNER = get("minecraft:orange_banner"); + @Nullable public static final BlockType ORANGE_BED = get("minecraft:orange_bed"); + @Nullable public static final BlockType ORANGE_CARPET = get("minecraft:orange_carpet"); + @Nullable public static final BlockType ORANGE_CONCRETE = get("minecraft:orange_concrete"); + @Nullable public static final BlockType ORANGE_CONCRETE_POWDER = get("minecraft:orange_concrete_powder"); + @Nullable public static final BlockType ORANGE_GLAZED_TERRACOTTA = get("minecraft:orange_glazed_terracotta"); + @Nullable public static final BlockType ORANGE_SHULKER_BOX = get("minecraft:orange_shulker_box"); + @Nullable public static final BlockType ORANGE_STAINED_GLASS = get("minecraft:orange_stained_glass"); + @Nullable public static final BlockType ORANGE_STAINED_GLASS_PANE = get("minecraft:orange_stained_glass_pane"); + @Nullable public static final BlockType ORANGE_TERRACOTTA = get("minecraft:orange_terracotta"); + @Nullable public static final BlockType ORANGE_TULIP = get("minecraft:orange_tulip"); + @Nullable public static final BlockType ORANGE_WALL_BANNER = get("minecraft:orange_wall_banner"); + @Nullable public static final BlockType ORANGE_WOOL = get("minecraft:orange_wool"); + @Nullable public static final BlockType OXEYE_DAISY = get("minecraft:oxeye_daisy"); + @Nullable public static final BlockType PACKED_ICE = get("minecraft:packed_ice"); + @Nullable public static final BlockType PEONY = get("minecraft:peony"); + @Nullable public static final BlockType PETRIFIED_OAK_SLAB = get("minecraft:petrified_oak_slab"); + @Nullable public static final BlockType PINK_BANNER = get("minecraft:pink_banner"); + @Nullable public static final BlockType PINK_BED = get("minecraft:pink_bed"); + @Nullable public static final BlockType PINK_CARPET = get("minecraft:pink_carpet"); + @Nullable public static final BlockType PINK_CONCRETE = get("minecraft:pink_concrete"); + @Nullable public static final BlockType PINK_CONCRETE_POWDER = get("minecraft:pink_concrete_powder"); + @Nullable public static final BlockType PINK_GLAZED_TERRACOTTA = get("minecraft:pink_glazed_terracotta"); + @Nullable public static final BlockType PINK_SHULKER_BOX = get("minecraft:pink_shulker_box"); + @Nullable public static final BlockType PINK_STAINED_GLASS = get("minecraft:pink_stained_glass"); + @Nullable public static final BlockType PINK_STAINED_GLASS_PANE = get("minecraft:pink_stained_glass_pane"); + @Nullable public static final BlockType PINK_TERRACOTTA = get("minecraft:pink_terracotta"); + @Nullable public static final BlockType PINK_TULIP = get("minecraft:pink_tulip"); + @Nullable public static final BlockType PINK_WALL_BANNER = get("minecraft:pink_wall_banner"); + @Nullable public static final BlockType PINK_WOOL = get("minecraft:pink_wool"); + @Nullable public static final BlockType PISTON = get("minecraft:piston"); + @Nullable public static final BlockType PISTON_HEAD = get("minecraft:piston_head"); + @Nullable public static final BlockType PLAYER_HEAD = get("minecraft:player_head"); + @Nullable public static final BlockType PLAYER_WALL_HEAD = get("minecraft:player_wall_head"); + @Nullable public static final BlockType PODZOL = get("minecraft:podzol"); + @Nullable public static final BlockType POLISHED_ANDESITE = get("minecraft:polished_andesite"); + @Nullable public static final BlockType POLISHED_DIORITE = get("minecraft:polished_diorite"); + @Nullable public static final BlockType POLISHED_GRANITE = get("minecraft:polished_granite"); + @Nullable public static final BlockType POPPY = get("minecraft:poppy"); + @Nullable public static final BlockType POTATOES = get("minecraft:potatoes"); + @Nullable public static final BlockType POTTED_ACACIA_SAPLING = get("minecraft:potted_acacia_sapling"); + @Nullable public static final BlockType POTTED_ALLIUM = get("minecraft:potted_allium"); + @Nullable public static final BlockType POTTED_AZURE_BLUET = get("minecraft:potted_azure_bluet"); + @Nullable public static final BlockType POTTED_BIRCH_SAPLING = get("minecraft:potted_birch_sapling"); + @Nullable public static final BlockType POTTED_BLUE_ORCHID = get("minecraft:potted_blue_orchid"); + @Nullable public static final BlockType POTTED_BROWN_MUSHROOM = get("minecraft:potted_brown_mushroom"); + @Nullable public static final BlockType POTTED_CACTUS = get("minecraft:potted_cactus"); + @Nullable public static final BlockType POTTED_DANDELION = get("minecraft:potted_dandelion"); + @Nullable public static final BlockType POTTED_DARK_OAK_SAPLING = get("minecraft:potted_dark_oak_sapling"); + @Nullable public static final BlockType POTTED_DEAD_BUSH = get("minecraft:potted_dead_bush"); + @Nullable public static final BlockType POTTED_FERN = get("minecraft:potted_fern"); + @Nullable public static final BlockType POTTED_JUNGLE_SAPLING = get("minecraft:potted_jungle_sapling"); + @Nullable public static final BlockType POTTED_OAK_SAPLING = get("minecraft:potted_oak_sapling"); + @Nullable public static final BlockType POTTED_ORANGE_TULIP = get("minecraft:potted_orange_tulip"); + @Nullable public static final BlockType POTTED_OXEYE_DAISY = get("minecraft:potted_oxeye_daisy"); + @Nullable public static final BlockType POTTED_PINK_TULIP = get("minecraft:potted_pink_tulip"); + @Nullable public static final BlockType POTTED_POPPY = get("minecraft:potted_poppy"); + @Nullable public static final BlockType POTTED_RED_MUSHROOM = get("minecraft:potted_red_mushroom"); + @Nullable public static final BlockType POTTED_RED_TULIP = get("minecraft:potted_red_tulip"); + @Nullable public static final BlockType POTTED_SPRUCE_SAPLING = get("minecraft:potted_spruce_sapling"); + @Nullable public static final BlockType POTTED_WHITE_TULIP = get("minecraft:potted_white_tulip"); + @Nullable public static final BlockType POWERED_RAIL = get("minecraft:powered_rail"); + @Nullable public static final BlockType PRISMARINE = get("minecraft:prismarine"); + @Nullable public static final BlockType PRISMARINE_BRICK_SLAB = get("minecraft:prismarine_brick_slab"); + @Nullable public static final BlockType PRISMARINE_BRICK_STAIRS = get("minecraft:prismarine_brick_stairs"); + @Nullable public static final BlockType PRISMARINE_BRICKS = get("minecraft:prismarine_bricks"); + @Nullable public static final BlockType PRISMARINE_SLAB = get("minecraft:prismarine_slab"); + @Nullable public static final BlockType PRISMARINE_STAIRS = get("minecraft:prismarine_stairs"); + @Nullable public static final BlockType PUMPKIN = get("minecraft:pumpkin"); + @Nullable public static final BlockType PUMPKIN_STEM = get("minecraft:pumpkin_stem"); + @Nullable public static final BlockType PURPLE_BANNER = get("minecraft:purple_banner"); + @Nullable public static final BlockType PURPLE_BED = get("minecraft:purple_bed"); + @Nullable public static final BlockType PURPLE_CARPET = get("minecraft:purple_carpet"); + @Nullable public static final BlockType PURPLE_CONCRETE = get("minecraft:purple_concrete"); + @Nullable public static final BlockType PURPLE_CONCRETE_POWDER = get("minecraft:purple_concrete_powder"); + @Nullable public static final BlockType PURPLE_GLAZED_TERRACOTTA = get("minecraft:purple_glazed_terracotta"); + @Nullable public static final BlockType PURPLE_SHULKER_BOX = get("minecraft:purple_shulker_box"); + @Nullable public static final BlockType PURPLE_STAINED_GLASS = get("minecraft:purple_stained_glass"); + @Nullable public static final BlockType PURPLE_STAINED_GLASS_PANE = get("minecraft:purple_stained_glass_pane"); + @Nullable public static final BlockType PURPLE_TERRACOTTA = get("minecraft:purple_terracotta"); + @Nullable public static final BlockType PURPLE_WALL_BANNER = get("minecraft:purple_wall_banner"); + @Nullable public static final BlockType PURPLE_WOOL = get("minecraft:purple_wool"); + @Nullable public static final BlockType PURPUR_BLOCK = get("minecraft:purpur_block"); + @Nullable public static final BlockType PURPUR_PILLAR = get("minecraft:purpur_pillar"); + @Nullable public static final BlockType PURPUR_SLAB = get("minecraft:purpur_slab"); + @Nullable public static final BlockType PURPUR_STAIRS = get("minecraft:purpur_stairs"); + @Nullable public static final BlockType QUARTZ_BLOCK = get("minecraft:quartz_block"); + @Nullable public static final BlockType QUARTZ_PILLAR = get("minecraft:quartz_pillar"); + @Nullable public static final BlockType QUARTZ_SLAB = get("minecraft:quartz_slab"); + @Nullable public static final BlockType QUARTZ_STAIRS = get("minecraft:quartz_stairs"); + @Nullable public static final BlockType RAIL = get("minecraft:rail"); + @Nullable public static final BlockType RED_BANNER = get("minecraft:red_banner"); + @Nullable public static final BlockType RED_BED = get("minecraft:red_bed"); + @Nullable public static final BlockType RED_CARPET = get("minecraft:red_carpet"); + @Nullable public static final BlockType RED_CONCRETE = get("minecraft:red_concrete"); + @Nullable public static final BlockType RED_CONCRETE_POWDER = get("minecraft:red_concrete_powder"); + @Nullable public static final BlockType RED_GLAZED_TERRACOTTA = get("minecraft:red_glazed_terracotta"); + @Nullable public static final BlockType RED_MUSHROOM = get("minecraft:red_mushroom"); + @Nullable public static final BlockType RED_MUSHROOM_BLOCK = get("minecraft:red_mushroom_block"); + @Nullable public static final BlockType RED_NETHER_BRICKS = get("minecraft:red_nether_bricks"); + @Nullable public static final BlockType RED_SAND = get("minecraft:red_sand"); + @Nullable public static final BlockType RED_SANDSTONE = get("minecraft:red_sandstone"); + @Nullable public static final BlockType RED_SANDSTONE_SLAB = get("minecraft:red_sandstone_slab"); + @Nullable public static final BlockType RED_SANDSTONE_STAIRS = get("minecraft:red_sandstone_stairs"); + @Nullable public static final BlockType RED_SHULKER_BOX = get("minecraft:red_shulker_box"); + @Nullable public static final BlockType RED_STAINED_GLASS = get("minecraft:red_stained_glass"); + @Nullable public static final BlockType RED_STAINED_GLASS_PANE = get("minecraft:red_stained_glass_pane"); + @Nullable public static final BlockType RED_TERRACOTTA = get("minecraft:red_terracotta"); + @Nullable public static final BlockType RED_TULIP = get("minecraft:red_tulip"); + @Nullable public static final BlockType RED_WALL_BANNER = get("minecraft:red_wall_banner"); + @Nullable public static final BlockType RED_WOOL = get("minecraft:red_wool"); + @Nullable public static final BlockType REDSTONE_BLOCK = get("minecraft:redstone_block"); + @Nullable public static final BlockType REDSTONE_LAMP = get("minecraft:redstone_lamp"); + @Nullable public static final BlockType REDSTONE_ORE = get("minecraft:redstone_ore"); + @Nullable public static final BlockType REDSTONE_TORCH = get("minecraft:redstone_torch"); + @Nullable public static final BlockType REDSTONE_WALL_TORCH = get("minecraft:redstone_wall_torch"); + @Nullable public static final BlockType REDSTONE_WIRE = get("minecraft:redstone_wire"); + @Nullable public static final BlockType REPEATER = get("minecraft:repeater"); + @Nullable public static final BlockType REPEATING_COMMAND_BLOCK = get("minecraft:repeating_command_block"); + @Nullable public static final BlockType ROSE_BUSH = get("minecraft:rose_bush"); + @Nullable public static final BlockType SAND = get("minecraft:sand"); + @Nullable public static final BlockType SANDSTONE = get("minecraft:sandstone"); + @Nullable public static final BlockType SANDSTONE_SLAB = get("minecraft:sandstone_slab"); + @Nullable public static final BlockType SANDSTONE_STAIRS = get("minecraft:sandstone_stairs"); + @Nullable public static final BlockType SEA_LANTERN = get("minecraft:sea_lantern"); + @Nullable public static final BlockType SEA_PICKLE = get("minecraft:sea_pickle"); + @Nullable public static final BlockType SEAGRASS = get("minecraft:seagrass"); + @Nullable public static final BlockType SHULKER_BOX = get("minecraft:shulker_box"); + @Nullable public static final BlockType SIGN = get("minecraft:sign"); + @Nullable public static final BlockType SKELETON_SKULL = get("minecraft:skeleton_skull"); + @Nullable public static final BlockType SKELETON_WALL_SKULL = get("minecraft:skeleton_wall_skull"); + @Nullable public static final BlockType SLIME_BLOCK = get("minecraft:slime_block"); + @Nullable public static final BlockType SMOOTH_QUARTZ = get("minecraft:smooth_quartz"); + @Nullable public static final BlockType SMOOTH_RED_SANDSTONE = get("minecraft:smooth_red_sandstone"); + @Nullable public static final BlockType SMOOTH_SANDSTONE = get("minecraft:smooth_sandstone"); + @Nullable public static final BlockType SMOOTH_STONE = get("minecraft:smooth_stone"); + @Nullable public static final BlockType SNOW = get("minecraft:snow"); + @Nullable public static final BlockType SNOW_BLOCK = get("minecraft:snow_block"); + @Nullable public static final BlockType SOUL_SAND = get("minecraft:soul_sand"); + @Nullable public static final BlockType SPAWNER = get("minecraft:spawner"); + @Nullable public static final BlockType SPONGE = get("minecraft:sponge"); + @Nullable public static final BlockType SPRUCE_BUTTON = get("minecraft:spruce_button"); + @Nullable public static final BlockType SPRUCE_DOOR = get("minecraft:spruce_door"); + @Nullable public static final BlockType SPRUCE_FENCE = get("minecraft:spruce_fence"); + @Nullable public static final BlockType SPRUCE_FENCE_GATE = get("minecraft:spruce_fence_gate"); + @Nullable public static final BlockType SPRUCE_LEAVES = get("minecraft:spruce_leaves"); + @Nullable public static final BlockType SPRUCE_LOG = get("minecraft:spruce_log"); + @Nullable public static final BlockType SPRUCE_PLANKS = get("minecraft:spruce_planks"); + @Nullable public static final BlockType SPRUCE_PRESSURE_PLATE = get("minecraft:spruce_pressure_plate"); + @Nullable public static final BlockType SPRUCE_SAPLING = get("minecraft:spruce_sapling"); + @Nullable public static final BlockType SPRUCE_SLAB = get("minecraft:spruce_slab"); + @Nullable public static final BlockType SPRUCE_STAIRS = get("minecraft:spruce_stairs"); + @Nullable public static final BlockType SPRUCE_TRAPDOOR = get("minecraft:spruce_trapdoor"); + @Nullable public static final BlockType SPRUCE_WOOD = get("minecraft:spruce_wood"); + @Nullable public static final BlockType STICKY_PISTON = get("minecraft:sticky_piston"); + @Nullable public static final BlockType STONE = get("minecraft:stone"); + @Nullable public static final BlockType STONE_BRICK_SLAB = get("minecraft:stone_brick_slab"); + @Nullable public static final BlockType STONE_BRICK_STAIRS = get("minecraft:stone_brick_stairs"); + @Nullable public static final BlockType STONE_BRICKS = get("minecraft:stone_bricks"); + @Nullable public static final BlockType STONE_BUTTON = get("minecraft:stone_button"); + @Nullable public static final BlockType STONE_PRESSURE_PLATE = get("minecraft:stone_pressure_plate"); + @Nullable public static final BlockType STONE_SLAB = get("minecraft:stone_slab"); + @Nullable public static final BlockType STRIPPED_ACACIA_LOG = get("minecraft:stripped_acacia_log"); + @Nullable public static final BlockType STRIPPED_ACACIA_WOOD = get("minecraft:stripped_acacia_wood"); + @Nullable public static final BlockType STRIPPED_BIRCH_LOG = get("minecraft:stripped_birch_log"); + @Nullable public static final BlockType STRIPPED_BIRCH_WOOD = get("minecraft:stripped_birch_wood"); + @Nullable public static final BlockType STRIPPED_DARK_OAK_LOG = get("minecraft:stripped_dark_oak_log"); + @Nullable public static final BlockType STRIPPED_DARK_OAK_WOOD = get("minecraft:stripped_dark_oak_wood"); + @Nullable public static final BlockType STRIPPED_JUNGLE_LOG = get("minecraft:stripped_jungle_log"); + @Nullable public static final BlockType STRIPPED_JUNGLE_WOOD = get("minecraft:stripped_jungle_wood"); + @Nullable public static final BlockType STRIPPED_OAK_LOG = get("minecraft:stripped_oak_log"); + @Nullable public static final BlockType STRIPPED_OAK_WOOD = get("minecraft:stripped_oak_wood"); + @Nullable public static final BlockType STRIPPED_SPRUCE_LOG = get("minecraft:stripped_spruce_log"); + @Nullable public static final BlockType STRIPPED_SPRUCE_WOOD = get("minecraft:stripped_spruce_wood"); + @Nullable public static final BlockType STRUCTURE_BLOCK = get("minecraft:structure_block"); + @Nullable public static final BlockType STRUCTURE_VOID = get("minecraft:structure_void"); + @Nullable public static final BlockType SUGAR_CANE = get("minecraft:sugar_cane"); + @Nullable public static final BlockType SUNFLOWER = get("minecraft:sunflower"); + @Nullable public static final BlockType TALL_GRASS = get("minecraft:tall_grass"); + @Nullable public static final BlockType TALL_SEAGRASS = get("minecraft:tall_seagrass"); + @Nullable public static final BlockType TERRACOTTA = get("minecraft:terracotta"); + @Nullable public static final BlockType TNT = get("minecraft:tnt"); + @Nullable public static final BlockType TORCH = get("minecraft:torch"); + @Nullable public static final BlockType TRAPPED_CHEST = get("minecraft:trapped_chest"); + @Nullable public static final BlockType TRIPWIRE = get("minecraft:tripwire"); + @Nullable public static final BlockType TRIPWIRE_HOOK = get("minecraft:tripwire_hook"); + @Nullable public static final BlockType TUBE_CORAL = get("minecraft:tube_coral"); + @Nullable public static final BlockType TUBE_CORAL_BLOCK = get("minecraft:tube_coral_block"); + @Nullable public static final BlockType TUBE_CORAL_FAN = get("minecraft:tube_coral_fan"); + @Nullable public static final BlockType TUBE_CORAL_WALL_FAN = get("minecraft:tube_coral_wall_fan"); + @Nullable public static final BlockType TURTLE_EGG = get("minecraft:turtle_egg"); + @Nullable public static final BlockType VINE = get("minecraft:vine"); + @Nullable public static final BlockType VOID_AIR = get("minecraft:void_air"); + @Nullable public static final BlockType WALL_SIGN = get("minecraft:wall_sign"); + @Nullable public static final BlockType WALL_TORCH = get("minecraft:wall_torch"); + @Nullable public static final BlockType WATER = get("minecraft:water"); + @Nullable public static final BlockType WET_SPONGE = get("minecraft:wet_sponge"); + @Nullable public static final BlockType WHEAT = get("minecraft:wheat"); + @Nullable public static final BlockType WHITE_BANNER = get("minecraft:white_banner"); + @Nullable public static final BlockType WHITE_BED = get("minecraft:white_bed"); + @Nullable public static final BlockType WHITE_CARPET = get("minecraft:white_carpet"); + @Nullable public static final BlockType WHITE_CONCRETE = get("minecraft:white_concrete"); + @Nullable public static final BlockType WHITE_CONCRETE_POWDER = get("minecraft:white_concrete_powder"); + @Nullable public static final BlockType WHITE_GLAZED_TERRACOTTA = get("minecraft:white_glazed_terracotta"); + @Nullable public static final BlockType WHITE_SHULKER_BOX = get("minecraft:white_shulker_box"); + @Nullable public static final BlockType WHITE_STAINED_GLASS = get("minecraft:white_stained_glass"); + @Nullable public static final BlockType WHITE_STAINED_GLASS_PANE = get("minecraft:white_stained_glass_pane"); + @Nullable public static final BlockType WHITE_TERRACOTTA = get("minecraft:white_terracotta"); + @Nullable public static final BlockType WHITE_TULIP = get("minecraft:white_tulip"); + @Nullable public static final BlockType WHITE_WALL_BANNER = get("minecraft:white_wall_banner"); + @Nullable public static final BlockType WHITE_WOOL = get("minecraft:white_wool"); + @Nullable public static final BlockType WITHER_SKELETON_SKULL = get("minecraft:wither_skeleton_skull"); + @Nullable public static final BlockType WITHER_SKELETON_WALL_SKULL = get("minecraft:wither_skeleton_wall_skull"); + @Nullable public static final BlockType YELLOW_BANNER = get("minecraft:yellow_banner"); + @Nullable public static final BlockType YELLOW_BED = get("minecraft:yellow_bed"); + @Nullable public static final BlockType YELLOW_CARPET = get("minecraft:yellow_carpet"); + @Nullable public static final BlockType YELLOW_CONCRETE = get("minecraft:yellow_concrete"); + @Nullable public static final BlockType YELLOW_CONCRETE_POWDER = get("minecraft:yellow_concrete_powder"); + @Nullable public static final BlockType YELLOW_GLAZED_TERRACOTTA = get("minecraft:yellow_glazed_terracotta"); + @Nullable public static final BlockType YELLOW_SHULKER_BOX = get("minecraft:yellow_shulker_box"); + @Nullable public static final BlockType YELLOW_STAINED_GLASS = get("minecraft:yellow_stained_glass"); + @Nullable public static final BlockType YELLOW_STAINED_GLASS_PANE = get("minecraft:yellow_stained_glass_pane"); + @Nullable public static final BlockType YELLOW_TERRACOTTA = get("minecraft:yellow_terracotta"); + @Nullable public static final BlockType YELLOW_WALL_BANNER = get("minecraft:yellow_wall_banner"); + @Nullable public static final BlockType YELLOW_WOOL = get("minecraft:yellow_wool"); + @Nullable public static final BlockType ZOMBIE_HEAD = get("minecraft:zombie_head"); + @Nullable public static final BlockType ZOMBIE_WALL_HEAD = get("minecraft:zombie_wall_head"); - private static BlockType register(String id) { + private static BlockType get(String id) { return register(new BlockType(id)); } - private static BlockType register(String id, Function values) { + private static BlockType get(String id, Function values) { return register(new BlockType(id, values)); } - public static BlockType register(BlockType type) { + public static BlockType get(BlockType type) { if(sortedRegistry == null) { sortedRegistry = new ArrayList<>(); stateList = new ArrayList<>(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/FuzzyBlockState.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/FuzzyBlockState.java index edbd65243..580bf8c1a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/FuzzyBlockState.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/FuzzyBlockState.java @@ -40,8 +40,7 @@ public class FuzzyBlockState extends BlockState { private FuzzyBlockState(BlockType blockType, Map, Object> values) { this(blockType); for (Map.Entry, Object> entry : values.entrySet()) { -// setState(entry.getKey(), entry.getValue()); - with((Property)entry.getKey(), entry.getValue()); + setState(entry.getKey(), entry.getValue()); } } @@ -58,7 +57,12 @@ public class FuzzyBlockState extends BlockState { Property objKey = (Property) entry.getKey(); state = state.with(objKey, entry.getValue()); } - return getBlockType().getDefaultState(); + return state; + } + + @Override + public BlockState toImmutableState() { + return getFullState(); } /** @@ -142,4 +146,4 @@ public class FuzzyBlockState extends BlockState { return this; } } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java index 2710fddd0..9d854a7af 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java @@ -27,7 +27,6 @@ import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.NBTUtils; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.WorldEdit; - import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.DataException; @@ -260,7 +259,7 @@ public class AnvilChunk implements Chunk { BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(id, data); if (state == null) { - WorldEdit.logger.warning("Unknown legacy block " + id + ":" + data + " found when loading legacy anvil chunk."); + WorldEdit.logger.warn("Unknown legacy block " + id + ":" + data + " found when loading legacy anvil chunk."); return BlockTypes.AIR.getDefaultState().toBaseBlock(); } if (state.getMaterial().hasContainer()) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java index c4d2eb939..8d18bd90f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java @@ -26,7 +26,6 @@ import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.LongArrayTag; import com.sk89q.jnbt.NBTUtils; import com.sk89q.jnbt.Tag; - import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.world.DataException; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java index add26e1c0..04f90411a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java @@ -153,7 +153,6 @@ public class OldChunk implements Chunk { } @Override - public BaseBlock getBlock(BlockVector3 position) throws DataException { if(position.getY() >= 128) return BlockTypes.VOID_AIR.getDefaultState().toBaseBlock(); int id, dataVal; @@ -183,7 +182,7 @@ public class OldChunk implements Chunk { BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(id, dataVal); if (state == null) { - WorldEdit.logger.warning("Unknown legacy block " + id + ":" + dataVal + " found when loading legacy anvil chunk."); + WorldEdit.logger.warn("Unknown legacy block " + id + ":" + dataVal + " found when loading legacy anvil chunk."); return BlockTypes.AIR.getDefaultState().toBaseBlock(); } if (state.getBlockType().getMaterial().hasContainer()) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java index a56cfbbfb..1d35cadf3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityTypes.java @@ -23,113 +23,105 @@ import javax.annotation.Nullable; public class EntityTypes { - public static final EntityType AREA_EFFECT_CLOUD = register("minecraft:area_effect_cloud"); - public static final EntityType ARMOR_STAND = register("minecraft:armor_stand"); - public static final EntityType ARROW = register("minecraft:arrow"); - public static final EntityType BAT = register("minecraft:bat"); - public static final EntityType BLAZE = register("minecraft:blaze"); - public static final EntityType BOAT = register("minecraft:boat"); - public static final EntityType CAVE_SPIDER = register("minecraft:cave_spider"); - public static final EntityType CHEST_MINECART = register("minecraft:chest_minecart"); - public static final EntityType CHICKEN = register("minecraft:chicken"); - public static final EntityType COD = register("minecraft:cod"); - public static final EntityType COMMAND_BLOCK_MINECART = register("minecraft:command_block_minecart"); - public static final EntityType COW = register("minecraft:cow"); - public static final EntityType CREEPER = register("minecraft:creeper"); - public static final EntityType DOLPHIN = register("minecraft:dolphin"); - public static final EntityType DONKEY = register("minecraft:donkey"); - public static final EntityType DRAGON_FIREBALL = register("minecraft:dragon_fireball"); - public static final EntityType DROWNED = register("minecraft:drowned"); - public static final EntityType EGG = register("minecraft:egg"); - public static final EntityType ELDER_GUARDIAN = register("minecraft:elder_guardian"); - public static final EntityType END_CRYSTAL = register("minecraft:end_crystal"); - public static final EntityType ENDER_DRAGON = register("minecraft:ender_dragon"); - public static final EntityType ENDER_PEARL = register("minecraft:ender_pearl"); - public static final EntityType ENDERMAN = register("minecraft:enderman"); - public static final EntityType ENDERMITE = register("minecraft:endermite"); - public static final EntityType EVOKER = register("minecraft:evoker"); - public static final EntityType EVOKER_FANGS = register("minecraft:evoker_fangs"); - public static final EntityType EXPERIENCE_BOTTLE = register("minecraft:experience_bottle"); - public static final EntityType EXPERIENCE_ORB = register("minecraft:experience_orb"); - public static final EntityType EYE_OF_ENDER = register("minecraft:eye_of_ender"); - public static final EntityType FALLING_BLOCK = register("minecraft:falling_block"); - public static final EntityType FIREBALL = register("minecraft:fireball"); - public static final EntityType FIREWORK_ROCKET = register("minecraft:firework_rocket"); - public static final EntityType FISHING_BOBBER = register("minecraft:fishing_bobber"); - public static final EntityType FURNACE_MINECART = register("minecraft:furnace_minecart"); - public static final EntityType GHAST = register("minecraft:ghast"); - public static final EntityType GIANT = register("minecraft:giant"); - public static final EntityType GUARDIAN = register("minecraft:guardian"); - public static final EntityType HOPPER_MINECART = register("minecraft:hopper_minecart"); - public static final EntityType HORSE = register("minecraft:horse"); - public static final EntityType HUSK = register("minecraft:husk"); - public static final EntityType ILLUSIONER = register("minecraft:illusioner"); - public static final EntityType IRON_GOLEM = register("minecraft:iron_golem"); - public static final EntityType ITEM = register("minecraft:item"); - public static final EntityType ITEM_FRAME = register("minecraft:item_frame"); - public static final EntityType LEASH_KNOT = register("minecraft:leash_knot"); - public static final EntityType LIGHTNING_BOLT = register("minecraft:lightning_bolt"); - public static final EntityType LLAMA = register("minecraft:llama"); - public static final EntityType LLAMA_SPIT = register("minecraft:llama_spit"); - public static final EntityType MAGMA_CUBE = register("minecraft:magma_cube"); - public static final EntityType MINECART = register("minecraft:minecart"); - public static final EntityType MOOSHROOM = register("minecraft:mooshroom"); - public static final EntityType MULE = register("minecraft:mule"); - public static final EntityType OCELOT = register("minecraft:ocelot"); - public static final EntityType PAINTING = register("minecraft:painting"); - public static final EntityType PARROT = register("minecraft:parrot"); - public static final EntityType PHANTOM = register("minecraft:phantom"); - public static final EntityType PIG = register("minecraft:pig"); - public static final EntityType PLAYER = register("minecraft:player"); - public static final EntityType POLAR_BEAR = register("minecraft:polar_bear"); - public static final EntityType POTION = register("minecraft:potion"); - public static final EntityType PUFFERFISH = register("minecraft:pufferfish"); - public static final EntityType RABBIT = register("minecraft:rabbit"); - public static final EntityType SALMON = register("minecraft:salmon"); - public static final EntityType SHEEP = register("minecraft:sheep"); - public static final EntityType SHULKER = register("minecraft:shulker"); - public static final EntityType SHULKER_BULLET = register("minecraft:shulker_bullet"); - public static final EntityType SILVERFISH = register("minecraft:silverfish"); - public static final EntityType SKELETON = register("minecraft:skeleton"); - public static final EntityType SKELETON_HORSE = register("minecraft:skeleton_horse"); - public static final EntityType SLIME = register("minecraft:slime"); - public static final EntityType SMALL_FIREBALL = register("minecraft:small_fireball"); - public static final EntityType SNOW_GOLEM = register("minecraft:snow_golem"); - public static final EntityType SNOWBALL = register("minecraft:snowball"); - public static final EntityType SPAWNER_MINECART = register("minecraft:spawner_minecart"); - public static final EntityType SPECTRAL_ARROW = register("minecraft:spectral_arrow"); - public static final EntityType SPIDER = register("minecraft:spider"); - public static final EntityType SQUID = register("minecraft:squid"); - public static final EntityType STRAY = register("minecraft:stray"); - public static final EntityType TNT = register("minecraft:tnt"); - public static final EntityType TNT_MINECART = register("minecraft:tnt_minecart"); - public static final EntityType TRIDENT = register("minecraft:trident"); - public static final EntityType TROPICAL_FISH = register("minecraft:tropical_fish"); - public static final EntityType TURTLE = register("minecraft:turtle"); - public static final EntityType VEX = register("minecraft:vex"); - public static final EntityType VILLAGER = register("minecraft:villager"); - public static final EntityType VINDICATOR = register("minecraft:vindicator"); - public static final EntityType WITCH = register("minecraft:witch"); - public static final EntityType WITHER = register("minecraft:wither"); - public static final EntityType WITHER_SKELETON = register("minecraft:wither_skeleton"); - public static final EntityType WITHER_SKULL = register("minecraft:wither_skull"); - public static final EntityType WOLF = register("minecraft:wolf"); - public static final EntityType ZOMBIE = register("minecraft:zombie"); - public static final EntityType ZOMBIE_HORSE = register("minecraft:zombie_horse"); - public static final EntityType ZOMBIE_PIGMAN = register("minecraft:zombie_pigman"); - public static final EntityType ZOMBIE_VILLAGER = register("minecraft:zombie_villager"); + @Nullable public static final EntityType AREA_EFFECT_CLOUD = get("minecraft:area_effect_cloud"); + @Nullable public static final EntityType ARMOR_STAND = get("minecraft:armor_stand"); + @Nullable public static final EntityType ARROW = get("minecraft:arrow"); + @Nullable public static final EntityType BAT = get("minecraft:bat"); + @Nullable public static final EntityType BLAZE = get("minecraft:blaze"); + @Nullable public static final EntityType BOAT = get("minecraft:boat"); + @Nullable public static final EntityType CAVE_SPIDER = get("minecraft:cave_spider"); + @Nullable public static final EntityType CHEST_MINECART = get("minecraft:chest_minecart"); + @Nullable public static final EntityType CHICKEN = get("minecraft:chicken"); + @Nullable public static final EntityType COD = get("minecraft:cod"); + @Nullable public static final EntityType COMMAND_BLOCK_MINECART = get("minecraft:command_block_minecart"); + @Nullable public static final EntityType COW = get("minecraft:cow"); + @Nullable public static final EntityType CREEPER = get("minecraft:creeper"); + @Nullable public static final EntityType DOLPHIN = get("minecraft:dolphin"); + @Nullable public static final EntityType DONKEY = get("minecraft:donkey"); + @Nullable public static final EntityType DRAGON_FIREBALL = get("minecraft:dragon_fireball"); + @Nullable public static final EntityType DROWNED = get("minecraft:drowned"); + @Nullable public static final EntityType EGG = get("minecraft:egg"); + @Nullable public static final EntityType ELDER_GUARDIAN = get("minecraft:elder_guardian"); + @Nullable public static final EntityType END_CRYSTAL = get("minecraft:end_crystal"); + @Nullable public static final EntityType ENDER_DRAGON = get("minecraft:ender_dragon"); + @Nullable public static final EntityType ENDER_PEARL = get("minecraft:ender_pearl"); + @Nullable public static final EntityType ENDERMAN = get("minecraft:enderman"); + @Nullable public static final EntityType ENDERMITE = get("minecraft:endermite"); + @Nullable public static final EntityType EVOKER = get("minecraft:evoker"); + @Nullable public static final EntityType EVOKER_FANGS = get("minecraft:evoker_fangs"); + @Nullable public static final EntityType EXPERIENCE_BOTTLE = get("minecraft:experience_bottle"); + @Nullable public static final EntityType EXPERIENCE_ORB = get("minecraft:experience_orb"); + @Nullable public static final EntityType EYE_OF_ENDER = get("minecraft:eye_of_ender"); + @Nullable public static final EntityType FALLING_BLOCK = get("minecraft:falling_block"); + @Nullable public static final EntityType FIREBALL = get("minecraft:fireball"); + @Nullable public static final EntityType FIREWORK_ROCKET = get("minecraft:firework_rocket"); + @Nullable public static final EntityType FISHING_BOBBER = get("minecraft:fishing_bobber"); + @Nullable public static final EntityType FURNACE_MINECART = get("minecraft:furnace_minecart"); + @Nullable public static final EntityType GHAST = get("minecraft:ghast"); + @Nullable public static final EntityType GIANT = get("minecraft:giant"); + @Nullable public static final EntityType GUARDIAN = get("minecraft:guardian"); + @Nullable public static final EntityType HOPPER_MINECART = get("minecraft:hopper_minecart"); + @Nullable public static final EntityType HORSE = get("minecraft:horse"); + @Nullable public static final EntityType HUSK = get("minecraft:husk"); + @Nullable public static final EntityType ILLUSIONER = get("minecraft:illusioner"); + @Nullable public static final EntityType IRON_GOLEM = get("minecraft:iron_golem"); + @Nullable public static final EntityType ITEM = get("minecraft:item"); + @Nullable public static final EntityType ITEM_FRAME = get("minecraft:item_frame"); + @Nullable public static final EntityType LEASH_KNOT = get("minecraft:leash_knot"); + @Nullable public static final EntityType LIGHTNING_BOLT = get("minecraft:lightning_bolt"); + @Nullable public static final EntityType LLAMA = get("minecraft:llama"); + @Nullable public static final EntityType LLAMA_SPIT = get("minecraft:llama_spit"); + @Nullable public static final EntityType MAGMA_CUBE = get("minecraft:magma_cube"); + @Nullable public static final EntityType MINECART = get("minecraft:minecart"); + @Nullable public static final EntityType MOOSHROOM = get("minecraft:mooshroom"); + @Nullable public static final EntityType MULE = get("minecraft:mule"); + @Nullable public static final EntityType OCELOT = get("minecraft:ocelot"); + @Nullable public static final EntityType PAINTING = get("minecraft:painting"); + @Nullable public static final EntityType PARROT = get("minecraft:parrot"); + @Nullable public static final EntityType PHANTOM = get("minecraft:phantom"); + @Nullable public static final EntityType PIG = get("minecraft:pig"); + @Nullable public static final EntityType PLAYER = get("minecraft:player"); + @Nullable public static final EntityType POLAR_BEAR = get("minecraft:polar_bear"); + @Nullable public static final EntityType POTION = get("minecraft:potion"); + @Nullable public static final EntityType PUFFERFISH = get("minecraft:pufferfish"); + @Nullable public static final EntityType RABBIT = get("minecraft:rabbit"); + @Nullable public static final EntityType SALMON = get("minecraft:salmon"); + @Nullable public static final EntityType SHEEP = get("minecraft:sheep"); + @Nullable public static final EntityType SHULKER = get("minecraft:shulker"); + @Nullable public static final EntityType SHULKER_BULLET = get("minecraft:shulker_bullet"); + @Nullable public static final EntityType SILVERFISH = get("minecraft:silverfish"); + @Nullable public static final EntityType SKELETON = get("minecraft:skeleton"); + @Nullable public static final EntityType SKELETON_HORSE = get("minecraft:skeleton_horse"); + @Nullable public static final EntityType SLIME = get("minecraft:slime"); + @Nullable public static final EntityType SMALL_FIREBALL = get("minecraft:small_fireball"); + @Nullable public static final EntityType SNOW_GOLEM = get("minecraft:snow_golem"); + @Nullable public static final EntityType SNOWBALL = get("minecraft:snowball"); + @Nullable public static final EntityType SPAWNER_MINECART = get("minecraft:spawner_minecart"); + @Nullable public static final EntityType SPECTRAL_ARROW = get("minecraft:spectral_arrow"); + @Nullable public static final EntityType SPIDER = get("minecraft:spider"); + @Nullable public static final EntityType SQUID = get("minecraft:squid"); + @Nullable public static final EntityType STRAY = get("minecraft:stray"); + @Nullable public static final EntityType TNT = get("minecraft:tnt"); + @Nullable public static final EntityType TNT_MINECART = get("minecraft:tnt_minecart"); + @Nullable public static final EntityType TRIDENT = get("minecraft:trident"); + @Nullable public static final EntityType TROPICAL_FISH = get("minecraft:tropical_fish"); + @Nullable public static final EntityType TURTLE = get("minecraft:turtle"); + @Nullable public static final EntityType VEX = get("minecraft:vex"); + @Nullable public static final EntityType VILLAGER = get("minecraft:villager"); + @Nullable public static final EntityType VINDICATOR = get("minecraft:vindicator"); + @Nullable public static final EntityType WITCH = get("minecraft:witch"); + @Nullable public static final EntityType WITHER = get("minecraft:wither"); + @Nullable public static final EntityType WITHER_SKELETON = get("minecraft:wither_skeleton"); + @Nullable public static final EntityType WITHER_SKULL = get("minecraft:wither_skull"); + @Nullable public static final EntityType WOLF = get("minecraft:wolf"); + @Nullable public static final EntityType ZOMBIE = get("minecraft:zombie"); + @Nullable public static final EntityType ZOMBIE_HORSE = get("minecraft:zombie_horse"); + @Nullable public static final EntityType ZOMBIE_PIGMAN = get("minecraft:zombie_pigman"); + @Nullable public static final EntityType ZOMBIE_VILLAGER = get("minecraft:zombie_villager"); private EntityTypes() { } - private static EntityType register(final String id) { - return register(new EntityType(id)); - } - - public static EntityType register(final EntityType entityType) { - return EntityType.REGISTRY.register(entityType.getId(), entityType); - } - public static @Nullable EntityType get(final String id) { return EntityType.REGISTRY.get(id); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java index 68f232d7b..021d6834c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemCategories.java @@ -19,56 +19,50 @@ package com.sk89q.worldedit.world.item; -import javax.annotation.Nullable; - /** * Stores a list of categories of Item Types. */ public final class ItemCategories { - public static final ItemCategory ACACIA_LOGS = register("minecraft:acacia_logs"); - public static final ItemCategory ANVIL = register("minecraft:anvil"); - public static final ItemCategory BANNERS = register("minecraft:banners"); - public static final ItemCategory BIRCH_LOGS = register("minecraft:birch_logs"); - public static final ItemCategory BOATS = register("minecraft:boats"); - public static final ItemCategory BUTTONS = register("minecraft:buttons"); - public static final ItemCategory CARPETS = register("minecraft:carpets"); - public static final ItemCategory CORAL = register("minecraft:coral"); - public static final ItemCategory CORAL_PLANTS = register("minecraft:coral_plants"); - public static final ItemCategory DARK_OAK_LOGS = register("minecraft:dark_oak_logs"); - public static final ItemCategory DOORS = register("minecraft:doors"); - public static final ItemCategory FISHES = register("minecraft:fishes"); - public static final ItemCategory JUNGLE_LOGS = register("minecraft:jungle_logs"); - public static final ItemCategory LEAVES = register("minecraft:leaves"); - public static final ItemCategory LOGS = register("minecraft:logs"); - public static final ItemCategory OAK_LOGS = register("minecraft:oak_logs"); - public static final ItemCategory PLANKS = register("minecraft:planks"); - public static final ItemCategory RAILS = register("minecraft:rails"); - public static final ItemCategory SAND = register("minecraft:sand"); - public static final ItemCategory SAPLINGS = register("minecraft:saplings"); - public static final ItemCategory SLABS = register("minecraft:slabs"); - public static final ItemCategory SPRUCE_LOGS = register("minecraft:spruce_logs"); - public static final ItemCategory STAIRS = register("minecraft:stairs"); - public static final ItemCategory STONE_BRICKS = register("minecraft:stone_bricks"); - public static final ItemCategory WOODEN_BUTTONS = register("minecraft:wooden_buttons"); - public static final ItemCategory WOODEN_DOORS = register("minecraft:wooden_doors"); - public static final ItemCategory WOODEN_PRESSURE_PLATES = register("minecraft:wooden_pressure_plates"); - public static final ItemCategory WOODEN_SLABS = register("minecraft:wooden_slabs"); - public static final ItemCategory WOODEN_STAIRS = register("minecraft:wooden_stairs"); - public static final ItemCategory WOOL = register("minecraft:wool"); + public static final ItemCategory ACACIA_LOGS = get("minecraft:acacia_logs"); + public static final ItemCategory ANVIL = get("minecraft:anvil"); + public static final ItemCategory BANNERS = get("minecraft:banners"); + public static final ItemCategory BIRCH_LOGS = get("minecraft:birch_logs"); + public static final ItemCategory BOATS = get("minecraft:boats"); + public static final ItemCategory BUTTONS = get("minecraft:buttons"); + public static final ItemCategory CARPETS = get("minecraft:carpets"); + public static final ItemCategory CORAL = get("minecraft:coral"); + public static final ItemCategory CORAL_PLANTS = get("minecraft:coral_plants"); + public static final ItemCategory DARK_OAK_LOGS = get("minecraft:dark_oak_logs"); + public static final ItemCategory DOORS = get("minecraft:doors"); + public static final ItemCategory FISHES = get("minecraft:fishes"); + public static final ItemCategory JUNGLE_LOGS = get("minecraft:jungle_logs"); + public static final ItemCategory LEAVES = get("minecraft:leaves"); + public static final ItemCategory LOGS = get("minecraft:logs"); + public static final ItemCategory OAK_LOGS = get("minecraft:oak_logs"); + public static final ItemCategory PLANKS = get("minecraft:planks"); + public static final ItemCategory RAILS = get("minecraft:rails"); + public static final ItemCategory SAND = get("minecraft:sand"); + public static final ItemCategory SAPLINGS = get("minecraft:saplings"); + public static final ItemCategory SLABS = get("minecraft:slabs"); + public static final ItemCategory SPRUCE_LOGS = get("minecraft:spruce_logs"); + public static final ItemCategory STAIRS = get("minecraft:stairs"); + public static final ItemCategory STONE_BRICKS = get("minecraft:stone_bricks"); + public static final ItemCategory WOODEN_BUTTONS = get("minecraft:wooden_buttons"); + public static final ItemCategory WOODEN_DOORS = get("minecraft:wooden_doors"); + public static final ItemCategory WOODEN_PRESSURE_PLATES = get("minecraft:wooden_pressure_plates"); + public static final ItemCategory WOODEN_SLABS = get("minecraft:wooden_slabs"); + public static final ItemCategory WOODEN_STAIRS = get("minecraft:wooden_stairs"); + public static final ItemCategory WOOL = get("minecraft:wool"); private ItemCategories() { } - private static ItemCategory register(final String id) { - return register(new ItemCategory(id)); - } - - public static ItemCategory register(final ItemCategory tag) { - return ItemCategory.REGISTRY.register(tag.getId(), tag); - } - - public static @Nullable ItemCategory get(final String id) { - return ItemCategory.REGISTRY.get(id); + private static ItemCategory get(final String id) { + ItemCategory itemCategory = ItemCategory.REGISTRY.get(id); + if (itemCategory == null) { + return new ItemCategory(id); + } + return itemCategory; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemType.java index b68db45b4..be59950cb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemType.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit.world.item; import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.registry.NamespacedRegistry; import com.sk89q.worldedit.world.block.BlockType; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java index 20ff44846..92d1a2f00 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/item/ItemTypes.java @@ -37,796 +37,796 @@ import com.sk89q.worldedit.world.registry.LegacyMapper; public final class ItemTypes { - @Nullable public static final ItemType ACACIA_BOAT = register("minecraft:acacia_boat"); - @Nullable public static final ItemType ACACIA_BUTTON = register("minecraft:acacia_button"); - @Nullable public static final ItemType ACACIA_DOOR = register("minecraft:acacia_door"); - @Nullable public static final ItemType ACACIA_FENCE = register("minecraft:acacia_fence"); - @Nullable public static final ItemType ACACIA_FENCE_GATE = register("minecraft:acacia_fence_gate"); - @Nullable public static final ItemType ACACIA_LEAVES = register("minecraft:acacia_leaves"); - @Nullable public static final ItemType ACACIA_LOG = register("minecraft:acacia_log"); - @Nullable public static final ItemType ACACIA_PLANKS = register("minecraft:acacia_planks"); - @Nullable public static final ItemType ACACIA_PRESSURE_PLATE = register("minecraft:acacia_pressure_plate"); - @Nullable public static final ItemType ACACIA_SAPLING = register("minecraft:acacia_sapling"); - @Nullable public static final ItemType ACACIA_SLAB = register("minecraft:acacia_slab"); - @Nullable public static final ItemType ACACIA_STAIRS = register("minecraft:acacia_stairs"); - @Nullable public static final ItemType ACACIA_TRAPDOOR = register("minecraft:acacia_trapdoor"); - @Nullable public static final ItemType ACACIA_WOOD = register("minecraft:acacia_wood"); - @Nullable public static final ItemType ACTIVATOR_RAIL = register("minecraft:activator_rail"); - @Nullable public static final ItemType AIR = register("minecraft:air"); - @Nullable public static final ItemType ALLIUM = register("minecraft:allium"); - @Nullable public static final ItemType ANDESITE = register("minecraft:andesite"); - @Nullable public static final ItemType ANVIL = register("minecraft:anvil"); - @Nullable public static final ItemType APPLE = register("minecraft:apple"); - @Nullable public static final ItemType ARMOR_STAND = register("minecraft:armor_stand"); - @Nullable public static final ItemType ARROW = register("minecraft:arrow"); - @Nullable public static final ItemType AZURE_BLUET = register("minecraft:azure_bluet"); - @Nullable public static final ItemType BAKED_POTATO = register("minecraft:baked_potato"); - @Nullable public static final ItemType BARRIER = register("minecraft:barrier"); - @Nullable public static final ItemType BAT_SPAWN_EGG = register("minecraft:bat_spawn_egg"); - @Nullable public static final ItemType BEACON = register("minecraft:beacon"); - @Nullable public static final ItemType BEDROCK = register("minecraft:bedrock"); - @Nullable public static final ItemType BEEF = register("minecraft:beef"); - @Nullable public static final ItemType BEETROOT = register("minecraft:beetroot"); - @Nullable public static final ItemType BEETROOT_SEEDS = register("minecraft:beetroot_seeds"); - @Nullable public static final ItemType BEETROOT_SOUP = register("minecraft:beetroot_soup"); - @Nullable public static final ItemType BIRCH_BOAT = register("minecraft:birch_boat"); - @Nullable public static final ItemType BIRCH_BUTTON = register("minecraft:birch_button"); - @Nullable public static final ItemType BIRCH_DOOR = register("minecraft:birch_door"); - @Nullable public static final ItemType BIRCH_FENCE = register("minecraft:birch_fence"); - @Nullable public static final ItemType BIRCH_FENCE_GATE = register("minecraft:birch_fence_gate"); - @Nullable public static final ItemType BIRCH_LEAVES = register("minecraft:birch_leaves"); - @Nullable public static final ItemType BIRCH_LOG = register("minecraft:birch_log"); - @Nullable public static final ItemType BIRCH_PLANKS = register("minecraft:birch_planks"); - @Nullable public static final ItemType BIRCH_PRESSURE_PLATE = register("minecraft:birch_pressure_plate"); - @Nullable public static final ItemType BIRCH_SAPLING = register("minecraft:birch_sapling"); - @Nullable public static final ItemType BIRCH_SLAB = register("minecraft:birch_slab"); - @Nullable public static final ItemType BIRCH_STAIRS = register("minecraft:birch_stairs"); - @Nullable public static final ItemType BIRCH_TRAPDOOR = register("minecraft:birch_trapdoor"); - @Nullable public static final ItemType BIRCH_WOOD = register("minecraft:birch_wood"); - @Nullable public static final ItemType BLACK_BANNER = register("minecraft:black_banner"); - @Nullable public static final ItemType BLACK_BED = register("minecraft:black_bed"); - @Nullable public static final ItemType BLACK_CARPET = register("minecraft:black_carpet"); - @Nullable public static final ItemType BLACK_CONCRETE = register("minecraft:black_concrete"); - @Nullable public static final ItemType BLACK_CONCRETE_POWDER = register("minecraft:black_concrete_powder"); - @Nullable public static final ItemType BLACK_GLAZED_TERRACOTTA = register("minecraft:black_glazed_terracotta"); - @Nullable public static final ItemType BLACK_SHULKER_BOX = register("minecraft:black_shulker_box"); - @Nullable public static final ItemType BLACK_STAINED_GLASS = register("minecraft:black_stained_glass"); - @Nullable public static final ItemType BLACK_STAINED_GLASS_PANE = register("minecraft:black_stained_glass_pane"); - @Nullable public static final ItemType BLACK_TERRACOTTA = register("minecraft:black_terracotta"); - @Nullable public static final ItemType BLACK_WOOL = register("minecraft:black_wool"); - @Nullable public static final ItemType BLAZE_POWDER = register("minecraft:blaze_powder"); - @Nullable public static final ItemType BLAZE_ROD = register("minecraft:blaze_rod"); - @Nullable public static final ItemType BLAZE_SPAWN_EGG = register("minecraft:blaze_spawn_egg"); - @Nullable public static final ItemType BLUE_BANNER = register("minecraft:blue_banner"); - @Nullable public static final ItemType BLUE_BED = register("minecraft:blue_bed"); - @Nullable public static final ItemType BLUE_CARPET = register("minecraft:blue_carpet"); - @Nullable public static final ItemType BLUE_CONCRETE = register("minecraft:blue_concrete"); - @Nullable public static final ItemType BLUE_CONCRETE_POWDER = register("minecraft:blue_concrete_powder"); - @Nullable public static final ItemType BLUE_GLAZED_TERRACOTTA = register("minecraft:blue_glazed_terracotta"); - @Nullable public static final ItemType BLUE_ICE = register("minecraft:blue_ice"); - @Nullable public static final ItemType BLUE_ORCHID = register("minecraft:blue_orchid"); - @Nullable public static final ItemType BLUE_SHULKER_BOX = register("minecraft:blue_shulker_box"); - @Nullable public static final ItemType BLUE_STAINED_GLASS = register("minecraft:blue_stained_glass"); - @Nullable public static final ItemType BLUE_STAINED_GLASS_PANE = register("minecraft:blue_stained_glass_pane"); - @Nullable public static final ItemType BLUE_TERRACOTTA = register("minecraft:blue_terracotta"); - @Nullable public static final ItemType BLUE_WOOL = register("minecraft:blue_wool"); - @Nullable public static final ItemType BONE = register("minecraft:bone"); - @Nullable public static final ItemType BONE_BLOCK = register("minecraft:bone_block"); - @Nullable public static final ItemType BONE_MEAL = register("minecraft:bone_meal"); - @Nullable public static final ItemType BOOK = register("minecraft:book"); - @Nullable public static final ItemType BOOKSHELF = register("minecraft:bookshelf"); - @Nullable public static final ItemType BOW = register("minecraft:bow"); - @Nullable public static final ItemType BOWL = register("minecraft:bowl"); - @Nullable public static final ItemType BRAIN_CORAL = register("minecraft:brain_coral"); - @Nullable public static final ItemType BRAIN_CORAL_BLOCK = register("minecraft:brain_coral_block"); - @Nullable public static final ItemType BRAIN_CORAL_FAN = register("minecraft:brain_coral_fan"); - @Nullable public static final ItemType BREAD = register("minecraft:bread"); - @Nullable public static final ItemType BREWING_STAND = register("minecraft:brewing_stand"); - @Nullable public static final ItemType BRICK = register("minecraft:brick"); - @Nullable public static final ItemType BRICK_SLAB = register("minecraft:brick_slab"); - @Nullable public static final ItemType BRICK_STAIRS = register("minecraft:brick_stairs"); - @Nullable public static final ItemType BRICKS = register("minecraft:bricks"); - @Nullable public static final ItemType BROWN_BANNER = register("minecraft:brown_banner"); - @Nullable public static final ItemType BROWN_BED = register("minecraft:brown_bed"); - @Nullable public static final ItemType BROWN_CARPET = register("minecraft:brown_carpet"); - @Nullable public static final ItemType BROWN_CONCRETE = register("minecraft:brown_concrete"); - @Nullable public static final ItemType BROWN_CONCRETE_POWDER = register("minecraft:brown_concrete_powder"); - @Nullable public static final ItemType BROWN_GLAZED_TERRACOTTA = register("minecraft:brown_glazed_terracotta"); - @Nullable public static final ItemType BROWN_MUSHROOM = register("minecraft:brown_mushroom"); - @Nullable public static final ItemType BROWN_MUSHROOM_BLOCK = register("minecraft:brown_mushroom_block"); - @Nullable public static final ItemType BROWN_SHULKER_BOX = register("minecraft:brown_shulker_box"); - @Nullable public static final ItemType BROWN_STAINED_GLASS = register("minecraft:brown_stained_glass"); - @Nullable public static final ItemType BROWN_STAINED_GLASS_PANE = register("minecraft:brown_stained_glass_pane"); - @Nullable public static final ItemType BROWN_TERRACOTTA = register("minecraft:brown_terracotta"); - @Nullable public static final ItemType BROWN_WOOL = register("minecraft:brown_wool"); - @Nullable public static final ItemType BUBBLE_CORAL = register("minecraft:bubble_coral"); - @Nullable public static final ItemType BUBBLE_CORAL_BLOCK = register("minecraft:bubble_coral_block"); - @Nullable public static final ItemType BUBBLE_CORAL_FAN = register("minecraft:bubble_coral_fan"); - @Nullable public static final ItemType BUCKET = register("minecraft:bucket"); - @Nullable public static final ItemType CACTUS = register("minecraft:cactus"); - @Nullable public static final ItemType CACTUS_GREEN = register("minecraft:cactus_green"); - @Nullable public static final ItemType CAKE = register("minecraft:cake"); - @Nullable public static final ItemType CARROT = register("minecraft:carrot"); - @Nullable public static final ItemType CARROT_ON_A_STICK = register("minecraft:carrot_on_a_stick"); - @Nullable public static final ItemType CARVED_PUMPKIN = register("minecraft:carved_pumpkin"); - @Nullable public static final ItemType CAULDRON = register("minecraft:cauldron"); - @Nullable public static final ItemType CAVE_SPIDER_SPAWN_EGG = register("minecraft:cave_spider_spawn_egg"); - @Nullable public static final ItemType CHAIN_COMMAND_BLOCK = register("minecraft:chain_command_block"); - @Nullable public static final ItemType CHAINMAIL_BOOTS = register("minecraft:chainmail_boots"); - @Nullable public static final ItemType CHAINMAIL_CHESTPLATE = register("minecraft:chainmail_chestplate"); - @Nullable public static final ItemType CHAINMAIL_HELMET = register("minecraft:chainmail_helmet"); - @Nullable public static final ItemType CHAINMAIL_LEGGINGS = register("minecraft:chainmail_leggings"); - @Nullable public static final ItemType CHARCOAL = register("minecraft:charcoal"); - @Nullable public static final ItemType CHEST = register("minecraft:chest"); - @Nullable public static final ItemType CHEST_MINECART = register("minecraft:chest_minecart"); - @Nullable public static final ItemType CHICKEN = register("minecraft:chicken"); - @Nullable public static final ItemType CHICKEN_SPAWN_EGG = register("minecraft:chicken_spawn_egg"); - @Nullable public static final ItemType CHIPPED_ANVIL = register("minecraft:chipped_anvil"); - @Nullable public static final ItemType CHISELED_QUARTZ_BLOCK = register("minecraft:chiseled_quartz_block"); - @Nullable public static final ItemType CHISELED_RED_SANDSTONE = register("minecraft:chiseled_red_sandstone"); - @Nullable public static final ItemType CHISELED_SANDSTONE = register("minecraft:chiseled_sandstone"); - @Nullable public static final ItemType CHISELED_STONE_BRICKS = register("minecraft:chiseled_stone_bricks"); - @Nullable public static final ItemType CHORUS_FLOWER = register("minecraft:chorus_flower"); - @Nullable public static final ItemType CHORUS_FRUIT = register("minecraft:chorus_fruit"); - @Nullable public static final ItemType CHORUS_PLANT = register("minecraft:chorus_plant"); - @Nullable public static final ItemType CLAY = register("minecraft:clay"); - @Nullable public static final ItemType CLAY_BALL = register("minecraft:clay_ball"); - @Nullable public static final ItemType CLOCK = register("minecraft:clock"); - @Nullable public static final ItemType COAL = register("minecraft:coal"); - @Nullable public static final ItemType COAL_BLOCK = register("minecraft:coal_block"); - @Nullable public static final ItemType COAL_ORE = register("minecraft:coal_ore"); - @Nullable public static final ItemType COARSE_DIRT = register("minecraft:coarse_dirt"); - @Nullable public static final ItemType COBBLESTONE = register("minecraft:cobblestone"); - @Nullable public static final ItemType COBBLESTONE_SLAB = register("minecraft:cobblestone_slab"); - @Nullable public static final ItemType COBBLESTONE_STAIRS = register("minecraft:cobblestone_stairs"); - @Nullable public static final ItemType COBBLESTONE_WALL = register("minecraft:cobblestone_wall"); - @Nullable public static final ItemType COBWEB = register("minecraft:cobweb"); - @Nullable public static final ItemType COCOA_BEANS = register("minecraft:cocoa_beans"); - @Nullable public static final ItemType COD = register("minecraft:cod"); - @Nullable public static final ItemType COD_BUCKET = register("minecraft:cod_bucket"); - @Nullable public static final ItemType COD_SPAWN_EGG = register("minecraft:cod_spawn_egg"); - @Nullable public static final ItemType COMMAND_BLOCK = register("minecraft:command_block"); - @Nullable public static final ItemType COMMAND_BLOCK_MINECART = register("minecraft:command_block_minecart"); - @Nullable public static final ItemType COMPARATOR = register("minecraft:comparator"); - @Nullable public static final ItemType COMPASS = register("minecraft:compass"); - @Nullable public static final ItemType CONDUIT = register("minecraft:conduit"); - @Nullable public static final ItemType COOKED_BEEF = register("minecraft:cooked_beef"); - @Nullable public static final ItemType COOKED_CHICKEN = register("minecraft:cooked_chicken"); - @Nullable public static final ItemType COOKED_COD = register("minecraft:cooked_cod"); - @Nullable public static final ItemType COOKED_MUTTON = register("minecraft:cooked_mutton"); - @Nullable public static final ItemType COOKED_PORKCHOP = register("minecraft:cooked_porkchop"); - @Nullable public static final ItemType COOKED_RABBIT = register("minecraft:cooked_rabbit"); - @Nullable public static final ItemType COOKED_SALMON = register("minecraft:cooked_salmon"); - @Nullable public static final ItemType COOKIE = register("minecraft:cookie"); - @Nullable public static final ItemType COW_SPAWN_EGG = register("minecraft:cow_spawn_egg"); - @Nullable public static final ItemType CRACKED_STONE_BRICKS = register("minecraft:cracked_stone_bricks"); - @Nullable public static final ItemType CRAFTING_TABLE = register("minecraft:crafting_table"); - @Nullable public static final ItemType CREEPER_HEAD = register("minecraft:creeper_head"); - @Nullable public static final ItemType CREEPER_SPAWN_EGG = register("minecraft:creeper_spawn_egg"); - @Nullable public static final ItemType CUT_RED_SANDSTONE = register("minecraft:cut_red_sandstone"); - @Nullable public static final ItemType CUT_SANDSTONE = register("minecraft:cut_sandstone"); - @Nullable public static final ItemType CYAN_BANNER = register("minecraft:cyan_banner"); - @Nullable public static final ItemType CYAN_BED = register("minecraft:cyan_bed"); - @Nullable public static final ItemType CYAN_CARPET = register("minecraft:cyan_carpet"); - @Nullable public static final ItemType CYAN_CONCRETE = register("minecraft:cyan_concrete"); - @Nullable public static final ItemType CYAN_CONCRETE_POWDER = register("minecraft:cyan_concrete_powder"); - @Nullable public static final ItemType CYAN_DYE = register("minecraft:cyan_dye"); - @Nullable public static final ItemType CYAN_GLAZED_TERRACOTTA = register("minecraft:cyan_glazed_terracotta"); - @Nullable public static final ItemType CYAN_SHULKER_BOX = register("minecraft:cyan_shulker_box"); - @Nullable public static final ItemType CYAN_STAINED_GLASS = register("minecraft:cyan_stained_glass"); - @Nullable public static final ItemType CYAN_STAINED_GLASS_PANE = register("minecraft:cyan_stained_glass_pane"); - @Nullable public static final ItemType CYAN_TERRACOTTA = register("minecraft:cyan_terracotta"); - @Nullable public static final ItemType CYAN_WOOL = register("minecraft:cyan_wool"); - @Nullable public static final ItemType DAMAGED_ANVIL = register("minecraft:damaged_anvil"); - @Nullable public static final ItemType DANDELION = register("minecraft:dandelion"); - @Nullable public static final ItemType DANDELION_YELLOW = register("minecraft:dandelion_yellow"); - @Nullable public static final ItemType DARK_OAK_BOAT = register("minecraft:dark_oak_boat"); - @Nullable public static final ItemType DARK_OAK_BUTTON = register("minecraft:dark_oak_button"); - @Nullable public static final ItemType DARK_OAK_DOOR = register("minecraft:dark_oak_door"); - @Nullable public static final ItemType DARK_OAK_FENCE = register("minecraft:dark_oak_fence"); - @Nullable public static final ItemType DARK_OAK_FENCE_GATE = register("minecraft:dark_oak_fence_gate"); - @Nullable public static final ItemType DARK_OAK_LEAVES = register("minecraft:dark_oak_leaves"); - @Nullable public static final ItemType DARK_OAK_LOG = register("minecraft:dark_oak_log"); - @Nullable public static final ItemType DARK_OAK_PLANKS = register("minecraft:dark_oak_planks"); - @Nullable public static final ItemType DARK_OAK_PRESSURE_PLATE = register("minecraft:dark_oak_pressure_plate"); - @Nullable public static final ItemType DARK_OAK_SAPLING = register("minecraft:dark_oak_sapling"); - @Nullable public static final ItemType DARK_OAK_SLAB = register("minecraft:dark_oak_slab"); - @Nullable public static final ItemType DARK_OAK_STAIRS = register("minecraft:dark_oak_stairs"); - @Nullable public static final ItemType DARK_OAK_TRAPDOOR = register("minecraft:dark_oak_trapdoor"); - @Nullable public static final ItemType DARK_OAK_WOOD = register("minecraft:dark_oak_wood"); - @Nullable public static final ItemType DARK_PRISMARINE = register("minecraft:dark_prismarine"); - @Nullable public static final ItemType DARK_PRISMARINE_SLAB = register("minecraft:dark_prismarine_slab"); - @Nullable public static final ItemType DARK_PRISMARINE_STAIRS = register("minecraft:dark_prismarine_stairs"); - @Nullable public static final ItemType DAYLIGHT_DETECTOR = register("minecraft:daylight_detector"); - @Nullable public static final ItemType DEAD_BRAIN_CORAL = register("minecraft:dead_brain_coral"); - @Nullable public static final ItemType DEAD_BRAIN_CORAL_BLOCK = register("minecraft:dead_brain_coral_block"); - @Nullable public static final ItemType DEAD_BRAIN_CORAL_FAN = register("minecraft:dead_brain_coral_fan"); - @Nullable public static final ItemType DEAD_BUBBLE_CORAL = register("minecraft:dead_bubble_coral"); - @Nullable public static final ItemType DEAD_BUBBLE_CORAL_BLOCK = register("minecraft:dead_bubble_coral_block"); - @Nullable public static final ItemType DEAD_BUBBLE_CORAL_FAN = register("minecraft:dead_bubble_coral_fan"); - @Nullable public static final ItemType DEAD_BUSH = register("minecraft:dead_bush"); - @Nullable public static final ItemType DEAD_FIRE_CORAL = register("minecraft:dead_fire_coral"); - @Nullable public static final ItemType DEAD_FIRE_CORAL_BLOCK = register("minecraft:dead_fire_coral_block"); - @Nullable public static final ItemType DEAD_FIRE_CORAL_FAN = register("minecraft:dead_fire_coral_fan"); - @Nullable public static final ItemType DEAD_HORN_CORAL = register("minecraft:dead_horn_coral"); - @Nullable public static final ItemType DEAD_HORN_CORAL_BLOCK = register("minecraft:dead_horn_coral_block"); - @Nullable public static final ItemType DEAD_HORN_CORAL_FAN = register("minecraft:dead_horn_coral_fan"); - @Nullable public static final ItemType DEAD_TUBE_CORAL = register("minecraft:dead_tube_coral"); - @Nullable public static final ItemType DEAD_TUBE_CORAL_BLOCK = register("minecraft:dead_tube_coral_block"); - @Nullable public static final ItemType DEAD_TUBE_CORAL_FAN = register("minecraft:dead_tube_coral_fan"); - @Nullable public static final ItemType DEBUG_STICK = register("minecraft:debug_stick"); - @Nullable public static final ItemType DETECTOR_RAIL = register("minecraft:detector_rail"); - @Nullable public static final ItemType DIAMOND = register("minecraft:diamond"); - @Nullable public static final ItemType DIAMOND_AXE = register("minecraft:diamond_axe"); - @Nullable public static final ItemType DIAMOND_BLOCK = register("minecraft:diamond_block"); - @Nullable public static final ItemType DIAMOND_BOOTS = register("minecraft:diamond_boots"); - @Nullable public static final ItemType DIAMOND_CHESTPLATE = register("minecraft:diamond_chestplate"); - @Nullable public static final ItemType DIAMOND_HELMET = register("minecraft:diamond_helmet"); - @Nullable public static final ItemType DIAMOND_HOE = register("minecraft:diamond_hoe"); - @Nullable public static final ItemType DIAMOND_HORSE_ARMOR = register("minecraft:diamond_horse_armor"); - @Nullable public static final ItemType DIAMOND_LEGGINGS = register("minecraft:diamond_leggings"); - @Nullable public static final ItemType DIAMOND_ORE = register("minecraft:diamond_ore"); - @Nullable public static final ItemType DIAMOND_PICKAXE = register("minecraft:diamond_pickaxe"); - @Nullable public static final ItemType DIAMOND_SHOVEL = register("minecraft:diamond_shovel"); - @Nullable public static final ItemType DIAMOND_SWORD = register("minecraft:diamond_sword"); - @Nullable public static final ItemType DIORITE = register("minecraft:diorite"); - @Nullable public static final ItemType DIRT = register("minecraft:dirt"); - @Nullable public static final ItemType DISPENSER = register("minecraft:dispenser"); - @Nullable public static final ItemType DOLPHIN_SPAWN_EGG = register("minecraft:dolphin_spawn_egg"); - @Nullable public static final ItemType DONKEY_SPAWN_EGG = register("minecraft:donkey_spawn_egg"); - @Nullable public static final ItemType DRAGON_BREATH = register("minecraft:dragon_breath"); - @Nullable public static final ItemType DRAGON_EGG = register("minecraft:dragon_egg"); - @Nullable public static final ItemType DRAGON_HEAD = register("minecraft:dragon_head"); - @Nullable public static final ItemType DRIED_KELP = register("minecraft:dried_kelp"); - @Nullable public static final ItemType DRIED_KELP_BLOCK = register("minecraft:dried_kelp_block"); - @Nullable public static final ItemType DROPPER = register("minecraft:dropper"); - @Nullable public static final ItemType DROWNED_SPAWN_EGG = register("minecraft:drowned_spawn_egg"); - @Nullable public static final ItemType EGG = register("minecraft:egg"); - @Nullable public static final ItemType ELDER_GUARDIAN_SPAWN_EGG = register("minecraft:elder_guardian_spawn_egg"); - @Nullable public static final ItemType ELYTRA = register("minecraft:elytra"); - @Nullable public static final ItemType EMERALD = register("minecraft:emerald"); - @Nullable public static final ItemType EMERALD_BLOCK = register("minecraft:emerald_block"); - @Nullable public static final ItemType EMERALD_ORE = register("minecraft:emerald_ore"); - @Nullable public static final ItemType ENCHANTED_BOOK = register("minecraft:enchanted_book"); - @Nullable public static final ItemType ENCHANTED_GOLDEN_APPLE = register("minecraft:enchanted_golden_apple"); - @Nullable public static final ItemType ENCHANTING_TABLE = register("minecraft:enchanting_table"); - @Nullable public static final ItemType END_CRYSTAL = register("minecraft:end_crystal"); - @Nullable public static final ItemType END_PORTAL_FRAME = register("minecraft:end_portal_frame"); - @Nullable public static final ItemType END_ROD = register("minecraft:end_rod"); - @Nullable public static final ItemType END_STONE = register("minecraft:end_stone"); - @Nullable public static final ItemType END_STONE_BRICKS = register("minecraft:end_stone_bricks"); - @Nullable public static final ItemType ENDER_CHEST = register("minecraft:ender_chest"); - @Nullable public static final ItemType ENDER_EYE = register("minecraft:ender_eye"); - @Nullable public static final ItemType ENDER_PEARL = register("minecraft:ender_pearl"); - @Nullable public static final ItemType ENDERMAN_SPAWN_EGG = register("minecraft:enderman_spawn_egg"); - @Nullable public static final ItemType ENDERMITE_SPAWN_EGG = register("minecraft:endermite_spawn_egg"); - @Nullable public static final ItemType EVOKER_SPAWN_EGG = register("minecraft:evoker_spawn_egg"); - @Nullable public static final ItemType EXPERIENCE_BOTTLE = register("minecraft:experience_bottle"); - @Nullable public static final ItemType FARMLAND = register("minecraft:farmland"); - @Nullable public static final ItemType FEATHER = register("minecraft:feather"); - @Nullable public static final ItemType FERMENTED_SPIDER_EYE = register("minecraft:fermented_spider_eye"); - @Nullable public static final ItemType FERN = register("minecraft:fern"); - @Nullable public static final ItemType FILLED_MAP = register("minecraft:filled_map"); - @Nullable public static final ItemType FIRE_CHARGE = register("minecraft:fire_charge"); - @Nullable public static final ItemType FIRE_CORAL = register("minecraft:fire_coral"); - @Nullable public static final ItemType FIRE_CORAL_BLOCK = register("minecraft:fire_coral_block"); - @Nullable public static final ItemType FIRE_CORAL_FAN = register("minecraft:fire_coral_fan"); - @Nullable public static final ItemType FIREWORK_ROCKET = register("minecraft:firework_rocket"); - @Nullable public static final ItemType FIREWORK_STAR = register("minecraft:firework_star"); - @Nullable public static final ItemType FISHING_ROD = register("minecraft:fishing_rod"); - @Nullable public static final ItemType FLINT = register("minecraft:flint"); - @Nullable public static final ItemType FLINT_AND_STEEL = register("minecraft:flint_and_steel"); - @Nullable public static final ItemType FLOWER_POT = register("minecraft:flower_pot"); - @Nullable public static final ItemType FURNACE = register("minecraft:furnace"); - @Nullable public static final ItemType FURNACE_MINECART = register("minecraft:furnace_minecart"); - @Nullable public static final ItemType GHAST_SPAWN_EGG = register("minecraft:ghast_spawn_egg"); - @Nullable public static final ItemType GHAST_TEAR = register("minecraft:ghast_tear"); - @Nullable public static final ItemType GLASS = register("minecraft:glass"); - @Nullable public static final ItemType GLASS_BOTTLE = register("minecraft:glass_bottle"); - @Nullable public static final ItemType GLASS_PANE = register("minecraft:glass_pane"); - @Nullable public static final ItemType GLISTERING_MELON_SLICE = register("minecraft:glistering_melon_slice"); - @Nullable public static final ItemType GLOWSTONE = register("minecraft:glowstone"); - @Nullable public static final ItemType GLOWSTONE_DUST = register("minecraft:glowstone_dust"); - @Nullable public static final ItemType GOLD_BLOCK = register("minecraft:gold_block"); - @Nullable public static final ItemType GOLD_INGOT = register("minecraft:gold_ingot"); - @Nullable public static final ItemType GOLD_NUGGET = register("minecraft:gold_nugget"); - @Nullable public static final ItemType GOLD_ORE = register("minecraft:gold_ore"); - @Nullable public static final ItemType GOLDEN_APPLE = register("minecraft:golden_apple"); - @Nullable public static final ItemType GOLDEN_AXE = register("minecraft:golden_axe"); - @Nullable public static final ItemType GOLDEN_BOOTS = register("minecraft:golden_boots"); - @Nullable public static final ItemType GOLDEN_CARROT = register("minecraft:golden_carrot"); - @Nullable public static final ItemType GOLDEN_CHESTPLATE = register("minecraft:golden_chestplate"); - @Nullable public static final ItemType GOLDEN_HELMET = register("minecraft:golden_helmet"); - @Nullable public static final ItemType GOLDEN_HOE = register("minecraft:golden_hoe"); - @Nullable public static final ItemType GOLDEN_HORSE_ARMOR = register("minecraft:golden_horse_armor"); - @Nullable public static final ItemType GOLDEN_LEGGINGS = register("minecraft:golden_leggings"); - @Nullable public static final ItemType GOLDEN_PICKAXE = register("minecraft:golden_pickaxe"); - @Nullable public static final ItemType GOLDEN_SHOVEL = register("minecraft:golden_shovel"); - @Nullable public static final ItemType GOLDEN_SWORD = register("minecraft:golden_sword"); - @Nullable public static final ItemType GRANITE = register("minecraft:granite"); - @Nullable public static final ItemType GRASS = register("minecraft:grass"); - @Nullable public static final ItemType GRASS_BLOCK = register("minecraft:grass_block"); - @Nullable public static final ItemType GRASS_PATH = register("minecraft:grass_path"); - @Nullable public static final ItemType GRAVEL = register("minecraft:gravel"); - @Nullable public static final ItemType GRAY_BANNER = register("minecraft:gray_banner"); - @Nullable public static final ItemType GRAY_BED = register("minecraft:gray_bed"); - @Nullable public static final ItemType GRAY_CARPET = register("minecraft:gray_carpet"); - @Nullable public static final ItemType GRAY_CONCRETE = register("minecraft:gray_concrete"); - @Nullable public static final ItemType GRAY_CONCRETE_POWDER = register("minecraft:gray_concrete_powder"); - @Nullable public static final ItemType GRAY_DYE = register("minecraft:gray_dye"); - @Nullable public static final ItemType GRAY_GLAZED_TERRACOTTA = register("minecraft:gray_glazed_terracotta"); - @Nullable public static final ItemType GRAY_SHULKER_BOX = register("minecraft:gray_shulker_box"); - @Nullable public static final ItemType GRAY_STAINED_GLASS = register("minecraft:gray_stained_glass"); - @Nullable public static final ItemType GRAY_STAINED_GLASS_PANE = register("minecraft:gray_stained_glass_pane"); - @Nullable public static final ItemType GRAY_TERRACOTTA = register("minecraft:gray_terracotta"); - @Nullable public static final ItemType GRAY_WOOL = register("minecraft:gray_wool"); - @Nullable public static final ItemType GREEN_BANNER = register("minecraft:green_banner"); - @Nullable public static final ItemType GREEN_BED = register("minecraft:green_bed"); - @Nullable public static final ItemType GREEN_CARPET = register("minecraft:green_carpet"); - @Nullable public static final ItemType GREEN_CONCRETE = register("minecraft:green_concrete"); - @Nullable public static final ItemType GREEN_CONCRETE_POWDER = register("minecraft:green_concrete_powder"); - @Nullable public static final ItemType GREEN_GLAZED_TERRACOTTA = register("minecraft:green_glazed_terracotta"); - @Nullable public static final ItemType GREEN_SHULKER_BOX = register("minecraft:green_shulker_box"); - @Nullable public static final ItemType GREEN_STAINED_GLASS = register("minecraft:green_stained_glass"); - @Nullable public static final ItemType GREEN_STAINED_GLASS_PANE = register("minecraft:green_stained_glass_pane"); - @Nullable public static final ItemType GREEN_TERRACOTTA = register("minecraft:green_terracotta"); - @Nullable public static final ItemType GREEN_WOOL = register("minecraft:green_wool"); - @Nullable public static final ItemType GUARDIAN_SPAWN_EGG = register("minecraft:guardian_spawn_egg"); - @Nullable public static final ItemType GUNPOWDER = register("minecraft:gunpowder"); - @Nullable public static final ItemType HAY_BLOCK = register("minecraft:hay_block"); - @Nullable public static final ItemType HEART_OF_THE_SEA = register("minecraft:heart_of_the_sea"); - @Nullable public static final ItemType HEAVY_WEIGHTED_PRESSURE_PLATE = register("minecraft:heavy_weighted_pressure_plate"); - @Nullable public static final ItemType HOPPER = register("minecraft:hopper"); - @Nullable public static final ItemType HOPPER_MINECART = register("minecraft:hopper_minecart"); - @Nullable public static final ItemType HORN_CORAL = register("minecraft:horn_coral"); - @Nullable public static final ItemType HORN_CORAL_BLOCK = register("minecraft:horn_coral_block"); - @Nullable public static final ItemType HORN_CORAL_FAN = register("minecraft:horn_coral_fan"); - @Nullable public static final ItemType HORSE_SPAWN_EGG = register("minecraft:horse_spawn_egg"); - @Nullable public static final ItemType HUSK_SPAWN_EGG = register("minecraft:husk_spawn_egg"); - @Nullable public static final ItemType ICE = register("minecraft:ice"); - @Nullable public static final ItemType INFESTED_CHISELED_STONE_BRICKS = register("minecraft:infested_chiseled_stone_bricks"); - @Nullable public static final ItemType INFESTED_COBBLESTONE = register("minecraft:infested_cobblestone"); - @Nullable public static final ItemType INFESTED_CRACKED_STONE_BRICKS = register("minecraft:infested_cracked_stone_bricks"); - @Nullable public static final ItemType INFESTED_MOSSY_STONE_BRICKS = register("minecraft:infested_mossy_stone_bricks"); - @Nullable public static final ItemType INFESTED_STONE = register("minecraft:infested_stone"); - @Nullable public static final ItemType INFESTED_STONE_BRICKS = register("minecraft:infested_stone_bricks"); - @Nullable public static final ItemType INK_SAC = register("minecraft:ink_sac"); - @Nullable public static final ItemType IRON_AXE = register("minecraft:iron_axe"); - @Nullable public static final ItemType IRON_BARS = register("minecraft:iron_bars"); - @Nullable public static final ItemType IRON_BLOCK = register("minecraft:iron_block"); - @Nullable public static final ItemType IRON_BOOTS = register("minecraft:iron_boots"); - @Nullable public static final ItemType IRON_CHESTPLATE = register("minecraft:iron_chestplate"); - @Nullable public static final ItemType IRON_DOOR = register("minecraft:iron_door"); - @Nullable public static final ItemType IRON_HELMET = register("minecraft:iron_helmet"); - @Nullable public static final ItemType IRON_HOE = register("minecraft:iron_hoe"); - @Nullable public static final ItemType IRON_HORSE_ARMOR = register("minecraft:iron_horse_armor"); - @Nullable public static final ItemType IRON_INGOT = register("minecraft:iron_ingot"); - @Nullable public static final ItemType IRON_LEGGINGS = register("minecraft:iron_leggings"); - @Nullable public static final ItemType IRON_NUGGET = register("minecraft:iron_nugget"); - @Nullable public static final ItemType IRON_ORE = register("minecraft:iron_ore"); - @Nullable public static final ItemType IRON_PICKAXE = register("minecraft:iron_pickaxe"); - @Nullable public static final ItemType IRON_SHOVEL = register("minecraft:iron_shovel"); - @Nullable public static final ItemType IRON_SWORD = register("minecraft:iron_sword"); - @Nullable public static final ItemType IRON_TRAPDOOR = register("minecraft:iron_trapdoor"); - @Nullable public static final ItemType ITEM_FRAME = register("minecraft:item_frame"); - @Nullable public static final ItemType JACK_O_LANTERN = register("minecraft:jack_o_lantern"); - @Nullable public static final ItemType JUKEBOX = register("minecraft:jukebox"); - @Nullable public static final ItemType JUNGLE_BOAT = register("minecraft:jungle_boat"); - @Nullable public static final ItemType JUNGLE_BUTTON = register("minecraft:jungle_button"); - @Nullable public static final ItemType JUNGLE_DOOR = register("minecraft:jungle_door"); - @Nullable public static final ItemType JUNGLE_FENCE = register("minecraft:jungle_fence"); - @Nullable public static final ItemType JUNGLE_FENCE_GATE = register("minecraft:jungle_fence_gate"); - @Nullable public static final ItemType JUNGLE_LEAVES = register("minecraft:jungle_leaves"); - @Nullable public static final ItemType JUNGLE_LOG = register("minecraft:jungle_log"); - @Nullable public static final ItemType JUNGLE_PLANKS = register("minecraft:jungle_planks"); - @Nullable public static final ItemType JUNGLE_PRESSURE_PLATE = register("minecraft:jungle_pressure_plate"); - @Nullable public static final ItemType JUNGLE_SAPLING = register("minecraft:jungle_sapling"); - @Nullable public static final ItemType JUNGLE_SLAB = register("minecraft:jungle_slab"); - @Nullable public static final ItemType JUNGLE_STAIRS = register("minecraft:jungle_stairs"); - @Nullable public static final ItemType JUNGLE_TRAPDOOR = register("minecraft:jungle_trapdoor"); - @Nullable public static final ItemType JUNGLE_WOOD = register("minecraft:jungle_wood"); - @Nullable public static final ItemType KELP = register("minecraft:kelp"); - @Nullable public static final ItemType KNOWLEDGE_BOOK = register("minecraft:knowledge_book"); - @Nullable public static final ItemType LADDER = register("minecraft:ladder"); - @Nullable public static final ItemType LAPIS_BLOCK = register("minecraft:lapis_block"); - @Nullable public static final ItemType LAPIS_LAZULI = register("minecraft:lapis_lazuli"); - @Nullable public static final ItemType LAPIS_ORE = register("minecraft:lapis_ore"); - @Nullable public static final ItemType LARGE_FERN = register("minecraft:large_fern"); - @Nullable public static final ItemType LAVA_BUCKET = register("minecraft:lava_bucket"); - @Nullable public static final ItemType LEAD = register("minecraft:lead"); - @Nullable public static final ItemType LEATHER = register("minecraft:leather"); - @Nullable public static final ItemType LEATHER_BOOTS = register("minecraft:leather_boots"); - @Nullable public static final ItemType LEATHER_CHESTPLATE = register("minecraft:leather_chestplate"); - @Nullable public static final ItemType LEATHER_HELMET = register("minecraft:leather_helmet"); - @Nullable public static final ItemType LEATHER_LEGGINGS = register("minecraft:leather_leggings"); - @Nullable public static final ItemType LEVER = register("minecraft:lever"); - @Nullable public static final ItemType LIGHT_BLUE_BANNER = register("minecraft:light_blue_banner"); - @Nullable public static final ItemType LIGHT_BLUE_BED = register("minecraft:light_blue_bed"); - @Nullable public static final ItemType LIGHT_BLUE_CARPET = register("minecraft:light_blue_carpet"); - @Nullable public static final ItemType LIGHT_BLUE_CONCRETE = register("minecraft:light_blue_concrete"); - @Nullable public static final ItemType LIGHT_BLUE_CONCRETE_POWDER = register("minecraft:light_blue_concrete_powder"); - @Nullable public static final ItemType LIGHT_BLUE_DYE = register("minecraft:light_blue_dye"); - @Nullable public static final ItemType LIGHT_BLUE_GLAZED_TERRACOTTA = register("minecraft:light_blue_glazed_terracotta"); - @Nullable public static final ItemType LIGHT_BLUE_SHULKER_BOX = register("minecraft:light_blue_shulker_box"); - @Nullable public static final ItemType LIGHT_BLUE_STAINED_GLASS = register("minecraft:light_blue_stained_glass"); - @Nullable public static final ItemType LIGHT_BLUE_STAINED_GLASS_PANE = register("minecraft:light_blue_stained_glass_pane"); - @Nullable public static final ItemType LIGHT_BLUE_TERRACOTTA = register("minecraft:light_blue_terracotta"); - @Nullable public static final ItemType LIGHT_BLUE_WOOL = register("minecraft:light_blue_wool"); - @Nullable public static final ItemType LIGHT_GRAY_BANNER = register("minecraft:light_gray_banner"); - @Nullable public static final ItemType LIGHT_GRAY_BED = register("minecraft:light_gray_bed"); - @Nullable public static final ItemType LIGHT_GRAY_CARPET = register("minecraft:light_gray_carpet"); - @Nullable public static final ItemType LIGHT_GRAY_CONCRETE = register("minecraft:light_gray_concrete"); - @Nullable public static final ItemType LIGHT_GRAY_CONCRETE_POWDER = register("minecraft:light_gray_concrete_powder"); - @Nullable public static final ItemType LIGHT_GRAY_DYE = register("minecraft:light_gray_dye"); - @Nullable public static final ItemType LIGHT_GRAY_GLAZED_TERRACOTTA = register("minecraft:light_gray_glazed_terracotta"); - @Nullable public static final ItemType LIGHT_GRAY_SHULKER_BOX = register("minecraft:light_gray_shulker_box"); - @Nullable public static final ItemType LIGHT_GRAY_STAINED_GLASS = register("minecraft:light_gray_stained_glass"); - @Nullable public static final ItemType LIGHT_GRAY_STAINED_GLASS_PANE = register("minecraft:light_gray_stained_glass_pane"); - @Nullable public static final ItemType LIGHT_GRAY_TERRACOTTA = register("minecraft:light_gray_terracotta"); - @Nullable public static final ItemType LIGHT_GRAY_WOOL = register("minecraft:light_gray_wool"); - @Nullable public static final ItemType LIGHT_WEIGHTED_PRESSURE_PLATE = register("minecraft:light_weighted_pressure_plate"); - @Nullable public static final ItemType LILAC = register("minecraft:lilac"); - @Nullable public static final ItemType LILY_PAD = register("minecraft:lily_pad"); - @Nullable public static final ItemType LIME_BANNER = register("minecraft:lime_banner"); - @Nullable public static final ItemType LIME_BED = register("minecraft:lime_bed"); - @Nullable public static final ItemType LIME_CARPET = register("minecraft:lime_carpet"); - @Nullable public static final ItemType LIME_CONCRETE = register("minecraft:lime_concrete"); - @Nullable public static final ItemType LIME_CONCRETE_POWDER = register("minecraft:lime_concrete_powder"); - @Nullable public static final ItemType LIME_DYE = register("minecraft:lime_dye"); - @Nullable public static final ItemType LIME_GLAZED_TERRACOTTA = register("minecraft:lime_glazed_terracotta"); - @Nullable public static final ItemType LIME_SHULKER_BOX = register("minecraft:lime_shulker_box"); - @Nullable public static final ItemType LIME_STAINED_GLASS = register("minecraft:lime_stained_glass"); - @Nullable public static final ItemType LIME_STAINED_GLASS_PANE = register("minecraft:lime_stained_glass_pane"); - @Nullable public static final ItemType LIME_TERRACOTTA = register("minecraft:lime_terracotta"); - @Nullable public static final ItemType LIME_WOOL = register("minecraft:lime_wool"); - @Nullable public static final ItemType LINGERING_POTION = register("minecraft:lingering_potion"); - @Nullable public static final ItemType LLAMA_SPAWN_EGG = register("minecraft:llama_spawn_egg"); - @Nullable public static final ItemType MAGENTA_BANNER = register("minecraft:magenta_banner"); - @Nullable public static final ItemType MAGENTA_BED = register("minecraft:magenta_bed"); - @Nullable public static final ItemType MAGENTA_CARPET = register("minecraft:magenta_carpet"); - @Nullable public static final ItemType MAGENTA_CONCRETE = register("minecraft:magenta_concrete"); - @Nullable public static final ItemType MAGENTA_CONCRETE_POWDER = register("minecraft:magenta_concrete_powder"); - @Nullable public static final ItemType MAGENTA_DYE = register("minecraft:magenta_dye"); - @Nullable public static final ItemType MAGENTA_GLAZED_TERRACOTTA = register("minecraft:magenta_glazed_terracotta"); - @Nullable public static final ItemType MAGENTA_SHULKER_BOX = register("minecraft:magenta_shulker_box"); - @Nullable public static final ItemType MAGENTA_STAINED_GLASS = register("minecraft:magenta_stained_glass"); - @Nullable public static final ItemType MAGENTA_STAINED_GLASS_PANE = register("minecraft:magenta_stained_glass_pane"); - @Nullable public static final ItemType MAGENTA_TERRACOTTA = register("minecraft:magenta_terracotta"); - @Nullable public static final ItemType MAGENTA_WOOL = register("minecraft:magenta_wool"); - @Nullable public static final ItemType MAGMA_BLOCK = register("minecraft:magma_block"); - @Nullable public static final ItemType MAGMA_CREAM = register("minecraft:magma_cream"); - @Nullable public static final ItemType MAGMA_CUBE_SPAWN_EGG = register("minecraft:magma_cube_spawn_egg"); - @Nullable public static final ItemType MAP = register("minecraft:map"); - @Nullable public static final ItemType MELON = register("minecraft:melon"); - @Nullable public static final ItemType MELON_SEEDS = register("minecraft:melon_seeds"); - @Nullable public static final ItemType MELON_SLICE = register("minecraft:melon_slice"); - @Nullable public static final ItemType MILK_BUCKET = register("minecraft:milk_bucket"); - @Nullable public static final ItemType MINECART = register("minecraft:minecart"); - @Nullable public static final ItemType MOOSHROOM_SPAWN_EGG = register("minecraft:mooshroom_spawn_egg"); - @Nullable public static final ItemType MOSSY_COBBLESTONE = register("minecraft:mossy_cobblestone"); - @Nullable public static final ItemType MOSSY_COBBLESTONE_WALL = register("minecraft:mossy_cobblestone_wall"); - @Nullable public static final ItemType MOSSY_STONE_BRICKS = register("minecraft:mossy_stone_bricks"); - @Nullable public static final ItemType MULE_SPAWN_EGG = register("minecraft:mule_spawn_egg"); - @Nullable public static final ItemType MUSHROOM_STEM = register("minecraft:mushroom_stem"); - @Nullable public static final ItemType MUSHROOM_STEW = register("minecraft:mushroom_stew"); - @Nullable public static final ItemType MUSIC_DISC_11 = register("minecraft:music_disc_11"); - @Nullable public static final ItemType MUSIC_DISC_13 = register("minecraft:music_disc_13"); - @Nullable public static final ItemType MUSIC_DISC_BLOCKS = register("minecraft:music_disc_blocks"); - @Nullable public static final ItemType MUSIC_DISC_CAT = register("minecraft:music_disc_cat"); - @Nullable public static final ItemType MUSIC_DISC_CHIRP = register("minecraft:music_disc_chirp"); - @Nullable public static final ItemType MUSIC_DISC_FAR = register("minecraft:music_disc_far"); - @Nullable public static final ItemType MUSIC_DISC_MALL = register("minecraft:music_disc_mall"); - @Nullable public static final ItemType MUSIC_DISC_MELLOHI = register("minecraft:music_disc_mellohi"); - @Nullable public static final ItemType MUSIC_DISC_STAL = register("minecraft:music_disc_stal"); - @Nullable public static final ItemType MUSIC_DISC_STRAD = register("minecraft:music_disc_strad"); - @Nullable public static final ItemType MUSIC_DISC_WAIT = register("minecraft:music_disc_wait"); - @Nullable public static final ItemType MUSIC_DISC_WARD = register("minecraft:music_disc_ward"); - @Nullable public static final ItemType MUTTON = register("minecraft:mutton"); - @Nullable public static final ItemType MYCELIUM = register("minecraft:mycelium"); - @Nullable public static final ItemType NAME_TAG = register("minecraft:name_tag"); - @Nullable public static final ItemType NAUTILUS_SHELL = register("minecraft:nautilus_shell"); - @Nullable public static final ItemType NETHER_BRICK = register("minecraft:nether_brick"); - @Nullable public static final ItemType NETHER_BRICK_FENCE = register("minecraft:nether_brick_fence"); - @Nullable public static final ItemType NETHER_BRICK_SLAB = register("minecraft:nether_brick_slab"); - @Nullable public static final ItemType NETHER_BRICK_STAIRS = register("minecraft:nether_brick_stairs"); - @Nullable public static final ItemType NETHER_BRICKS = register("minecraft:nether_bricks"); - @Nullable public static final ItemType NETHER_QUARTZ_ORE = register("minecraft:nether_quartz_ore"); - @Nullable public static final ItemType NETHER_STAR = register("minecraft:nether_star"); - @Nullable public static final ItemType NETHER_WART = register("minecraft:nether_wart"); - @Nullable public static final ItemType NETHER_WART_BLOCK = register("minecraft:nether_wart_block"); - @Nullable public static final ItemType NETHERRACK = register("minecraft:netherrack"); - @Nullable public static final ItemType NOTE_BLOCK = register("minecraft:note_block"); - @Nullable public static final ItemType OAK_BOAT = register("minecraft:oak_boat"); - @Nullable public static final ItemType OAK_BUTTON = register("minecraft:oak_button"); - @Nullable public static final ItemType OAK_DOOR = register("minecraft:oak_door"); - @Nullable public static final ItemType OAK_FENCE = register("minecraft:oak_fence"); - @Nullable public static final ItemType OAK_FENCE_GATE = register("minecraft:oak_fence_gate"); - @Nullable public static final ItemType OAK_LEAVES = register("minecraft:oak_leaves"); - @Nullable public static final ItemType OAK_LOG = register("minecraft:oak_log"); - @Nullable public static final ItemType OAK_PLANKS = register("minecraft:oak_planks"); - @Nullable public static final ItemType OAK_PRESSURE_PLATE = register("minecraft:oak_pressure_plate"); - @Nullable public static final ItemType OAK_SAPLING = register("minecraft:oak_sapling"); - @Nullable public static final ItemType OAK_SLAB = register("minecraft:oak_slab"); - @Nullable public static final ItemType OAK_STAIRS = register("minecraft:oak_stairs"); - @Nullable public static final ItemType OAK_TRAPDOOR = register("minecraft:oak_trapdoor"); - @Nullable public static final ItemType OAK_WOOD = register("minecraft:oak_wood"); - @Nullable public static final ItemType OBSERVER = register("minecraft:observer"); - @Nullable public static final ItemType OBSIDIAN = register("minecraft:obsidian"); - @Nullable public static final ItemType OCELOT_SPAWN_EGG = register("minecraft:ocelot_spawn_egg"); - @Nullable public static final ItemType ORANGE_BANNER = register("minecraft:orange_banner"); - @Nullable public static final ItemType ORANGE_BED = register("minecraft:orange_bed"); - @Nullable public static final ItemType ORANGE_CARPET = register("minecraft:orange_carpet"); - @Nullable public static final ItemType ORANGE_CONCRETE = register("minecraft:orange_concrete"); - @Nullable public static final ItemType ORANGE_CONCRETE_POWDER = register("minecraft:orange_concrete_powder"); - @Nullable public static final ItemType ORANGE_DYE = register("minecraft:orange_dye"); - @Nullable public static final ItemType ORANGE_GLAZED_TERRACOTTA = register("minecraft:orange_glazed_terracotta"); - @Nullable public static final ItemType ORANGE_SHULKER_BOX = register("minecraft:orange_shulker_box"); - @Nullable public static final ItemType ORANGE_STAINED_GLASS = register("minecraft:orange_stained_glass"); - @Nullable public static final ItemType ORANGE_STAINED_GLASS_PANE = register("minecraft:orange_stained_glass_pane"); - @Nullable public static final ItemType ORANGE_TERRACOTTA = register("minecraft:orange_terracotta"); - @Nullable public static final ItemType ORANGE_TULIP = register("minecraft:orange_tulip"); - @Nullable public static final ItemType ORANGE_WOOL = register("minecraft:orange_wool"); - @Nullable public static final ItemType OXEYE_DAISY = register("minecraft:oxeye_daisy"); - @Nullable public static final ItemType PACKED_ICE = register("minecraft:packed_ice"); - @Nullable public static final ItemType PAINTING = register("minecraft:painting"); - @Nullable public static final ItemType PAPER = register("minecraft:paper"); - @Nullable public static final ItemType PARROT_SPAWN_EGG = register("minecraft:parrot_spawn_egg"); - @Nullable public static final ItemType PEONY = register("minecraft:peony"); - @Nullable public static final ItemType PETRIFIED_OAK_SLAB = register("minecraft:petrified_oak_slab"); - @Nullable public static final ItemType PHANTOM_MEMBRANE = register("minecraft:phantom_membrane"); - @Nullable public static final ItemType PHANTOM_SPAWN_EGG = register("minecraft:phantom_spawn_egg"); - @Nullable public static final ItemType PIG_SPAWN_EGG = register("minecraft:pig_spawn_egg"); - @Nullable public static final ItemType PINK_BANNER = register("minecraft:pink_banner"); - @Nullable public static final ItemType PINK_BED = register("minecraft:pink_bed"); - @Nullable public static final ItemType PINK_CARPET = register("minecraft:pink_carpet"); - @Nullable public static final ItemType PINK_CONCRETE = register("minecraft:pink_concrete"); - @Nullable public static final ItemType PINK_CONCRETE_POWDER = register("minecraft:pink_concrete_powder"); - @Nullable public static final ItemType PINK_DYE = register("minecraft:pink_dye"); - @Nullable public static final ItemType PINK_GLAZED_TERRACOTTA = register("minecraft:pink_glazed_terracotta"); - @Nullable public static final ItemType PINK_SHULKER_BOX = register("minecraft:pink_shulker_box"); - @Nullable public static final ItemType PINK_STAINED_GLASS = register("minecraft:pink_stained_glass"); - @Nullable public static final ItemType PINK_STAINED_GLASS_PANE = register("minecraft:pink_stained_glass_pane"); - @Nullable public static final ItemType PINK_TERRACOTTA = register("minecraft:pink_terracotta"); - @Nullable public static final ItemType PINK_TULIP = register("minecraft:pink_tulip"); - @Nullable public static final ItemType PINK_WOOL = register("minecraft:pink_wool"); - @Nullable public static final ItemType PISTON = register("minecraft:piston"); - @Nullable public static final ItemType PLAYER_HEAD = register("minecraft:player_head"); - @Nullable public static final ItemType PODZOL = register("minecraft:podzol"); - @Nullable public static final ItemType POISONOUS_POTATO = register("minecraft:poisonous_potato"); - @Nullable public static final ItemType POLAR_BEAR_SPAWN_EGG = register("minecraft:polar_bear_spawn_egg"); - @Nullable public static final ItemType POLISHED_ANDESITE = register("minecraft:polished_andesite"); - @Nullable public static final ItemType POLISHED_DIORITE = register("minecraft:polished_diorite"); - @Nullable public static final ItemType POLISHED_GRANITE = register("minecraft:polished_granite"); - @Nullable public static final ItemType POPPED_CHORUS_FRUIT = register("minecraft:popped_chorus_fruit"); - @Nullable public static final ItemType POPPY = register("minecraft:poppy"); - @Nullable public static final ItemType PORKCHOP = register("minecraft:porkchop"); - @Nullable public static final ItemType POTATO = register("minecraft:potato"); - @Nullable public static final ItemType POTION = register("minecraft:potion"); - @Nullable public static final ItemType POWERED_RAIL = register("minecraft:powered_rail"); - @Nullable public static final ItemType PRISMARINE = register("minecraft:prismarine"); - @Nullable public static final ItemType PRISMARINE_BRICK_SLAB = register("minecraft:prismarine_brick_slab"); - @Nullable public static final ItemType PRISMARINE_BRICK_STAIRS = register("minecraft:prismarine_brick_stairs"); - @Nullable public static final ItemType PRISMARINE_BRICKS = register("minecraft:prismarine_bricks"); - @Nullable public static final ItemType PRISMARINE_CRYSTALS = register("minecraft:prismarine_crystals"); - @Nullable public static final ItemType PRISMARINE_SHARD = register("minecraft:prismarine_shard"); - @Nullable public static final ItemType PRISMARINE_SLAB = register("minecraft:prismarine_slab"); - @Nullable public static final ItemType PRISMARINE_STAIRS = register("minecraft:prismarine_stairs"); - @Nullable public static final ItemType PUFFERFISH = register("minecraft:pufferfish"); - @Nullable public static final ItemType PUFFERFISH_BUCKET = register("minecraft:pufferfish_bucket"); - @Nullable public static final ItemType PUFFERFISH_SPAWN_EGG = register("minecraft:pufferfish_spawn_egg"); - @Nullable public static final ItemType PUMPKIN = register("minecraft:pumpkin"); - @Nullable public static final ItemType PUMPKIN_PIE = register("minecraft:pumpkin_pie"); - @Nullable public static final ItemType PUMPKIN_SEEDS = register("minecraft:pumpkin_seeds"); - @Nullable public static final ItemType PURPLE_BANNER = register("minecraft:purple_banner"); - @Nullable public static final ItemType PURPLE_BED = register("minecraft:purple_bed"); - @Nullable public static final ItemType PURPLE_CARPET = register("minecraft:purple_carpet"); - @Nullable public static final ItemType PURPLE_CONCRETE = register("minecraft:purple_concrete"); - @Nullable public static final ItemType PURPLE_CONCRETE_POWDER = register("minecraft:purple_concrete_powder"); - @Nullable public static final ItemType PURPLE_DYE = register("minecraft:purple_dye"); - @Nullable public static final ItemType PURPLE_GLAZED_TERRACOTTA = register("minecraft:purple_glazed_terracotta"); - @Nullable public static final ItemType PURPLE_SHULKER_BOX = register("minecraft:purple_shulker_box"); - @Nullable public static final ItemType PURPLE_STAINED_GLASS = register("minecraft:purple_stained_glass"); - @Nullable public static final ItemType PURPLE_STAINED_GLASS_PANE = register("minecraft:purple_stained_glass_pane"); - @Nullable public static final ItemType PURPLE_TERRACOTTA = register("minecraft:purple_terracotta"); - @Nullable public static final ItemType PURPLE_WOOL = register("minecraft:purple_wool"); - @Nullable public static final ItemType PURPUR_BLOCK = register("minecraft:purpur_block"); - @Nullable public static final ItemType PURPUR_PILLAR = register("minecraft:purpur_pillar"); - @Nullable public static final ItemType PURPUR_SLAB = register("minecraft:purpur_slab"); - @Nullable public static final ItemType PURPUR_STAIRS = register("minecraft:purpur_stairs"); - @Nullable public static final ItemType QUARTZ = register("minecraft:quartz"); - @Nullable public static final ItemType QUARTZ_BLOCK = register("minecraft:quartz_block"); - @Nullable public static final ItemType QUARTZ_PILLAR = register("minecraft:quartz_pillar"); - @Nullable public static final ItemType QUARTZ_SLAB = register("minecraft:quartz_slab"); - @Nullable public static final ItemType QUARTZ_STAIRS = register("minecraft:quartz_stairs"); - @Nullable public static final ItemType RABBIT = register("minecraft:rabbit"); - @Nullable public static final ItemType RABBIT_FOOT = register("minecraft:rabbit_foot"); - @Nullable public static final ItemType RABBIT_HIDE = register("minecraft:rabbit_hide"); - @Nullable public static final ItemType RABBIT_SPAWN_EGG = register("minecraft:rabbit_spawn_egg"); - @Nullable public static final ItemType RABBIT_STEW = register("minecraft:rabbit_stew"); - @Nullable public static final ItemType RAIL = register("minecraft:rail"); - @Nullable public static final ItemType RED_BANNER = register("minecraft:red_banner"); - @Nullable public static final ItemType RED_BED = register("minecraft:red_bed"); - @Nullable public static final ItemType RED_CARPET = register("minecraft:red_carpet"); - @Nullable public static final ItemType RED_CONCRETE = register("minecraft:red_concrete"); - @Nullable public static final ItemType RED_CONCRETE_POWDER = register("minecraft:red_concrete_powder"); - @Nullable public static final ItemType RED_GLAZED_TERRACOTTA = register("minecraft:red_glazed_terracotta"); - @Nullable public static final ItemType RED_MUSHROOM = register("minecraft:red_mushroom"); - @Nullable public static final ItemType RED_MUSHROOM_BLOCK = register("minecraft:red_mushroom_block"); - @Nullable public static final ItemType RED_NETHER_BRICKS = register("minecraft:red_nether_bricks"); - @Nullable public static final ItemType RED_SAND = register("minecraft:red_sand"); - @Nullable public static final ItemType RED_SANDSTONE = register("minecraft:red_sandstone"); - @Nullable public static final ItemType RED_SANDSTONE_SLAB = register("minecraft:red_sandstone_slab"); - @Nullable public static final ItemType RED_SANDSTONE_STAIRS = register("minecraft:red_sandstone_stairs"); - @Nullable public static final ItemType RED_SHULKER_BOX = register("minecraft:red_shulker_box"); - @Nullable public static final ItemType RED_STAINED_GLASS = register("minecraft:red_stained_glass"); - @Nullable public static final ItemType RED_STAINED_GLASS_PANE = register("minecraft:red_stained_glass_pane"); - @Nullable public static final ItemType RED_TERRACOTTA = register("minecraft:red_terracotta"); - @Nullable public static final ItemType RED_TULIP = register("minecraft:red_tulip"); - @Nullable public static final ItemType RED_WOOL = register("minecraft:red_wool"); - @Nullable public static final ItemType REDSTONE = register("minecraft:redstone"); - @Nullable public static final ItemType REDSTONE_BLOCK = register("minecraft:redstone_block"); - @Nullable public static final ItemType REDSTONE_LAMP = register("minecraft:redstone_lamp"); - @Nullable public static final ItemType REDSTONE_ORE = register("minecraft:redstone_ore"); - @Nullable public static final ItemType REDSTONE_TORCH = register("minecraft:redstone_torch"); - @Nullable public static final ItemType REPEATER = register("minecraft:repeater"); - @Nullable public static final ItemType REPEATING_COMMAND_BLOCK = register("minecraft:repeating_command_block"); - @Nullable public static final ItemType ROSE_BUSH = register("minecraft:rose_bush"); - @Nullable public static final ItemType ROSE_RED = register("minecraft:rose_red"); - @Nullable public static final ItemType ROTTEN_FLESH = register("minecraft:rotten_flesh"); - @Nullable public static final ItemType SADDLE = register("minecraft:saddle"); - @Nullable public static final ItemType SALMON = register("minecraft:salmon"); - @Nullable public static final ItemType SALMON_BUCKET = register("minecraft:salmon_bucket"); - @Nullable public static final ItemType SALMON_SPAWN_EGG = register("minecraft:salmon_spawn_egg"); - @Nullable public static final ItemType SAND = register("minecraft:sand"); - @Nullable public static final ItemType SANDSTONE = register("minecraft:sandstone"); - @Nullable public static final ItemType SANDSTONE_SLAB = register("minecraft:sandstone_slab"); - @Nullable public static final ItemType SANDSTONE_STAIRS = register("minecraft:sandstone_stairs"); - @Nullable public static final ItemType SCUTE = register("minecraft:scute"); - @Nullable public static final ItemType SEA_LANTERN = register("minecraft:sea_lantern"); - @Nullable public static final ItemType SEA_PICKLE = register("minecraft:sea_pickle"); - @Nullable public static final ItemType SEAGRASS = register("minecraft:seagrass"); - @Nullable public static final ItemType SHEARS = register("minecraft:shears"); - @Nullable public static final ItemType SHEEP_SPAWN_EGG = register("minecraft:sheep_spawn_egg"); - @Nullable public static final ItemType SHIELD = register("minecraft:shield"); - @Nullable public static final ItemType SHULKER_BOX = register("minecraft:shulker_box"); - @Nullable public static final ItemType SHULKER_SHELL = register("minecraft:shulker_shell"); - @Nullable public static final ItemType SHULKER_SPAWN_EGG = register("minecraft:shulker_spawn_egg"); - @Nullable public static final ItemType SIGN = register("minecraft:sign"); - @Nullable public static final ItemType SILVERFISH_SPAWN_EGG = register("minecraft:silverfish_spawn_egg"); - @Nullable public static final ItemType SKELETON_HORSE_SPAWN_EGG = register("minecraft:skeleton_horse_spawn_egg"); - @Nullable public static final ItemType SKELETON_SKULL = register("minecraft:skeleton_skull"); - @Nullable public static final ItemType SKELETON_SPAWN_EGG = register("minecraft:skeleton_spawn_egg"); - @Nullable public static final ItemType SLIME_BALL = register("minecraft:slime_ball"); - @Nullable public static final ItemType SLIME_BLOCK = register("minecraft:slime_block"); - @Nullable public static final ItemType SLIME_SPAWN_EGG = register("minecraft:slime_spawn_egg"); - @Nullable public static final ItemType SMOOTH_QUARTZ = register("minecraft:smooth_quartz"); - @Nullable public static final ItemType SMOOTH_RED_SANDSTONE = register("minecraft:smooth_red_sandstone"); - @Nullable public static final ItemType SMOOTH_SANDSTONE = register("minecraft:smooth_sandstone"); - @Nullable public static final ItemType SMOOTH_STONE = register("minecraft:smooth_stone"); - @Nullable public static final ItemType SNOW = register("minecraft:snow"); - @Nullable public static final ItemType SNOW_BLOCK = register("minecraft:snow_block"); - @Nullable public static final ItemType SNOWBALL = register("minecraft:snowball"); - @Nullable public static final ItemType SOUL_SAND = register("minecraft:soul_sand"); - @Nullable public static final ItemType SPAWNER = register("minecraft:spawner"); - @Nullable public static final ItemType SPECTRAL_ARROW = register("minecraft:spectral_arrow"); - @Nullable public static final ItemType SPIDER_EYE = register("minecraft:spider_eye"); - @Nullable public static final ItemType SPIDER_SPAWN_EGG = register("minecraft:spider_spawn_egg"); - @Nullable public static final ItemType SPLASH_POTION = register("minecraft:splash_potion"); - @Nullable public static final ItemType SPONGE = register("minecraft:sponge"); - @Nullable public static final ItemType SPRUCE_BOAT = register("minecraft:spruce_boat"); - @Nullable public static final ItemType SPRUCE_BUTTON = register("minecraft:spruce_button"); - @Nullable public static final ItemType SPRUCE_DOOR = register("minecraft:spruce_door"); - @Nullable public static final ItemType SPRUCE_FENCE = register("minecraft:spruce_fence"); - @Nullable public static final ItemType SPRUCE_FENCE_GATE = register("minecraft:spruce_fence_gate"); - @Nullable public static final ItemType SPRUCE_LEAVES = register("minecraft:spruce_leaves"); - @Nullable public static final ItemType SPRUCE_LOG = register("minecraft:spruce_log"); - @Nullable public static final ItemType SPRUCE_PLANKS = register("minecraft:spruce_planks"); - @Nullable public static final ItemType SPRUCE_PRESSURE_PLATE = register("minecraft:spruce_pressure_plate"); - @Nullable public static final ItemType SPRUCE_SAPLING = register("minecraft:spruce_sapling"); - @Nullable public static final ItemType SPRUCE_SLAB = register("minecraft:spruce_slab"); - @Nullable public static final ItemType SPRUCE_STAIRS = register("minecraft:spruce_stairs"); - @Nullable public static final ItemType SPRUCE_TRAPDOOR = register("minecraft:spruce_trapdoor"); - @Nullable public static final ItemType SPRUCE_WOOD = register("minecraft:spruce_wood"); - @Nullable public static final ItemType SQUID_SPAWN_EGG = register("minecraft:squid_spawn_egg"); - @Nullable public static final ItemType STICK = register("minecraft:stick"); - @Nullable public static final ItemType STICKY_PISTON = register("minecraft:sticky_piston"); - @Nullable public static final ItemType STONE = register("minecraft:stone"); - @Nullable public static final ItemType STONE_AXE = register("minecraft:stone_axe"); - @Nullable public static final ItemType STONE_BRICK_SLAB = register("minecraft:stone_brick_slab"); - @Nullable public static final ItemType STONE_BRICK_STAIRS = register("minecraft:stone_brick_stairs"); - @Nullable public static final ItemType STONE_BRICKS = register("minecraft:stone_bricks"); - @Nullable public static final ItemType STONE_BUTTON = register("minecraft:stone_button"); - @Nullable public static final ItemType STONE_HOE = register("minecraft:stone_hoe"); - @Nullable public static final ItemType STONE_PICKAXE = register("minecraft:stone_pickaxe"); - @Nullable public static final ItemType STONE_PRESSURE_PLATE = register("minecraft:stone_pressure_plate"); - @Nullable public static final ItemType STONE_SHOVEL = register("minecraft:stone_shovel"); - @Nullable public static final ItemType STONE_SLAB = register("minecraft:stone_slab"); - @Nullable public static final ItemType STONE_SWORD = register("minecraft:stone_sword"); - @Nullable public static final ItemType STRAY_SPAWN_EGG = register("minecraft:stray_spawn_egg"); - @Nullable public static final ItemType STRING = register("minecraft:string"); - @Nullable public static final ItemType STRIPPED_ACACIA_LOG = register("minecraft:stripped_acacia_log"); - @Nullable public static final ItemType STRIPPED_ACACIA_WOOD = register("minecraft:stripped_acacia_wood"); - @Nullable public static final ItemType STRIPPED_BIRCH_LOG = register("minecraft:stripped_birch_log"); - @Nullable public static final ItemType STRIPPED_BIRCH_WOOD = register("minecraft:stripped_birch_wood"); - @Nullable public static final ItemType STRIPPED_DARK_OAK_LOG = register("minecraft:stripped_dark_oak_log"); - @Nullable public static final ItemType STRIPPED_DARK_OAK_WOOD = register("minecraft:stripped_dark_oak_wood"); - @Nullable public static final ItemType STRIPPED_JUNGLE_LOG = register("minecraft:stripped_jungle_log"); - @Nullable public static final ItemType STRIPPED_JUNGLE_WOOD = register("minecraft:stripped_jungle_wood"); - @Nullable public static final ItemType STRIPPED_OAK_LOG = register("minecraft:stripped_oak_log"); - @Nullable public static final ItemType STRIPPED_OAK_WOOD = register("minecraft:stripped_oak_wood"); - @Nullable public static final ItemType STRIPPED_SPRUCE_LOG = register("minecraft:stripped_spruce_log"); - @Nullable public static final ItemType STRIPPED_SPRUCE_WOOD = register("minecraft:stripped_spruce_wood"); - @Nullable public static final ItemType STRUCTURE_BLOCK = register("minecraft:structure_block"); - @Nullable public static final ItemType STRUCTURE_VOID = register("minecraft:structure_void"); - @Nullable public static final ItemType SUGAR = register("minecraft:sugar"); - @Nullable public static final ItemType SUGAR_CANE = register("minecraft:sugar_cane"); - @Nullable public static final ItemType SUNFLOWER = register("minecraft:sunflower"); - @Nullable public static final ItemType TALL_GRASS = register("minecraft:tall_grass"); - @Nullable public static final ItemType TERRACOTTA = register("minecraft:terracotta"); - @Nullable public static final ItemType TIPPED_ARROW = register("minecraft:tipped_arrow"); - @Nullable public static final ItemType TNT = register("minecraft:tnt"); - @Nullable public static final ItemType TNT_MINECART = register("minecraft:tnt_minecart"); - @Nullable public static final ItemType TORCH = register("minecraft:torch"); - @Nullable public static final ItemType TOTEM_OF_UNDYING = register("minecraft:totem_of_undying"); - @Nullable public static final ItemType TRAPPED_CHEST = register("minecraft:trapped_chest"); - @Nullable public static final ItemType TRIDENT = register("minecraft:trident"); - @Nullable public static final ItemType TRIPWIRE_HOOK = register("minecraft:tripwire_hook"); - @Nullable public static final ItemType TROPICAL_FISH = register("minecraft:tropical_fish"); - @Nullable public static final ItemType TROPICAL_FISH_BUCKET = register("minecraft:tropical_fish_bucket"); - @Nullable public static final ItemType TROPICAL_FISH_SPAWN_EGG = register("minecraft:tropical_fish_spawn_egg"); - @Nullable public static final ItemType TUBE_CORAL = register("minecraft:tube_coral"); - @Nullable public static final ItemType TUBE_CORAL_BLOCK = register("minecraft:tube_coral_block"); - @Nullable public static final ItemType TUBE_CORAL_FAN = register("minecraft:tube_coral_fan"); - @Nullable public static final ItemType TURTLE_EGG = register("minecraft:turtle_egg"); - @Nullable public static final ItemType TURTLE_HELMET = register("minecraft:turtle_helmet"); - @Nullable public static final ItemType TURTLE_SPAWN_EGG = register("minecraft:turtle_spawn_egg"); - @Nullable public static final ItemType VEX_SPAWN_EGG = register("minecraft:vex_spawn_egg"); - @Nullable public static final ItemType VILLAGER_SPAWN_EGG = register("minecraft:villager_spawn_egg"); - @Nullable public static final ItemType VINDICATOR_SPAWN_EGG = register("minecraft:vindicator_spawn_egg"); - @Nullable public static final ItemType VINE = register("minecraft:vine"); - @Nullable public static final ItemType WATER_BUCKET = register("minecraft:water_bucket"); - @Nullable public static final ItemType WET_SPONGE = register("minecraft:wet_sponge"); - @Nullable public static final ItemType WHEAT = register("minecraft:wheat"); - @Nullable public static final ItemType WHEAT_SEEDS = register("minecraft:wheat_seeds"); - @Nullable public static final ItemType WHITE_BANNER = register("minecraft:white_banner"); - @Nullable public static final ItemType WHITE_BED = register("minecraft:white_bed"); - @Nullable public static final ItemType WHITE_CARPET = register("minecraft:white_carpet"); - @Nullable public static final ItemType WHITE_CONCRETE = register("minecraft:white_concrete"); - @Nullable public static final ItemType WHITE_CONCRETE_POWDER = register("minecraft:white_concrete_powder"); - @Nullable public static final ItemType WHITE_GLAZED_TERRACOTTA = register("minecraft:white_glazed_terracotta"); - @Nullable public static final ItemType WHITE_SHULKER_BOX = register("minecraft:white_shulker_box"); - @Nullable public static final ItemType WHITE_STAINED_GLASS = register("minecraft:white_stained_glass"); - @Nullable public static final ItemType WHITE_STAINED_GLASS_PANE = register("minecraft:white_stained_glass_pane"); - @Nullable public static final ItemType WHITE_TERRACOTTA = register("minecraft:white_terracotta"); - @Nullable public static final ItemType WHITE_TULIP = register("minecraft:white_tulip"); - @Nullable public static final ItemType WHITE_WOOL = register("minecraft:white_wool"); - @Nullable public static final ItemType WITCH_SPAWN_EGG = register("minecraft:witch_spawn_egg"); - @Nullable public static final ItemType WITHER_SKELETON_SKULL = register("minecraft:wither_skeleton_skull"); - @Nullable public static final ItemType WITHER_SKELETON_SPAWN_EGG = register("minecraft:wither_skeleton_spawn_egg"); - @Nullable public static final ItemType WOLF_SPAWN_EGG = register("minecraft:wolf_spawn_egg"); - @Nullable public static final ItemType WOODEN_AXE = register("minecraft:wooden_axe"); - @Nullable public static final ItemType WOODEN_HOE = register("minecraft:wooden_hoe"); - @Nullable public static final ItemType WOODEN_PICKAXE = register("minecraft:wooden_pickaxe"); - @Nullable public static final ItemType WOODEN_SHOVEL = register("minecraft:wooden_shovel"); - @Nullable public static final ItemType WOODEN_SWORD = register("minecraft:wooden_sword"); - @Nullable public static final ItemType WRITABLE_BOOK = register("minecraft:writable_book"); - @Nullable public static final ItemType WRITTEN_BOOK = register("minecraft:written_book"); - @Nullable public static final ItemType YELLOW_BANNER = register("minecraft:yellow_banner"); - @Nullable public static final ItemType YELLOW_BED = register("minecraft:yellow_bed"); - @Nullable public static final ItemType YELLOW_CARPET = register("minecraft:yellow_carpet"); - @Nullable public static final ItemType YELLOW_CONCRETE = register("minecraft:yellow_concrete"); - @Nullable public static final ItemType YELLOW_CONCRETE_POWDER = register("minecraft:yellow_concrete_powder"); - @Nullable public static final ItemType YELLOW_GLAZED_TERRACOTTA = register("minecraft:yellow_glazed_terracotta"); - @Nullable public static final ItemType YELLOW_SHULKER_BOX = register("minecraft:yellow_shulker_box"); - @Nullable public static final ItemType YELLOW_STAINED_GLASS = register("minecraft:yellow_stained_glass"); - @Nullable public static final ItemType YELLOW_STAINED_GLASS_PANE = register("minecraft:yellow_stained_glass_pane"); - @Nullable public static final ItemType YELLOW_TERRACOTTA = register("minecraft:yellow_terracotta"); - @Nullable public static final ItemType YELLOW_WOOL = register("minecraft:yellow_wool"); - @Nullable public static final ItemType ZOMBIE_HEAD = register("minecraft:zombie_head"); - @Nullable public static final ItemType ZOMBIE_HORSE_SPAWN_EGG = register("minecraft:zombie_horse_spawn_egg"); - @Nullable public static final ItemType ZOMBIE_PIGMAN_SPAWN_EGG = register("minecraft:zombie_pigman_spawn_egg"); - @Nullable public static final ItemType ZOMBIE_SPAWN_EGG = register("minecraft:zombie_spawn_egg"); - @Nullable public static final ItemType ZOMBIE_VILLAGER_SPAWN_EGG = register("minecraft:zombie_villager_spawn_egg"); + @Nullable public static final ItemType ACACIA_BOAT = get("minecraft:acacia_boat"); + @Nullable public static final ItemType ACACIA_BUTTON = get("minecraft:acacia_button"); + @Nullable public static final ItemType ACACIA_DOOR = get("minecraft:acacia_door"); + @Nullable public static final ItemType ACACIA_FENCE = get("minecraft:acacia_fence"); + @Nullable public static final ItemType ACACIA_FENCE_GATE = get("minecraft:acacia_fence_gate"); + @Nullable public static final ItemType ACACIA_LEAVES = get("minecraft:acacia_leaves"); + @Nullable public static final ItemType ACACIA_LOG = get("minecraft:acacia_log"); + @Nullable public static final ItemType ACACIA_PLANKS = get("minecraft:acacia_planks"); + @Nullable public static final ItemType ACACIA_PRESSURE_PLATE = get("minecraft:acacia_pressure_plate"); + @Nullable public static final ItemType ACACIA_SAPLING = get("minecraft:acacia_sapling"); + @Nullable public static final ItemType ACACIA_SLAB = get("minecraft:acacia_slab"); + @Nullable public static final ItemType ACACIA_STAIRS = get("minecraft:acacia_stairs"); + @Nullable public static final ItemType ACACIA_TRAPDOOR = get("minecraft:acacia_trapdoor"); + @Nullable public static final ItemType ACACIA_WOOD = get("minecraft:acacia_wood"); + @Nullable public static final ItemType ACTIVATOR_RAIL = get("minecraft:activator_rail"); + @Nullable public static final ItemType AIR = get("minecraft:air"); + @Nullable public static final ItemType ALLIUM = get("minecraft:allium"); + @Nullable public static final ItemType ANDESITE = get("minecraft:andesite"); + @Nullable public static final ItemType ANVIL = get("minecraft:anvil"); + @Nullable public static final ItemType APPLE = get("minecraft:apple"); + @Nullable public static final ItemType ARMOR_STAND = get("minecraft:armor_stand"); + @Nullable public static final ItemType ARROW = get("minecraft:arrow"); + @Nullable public static final ItemType AZURE_BLUET = get("minecraft:azure_bluet"); + @Nullable public static final ItemType BAKED_POTATO = get("minecraft:baked_potato"); + @Nullable public static final ItemType BARRIER = get("minecraft:barrier"); + @Nullable public static final ItemType BAT_SPAWN_EGG = get("minecraft:bat_spawn_egg"); + @Nullable public static final ItemType BEACON = get("minecraft:beacon"); + @Nullable public static final ItemType BEDROCK = get("minecraft:bedrock"); + @Nullable public static final ItemType BEEF = get("minecraft:beef"); + @Nullable public static final ItemType BEETROOT = get("minecraft:beetroot"); + @Nullable public static final ItemType BEETROOT_SEEDS = get("minecraft:beetroot_seeds"); + @Nullable public static final ItemType BEETROOT_SOUP = get("minecraft:beetroot_soup"); + @Nullable public static final ItemType BIRCH_BOAT = get("minecraft:birch_boat"); + @Nullable public static final ItemType BIRCH_BUTTON = get("minecraft:birch_button"); + @Nullable public static final ItemType BIRCH_DOOR = get("minecraft:birch_door"); + @Nullable public static final ItemType BIRCH_FENCE = get("minecraft:birch_fence"); + @Nullable public static final ItemType BIRCH_FENCE_GATE = get("minecraft:birch_fence_gate"); + @Nullable public static final ItemType BIRCH_LEAVES = get("minecraft:birch_leaves"); + @Nullable public static final ItemType BIRCH_LOG = get("minecraft:birch_log"); + @Nullable public static final ItemType BIRCH_PLANKS = get("minecraft:birch_planks"); + @Nullable public static final ItemType BIRCH_PRESSURE_PLATE = get("minecraft:birch_pressure_plate"); + @Nullable public static final ItemType BIRCH_SAPLING = get("minecraft:birch_sapling"); + @Nullable public static final ItemType BIRCH_SLAB = get("minecraft:birch_slab"); + @Nullable public static final ItemType BIRCH_STAIRS = get("minecraft:birch_stairs"); + @Nullable public static final ItemType BIRCH_TRAPDOOR = get("minecraft:birch_trapdoor"); + @Nullable public static final ItemType BIRCH_WOOD = get("minecraft:birch_wood"); + @Nullable public static final ItemType BLACK_BANNER = get("minecraft:black_banner"); + @Nullable public static final ItemType BLACK_BED = get("minecraft:black_bed"); + @Nullable public static final ItemType BLACK_CARPET = get("minecraft:black_carpet"); + @Nullable public static final ItemType BLACK_CONCRETE = get("minecraft:black_concrete"); + @Nullable public static final ItemType BLACK_CONCRETE_POWDER = get("minecraft:black_concrete_powder"); + @Nullable public static final ItemType BLACK_GLAZED_TERRACOTTA = get("minecraft:black_glazed_terracotta"); + @Nullable public static final ItemType BLACK_SHULKER_BOX = get("minecraft:black_shulker_box"); + @Nullable public static final ItemType BLACK_STAINED_GLASS = get("minecraft:black_stained_glass"); + @Nullable public static final ItemType BLACK_STAINED_GLASS_PANE = get("minecraft:black_stained_glass_pane"); + @Nullable public static final ItemType BLACK_TERRACOTTA = get("minecraft:black_terracotta"); + @Nullable public static final ItemType BLACK_WOOL = get("minecraft:black_wool"); + @Nullable public static final ItemType BLAZE_POWDER = get("minecraft:blaze_powder"); + @Nullable public static final ItemType BLAZE_ROD = get("minecraft:blaze_rod"); + @Nullable public static final ItemType BLAZE_SPAWN_EGG = get("minecraft:blaze_spawn_egg"); + @Nullable public static final ItemType BLUE_BANNER = get("minecraft:blue_banner"); + @Nullable public static final ItemType BLUE_BED = get("minecraft:blue_bed"); + @Nullable public static final ItemType BLUE_CARPET = get("minecraft:blue_carpet"); + @Nullable public static final ItemType BLUE_CONCRETE = get("minecraft:blue_concrete"); + @Nullable public static final ItemType BLUE_CONCRETE_POWDER = get("minecraft:blue_concrete_powder"); + @Nullable public static final ItemType BLUE_GLAZED_TERRACOTTA = get("minecraft:blue_glazed_terracotta"); + @Nullable public static final ItemType BLUE_ICE = get("minecraft:blue_ice"); + @Nullable public static final ItemType BLUE_ORCHID = get("minecraft:blue_orchid"); + @Nullable public static final ItemType BLUE_SHULKER_BOX = get("minecraft:blue_shulker_box"); + @Nullable public static final ItemType BLUE_STAINED_GLASS = get("minecraft:blue_stained_glass"); + @Nullable public static final ItemType BLUE_STAINED_GLASS_PANE = get("minecraft:blue_stained_glass_pane"); + @Nullable public static final ItemType BLUE_TERRACOTTA = get("minecraft:blue_terracotta"); + @Nullable public static final ItemType BLUE_WOOL = get("minecraft:blue_wool"); + @Nullable public static final ItemType BONE = get("minecraft:bone"); + @Nullable public static final ItemType BONE_BLOCK = get("minecraft:bone_block"); + @Nullable public static final ItemType BONE_MEAL = get("minecraft:bone_meal"); + @Nullable public static final ItemType BOOK = get("minecraft:book"); + @Nullable public static final ItemType BOOKSHELF = get("minecraft:bookshelf"); + @Nullable public static final ItemType BOW = get("minecraft:bow"); + @Nullable public static final ItemType BOWL = get("minecraft:bowl"); + @Nullable public static final ItemType BRAIN_CORAL = get("minecraft:brain_coral"); + @Nullable public static final ItemType BRAIN_CORAL_BLOCK = get("minecraft:brain_coral_block"); + @Nullable public static final ItemType BRAIN_CORAL_FAN = get("minecraft:brain_coral_fan"); + @Nullable public static final ItemType BREAD = get("minecraft:bread"); + @Nullable public static final ItemType BREWING_STAND = get("minecraft:brewing_stand"); + @Nullable public static final ItemType BRICK = get("minecraft:brick"); + @Nullable public static final ItemType BRICK_SLAB = get("minecraft:brick_slab"); + @Nullable public static final ItemType BRICK_STAIRS = get("minecraft:brick_stairs"); + @Nullable public static final ItemType BRICKS = get("minecraft:bricks"); + @Nullable public static final ItemType BROWN_BANNER = get("minecraft:brown_banner"); + @Nullable public static final ItemType BROWN_BED = get("minecraft:brown_bed"); + @Nullable public static final ItemType BROWN_CARPET = get("minecraft:brown_carpet"); + @Nullable public static final ItemType BROWN_CONCRETE = get("minecraft:brown_concrete"); + @Nullable public static final ItemType BROWN_CONCRETE_POWDER = get("minecraft:brown_concrete_powder"); + @Nullable public static final ItemType BROWN_GLAZED_TERRACOTTA = get("minecraft:brown_glazed_terracotta"); + @Nullable public static final ItemType BROWN_MUSHROOM = get("minecraft:brown_mushroom"); + @Nullable public static final ItemType BROWN_MUSHROOM_BLOCK = get("minecraft:brown_mushroom_block"); + @Nullable public static final ItemType BROWN_SHULKER_BOX = get("minecraft:brown_shulker_box"); + @Nullable public static final ItemType BROWN_STAINED_GLASS = get("minecraft:brown_stained_glass"); + @Nullable public static final ItemType BROWN_STAINED_GLASS_PANE = get("minecraft:brown_stained_glass_pane"); + @Nullable public static final ItemType BROWN_TERRACOTTA = get("minecraft:brown_terracotta"); + @Nullable public static final ItemType BROWN_WOOL = get("minecraft:brown_wool"); + @Nullable public static final ItemType BUBBLE_CORAL = get("minecraft:bubble_coral"); + @Nullable public static final ItemType BUBBLE_CORAL_BLOCK = get("minecraft:bubble_coral_block"); + @Nullable public static final ItemType BUBBLE_CORAL_FAN = get("minecraft:bubble_coral_fan"); + @Nullable public static final ItemType BUCKET = get("minecraft:bucket"); + @Nullable public static final ItemType CACTUS = get("minecraft:cactus"); + @Nullable public static final ItemType CACTUS_GREEN = get("minecraft:cactus_green"); + @Nullable public static final ItemType CAKE = get("minecraft:cake"); + @Nullable public static final ItemType CARROT = get("minecraft:carrot"); + @Nullable public static final ItemType CARROT_ON_A_STICK = get("minecraft:carrot_on_a_stick"); + @Nullable public static final ItemType CARVED_PUMPKIN = get("minecraft:carved_pumpkin"); + @Nullable public static final ItemType CAULDRON = get("minecraft:cauldron"); + @Nullable public static final ItemType CAVE_SPIDER_SPAWN_EGG = get("minecraft:cave_spider_spawn_egg"); + @Nullable public static final ItemType CHAIN_COMMAND_BLOCK = get("minecraft:chain_command_block"); + @Nullable public static final ItemType CHAINMAIL_BOOTS = get("minecraft:chainmail_boots"); + @Nullable public static final ItemType CHAINMAIL_CHESTPLATE = get("minecraft:chainmail_chestplate"); + @Nullable public static final ItemType CHAINMAIL_HELMET = get("minecraft:chainmail_helmet"); + @Nullable public static final ItemType CHAINMAIL_LEGGINGS = get("minecraft:chainmail_leggings"); + @Nullable public static final ItemType CHARCOAL = get("minecraft:charcoal"); + @Nullable public static final ItemType CHEST = get("minecraft:chest"); + @Nullable public static final ItemType CHEST_MINECART = get("minecraft:chest_minecart"); + @Nullable public static final ItemType CHICKEN = get("minecraft:chicken"); + @Nullable public static final ItemType CHICKEN_SPAWN_EGG = get("minecraft:chicken_spawn_egg"); + @Nullable public static final ItemType CHIPPED_ANVIL = get("minecraft:chipped_anvil"); + @Nullable public static final ItemType CHISELED_QUARTZ_BLOCK = get("minecraft:chiseled_quartz_block"); + @Nullable public static final ItemType CHISELED_RED_SANDSTONE = get("minecraft:chiseled_red_sandstone"); + @Nullable public static final ItemType CHISELED_SANDSTONE = get("minecraft:chiseled_sandstone"); + @Nullable public static final ItemType CHISELED_STONE_BRICKS = get("minecraft:chiseled_stone_bricks"); + @Nullable public static final ItemType CHORUS_FLOWER = get("minecraft:chorus_flower"); + @Nullable public static final ItemType CHORUS_FRUIT = get("minecraft:chorus_fruit"); + @Nullable public static final ItemType CHORUS_PLANT = get("minecraft:chorus_plant"); + @Nullable public static final ItemType CLAY = get("minecraft:clay"); + @Nullable public static final ItemType CLAY_BALL = get("minecraft:clay_ball"); + @Nullable public static final ItemType CLOCK = get("minecraft:clock"); + @Nullable public static final ItemType COAL = get("minecraft:coal"); + @Nullable public static final ItemType COAL_BLOCK = get("minecraft:coal_block"); + @Nullable public static final ItemType COAL_ORE = get("minecraft:coal_ore"); + @Nullable public static final ItemType COARSE_DIRT = get("minecraft:coarse_dirt"); + @Nullable public static final ItemType COBBLESTONE = get("minecraft:cobblestone"); + @Nullable public static final ItemType COBBLESTONE_SLAB = get("minecraft:cobblestone_slab"); + @Nullable public static final ItemType COBBLESTONE_STAIRS = get("minecraft:cobblestone_stairs"); + @Nullable public static final ItemType COBBLESTONE_WALL = get("minecraft:cobblestone_wall"); + @Nullable public static final ItemType COBWEB = get("minecraft:cobweb"); + @Nullable public static final ItemType COCOA_BEANS = get("minecraft:cocoa_beans"); + @Nullable public static final ItemType COD = get("minecraft:cod"); + @Nullable public static final ItemType COD_BUCKET = get("minecraft:cod_bucket"); + @Nullable public static final ItemType COD_SPAWN_EGG = get("minecraft:cod_spawn_egg"); + @Nullable public static final ItemType COMMAND_BLOCK = get("minecraft:command_block"); + @Nullable public static final ItemType COMMAND_BLOCK_MINECART = get("minecraft:command_block_minecart"); + @Nullable public static final ItemType COMPARATOR = get("minecraft:comparator"); + @Nullable public static final ItemType COMPASS = get("minecraft:compass"); + @Nullable public static final ItemType CONDUIT = get("minecraft:conduit"); + @Nullable public static final ItemType COOKED_BEEF = get("minecraft:cooked_beef"); + @Nullable public static final ItemType COOKED_CHICKEN = get("minecraft:cooked_chicken"); + @Nullable public static final ItemType COOKED_COD = get("minecraft:cooked_cod"); + @Nullable public static final ItemType COOKED_MUTTON = get("minecraft:cooked_mutton"); + @Nullable public static final ItemType COOKED_PORKCHOP = get("minecraft:cooked_porkchop"); + @Nullable public static final ItemType COOKED_RABBIT = get("minecraft:cooked_rabbit"); + @Nullable public static final ItemType COOKED_SALMON = get("minecraft:cooked_salmon"); + @Nullable public static final ItemType COOKIE = get("minecraft:cookie"); + @Nullable public static final ItemType COW_SPAWN_EGG = get("minecraft:cow_spawn_egg"); + @Nullable public static final ItemType CRACKED_STONE_BRICKS = get("minecraft:cracked_stone_bricks"); + @Nullable public static final ItemType CRAFTING_TABLE = get("minecraft:crafting_table"); + @Nullable public static final ItemType CREEPER_HEAD = get("minecraft:creeper_head"); + @Nullable public static final ItemType CREEPER_SPAWN_EGG = get("minecraft:creeper_spawn_egg"); + @Nullable public static final ItemType CUT_RED_SANDSTONE = get("minecraft:cut_red_sandstone"); + @Nullable public static final ItemType CUT_SANDSTONE = get("minecraft:cut_sandstone"); + @Nullable public static final ItemType CYAN_BANNER = get("minecraft:cyan_banner"); + @Nullable public static final ItemType CYAN_BED = get("minecraft:cyan_bed"); + @Nullable public static final ItemType CYAN_CARPET = get("minecraft:cyan_carpet"); + @Nullable public static final ItemType CYAN_CONCRETE = get("minecraft:cyan_concrete"); + @Nullable public static final ItemType CYAN_CONCRETE_POWDER = get("minecraft:cyan_concrete_powder"); + @Nullable public static final ItemType CYAN_DYE = get("minecraft:cyan_dye"); + @Nullable public static final ItemType CYAN_GLAZED_TERRACOTTA = get("minecraft:cyan_glazed_terracotta"); + @Nullable public static final ItemType CYAN_SHULKER_BOX = get("minecraft:cyan_shulker_box"); + @Nullable public static final ItemType CYAN_STAINED_GLASS = get("minecraft:cyan_stained_glass"); + @Nullable public static final ItemType CYAN_STAINED_GLASS_PANE = get("minecraft:cyan_stained_glass_pane"); + @Nullable public static final ItemType CYAN_TERRACOTTA = get("minecraft:cyan_terracotta"); + @Nullable public static final ItemType CYAN_WOOL = get("minecraft:cyan_wool"); + @Nullable public static final ItemType DAMAGED_ANVIL = get("minecraft:damaged_anvil"); + @Nullable public static final ItemType DANDELION = get("minecraft:dandelion"); + @Nullable public static final ItemType DANDELION_YELLOW = get("minecraft:dandelion_yellow"); + @Nullable public static final ItemType DARK_OAK_BOAT = get("minecraft:dark_oak_boat"); + @Nullable public static final ItemType DARK_OAK_BUTTON = get("minecraft:dark_oak_button"); + @Nullable public static final ItemType DARK_OAK_DOOR = get("minecraft:dark_oak_door"); + @Nullable public static final ItemType DARK_OAK_FENCE = get("minecraft:dark_oak_fence"); + @Nullable public static final ItemType DARK_OAK_FENCE_GATE = get("minecraft:dark_oak_fence_gate"); + @Nullable public static final ItemType DARK_OAK_LEAVES = get("minecraft:dark_oak_leaves"); + @Nullable public static final ItemType DARK_OAK_LOG = get("minecraft:dark_oak_log"); + @Nullable public static final ItemType DARK_OAK_PLANKS = get("minecraft:dark_oak_planks"); + @Nullable public static final ItemType DARK_OAK_PRESSURE_PLATE = get("minecraft:dark_oak_pressure_plate"); + @Nullable public static final ItemType DARK_OAK_SAPLING = get("minecraft:dark_oak_sapling"); + @Nullable public static final ItemType DARK_OAK_SLAB = get("minecraft:dark_oak_slab"); + @Nullable public static final ItemType DARK_OAK_STAIRS = get("minecraft:dark_oak_stairs"); + @Nullable public static final ItemType DARK_OAK_TRAPDOOR = get("minecraft:dark_oak_trapdoor"); + @Nullable public static final ItemType DARK_OAK_WOOD = get("minecraft:dark_oak_wood"); + @Nullable public static final ItemType DARK_PRISMARINE = get("minecraft:dark_prismarine"); + @Nullable public static final ItemType DARK_PRISMARINE_SLAB = get("minecraft:dark_prismarine_slab"); + @Nullable public static final ItemType DARK_PRISMARINE_STAIRS = get("minecraft:dark_prismarine_stairs"); + @Nullable public static final ItemType DAYLIGHT_DETECTOR = get("minecraft:daylight_detector"); + @Nullable public static final ItemType DEAD_BRAIN_CORAL = get("minecraft:dead_brain_coral"); + @Nullable public static final ItemType DEAD_BRAIN_CORAL_BLOCK = get("minecraft:dead_brain_coral_block"); + @Nullable public static final ItemType DEAD_BRAIN_CORAL_FAN = get("minecraft:dead_brain_coral_fan"); + @Nullable public static final ItemType DEAD_BUBBLE_CORAL = get("minecraft:dead_bubble_coral"); + @Nullable public static final ItemType DEAD_BUBBLE_CORAL_BLOCK = get("minecraft:dead_bubble_coral_block"); + @Nullable public static final ItemType DEAD_BUBBLE_CORAL_FAN = get("minecraft:dead_bubble_coral_fan"); + @Nullable public static final ItemType DEAD_BUSH = get("minecraft:dead_bush"); + @Nullable public static final ItemType DEAD_FIRE_CORAL = get("minecraft:dead_fire_coral"); + @Nullable public static final ItemType DEAD_FIRE_CORAL_BLOCK = get("minecraft:dead_fire_coral_block"); + @Nullable public static final ItemType DEAD_FIRE_CORAL_FAN = get("minecraft:dead_fire_coral_fan"); + @Nullable public static final ItemType DEAD_HORN_CORAL = get("minecraft:dead_horn_coral"); + @Nullable public static final ItemType DEAD_HORN_CORAL_BLOCK = get("minecraft:dead_horn_coral_block"); + @Nullable public static final ItemType DEAD_HORN_CORAL_FAN = get("minecraft:dead_horn_coral_fan"); + @Nullable public static final ItemType DEAD_TUBE_CORAL = get("minecraft:dead_tube_coral"); + @Nullable public static final ItemType DEAD_TUBE_CORAL_BLOCK = get("minecraft:dead_tube_coral_block"); + @Nullable public static final ItemType DEAD_TUBE_CORAL_FAN = get("minecraft:dead_tube_coral_fan"); + @Nullable public static final ItemType DEBUG_STICK = get("minecraft:debug_stick"); + @Nullable public static final ItemType DETECTOR_RAIL = get("minecraft:detector_rail"); + @Nullable public static final ItemType DIAMOND = get("minecraft:diamond"); + @Nullable public static final ItemType DIAMOND_AXE = get("minecraft:diamond_axe"); + @Nullable public static final ItemType DIAMOND_BLOCK = get("minecraft:diamond_block"); + @Nullable public static final ItemType DIAMOND_BOOTS = get("minecraft:diamond_boots"); + @Nullable public static final ItemType DIAMOND_CHESTPLATE = get("minecraft:diamond_chestplate"); + @Nullable public static final ItemType DIAMOND_HELMET = get("minecraft:diamond_helmet"); + @Nullable public static final ItemType DIAMOND_HOE = get("minecraft:diamond_hoe"); + @Nullable public static final ItemType DIAMOND_HORSE_ARMOR = get("minecraft:diamond_horse_armor"); + @Nullable public static final ItemType DIAMOND_LEGGINGS = get("minecraft:diamond_leggings"); + @Nullable public static final ItemType DIAMOND_ORE = get("minecraft:diamond_ore"); + @Nullable public static final ItemType DIAMOND_PICKAXE = get("minecraft:diamond_pickaxe"); + @Nullable public static final ItemType DIAMOND_SHOVEL = get("minecraft:diamond_shovel"); + @Nullable public static final ItemType DIAMOND_SWORD = get("minecraft:diamond_sword"); + @Nullable public static final ItemType DIORITE = get("minecraft:diorite"); + @Nullable public static final ItemType DIRT = get("minecraft:dirt"); + @Nullable public static final ItemType DISPENSER = get("minecraft:dispenser"); + @Nullable public static final ItemType DOLPHIN_SPAWN_EGG = get("minecraft:dolphin_spawn_egg"); + @Nullable public static final ItemType DONKEY_SPAWN_EGG = get("minecraft:donkey_spawn_egg"); + @Nullable public static final ItemType DRAGON_BREATH = get("minecraft:dragon_breath"); + @Nullable public static final ItemType DRAGON_EGG = get("minecraft:dragon_egg"); + @Nullable public static final ItemType DRAGON_HEAD = get("minecraft:dragon_head"); + @Nullable public static final ItemType DRIED_KELP = get("minecraft:dried_kelp"); + @Nullable public static final ItemType DRIED_KELP_BLOCK = get("minecraft:dried_kelp_block"); + @Nullable public static final ItemType DROPPER = get("minecraft:dropper"); + @Nullable public static final ItemType DROWNED_SPAWN_EGG = get("minecraft:drowned_spawn_egg"); + @Nullable public static final ItemType EGG = get("minecraft:egg"); + @Nullable public static final ItemType ELDER_GUARDIAN_SPAWN_EGG = get("minecraft:elder_guardian_spawn_egg"); + @Nullable public static final ItemType ELYTRA = get("minecraft:elytra"); + @Nullable public static final ItemType EMERALD = get("minecraft:emerald"); + @Nullable public static final ItemType EMERALD_BLOCK = get("minecraft:emerald_block"); + @Nullable public static final ItemType EMERALD_ORE = get("minecraft:emerald_ore"); + @Nullable public static final ItemType ENCHANTED_BOOK = get("minecraft:enchanted_book"); + @Nullable public static final ItemType ENCHANTED_GOLDEN_APPLE = get("minecraft:enchanted_golden_apple"); + @Nullable public static final ItemType ENCHANTING_TABLE = get("minecraft:enchanting_table"); + @Nullable public static final ItemType END_CRYSTAL = get("minecraft:end_crystal"); + @Nullable public static final ItemType END_PORTAL_FRAME = get("minecraft:end_portal_frame"); + @Nullable public static final ItemType END_ROD = get("minecraft:end_rod"); + @Nullable public static final ItemType END_STONE = get("minecraft:end_stone"); + @Nullable public static final ItemType END_STONE_BRICKS = get("minecraft:end_stone_bricks"); + @Nullable public static final ItemType ENDER_CHEST = get("minecraft:ender_chest"); + @Nullable public static final ItemType ENDER_EYE = get("minecraft:ender_eye"); + @Nullable public static final ItemType ENDER_PEARL = get("minecraft:ender_pearl"); + @Nullable public static final ItemType ENDERMAN_SPAWN_EGG = get("minecraft:enderman_spawn_egg"); + @Nullable public static final ItemType ENDERMITE_SPAWN_EGG = get("minecraft:endermite_spawn_egg"); + @Nullable public static final ItemType EVOKER_SPAWN_EGG = get("minecraft:evoker_spawn_egg"); + @Nullable public static final ItemType EXPERIENCE_BOTTLE = get("minecraft:experience_bottle"); + @Nullable public static final ItemType FARMLAND = get("minecraft:farmland"); + @Nullable public static final ItemType FEATHER = get("minecraft:feather"); + @Nullable public static final ItemType FERMENTED_SPIDER_EYE = get("minecraft:fermented_spider_eye"); + @Nullable public static final ItemType FERN = get("minecraft:fern"); + @Nullable public static final ItemType FILLED_MAP = get("minecraft:filled_map"); + @Nullable public static final ItemType FIRE_CHARGE = get("minecraft:fire_charge"); + @Nullable public static final ItemType FIRE_CORAL = get("minecraft:fire_coral"); + @Nullable public static final ItemType FIRE_CORAL_BLOCK = get("minecraft:fire_coral_block"); + @Nullable public static final ItemType FIRE_CORAL_FAN = get("minecraft:fire_coral_fan"); + @Nullable public static final ItemType FIREWORK_ROCKET = get("minecraft:firework_rocket"); + @Nullable public static final ItemType FIREWORK_STAR = get("minecraft:firework_star"); + @Nullable public static final ItemType FISHING_ROD = get("minecraft:fishing_rod"); + @Nullable public static final ItemType FLINT = get("minecraft:flint"); + @Nullable public static final ItemType FLINT_AND_STEEL = get("minecraft:flint_and_steel"); + @Nullable public static final ItemType FLOWER_POT = get("minecraft:flower_pot"); + @Nullable public static final ItemType FURNACE = get("minecraft:furnace"); + @Nullable public static final ItemType FURNACE_MINECART = get("minecraft:furnace_minecart"); + @Nullable public static final ItemType GHAST_SPAWN_EGG = get("minecraft:ghast_spawn_egg"); + @Nullable public static final ItemType GHAST_TEAR = get("minecraft:ghast_tear"); + @Nullable public static final ItemType GLASS = get("minecraft:glass"); + @Nullable public static final ItemType GLASS_BOTTLE = get("minecraft:glass_bottle"); + @Nullable public static final ItemType GLASS_PANE = get("minecraft:glass_pane"); + @Nullable public static final ItemType GLISTERING_MELON_SLICE = get("minecraft:glistering_melon_slice"); + @Nullable public static final ItemType GLOWSTONE = get("minecraft:glowstone"); + @Nullable public static final ItemType GLOWSTONE_DUST = get("minecraft:glowstone_dust"); + @Nullable public static final ItemType GOLD_BLOCK = get("minecraft:gold_block"); + @Nullable public static final ItemType GOLD_INGOT = get("minecraft:gold_ingot"); + @Nullable public static final ItemType GOLD_NUGGET = get("minecraft:gold_nugget"); + @Nullable public static final ItemType GOLD_ORE = get("minecraft:gold_ore"); + @Nullable public static final ItemType GOLDEN_APPLE = get("minecraft:golden_apple"); + @Nullable public static final ItemType GOLDEN_AXE = get("minecraft:golden_axe"); + @Nullable public static final ItemType GOLDEN_BOOTS = get("minecraft:golden_boots"); + @Nullable public static final ItemType GOLDEN_CARROT = get("minecraft:golden_carrot"); + @Nullable public static final ItemType GOLDEN_CHESTPLATE = get("minecraft:golden_chestplate"); + @Nullable public static final ItemType GOLDEN_HELMET = get("minecraft:golden_helmet"); + @Nullable public static final ItemType GOLDEN_HOE = get("minecraft:golden_hoe"); + @Nullable public static final ItemType GOLDEN_HORSE_ARMOR = get("minecraft:golden_horse_armor"); + @Nullable public static final ItemType GOLDEN_LEGGINGS = get("minecraft:golden_leggings"); + @Nullable public static final ItemType GOLDEN_PICKAXE = get("minecraft:golden_pickaxe"); + @Nullable public static final ItemType GOLDEN_SHOVEL = get("minecraft:golden_shovel"); + @Nullable public static final ItemType GOLDEN_SWORD = get("minecraft:golden_sword"); + @Nullable public static final ItemType GRANITE = get("minecraft:granite"); + @Nullable public static final ItemType GRASS = get("minecraft:grass"); + @Nullable public static final ItemType GRASS_BLOCK = get("minecraft:grass_block"); + @Nullable public static final ItemType GRASS_PATH = get("minecraft:grass_path"); + @Nullable public static final ItemType GRAVEL = get("minecraft:gravel"); + @Nullable public static final ItemType GRAY_BANNER = get("minecraft:gray_banner"); + @Nullable public static final ItemType GRAY_BED = get("minecraft:gray_bed"); + @Nullable public static final ItemType GRAY_CARPET = get("minecraft:gray_carpet"); + @Nullable public static final ItemType GRAY_CONCRETE = get("minecraft:gray_concrete"); + @Nullable public static final ItemType GRAY_CONCRETE_POWDER = get("minecraft:gray_concrete_powder"); + @Nullable public static final ItemType GRAY_DYE = get("minecraft:gray_dye"); + @Nullable public static final ItemType GRAY_GLAZED_TERRACOTTA = get("minecraft:gray_glazed_terracotta"); + @Nullable public static final ItemType GRAY_SHULKER_BOX = get("minecraft:gray_shulker_box"); + @Nullable public static final ItemType GRAY_STAINED_GLASS = get("minecraft:gray_stained_glass"); + @Nullable public static final ItemType GRAY_STAINED_GLASS_PANE = get("minecraft:gray_stained_glass_pane"); + @Nullable public static final ItemType GRAY_TERRACOTTA = get("minecraft:gray_terracotta"); + @Nullable public static final ItemType GRAY_WOOL = get("minecraft:gray_wool"); + @Nullable public static final ItemType GREEN_BANNER = get("minecraft:green_banner"); + @Nullable public static final ItemType GREEN_BED = get("minecraft:green_bed"); + @Nullable public static final ItemType GREEN_CARPET = get("minecraft:green_carpet"); + @Nullable public static final ItemType GREEN_CONCRETE = get("minecraft:green_concrete"); + @Nullable public static final ItemType GREEN_CONCRETE_POWDER = get("minecraft:green_concrete_powder"); + @Nullable public static final ItemType GREEN_GLAZED_TERRACOTTA = get("minecraft:green_glazed_terracotta"); + @Nullable public static final ItemType GREEN_SHULKER_BOX = get("minecraft:green_shulker_box"); + @Nullable public static final ItemType GREEN_STAINED_GLASS = get("minecraft:green_stained_glass"); + @Nullable public static final ItemType GREEN_STAINED_GLASS_PANE = get("minecraft:green_stained_glass_pane"); + @Nullable public static final ItemType GREEN_TERRACOTTA = get("minecraft:green_terracotta"); + @Nullable public static final ItemType GREEN_WOOL = get("minecraft:green_wool"); + @Nullable public static final ItemType GUARDIAN_SPAWN_EGG = get("minecraft:guardian_spawn_egg"); + @Nullable public static final ItemType GUNPOWDER = get("minecraft:gunpowder"); + @Nullable public static final ItemType HAY_BLOCK = get("minecraft:hay_block"); + @Nullable public static final ItemType HEART_OF_THE_SEA = get("minecraft:heart_of_the_sea"); + @Nullable public static final ItemType HEAVY_WEIGHTED_PRESSURE_PLATE = get("minecraft:heavy_weighted_pressure_plate"); + @Nullable public static final ItemType HOPPER = get("minecraft:hopper"); + @Nullable public static final ItemType HOPPER_MINECART = get("minecraft:hopper_minecart"); + @Nullable public static final ItemType HORN_CORAL = get("minecraft:horn_coral"); + @Nullable public static final ItemType HORN_CORAL_BLOCK = get("minecraft:horn_coral_block"); + @Nullable public static final ItemType HORN_CORAL_FAN = get("minecraft:horn_coral_fan"); + @Nullable public static final ItemType HORSE_SPAWN_EGG = get("minecraft:horse_spawn_egg"); + @Nullable public static final ItemType HUSK_SPAWN_EGG = get("minecraft:husk_spawn_egg"); + @Nullable public static final ItemType ICE = get("minecraft:ice"); + @Nullable public static final ItemType INFESTED_CHISELED_STONE_BRICKS = get("minecraft:infested_chiseled_stone_bricks"); + @Nullable public static final ItemType INFESTED_COBBLESTONE = get("minecraft:infested_cobblestone"); + @Nullable public static final ItemType INFESTED_CRACKED_STONE_BRICKS = get("minecraft:infested_cracked_stone_bricks"); + @Nullable public static final ItemType INFESTED_MOSSY_STONE_BRICKS = get("minecraft:infested_mossy_stone_bricks"); + @Nullable public static final ItemType INFESTED_STONE = get("minecraft:infested_stone"); + @Nullable public static final ItemType INFESTED_STONE_BRICKS = get("minecraft:infested_stone_bricks"); + @Nullable public static final ItemType INK_SAC = get("minecraft:ink_sac"); + @Nullable public static final ItemType IRON_AXE = get("minecraft:iron_axe"); + @Nullable public static final ItemType IRON_BARS = get("minecraft:iron_bars"); + @Nullable public static final ItemType IRON_BLOCK = get("minecraft:iron_block"); + @Nullable public static final ItemType IRON_BOOTS = get("minecraft:iron_boots"); + @Nullable public static final ItemType IRON_CHESTPLATE = get("minecraft:iron_chestplate"); + @Nullable public static final ItemType IRON_DOOR = get("minecraft:iron_door"); + @Nullable public static final ItemType IRON_HELMET = get("minecraft:iron_helmet"); + @Nullable public static final ItemType IRON_HOE = get("minecraft:iron_hoe"); + @Nullable public static final ItemType IRON_HORSE_ARMOR = get("minecraft:iron_horse_armor"); + @Nullable public static final ItemType IRON_INGOT = get("minecraft:iron_ingot"); + @Nullable public static final ItemType IRON_LEGGINGS = get("minecraft:iron_leggings"); + @Nullable public static final ItemType IRON_NUGGET = get("minecraft:iron_nugget"); + @Nullable public static final ItemType IRON_ORE = get("minecraft:iron_ore"); + @Nullable public static final ItemType IRON_PICKAXE = get("minecraft:iron_pickaxe"); + @Nullable public static final ItemType IRON_SHOVEL = get("minecraft:iron_shovel"); + @Nullable public static final ItemType IRON_SWORD = get("minecraft:iron_sword"); + @Nullable public static final ItemType IRON_TRAPDOOR = get("minecraft:iron_trapdoor"); + @Nullable public static final ItemType ITEM_FRAME = get("minecraft:item_frame"); + @Nullable public static final ItemType JACK_O_LANTERN = get("minecraft:jack_o_lantern"); + @Nullable public static final ItemType JUKEBOX = get("minecraft:jukebox"); + @Nullable public static final ItemType JUNGLE_BOAT = get("minecraft:jungle_boat"); + @Nullable public static final ItemType JUNGLE_BUTTON = get("minecraft:jungle_button"); + @Nullable public static final ItemType JUNGLE_DOOR = get("minecraft:jungle_door"); + @Nullable public static final ItemType JUNGLE_FENCE = get("minecraft:jungle_fence"); + @Nullable public static final ItemType JUNGLE_FENCE_GATE = get("minecraft:jungle_fence_gate"); + @Nullable public static final ItemType JUNGLE_LEAVES = get("minecraft:jungle_leaves"); + @Nullable public static final ItemType JUNGLE_LOG = get("minecraft:jungle_log"); + @Nullable public static final ItemType JUNGLE_PLANKS = get("minecraft:jungle_planks"); + @Nullable public static final ItemType JUNGLE_PRESSURE_PLATE = get("minecraft:jungle_pressure_plate"); + @Nullable public static final ItemType JUNGLE_SAPLING = get("minecraft:jungle_sapling"); + @Nullable public static final ItemType JUNGLE_SLAB = get("minecraft:jungle_slab"); + @Nullable public static final ItemType JUNGLE_STAIRS = get("minecraft:jungle_stairs"); + @Nullable public static final ItemType JUNGLE_TRAPDOOR = get("minecraft:jungle_trapdoor"); + @Nullable public static final ItemType JUNGLE_WOOD = get("minecraft:jungle_wood"); + @Nullable public static final ItemType KELP = get("minecraft:kelp"); + @Nullable public static final ItemType KNOWLEDGE_BOOK = get("minecraft:knowledge_book"); + @Nullable public static final ItemType LADDER = get("minecraft:ladder"); + @Nullable public static final ItemType LAPIS_BLOCK = get("minecraft:lapis_block"); + @Nullable public static final ItemType LAPIS_LAZULI = get("minecraft:lapis_lazuli"); + @Nullable public static final ItemType LAPIS_ORE = get("minecraft:lapis_ore"); + @Nullable public static final ItemType LARGE_FERN = get("minecraft:large_fern"); + @Nullable public static final ItemType LAVA_BUCKET = get("minecraft:lava_bucket"); + @Nullable public static final ItemType LEAD = get("minecraft:lead"); + @Nullable public static final ItemType LEATHER = get("minecraft:leather"); + @Nullable public static final ItemType LEATHER_BOOTS = get("minecraft:leather_boots"); + @Nullable public static final ItemType LEATHER_CHESTPLATE = get("minecraft:leather_chestplate"); + @Nullable public static final ItemType LEATHER_HELMET = get("minecraft:leather_helmet"); + @Nullable public static final ItemType LEATHER_LEGGINGS = get("minecraft:leather_leggings"); + @Nullable public static final ItemType LEVER = get("minecraft:lever"); + @Nullable public static final ItemType LIGHT_BLUE_BANNER = get("minecraft:light_blue_banner"); + @Nullable public static final ItemType LIGHT_BLUE_BED = get("minecraft:light_blue_bed"); + @Nullable public static final ItemType LIGHT_BLUE_CARPET = get("minecraft:light_blue_carpet"); + @Nullable public static final ItemType LIGHT_BLUE_CONCRETE = get("minecraft:light_blue_concrete"); + @Nullable public static final ItemType LIGHT_BLUE_CONCRETE_POWDER = get("minecraft:light_blue_concrete_powder"); + @Nullable public static final ItemType LIGHT_BLUE_DYE = get("minecraft:light_blue_dye"); + @Nullable public static final ItemType LIGHT_BLUE_GLAZED_TERRACOTTA = get("minecraft:light_blue_glazed_terracotta"); + @Nullable public static final ItemType LIGHT_BLUE_SHULKER_BOX = get("minecraft:light_blue_shulker_box"); + @Nullable public static final ItemType LIGHT_BLUE_STAINED_GLASS = get("minecraft:light_blue_stained_glass"); + @Nullable public static final ItemType LIGHT_BLUE_STAINED_GLASS_PANE = get("minecraft:light_blue_stained_glass_pane"); + @Nullable public static final ItemType LIGHT_BLUE_TERRACOTTA = get("minecraft:light_blue_terracotta"); + @Nullable public static final ItemType LIGHT_BLUE_WOOL = get("minecraft:light_blue_wool"); + @Nullable public static final ItemType LIGHT_GRAY_BANNER = get("minecraft:light_gray_banner"); + @Nullable public static final ItemType LIGHT_GRAY_BED = get("minecraft:light_gray_bed"); + @Nullable public static final ItemType LIGHT_GRAY_CARPET = get("minecraft:light_gray_carpet"); + @Nullable public static final ItemType LIGHT_GRAY_CONCRETE = get("minecraft:light_gray_concrete"); + @Nullable public static final ItemType LIGHT_GRAY_CONCRETE_POWDER = get("minecraft:light_gray_concrete_powder"); + @Nullable public static final ItemType LIGHT_GRAY_DYE = get("minecraft:light_gray_dye"); + @Nullable public static final ItemType LIGHT_GRAY_GLAZED_TERRACOTTA = get("minecraft:light_gray_glazed_terracotta"); + @Nullable public static final ItemType LIGHT_GRAY_SHULKER_BOX = get("minecraft:light_gray_shulker_box"); + @Nullable public static final ItemType LIGHT_GRAY_STAINED_GLASS = get("minecraft:light_gray_stained_glass"); + @Nullable public static final ItemType LIGHT_GRAY_STAINED_GLASS_PANE = get("minecraft:light_gray_stained_glass_pane"); + @Nullable public static final ItemType LIGHT_GRAY_TERRACOTTA = get("minecraft:light_gray_terracotta"); + @Nullable public static final ItemType LIGHT_GRAY_WOOL = get("minecraft:light_gray_wool"); + @Nullable public static final ItemType LIGHT_WEIGHTED_PRESSURE_PLATE = get("minecraft:light_weighted_pressure_plate"); + @Nullable public static final ItemType LILAC = get("minecraft:lilac"); + @Nullable public static final ItemType LILY_PAD = get("minecraft:lily_pad"); + @Nullable public static final ItemType LIME_BANNER = get("minecraft:lime_banner"); + @Nullable public static final ItemType LIME_BED = get("minecraft:lime_bed"); + @Nullable public static final ItemType LIME_CARPET = get("minecraft:lime_carpet"); + @Nullable public static final ItemType LIME_CONCRETE = get("minecraft:lime_concrete"); + @Nullable public static final ItemType LIME_CONCRETE_POWDER = get("minecraft:lime_concrete_powder"); + @Nullable public static final ItemType LIME_DYE = get("minecraft:lime_dye"); + @Nullable public static final ItemType LIME_GLAZED_TERRACOTTA = get("minecraft:lime_glazed_terracotta"); + @Nullable public static final ItemType LIME_SHULKER_BOX = get("minecraft:lime_shulker_box"); + @Nullable public static final ItemType LIME_STAINED_GLASS = get("minecraft:lime_stained_glass"); + @Nullable public static final ItemType LIME_STAINED_GLASS_PANE = get("minecraft:lime_stained_glass_pane"); + @Nullable public static final ItemType LIME_TERRACOTTA = get("minecraft:lime_terracotta"); + @Nullable public static final ItemType LIME_WOOL = get("minecraft:lime_wool"); + @Nullable public static final ItemType LINGERING_POTION = get("minecraft:lingering_potion"); + @Nullable public static final ItemType LLAMA_SPAWN_EGG = get("minecraft:llama_spawn_egg"); + @Nullable public static final ItemType MAGENTA_BANNER = get("minecraft:magenta_banner"); + @Nullable public static final ItemType MAGENTA_BED = get("minecraft:magenta_bed"); + @Nullable public static final ItemType MAGENTA_CARPET = get("minecraft:magenta_carpet"); + @Nullable public static final ItemType MAGENTA_CONCRETE = get("minecraft:magenta_concrete"); + @Nullable public static final ItemType MAGENTA_CONCRETE_POWDER = get("minecraft:magenta_concrete_powder"); + @Nullable public static final ItemType MAGENTA_DYE = get("minecraft:magenta_dye"); + @Nullable public static final ItemType MAGENTA_GLAZED_TERRACOTTA = get("minecraft:magenta_glazed_terracotta"); + @Nullable public static final ItemType MAGENTA_SHULKER_BOX = get("minecraft:magenta_shulker_box"); + @Nullable public static final ItemType MAGENTA_STAINED_GLASS = get("minecraft:magenta_stained_glass"); + @Nullable public static final ItemType MAGENTA_STAINED_GLASS_PANE = get("minecraft:magenta_stained_glass_pane"); + @Nullable public static final ItemType MAGENTA_TERRACOTTA = get("minecraft:magenta_terracotta"); + @Nullable public static final ItemType MAGENTA_WOOL = get("minecraft:magenta_wool"); + @Nullable public static final ItemType MAGMA_BLOCK = get("minecraft:magma_block"); + @Nullable public static final ItemType MAGMA_CREAM = get("minecraft:magma_cream"); + @Nullable public static final ItemType MAGMA_CUBE_SPAWN_EGG = get("minecraft:magma_cube_spawn_egg"); + @Nullable public static final ItemType MAP = get("minecraft:map"); + @Nullable public static final ItemType MELON = get("minecraft:melon"); + @Nullable public static final ItemType MELON_SEEDS = get("minecraft:melon_seeds"); + @Nullable public static final ItemType MELON_SLICE = get("minecraft:melon_slice"); + @Nullable public static final ItemType MILK_BUCKET = get("minecraft:milk_bucket"); + @Nullable public static final ItemType MINECART = get("minecraft:minecart"); + @Nullable public static final ItemType MOOSHROOM_SPAWN_EGG = get("minecraft:mooshroom_spawn_egg"); + @Nullable public static final ItemType MOSSY_COBBLESTONE = get("minecraft:mossy_cobblestone"); + @Nullable public static final ItemType MOSSY_COBBLESTONE_WALL = get("minecraft:mossy_cobblestone_wall"); + @Nullable public static final ItemType MOSSY_STONE_BRICKS = get("minecraft:mossy_stone_bricks"); + @Nullable public static final ItemType MULE_SPAWN_EGG = get("minecraft:mule_spawn_egg"); + @Nullable public static final ItemType MUSHROOM_STEM = get("minecraft:mushroom_stem"); + @Nullable public static final ItemType MUSHROOM_STEW = get("minecraft:mushroom_stew"); + @Nullable public static final ItemType MUSIC_DISC_11 = get("minecraft:music_disc_11"); + @Nullable public static final ItemType MUSIC_DISC_13 = get("minecraft:music_disc_13"); + @Nullable public static final ItemType MUSIC_DISC_BLOCKS = get("minecraft:music_disc_blocks"); + @Nullable public static final ItemType MUSIC_DISC_CAT = get("minecraft:music_disc_cat"); + @Nullable public static final ItemType MUSIC_DISC_CHIRP = get("minecraft:music_disc_chirp"); + @Nullable public static final ItemType MUSIC_DISC_FAR = get("minecraft:music_disc_far"); + @Nullable public static final ItemType MUSIC_DISC_MALL = get("minecraft:music_disc_mall"); + @Nullable public static final ItemType MUSIC_DISC_MELLOHI = get("minecraft:music_disc_mellohi"); + @Nullable public static final ItemType MUSIC_DISC_STAL = get("minecraft:music_disc_stal"); + @Nullable public static final ItemType MUSIC_DISC_STRAD = get("minecraft:music_disc_strad"); + @Nullable public static final ItemType MUSIC_DISC_WAIT = get("minecraft:music_disc_wait"); + @Nullable public static final ItemType MUSIC_DISC_WARD = get("minecraft:music_disc_ward"); + @Nullable public static final ItemType MUTTON = get("minecraft:mutton"); + @Nullable public static final ItemType MYCELIUM = get("minecraft:mycelium"); + @Nullable public static final ItemType NAME_TAG = get("minecraft:name_tag"); + @Nullable public static final ItemType NAUTILUS_SHELL = get("minecraft:nautilus_shell"); + @Nullable public static final ItemType NETHER_BRICK = get("minecraft:nether_brick"); + @Nullable public static final ItemType NETHER_BRICK_FENCE = get("minecraft:nether_brick_fence"); + @Nullable public static final ItemType NETHER_BRICK_SLAB = get("minecraft:nether_brick_slab"); + @Nullable public static final ItemType NETHER_BRICK_STAIRS = get("minecraft:nether_brick_stairs"); + @Nullable public static final ItemType NETHER_BRICKS = get("minecraft:nether_bricks"); + @Nullable public static final ItemType NETHER_QUARTZ_ORE = get("minecraft:nether_quartz_ore"); + @Nullable public static final ItemType NETHER_STAR = get("minecraft:nether_star"); + @Nullable public static final ItemType NETHER_WART = get("minecraft:nether_wart"); + @Nullable public static final ItemType NETHER_WART_BLOCK = get("minecraft:nether_wart_block"); + @Nullable public static final ItemType NETHERRACK = get("minecraft:netherrack"); + @Nullable public static final ItemType NOTE_BLOCK = get("minecraft:note_block"); + @Nullable public static final ItemType OAK_BOAT = get("minecraft:oak_boat"); + @Nullable public static final ItemType OAK_BUTTON = get("minecraft:oak_button"); + @Nullable public static final ItemType OAK_DOOR = get("minecraft:oak_door"); + @Nullable public static final ItemType OAK_FENCE = get("minecraft:oak_fence"); + @Nullable public static final ItemType OAK_FENCE_GATE = get("minecraft:oak_fence_gate"); + @Nullable public static final ItemType OAK_LEAVES = get("minecraft:oak_leaves"); + @Nullable public static final ItemType OAK_LOG = get("minecraft:oak_log"); + @Nullable public static final ItemType OAK_PLANKS = get("minecraft:oak_planks"); + @Nullable public static final ItemType OAK_PRESSURE_PLATE = get("minecraft:oak_pressure_plate"); + @Nullable public static final ItemType OAK_SAPLING = get("minecraft:oak_sapling"); + @Nullable public static final ItemType OAK_SLAB = get("minecraft:oak_slab"); + @Nullable public static final ItemType OAK_STAIRS = get("minecraft:oak_stairs"); + @Nullable public static final ItemType OAK_TRAPDOOR = get("minecraft:oak_trapdoor"); + @Nullable public static final ItemType OAK_WOOD = get("minecraft:oak_wood"); + @Nullable public static final ItemType OBSERVER = get("minecraft:observer"); + @Nullable public static final ItemType OBSIDIAN = get("minecraft:obsidian"); + @Nullable public static final ItemType OCELOT_SPAWN_EGG = get("minecraft:ocelot_spawn_egg"); + @Nullable public static final ItemType ORANGE_BANNER = get("minecraft:orange_banner"); + @Nullable public static final ItemType ORANGE_BED = get("minecraft:orange_bed"); + @Nullable public static final ItemType ORANGE_CARPET = get("minecraft:orange_carpet"); + @Nullable public static final ItemType ORANGE_CONCRETE = get("minecraft:orange_concrete"); + @Nullable public static final ItemType ORANGE_CONCRETE_POWDER = get("minecraft:orange_concrete_powder"); + @Nullable public static final ItemType ORANGE_DYE = get("minecraft:orange_dye"); + @Nullable public static final ItemType ORANGE_GLAZED_TERRACOTTA = get("minecraft:orange_glazed_terracotta"); + @Nullable public static final ItemType ORANGE_SHULKER_BOX = get("minecraft:orange_shulker_box"); + @Nullable public static final ItemType ORANGE_STAINED_GLASS = get("minecraft:orange_stained_glass"); + @Nullable public static final ItemType ORANGE_STAINED_GLASS_PANE = get("minecraft:orange_stained_glass_pane"); + @Nullable public static final ItemType ORANGE_TERRACOTTA = get("minecraft:orange_terracotta"); + @Nullable public static final ItemType ORANGE_TULIP = get("minecraft:orange_tulip"); + @Nullable public static final ItemType ORANGE_WOOL = get("minecraft:orange_wool"); + @Nullable public static final ItemType OXEYE_DAISY = get("minecraft:oxeye_daisy"); + @Nullable public static final ItemType PACKED_ICE = get("minecraft:packed_ice"); + @Nullable public static final ItemType PAINTING = get("minecraft:painting"); + @Nullable public static final ItemType PAPER = get("minecraft:paper"); + @Nullable public static final ItemType PARROT_SPAWN_EGG = get("minecraft:parrot_spawn_egg"); + @Nullable public static final ItemType PEONY = get("minecraft:peony"); + @Nullable public static final ItemType PETRIFIED_OAK_SLAB = get("minecraft:petrified_oak_slab"); + @Nullable public static final ItemType PHANTOM_MEMBRANE = get("minecraft:phantom_membrane"); + @Nullable public static final ItemType PHANTOM_SPAWN_EGG = get("minecraft:phantom_spawn_egg"); + @Nullable public static final ItemType PIG_SPAWN_EGG = get("minecraft:pig_spawn_egg"); + @Nullable public static final ItemType PINK_BANNER = get("minecraft:pink_banner"); + @Nullable public static final ItemType PINK_BED = get("minecraft:pink_bed"); + @Nullable public static final ItemType PINK_CARPET = get("minecraft:pink_carpet"); + @Nullable public static final ItemType PINK_CONCRETE = get("minecraft:pink_concrete"); + @Nullable public static final ItemType PINK_CONCRETE_POWDER = get("minecraft:pink_concrete_powder"); + @Nullable public static final ItemType PINK_DYE = get("minecraft:pink_dye"); + @Nullable public static final ItemType PINK_GLAZED_TERRACOTTA = get("minecraft:pink_glazed_terracotta"); + @Nullable public static final ItemType PINK_SHULKER_BOX = get("minecraft:pink_shulker_box"); + @Nullable public static final ItemType PINK_STAINED_GLASS = get("minecraft:pink_stained_glass"); + @Nullable public static final ItemType PINK_STAINED_GLASS_PANE = get("minecraft:pink_stained_glass_pane"); + @Nullable public static final ItemType PINK_TERRACOTTA = get("minecraft:pink_terracotta"); + @Nullable public static final ItemType PINK_TULIP = get("minecraft:pink_tulip"); + @Nullable public static final ItemType PINK_WOOL = get("minecraft:pink_wool"); + @Nullable public static final ItemType PISTON = get("minecraft:piston"); + @Nullable public static final ItemType PLAYER_HEAD = get("minecraft:player_head"); + @Nullable public static final ItemType PODZOL = get("minecraft:podzol"); + @Nullable public static final ItemType POISONOUS_POTATO = get("minecraft:poisonous_potato"); + @Nullable public static final ItemType POLAR_BEAR_SPAWN_EGG = get("minecraft:polar_bear_spawn_egg"); + @Nullable public static final ItemType POLISHED_ANDESITE = get("minecraft:polished_andesite"); + @Nullable public static final ItemType POLISHED_DIORITE = get("minecraft:polished_diorite"); + @Nullable public static final ItemType POLISHED_GRANITE = get("minecraft:polished_granite"); + @Nullable public static final ItemType POPPED_CHORUS_FRUIT = get("minecraft:popped_chorus_fruit"); + @Nullable public static final ItemType POPPY = get("minecraft:poppy"); + @Nullable public static final ItemType PORKCHOP = get("minecraft:porkchop"); + @Nullable public static final ItemType POTATO = get("minecraft:potato"); + @Nullable public static final ItemType POTION = get("minecraft:potion"); + @Nullable public static final ItemType POWERED_RAIL = get("minecraft:powered_rail"); + @Nullable public static final ItemType PRISMARINE = get("minecraft:prismarine"); + @Nullable public static final ItemType PRISMARINE_BRICK_SLAB = get("minecraft:prismarine_brick_slab"); + @Nullable public static final ItemType PRISMARINE_BRICK_STAIRS = get("minecraft:prismarine_brick_stairs"); + @Nullable public static final ItemType PRISMARINE_BRICKS = get("minecraft:prismarine_bricks"); + @Nullable public static final ItemType PRISMARINE_CRYSTALS = get("minecraft:prismarine_crystals"); + @Nullable public static final ItemType PRISMARINE_SHARD = get("minecraft:prismarine_shard"); + @Nullable public static final ItemType PRISMARINE_SLAB = get("minecraft:prismarine_slab"); + @Nullable public static final ItemType PRISMARINE_STAIRS = get("minecraft:prismarine_stairs"); + @Nullable public static final ItemType PUFFERFISH = get("minecraft:pufferfish"); + @Nullable public static final ItemType PUFFERFISH_BUCKET = get("minecraft:pufferfish_bucket"); + @Nullable public static final ItemType PUFFERFISH_SPAWN_EGG = get("minecraft:pufferfish_spawn_egg"); + @Nullable public static final ItemType PUMPKIN = get("minecraft:pumpkin"); + @Nullable public static final ItemType PUMPKIN_PIE = get("minecraft:pumpkin_pie"); + @Nullable public static final ItemType PUMPKIN_SEEDS = get("minecraft:pumpkin_seeds"); + @Nullable public static final ItemType PURPLE_BANNER = get("minecraft:purple_banner"); + @Nullable public static final ItemType PURPLE_BED = get("minecraft:purple_bed"); + @Nullable public static final ItemType PURPLE_CARPET = get("minecraft:purple_carpet"); + @Nullable public static final ItemType PURPLE_CONCRETE = get("minecraft:purple_concrete"); + @Nullable public static final ItemType PURPLE_CONCRETE_POWDER = get("minecraft:purple_concrete_powder"); + @Nullable public static final ItemType PURPLE_DYE = get("minecraft:purple_dye"); + @Nullable public static final ItemType PURPLE_GLAZED_TERRACOTTA = get("minecraft:purple_glazed_terracotta"); + @Nullable public static final ItemType PURPLE_SHULKER_BOX = get("minecraft:purple_shulker_box"); + @Nullable public static final ItemType PURPLE_STAINED_GLASS = get("minecraft:purple_stained_glass"); + @Nullable public static final ItemType PURPLE_STAINED_GLASS_PANE = get("minecraft:purple_stained_glass_pane"); + @Nullable public static final ItemType PURPLE_TERRACOTTA = get("minecraft:purple_terracotta"); + @Nullable public static final ItemType PURPLE_WOOL = get("minecraft:purple_wool"); + @Nullable public static final ItemType PURPUR_BLOCK = get("minecraft:purpur_block"); + @Nullable public static final ItemType PURPUR_PILLAR = get("minecraft:purpur_pillar"); + @Nullable public static final ItemType PURPUR_SLAB = get("minecraft:purpur_slab"); + @Nullable public static final ItemType PURPUR_STAIRS = get("minecraft:purpur_stairs"); + @Nullable public static final ItemType QUARTZ = get("minecraft:quartz"); + @Nullable public static final ItemType QUARTZ_BLOCK = get("minecraft:quartz_block"); + @Nullable public static final ItemType QUARTZ_PILLAR = get("minecraft:quartz_pillar"); + @Nullable public static final ItemType QUARTZ_SLAB = get("minecraft:quartz_slab"); + @Nullable public static final ItemType QUARTZ_STAIRS = get("minecraft:quartz_stairs"); + @Nullable public static final ItemType RABBIT = get("minecraft:rabbit"); + @Nullable public static final ItemType RABBIT_FOOT = get("minecraft:rabbit_foot"); + @Nullable public static final ItemType RABBIT_HIDE = get("minecraft:rabbit_hide"); + @Nullable public static final ItemType RABBIT_SPAWN_EGG = get("minecraft:rabbit_spawn_egg"); + @Nullable public static final ItemType RABBIT_STEW = get("minecraft:rabbit_stew"); + @Nullable public static final ItemType RAIL = get("minecraft:rail"); + @Nullable public static final ItemType RED_BANNER = get("minecraft:red_banner"); + @Nullable public static final ItemType RED_BED = get("minecraft:red_bed"); + @Nullable public static final ItemType RED_CARPET = get("minecraft:red_carpet"); + @Nullable public static final ItemType RED_CONCRETE = get("minecraft:red_concrete"); + @Nullable public static final ItemType RED_CONCRETE_POWDER = get("minecraft:red_concrete_powder"); + @Nullable public static final ItemType RED_GLAZED_TERRACOTTA = get("minecraft:red_glazed_terracotta"); + @Nullable public static final ItemType RED_MUSHROOM = get("minecraft:red_mushroom"); + @Nullable public static final ItemType RED_MUSHROOM_BLOCK = get("minecraft:red_mushroom_block"); + @Nullable public static final ItemType RED_NETHER_BRICKS = get("minecraft:red_nether_bricks"); + @Nullable public static final ItemType RED_SAND = get("minecraft:red_sand"); + @Nullable public static final ItemType RED_SANDSTONE = get("minecraft:red_sandstone"); + @Nullable public static final ItemType RED_SANDSTONE_SLAB = get("minecraft:red_sandstone_slab"); + @Nullable public static final ItemType RED_SANDSTONE_STAIRS = get("minecraft:red_sandstone_stairs"); + @Nullable public static final ItemType RED_SHULKER_BOX = get("minecraft:red_shulker_box"); + @Nullable public static final ItemType RED_STAINED_GLASS = get("minecraft:red_stained_glass"); + @Nullable public static final ItemType RED_STAINED_GLASS_PANE = get("minecraft:red_stained_glass_pane"); + @Nullable public static final ItemType RED_TERRACOTTA = get("minecraft:red_terracotta"); + @Nullable public static final ItemType RED_TULIP = get("minecraft:red_tulip"); + @Nullable public static final ItemType RED_WOOL = get("minecraft:red_wool"); + @Nullable public static final ItemType REDSTONE = get("minecraft:redstone"); + @Nullable public static final ItemType REDSTONE_BLOCK = get("minecraft:redstone_block"); + @Nullable public static final ItemType REDSTONE_LAMP = get("minecraft:redstone_lamp"); + @Nullable public static final ItemType REDSTONE_ORE = get("minecraft:redstone_ore"); + @Nullable public static final ItemType REDSTONE_TORCH = get("minecraft:redstone_torch"); + @Nullable public static final ItemType REPEATER = get("minecraft:repeater"); + @Nullable public static final ItemType REPEATING_COMMAND_BLOCK = get("minecraft:repeating_command_block"); + @Nullable public static final ItemType ROSE_BUSH = get("minecraft:rose_bush"); + @Nullable public static final ItemType ROSE_RED = get("minecraft:rose_red"); + @Nullable public static final ItemType ROTTEN_FLESH = get("minecraft:rotten_flesh"); + @Nullable public static final ItemType SADDLE = get("minecraft:saddle"); + @Nullable public static final ItemType SALMON = get("minecraft:salmon"); + @Nullable public static final ItemType SALMON_BUCKET = get("minecraft:salmon_bucket"); + @Nullable public static final ItemType SALMON_SPAWN_EGG = get("minecraft:salmon_spawn_egg"); + @Nullable public static final ItemType SAND = get("minecraft:sand"); + @Nullable public static final ItemType SANDSTONE = get("minecraft:sandstone"); + @Nullable public static final ItemType SANDSTONE_SLAB = get("minecraft:sandstone_slab"); + @Nullable public static final ItemType SANDSTONE_STAIRS = get("minecraft:sandstone_stairs"); + @Nullable public static final ItemType SCUTE = get("minecraft:scute"); + @Nullable public static final ItemType SEA_LANTERN = get("minecraft:sea_lantern"); + @Nullable public static final ItemType SEA_PICKLE = get("minecraft:sea_pickle"); + @Nullable public static final ItemType SEAGRASS = get("minecraft:seagrass"); + @Nullable public static final ItemType SHEARS = get("minecraft:shears"); + @Nullable public static final ItemType SHEEP_SPAWN_EGG = get("minecraft:sheep_spawn_egg"); + @Nullable public static final ItemType SHIELD = get("minecraft:shield"); + @Nullable public static final ItemType SHULKER_BOX = get("minecraft:shulker_box"); + @Nullable public static final ItemType SHULKER_SHELL = get("minecraft:shulker_shell"); + @Nullable public static final ItemType SHULKER_SPAWN_EGG = get("minecraft:shulker_spawn_egg"); + @Nullable public static final ItemType SIGN = get("minecraft:sign"); + @Nullable public static final ItemType SILVERFISH_SPAWN_EGG = get("minecraft:silverfish_spawn_egg"); + @Nullable public static final ItemType SKELETON_HORSE_SPAWN_EGG = get("minecraft:skeleton_horse_spawn_egg"); + @Nullable public static final ItemType SKELETON_SKULL = get("minecraft:skeleton_skull"); + @Nullable public static final ItemType SKELETON_SPAWN_EGG = get("minecraft:skeleton_spawn_egg"); + @Nullable public static final ItemType SLIME_BALL = get("minecraft:slime_ball"); + @Nullable public static final ItemType SLIME_BLOCK = get("minecraft:slime_block"); + @Nullable public static final ItemType SLIME_SPAWN_EGG = get("minecraft:slime_spawn_egg"); + @Nullable public static final ItemType SMOOTH_QUARTZ = get("minecraft:smooth_quartz"); + @Nullable public static final ItemType SMOOTH_RED_SANDSTONE = get("minecraft:smooth_red_sandstone"); + @Nullable public static final ItemType SMOOTH_SANDSTONE = get("minecraft:smooth_sandstone"); + @Nullable public static final ItemType SMOOTH_STONE = get("minecraft:smooth_stone"); + @Nullable public static final ItemType SNOW = get("minecraft:snow"); + @Nullable public static final ItemType SNOW_BLOCK = get("minecraft:snow_block"); + @Nullable public static final ItemType SNOWBALL = get("minecraft:snowball"); + @Nullable public static final ItemType SOUL_SAND = get("minecraft:soul_sand"); + @Nullable public static final ItemType SPAWNER = get("minecraft:spawner"); + @Nullable public static final ItemType SPECTRAL_ARROW = get("minecraft:spectral_arrow"); + @Nullable public static final ItemType SPIDER_EYE = get("minecraft:spider_eye"); + @Nullable public static final ItemType SPIDER_SPAWN_EGG = get("minecraft:spider_spawn_egg"); + @Nullable public static final ItemType SPLASH_POTION = get("minecraft:splash_potion"); + @Nullable public static final ItemType SPONGE = get("minecraft:sponge"); + @Nullable public static final ItemType SPRUCE_BOAT = get("minecraft:spruce_boat"); + @Nullable public static final ItemType SPRUCE_BUTTON = get("minecraft:spruce_button"); + @Nullable public static final ItemType SPRUCE_DOOR = get("minecraft:spruce_door"); + @Nullable public static final ItemType SPRUCE_FENCE = get("minecraft:spruce_fence"); + @Nullable public static final ItemType SPRUCE_FENCE_GATE = get("minecraft:spruce_fence_gate"); + @Nullable public static final ItemType SPRUCE_LEAVES = get("minecraft:spruce_leaves"); + @Nullable public static final ItemType SPRUCE_LOG = get("minecraft:spruce_log"); + @Nullable public static final ItemType SPRUCE_PLANKS = get("minecraft:spruce_planks"); + @Nullable public static final ItemType SPRUCE_PRESSURE_PLATE = get("minecraft:spruce_pressure_plate"); + @Nullable public static final ItemType SPRUCE_SAPLING = get("minecraft:spruce_sapling"); + @Nullable public static final ItemType SPRUCE_SLAB = get("minecraft:spruce_slab"); + @Nullable public static final ItemType SPRUCE_STAIRS = get("minecraft:spruce_stairs"); + @Nullable public static final ItemType SPRUCE_TRAPDOOR = get("minecraft:spruce_trapdoor"); + @Nullable public static final ItemType SPRUCE_WOOD = get("minecraft:spruce_wood"); + @Nullable public static final ItemType SQUID_SPAWN_EGG = get("minecraft:squid_spawn_egg"); + @Nullable public static final ItemType STICK = get("minecraft:stick"); + @Nullable public static final ItemType STICKY_PISTON = get("minecraft:sticky_piston"); + @Nullable public static final ItemType STONE = get("minecraft:stone"); + @Nullable public static final ItemType STONE_AXE = get("minecraft:stone_axe"); + @Nullable public static final ItemType STONE_BRICK_SLAB = get("minecraft:stone_brick_slab"); + @Nullable public static final ItemType STONE_BRICK_STAIRS = get("minecraft:stone_brick_stairs"); + @Nullable public static final ItemType STONE_BRICKS = get("minecraft:stone_bricks"); + @Nullable public static final ItemType STONE_BUTTON = get("minecraft:stone_button"); + @Nullable public static final ItemType STONE_HOE = get("minecraft:stone_hoe"); + @Nullable public static final ItemType STONE_PICKAXE = get("minecraft:stone_pickaxe"); + @Nullable public static final ItemType STONE_PRESSURE_PLATE = get("minecraft:stone_pressure_plate"); + @Nullable public static final ItemType STONE_SHOVEL = get("minecraft:stone_shovel"); + @Nullable public static final ItemType STONE_SLAB = get("minecraft:stone_slab"); + @Nullable public static final ItemType STONE_SWORD = get("minecraft:stone_sword"); + @Nullable public static final ItemType STRAY_SPAWN_EGG = get("minecraft:stray_spawn_egg"); + @Nullable public static final ItemType STRING = get("minecraft:string"); + @Nullable public static final ItemType STRIPPED_ACACIA_LOG = get("minecraft:stripped_acacia_log"); + @Nullable public static final ItemType STRIPPED_ACACIA_WOOD = get("minecraft:stripped_acacia_wood"); + @Nullable public static final ItemType STRIPPED_BIRCH_LOG = get("minecraft:stripped_birch_log"); + @Nullable public static final ItemType STRIPPED_BIRCH_WOOD = get("minecraft:stripped_birch_wood"); + @Nullable public static final ItemType STRIPPED_DARK_OAK_LOG = get("minecraft:stripped_dark_oak_log"); + @Nullable public static final ItemType STRIPPED_DARK_OAK_WOOD = get("minecraft:stripped_dark_oak_wood"); + @Nullable public static final ItemType STRIPPED_JUNGLE_LOG = get("minecraft:stripped_jungle_log"); + @Nullable public static final ItemType STRIPPED_JUNGLE_WOOD = get("minecraft:stripped_jungle_wood"); + @Nullable public static final ItemType STRIPPED_OAK_LOG = get("minecraft:stripped_oak_log"); + @Nullable public static final ItemType STRIPPED_OAK_WOOD = get("minecraft:stripped_oak_wood"); + @Nullable public static final ItemType STRIPPED_SPRUCE_LOG = get("minecraft:stripped_spruce_log"); + @Nullable public static final ItemType STRIPPED_SPRUCE_WOOD = get("minecraft:stripped_spruce_wood"); + @Nullable public static final ItemType STRUCTURE_BLOCK = get("minecraft:structure_block"); + @Nullable public static final ItemType STRUCTURE_VOID = get("minecraft:structure_void"); + @Nullable public static final ItemType SUGAR = get("minecraft:sugar"); + @Nullable public static final ItemType SUGAR_CANE = get("minecraft:sugar_cane"); + @Nullable public static final ItemType SUNFLOWER = get("minecraft:sunflower"); + @Nullable public static final ItemType TALL_GRASS = get("minecraft:tall_grass"); + @Nullable public static final ItemType TERRACOTTA = get("minecraft:terracotta"); + @Nullable public static final ItemType TIPPED_ARROW = get("minecraft:tipped_arrow"); + @Nullable public static final ItemType TNT = get("minecraft:tnt"); + @Nullable public static final ItemType TNT_MINECART = get("minecraft:tnt_minecart"); + @Nullable public static final ItemType TORCH = get("minecraft:torch"); + @Nullable public static final ItemType TOTEM_OF_UNDYING = get("minecraft:totem_of_undying"); + @Nullable public static final ItemType TRAPPED_CHEST = get("minecraft:trapped_chest"); + @Nullable public static final ItemType TRIDENT = get("minecraft:trident"); + @Nullable public static final ItemType TRIPWIRE_HOOK = get("minecraft:tripwire_hook"); + @Nullable public static final ItemType TROPICAL_FISH = get("minecraft:tropical_fish"); + @Nullable public static final ItemType TROPICAL_FISH_BUCKET = get("minecraft:tropical_fish_bucket"); + @Nullable public static final ItemType TROPICAL_FISH_SPAWN_EGG = get("minecraft:tropical_fish_spawn_egg"); + @Nullable public static final ItemType TUBE_CORAL = get("minecraft:tube_coral"); + @Nullable public static final ItemType TUBE_CORAL_BLOCK = get("minecraft:tube_coral_block"); + @Nullable public static final ItemType TUBE_CORAL_FAN = get("minecraft:tube_coral_fan"); + @Nullable public static final ItemType TURTLE_EGG = get("minecraft:turtle_egg"); + @Nullable public static final ItemType TURTLE_HELMET = get("minecraft:turtle_helmet"); + @Nullable public static final ItemType TURTLE_SPAWN_EGG = get("minecraft:turtle_spawn_egg"); + @Nullable public static final ItemType VEX_SPAWN_EGG = get("minecraft:vex_spawn_egg"); + @Nullable public static final ItemType VILLAGER_SPAWN_EGG = get("minecraft:villager_spawn_egg"); + @Nullable public static final ItemType VINDICATOR_SPAWN_EGG = get("minecraft:vindicator_spawn_egg"); + @Nullable public static final ItemType VINE = get("minecraft:vine"); + @Nullable public static final ItemType WATER_BUCKET = get("minecraft:water_bucket"); + @Nullable public static final ItemType WET_SPONGE = get("minecraft:wet_sponge"); + @Nullable public static final ItemType WHEAT = get("minecraft:wheat"); + @Nullable public static final ItemType WHEAT_SEEDS = get("minecraft:wheat_seeds"); + @Nullable public static final ItemType WHITE_BANNER = get("minecraft:white_banner"); + @Nullable public static final ItemType WHITE_BED = get("minecraft:white_bed"); + @Nullable public static final ItemType WHITE_CARPET = get("minecraft:white_carpet"); + @Nullable public static final ItemType WHITE_CONCRETE = get("minecraft:white_concrete"); + @Nullable public static final ItemType WHITE_CONCRETE_POWDER = get("minecraft:white_concrete_powder"); + @Nullable public static final ItemType WHITE_GLAZED_TERRACOTTA = get("minecraft:white_glazed_terracotta"); + @Nullable public static final ItemType WHITE_SHULKER_BOX = get("minecraft:white_shulker_box"); + @Nullable public static final ItemType WHITE_STAINED_GLASS = get("minecraft:white_stained_glass"); + @Nullable public static final ItemType WHITE_STAINED_GLASS_PANE = get("minecraft:white_stained_glass_pane"); + @Nullable public static final ItemType WHITE_TERRACOTTA = get("minecraft:white_terracotta"); + @Nullable public static final ItemType WHITE_TULIP = get("minecraft:white_tulip"); + @Nullable public static final ItemType WHITE_WOOL = get("minecraft:white_wool"); + @Nullable public static final ItemType WITCH_SPAWN_EGG = get("minecraft:witch_spawn_egg"); + @Nullable public static final ItemType WITHER_SKELETON_SKULL = get("minecraft:wither_skeleton_skull"); + @Nullable public static final ItemType WITHER_SKELETON_SPAWN_EGG = get("minecraft:wither_skeleton_spawn_egg"); + @Nullable public static final ItemType WOLF_SPAWN_EGG = get("minecraft:wolf_spawn_egg"); + @Nullable public static final ItemType WOODEN_AXE = get("minecraft:wooden_axe"); + @Nullable public static final ItemType WOODEN_HOE = get("minecraft:wooden_hoe"); + @Nullable public static final ItemType WOODEN_PICKAXE = get("minecraft:wooden_pickaxe"); + @Nullable public static final ItemType WOODEN_SHOVEL = get("minecraft:wooden_shovel"); + @Nullable public static final ItemType WOODEN_SWORD = get("minecraft:wooden_sword"); + @Nullable public static final ItemType WRITABLE_BOOK = get("minecraft:writable_book"); + @Nullable public static final ItemType WRITTEN_BOOK = get("minecraft:written_book"); + @Nullable public static final ItemType YELLOW_BANNER = get("minecraft:yellow_banner"); + @Nullable public static final ItemType YELLOW_BED = get("minecraft:yellow_bed"); + @Nullable public static final ItemType YELLOW_CARPET = get("minecraft:yellow_carpet"); + @Nullable public static final ItemType YELLOW_CONCRETE = get("minecraft:yellow_concrete"); + @Nullable public static final ItemType YELLOW_CONCRETE_POWDER = get("minecraft:yellow_concrete_powder"); + @Nullable public static final ItemType YELLOW_GLAZED_TERRACOTTA = get("minecraft:yellow_glazed_terracotta"); + @Nullable public static final ItemType YELLOW_SHULKER_BOX = get("minecraft:yellow_shulker_box"); + @Nullable public static final ItemType YELLOW_STAINED_GLASS = get("minecraft:yellow_stained_glass"); + @Nullable public static final ItemType YELLOW_STAINED_GLASS_PANE = get("minecraft:yellow_stained_glass_pane"); + @Nullable public static final ItemType YELLOW_TERRACOTTA = get("minecraft:yellow_terracotta"); + @Nullable public static final ItemType YELLOW_WOOL = get("minecraft:yellow_wool"); + @Nullable public static final ItemType ZOMBIE_HEAD = get("minecraft:zombie_head"); + @Nullable public static final ItemType ZOMBIE_HORSE_SPAWN_EGG = get("minecraft:zombie_horse_spawn_egg"); + @Nullable public static final ItemType ZOMBIE_PIGMAN_SPAWN_EGG = get("minecraft:zombie_pigman_spawn_egg"); + @Nullable public static final ItemType ZOMBIE_SPAWN_EGG = get("minecraft:zombie_spawn_egg"); + @Nullable public static final ItemType ZOMBIE_VILLAGER_SPAWN_EGG = get("minecraft:zombie_villager_spawn_egg"); private ItemTypes() { } @@ -842,10 +842,6 @@ public final class ItemTypes { // return ItemType.REGISTRY.register(item.getId(), item); return internalRegister(item); } - - public static @Nullable ItemType get(final String id) { - return ItemType.REGISTRY.get(id); - } private static ArrayList sortedRegistry; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BiomeRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BiomeRegistry.java index 8a581b7a6..52874d034 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BiomeRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BiomeRegistry.java @@ -19,10 +19,8 @@ package com.sk89q.worldedit.world.registry; -import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BiomeData; - -import java.util.List; +import com.sk89q.worldedit.world.biome.BiomeType; import javax.annotation.Nullable; @@ -31,22 +29,6 @@ import javax.annotation.Nullable; */ public interface BiomeRegistry { - /** - * Create a new biome given its biome ID. - * - * @param id its biome ID - * @return a new biome or null if it can't be created - */ - @Nullable - BaseBiome createFromId(int id); - - /** - * Get a list of available biomes. - * - * @return a list of biomes - */ - List getBiomes(); - /** * Get data about a biome. * @@ -54,6 +36,6 @@ public interface BiomeRegistry { * @return a data object or null if information is not known */ @Nullable - BiomeData getData(BaseBiome biome); + BiomeData getData(BiomeType biome); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java index 9023fefd5..e7c83ca7c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java @@ -24,7 +24,10 @@ import com.google.gson.*; import com.google.gson.reflect.TypeToken; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.gson.VectorAdapter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Nullable; import java.io.IOException; import java.lang.reflect.Type; import java.net.URL; @@ -32,10 +35,6 @@ import java.nio.charset.Charset; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.annotation.Nullable; /** * Provides block data based on the built-in block database that is bundled @@ -50,7 +49,7 @@ import javax.annotation.Nullable; */ public class BundledBlockData { - private static final Logger log = Logger.getLogger(BundledBlockData.class.getCanonicalName()); + private static final Logger log = LoggerFactory.getLogger(BundledBlockData.class); private static BundledBlockData INSTANCE; private final Map idMap = new HashMap<>(); @@ -62,7 +61,7 @@ public class BundledBlockData { try { loadFromResource(); } catch (Throwable e) { - log.log(Level.WARNING, "Failed to load the built-in block registry", e); + log.warn("Failed to load the built-in block registry", e); } } @@ -73,7 +72,6 @@ public class BundledBlockData { */ private void loadFromResource() throws IOException { GsonBuilder gsonBuilder = new GsonBuilder(); -//<<<<<<< HEAD gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter()); gsonBuilder.registerTypeAdapter(int.class, new JsonDeserializer() { @Override @@ -87,9 +85,6 @@ public class BundledBlockData { return primitive.getAsInt(); } }); -//======= -// gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter()); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner Gson gson = gsonBuilder.create(); URL url = BundledBlockData.class.getResource("blocks.json"); if (url == null) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java index 2867b2e56..4bdac0c8a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java @@ -25,17 +25,16 @@ import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.gson.VectorAdapter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Nullable; import java.io.IOException; import java.net.URL; import java.nio.charset.Charset; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.annotation.Nullable; /** * Provides item data based on the built-in item database that is bundled @@ -50,7 +49,7 @@ import javax.annotation.Nullable; */ public class BundledItemData { - private static final Logger log = Logger.getLogger(BundledItemData.class.getCanonicalName()); + private static final Logger log = LoggerFactory.getLogger(BundledItemData.class); private static BundledItemData INSTANCE; private final Map idMap = new HashMap<>(); @@ -62,7 +61,7 @@ public class BundledItemData { try { loadFromResource(); } catch (Throwable e) { - log.log(Level.WARNING, "Failed to load the built-in item registry", e); + log.warn("Failed to load the built-in item registry", e); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemRegistry.java index 4af6acaaf..3d6b4c72d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemRegistry.java @@ -19,9 +19,7 @@ package com.sk89q.worldedit.world.registry; -import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.world.item.ItemType; -import com.sk89q.worldedit.world.item.ItemTypes; import javax.annotation.Nullable; import java.util.Collection; @@ -35,9 +33,18 @@ public class BundledItemRegistry implements ItemRegistry { @Nullable @Override - public BaseItem createFromId(String id) { - ItemType itemType = ItemTypes.get(id); - return itemType == null ? null : new BaseItem(itemType); + public String getName(ItemType itemType) { + String id = itemType.getId(); + BundledItemData.ItemEntry itemEntry = BundledItemData.getInstance().findById(id); + if (itemEntry != null) { + String localized = itemEntry.localizedName; + if (localized.equals("Air")) { + int c = id.indexOf(':'); + return c < 0 ? id : id.substring(c + 1); + } + return localized; + } + return null; } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java index 5e46af3fe..d129992d4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.world.registry; -import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.world.item.ItemType; import javax.annotation.Nullable; @@ -29,13 +28,13 @@ import java.util.Collections; public interface ItemRegistry { /** - * Create a new item using its ID. + * Gets the name for the given item. * - * @param id the id - * @return the item, which may be null if no item exists + * @param itemType the item + * @return The name, or null if it's unknown */ @Nullable - BaseItem createFromId(String id); + String getName(ItemType itemType); /** * Register all items diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java index 369578dfa..49bea4045 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java @@ -43,19 +43,20 @@ import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.util.gson.VectorAdapter; import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.annotation.Nullable; import java.io.IOException; import java.net.URL; import java.nio.charset.Charset; import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.annotation.Nullable; +import static com.google.common.base.Preconditions.checkNotNull; public class LegacyMapper { - private static final Logger log = Logger.getLogger(LegacyMapper.class.getCanonicalName()); + private static final Logger log = LoggerFactory.getLogger(LegacyMapper.class); private static LegacyMapper INSTANCE; private final Int2ObjectArrayMap blockStateToLegacyId4Data = new Int2ObjectArrayMap<>(); @@ -71,7 +72,7 @@ public class LegacyMapper { loadFromResource(); } catch (Throwable e) { e.printStackTrace(); - log.log(Level.WARNING, "Failed to load the built-in legacy id registry", e); + log.warn("Failed to load the built-in legacy id registry", e); } } @@ -110,7 +111,7 @@ public class LegacyMapper { blockStateToLegacyId4Data.put(blockState.getInternalId(), (Integer) combinedId); blockStateToLegacyId4Data.putIfAbsent(blockState.getInternalBlockTypeId(), combinedId); } catch (Exception e) { - log.fine("Unknown block: " + blockEntry.getValue()); + log.warn("Unknown block: " + blockEntry.getValue()); } } for (int id = 0; id < 256; id++) { @@ -127,7 +128,7 @@ public class LegacyMapper { try { itemMap.put(getCombinedId(itemEntry.getKey()), ItemTypes.get(itemEntry.getValue())); } catch (Exception e) { - log.fine("Unknown item: " + itemEntry.getValue()); + log.warn("Unknown item: " + itemEntry.getValue()); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/NullBiomeRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/NullBiomeRegistry.java index 551cbc039..ac0d95240 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/NullBiomeRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/NullBiomeRegistry.java @@ -19,11 +19,8 @@ package com.sk89q.worldedit.world.registry; -import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BiomeData; - -import java.util.Collections; -import java.util.List; +import com.sk89q.worldedit.world.biome.BiomeType; import javax.annotation.Nullable; @@ -40,18 +37,7 @@ public class NullBiomeRegistry implements BiomeRegistry { @Nullable @Override - public BaseBiome createFromId(int id) { - return null; - } - - @Override - public List getBiomes() { - return Collections.emptyList(); - } - - @Nullable - @Override - public BiomeData getData(BaseBiome biome) { + public BiomeData getData(BiomeType biome) { return null; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/Snapshot.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/Snapshot.java index 58525a7d2..0af2b6e18 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/Snapshot.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/Snapshot.java @@ -29,11 +29,12 @@ import com.sk89q.worldedit.world.storage.TrueZipLegacyChunkStore; import com.sk89q.worldedit.world.storage.TrueZipMcRegionChunkStore; import com.sk89q.worldedit.world.storage.ZippedLegacyChunkStore; import com.sk89q.worldedit.world.storage.ZippedMcRegionChunkStore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.util.Calendar; -import java.util.logging.Logger; import java.util.zip.ZipFile; /** @@ -41,7 +42,7 @@ import java.util.zip.ZipFile; */ public class Snapshot implements Comparable { - protected static Logger logger = Logger.getLogger(Snapshot.class.getCanonicalName()); + protected static Logger logger = LoggerFactory.getLogger(Snapshot.class); protected File file; protected String name; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java index 4a128409c..c5b134c62 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java @@ -23,7 +23,6 @@ import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.DataException; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java index 4d193b694..b3b5728fe 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java @@ -29,7 +29,6 @@ import com.sk89q.worldedit.world.World; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.util.Map; import java.util.zip.GZIPInputStream; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/weather/WeatherTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/weather/WeatherTypes.java index 1aa1c9f12..d7450610d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/weather/WeatherTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/weather/WeatherTypes.java @@ -23,21 +23,20 @@ import javax.annotation.Nullable; public class WeatherTypes { - public static final WeatherType CLEAR = register("clear"); - public static final WeatherType RAIN = register("rain"); - public static final WeatherType THUNDER_STORM = register("thunder_storm"); + static { + // This isn't really a proper registry - so inject these before they're obtained. + WeatherType.REGISTRY.register("clear", new WeatherType("clear")); + WeatherType.REGISTRY.register("rain", new WeatherType("rain")); + WeatherType.REGISTRY.register("thunder_storm", new WeatherType("thunder_storm")); + } + + @Nullable public static final WeatherType CLEAR = get("clear"); + @Nullable public static final WeatherType RAIN = get("rain"); + @Nullable public static final WeatherType THUNDER_STORM = get("thunder_storm"); private WeatherTypes() { } - private static WeatherType register(final String id) { - return register(new WeatherType(id)); - } - - public static WeatherType register(final WeatherType weatherType) { - return WeatherType.REGISTRY.register(weatherType.getId(), weatherType); - } - public static @Nullable WeatherType get(final String id) { return WeatherType.REGISTRY.get(id); } diff --git a/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/legacy.json b/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/legacy.json index 7a5f42453..f8785401d 100644 --- a/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/legacy.json +++ b/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/legacy.json @@ -1849,7 +1849,7 @@ "48:0": "minecraft:mossy_cobblestone", "49:0": "minecraft:obsidian", "50:0": "minecraft:torch", - "52:0": "minecraft:mob_spawner", + "52:0": "minecraft:spawner", "53:0": "minecraft:oak_stairs", "54:0": "minecraft:chest", "56:0": "minecraft:diamond_ore", diff --git a/worldedit-core/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java b/worldedit-core/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java index 025981e6e..a542ebe30 100644 --- a/worldedit-core/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java +++ b/worldedit-core/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java @@ -21,17 +21,23 @@ package com.sk89q.minecraft.util.commands; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Arrays; import java.util.HashSet; -import java.util.logging.Level; -import java.util.logging.Logger; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import static org.junit.Assert.*; public class CommandContextTest { - private static final Logger log = Logger.getLogger(CommandContextTest.class.getCanonicalName()); + private static final Logger log = LoggerFactory.getLogger(CommandContextTest.class); private static final String firstCmdString = "herpderp -opw testers \"mani world\" 'another thing' because something"; CommandContext firstCommand; @@ -40,7 +46,7 @@ public class CommandContextTest { try { firstCommand = new CommandContext(firstCmdString, new HashSet<>(Arrays.asList('o', 'w'))); } catch (CommandException e) { - log.log(Level.WARNING, "Error", e); + log.warn("Error", e); fail("Unexpected exception when creating CommandContext"); } } @@ -79,7 +85,7 @@ public class CommandContextTest { new CommandContext(cmd); new CommandContext(cmd2); } catch (CommandException e) { - log.log(Level.WARNING, "Error", e); + log.warn("Error", e); fail("Error creating CommandContext"); } } @@ -90,7 +96,7 @@ public class CommandContextTest { try { new CommandContext(cmd); } catch (CommandException e) { - log.log(Level.WARNING, "Error", e); + log.warn("Error", e); fail("Error creating CommandContext"); } } @@ -101,7 +107,7 @@ public class CommandContextTest { try { new CommandContext(cmd); } catch (CommandException e) { - log.log(Level.WARNING, "Error", e); + log.warn("Error", e); fail("Error creating CommandContext"); } } @@ -115,7 +121,7 @@ public class CommandContextTest { CommandContext context2 = new CommandContext("r hello -f world"); assertTrue(context2.hasFlag('f')); } catch (CommandException e) { - log.log(Level.WARNING, "Error", e); + log.warn("Error", e); fail("Error creating CommandContext"); } } @@ -131,7 +137,7 @@ public class CommandContextTest { CommandContext context2 = new CommandContext("pm name \"hello world\" foo bar"); assertEquals("\"hello world\" foo bar", context2.getJoinedStrings(1)); } catch (CommandException e) { - log.log(Level.WARNING, "Error", e); + log.warn("Error", e); fail("Error creating CommandContext"); } } @@ -143,7 +149,7 @@ public class CommandContextTest { assertArrayEquals(new String[] { "foo", "bar", "baz" }, context.getSlice(0)); } catch (CommandException e) { - log.log(Level.WARNING, "Error", e); + log.warn("Error", e); fail("Error creating CommandContext"); } } @@ -154,7 +160,7 @@ public class CommandContextTest { CommandContext context = new CommandContext("region flag xmas blocked-cmds \"\""); assertEquals(context.argsLength(), 3); } catch (CommandException e) { - log.log(Level.WARNING, "Error", e); + log.warn("Error", e); fail("Error creating CommandContext"); } } diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java index e32b7c6cd..c90f312fe 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java @@ -42,7 +42,7 @@ public class BlockTransformExtentTest { @Before public void setUp() throws Exception { - BlockTypes.register(new BlockType("worldedit:test")); + BlockType.REGISTRY.register("worldedit:test", new BlockType("worldedit:test")); } @Test diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java index d60ed68f9..15d4f8225 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java @@ -19,11 +19,23 @@ package com.sk89q.worldedit.internal.expression; +import static java.lang.Math.atan2; +import static java.lang.Math.sin; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import com.sk89q.worldedit.LocalConfiguration; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.internal.expression.lexer.LexerException; import com.sk89q.worldedit.internal.expression.parser.ParserException; import com.sk89q.worldedit.internal.expression.runtime.EvaluationException; import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment; -import org.junit.Test; import static java.lang.Math.atan2; import static java.lang.Math.sin; @@ -31,6 +43,17 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; public class ExpressionTest { + @Before + public void setup() { + Platform mockPlat = Mockito.mock(Platform.class); + Mockito.when(mockPlat.getConfiguration()).thenReturn(new LocalConfiguration() { + @Override + public void load() { + } + }); + WorldEdit.getInstance().getPlatformManager().register(mockPlat); + } + @Test public void testEvaluate() throws ExpressionException { // check @@ -46,7 +69,7 @@ public class ExpressionTest { assertEquals(atan2(3, 4), simpleEval("atan2(3, 4)"), 0); // check variables - assertEquals(8, compile("foo+bar", "foo", "bar").evaluate(5, 3), 0); + assertEquals(8, compile("foo+bar", "foo", "bar").evaluate(5D, 3D), 0); } @Test @@ -105,7 +128,7 @@ public class ExpressionTest { @Test public void testAssign() throws ExpressionException { Expression foo = compile("{a=x} b=y; c=z", "x", "y", "z", "a", "b", "c"); - foo.evaluate(2, 3, 5); + foo.evaluate(2D, 3D, 5D); assertEquals(2, foo.getVariable("a", false).getValue(), 0); assertEquals(3, foo.getVariable("b", false).getValue(), 0); assertEquals(5, foo.getVariable("c", false).getValue(), 0); @@ -118,13 +141,13 @@ public class ExpressionTest { // test 'dangling else' final Expression expression1 = compile("if (1) if (0) x=4; else y=5;", "x", "y"); - expression1.evaluate(1, 2); + expression1.evaluate(1D, 2D); assertEquals(1, expression1.getVariable("x", false).getValue(), 0); assertEquals(5, expression1.getVariable("y", false).getValue(), 0); // test if the if construct is correctly recognized as a statement final Expression expression2 = compile("if (0) if (1) x=5; y=4;", "x", "y"); - expression2.evaluate(1, 2); + expression2.evaluate(1D, 2D); assertEquals(4, expression2.getVariable("y", false).getValue(), 0); } @@ -162,6 +185,16 @@ public class ExpressionTest { assertEquals(1, simpleEval("!queryRel(3,4,5,100,200)"), 0); } + @Test + public void testTimeout() throws Exception { + try { + simpleEval("for(i=0;i<256;i++){for(j=0;j<256;j++){for(k=0;k<256;k++){for(l=0;l<256;l++){ln(pi)}}}}"); + fail("Loop was not stopped."); + } catch (EvaluationException e) { + assertTrue(e.getMessage().contains("Calculations exceeded time limit")); + } + } + private double simpleEval(String expressionString) throws ExpressionException { final Expression expression = compile(expressionString); diff --git a/worldedit-forge/build.gradle b/worldedit-forge/build.gradle index f5c6e0f7d..8fe3fb9af 100644 --- a/worldedit-forge/build.gradle +++ b/worldedit-forge/build.gradle @@ -1,59 +1,76 @@ buildscript { repositories { + mavenLocal() mavenCentral() - maven { url = "http://files.minecraftforge.net/maven" } - maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url = "https://files.minecraftforge.net/maven" } jcenter() } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true } } -apply plugin: 'net.minecraftforge.gradle.forge' +apply plugin: 'net.minecraftforge.gradle' +def minecraftVersion = "1.13.2" +def forgeVersion = "25.0.76" dependencies { compile project(':worldedit-core') - compile 'org.spongepowered:spongeapi:6.0.0-SNAPSHOT' + compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.11.2' + + minecraft "net.minecraftforge:forge:${minecraftVersion}-${forgeVersion}" + testCompile group: 'org.mockito', name: 'mockito-core', version: '1.9.0-rc1' } sourceCompatibility = 1.8 targetCompatibility = 1.8 -repositories { - maven { - name = "Sponge" - url = "https://repo.spongepowered.org/maven" - } -} - -ext.forgeVersion = "14.22.0.2456" - minecraft { - version = "1.12.1-${project.forgeVersion}" - mappings = "snapshot_20170815" - runDir = 'run' + mappings channel: 'snapshot', version: '20190311-1.13.2' - replaceIn "com/sk89q/worldedit/forge/ForgeWorldEdit.java" - replace "%VERSION%", project.version + runs { + client = { + // recommended logging data for a userdev environment + properties 'forge.logging.markers': 'SCAN,REGISTRIES,REGISTRYDUMP' + // recommended logging level for the console + properties 'forge.logging.console.level': 'debug' + workingDirectory project.file('run').canonicalPath + source sourceSets.main + } + server = { + // recommended logging data for a userdev environment + properties 'forge.logging.markers': 'SCAN,REGISTRIES,REGISTRYDUMP' + // recommended logging level for the console + properties 'forge.logging.console.level': 'debug' + workingDirectory project.file('run').canonicalPath + source sourceSets.main + } + } + + accessTransformer = file('worldedit_at.cfg') } -project.archivesBaseName = "${project.archivesBaseName}-mc${minecraft.version}" +project.archivesBaseName = "${project.archivesBaseName}-mc${minecraftVersion}" processResources { - from (sourceSets.main.resources.srcDirs) { - expand 'version': project.version, - 'mcVersion': project.minecraft.version, - 'forgeVersion': project.forgeVersion, - 'internalVersion': project.internalVersion - include 'mcmod.info' + // this will ensure that this task is redone when the versions change. + inputs.property 'version', project.internalVersion + inputs.property 'forgeVersion', forgeVersion + + // replace stuff in mcmod.info, nothing else + from(sourceSets.main.resources.srcDirs) { + include 'META-INF/mods.toml' + + // replace version and mcversion + expand 'version': project.internalVersion, 'forgeVersion': forgeVersion } - from (sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' + // copy everything else except the mcmod.info + from(sourceSets.main.resources.srcDirs) { + exclude 'META-INF/mods.toml' } } @@ -67,13 +84,20 @@ jar { shadowJar { dependencies { + relocate "org.slf4j", "com.sk89q.worldedit.slf4j" + relocate "org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge" + include(dependency(':worldedit-core')) + include(dependency('org.slf4j:slf4j-api')) + include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) } } -reobf { - shadowJar { - mappingType = 'SEARGE' +afterEvaluate { + reobf { + shadowJar { + mappings = createMcpToSrg.output + } } } diff --git a/worldedit-forge/src/main/ant/build.xml b/worldedit-forge/src/main/ant/build.xml deleted file mode 100644 index 5753b52ce..000000000 --- a/worldedit-forge/src/main/ant/build.xml +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/CommandWrapper.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/CommandWrapper.java index 1ad0f10ca..daab12824 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/CommandWrapper.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/CommandWrapper.java @@ -19,60 +19,50 @@ package com.sk89q.worldedit.forge; +import com.mojang.brigadier.Command; +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.mojang.brigadier.tree.LiteralCommandNode; import com.sk89q.worldedit.util.command.CommandMapping; -import net.minecraft.command.CommandBase; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommand; -import net.minecraft.command.ICommandSender; -import net.minecraft.server.MinecraftServer; +import net.minecraft.command.CommandSource; +import net.minecraft.entity.player.EntityPlayerMP; -import java.util.Arrays; -import java.util.List; +import java.util.function.Predicate; -import javax.annotation.Nullable; +import static net.minecraft.command.Commands.literal; -public class CommandWrapper extends CommandBase { - private CommandMapping command; - - protected CommandWrapper(CommandMapping command) { - this.command = command; +public final class CommandWrapper { + private CommandWrapper() { } - @Override - public String getName() { - return command.getPrimaryAlias(); - } - - @Override - public List getAliases() { - return Arrays.asList(command.getAllAliases()); - } - - @Override - public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { - } - - @Override - public String getUsage(ICommandSender icommandsender) { - return "/" + command.getPrimaryAlias() + " " + command.getDescription().getUsage(); - } - - @Override - public int getRequiredPermissionLevel() { - return 0; - } - - @Override - public boolean checkPermission(MinecraftServer server, ICommandSender sender) { - return true; - } - - @Override - public int compareTo(@Nullable ICommand o) { - if (o == null) { - return 0; - } else { - return super.compareTo(o); + public static void register(CommandDispatcher dispatcher, CommandMapping command) { + for (String alias : command.getAllAliases()) { + LiteralArgumentBuilder base = literal(alias) + .executes(FAKE_COMMAND); + if (command.getDescription().getPermissions().size() > 0) { + base.requires(requirementsFor(command)); + } + dispatcher.register(base); } } + + public static final Command FAKE_COMMAND = ctx -> { + EntityPlayerMP player = ctx.getSource().asPlayer(); + if (player.world.isRemote()) { + return 0; + } + return 1; + }; + + private static Predicate requirementsFor(CommandMapping mapping) { + return ctx -> { + ForgePermissionsProvider permsProvider = ForgeWorldEdit.inst.getPermissionsProvider(); + return ctx.getEntity() instanceof EntityPlayerMP && + mapping.getDescription().getPermissions().stream() + .allMatch(perm -> permsProvider.hasPermission( + (EntityPlayerMP) ctx.getEntity(), perm + )); + }; + } + } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeAdapter.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeAdapter.java index e0f319cee..164ac65cf 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeAdapter.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeAdapter.java @@ -20,6 +20,8 @@ package com.sk89q.worldedit.forge; import com.google.common.collect.ImmutableList; +import com.sk89q.jnbt.CompoundTag; +import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.registry.state.BooleanProperty; @@ -29,19 +31,38 @@ import com.sk89q.worldedit.registry.state.IntegerProperty; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.world.World; - -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.properties.PropertyBool; -import net.minecraft.block.properties.PropertyDirection; -import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.properties.PropertyInteger; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.biome.BiomeTypes; +import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockType; +import com.sk89q.worldedit.world.block.BlockTypes; +import com.sk89q.worldedit.world.item.ItemType; +import com.sk89q.worldedit.world.item.ItemTypes; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.state.DirectionProperty; +import net.minecraft.state.IProperty; +import net.minecraft.state.StateContainer; import net.minecraft.util.EnumFacing; +import net.minecraft.util.IStringSerializable; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.biome.Biome; +import net.minecraftforge.registries.ForgeRegistries; +import java.util.Comparator; +import java.util.Map; +import java.util.TreeMap; import java.util.stream.Collectors; -final class ForgeAdapter { +import static com.google.common.base.Preconditions.checkNotNull; + +public final class ForgeAdapter { private ForgeAdapter() { } @@ -50,6 +71,14 @@ final class ForgeAdapter { return new ForgeWorld(world); } + public static Biome adapt(BiomeType biomeType) { + return ForgeRegistries.BIOMES.getValue(new ResourceLocation(biomeType.getId())); + } + + public static BiomeType adapt(Biome biome) { + return BiomeTypes.get(biome.getRegistryName().toString()); + } + public static Vector3 adapt(Vec3d vector) { return Vector3.at(vector.x, vector.y, vector.z); } @@ -93,23 +122,110 @@ final class ForgeAdapter { } public static Property adaptProperty(IProperty property) { - if (property instanceof PropertyBool) { - return new BooleanProperty(property.getName(), ImmutableList.copyOf(((PropertyBool) property).getAllowedValues())); + if (property instanceof net.minecraft.state.BooleanProperty) { + return new BooleanProperty(property.getName(), ImmutableList.copyOf(((net.minecraft.state.BooleanProperty) property).getAllowedValues())); } - if (property instanceof PropertyInteger) { - return new IntegerProperty(property.getName(), ImmutableList.copyOf(((PropertyInteger) property).getAllowedValues())); + if (property instanceof net.minecraft.state.IntegerProperty) { + return new IntegerProperty(property.getName(), ImmutableList.copyOf(((net.minecraft.state.IntegerProperty) property).getAllowedValues())); } - if (property instanceof PropertyDirection) { - return new DirectionalProperty(property.getName(), ((PropertyDirection) property).getAllowedValues().stream() + if (property instanceof DirectionProperty) { + return new DirectionalProperty(property.getName(), ((DirectionProperty) property).getAllowedValues().stream() .map(ForgeAdapter::adaptEnumFacing) .collect(Collectors.toList())); } - if (property instanceof PropertyEnum) { - return new EnumProperty(property.getName(), ((PropertyEnum) property).getAllowedValues().stream() - .map(e -> e.getName()) + if (property instanceof net.minecraft.state.EnumProperty) { + // Note: do not make x.getName a method reference. + // It will cause runtime bootstrap exceptions. + return new EnumProperty(property.getName(), ((net.minecraft.state.EnumProperty) property).getAllowedValues().stream() + .map(x -> x.getName()) .collect(Collectors.toList())); } return new IPropertyAdapter<>(property); } + public static Map, Object> adaptProperties(BlockType block, Map, Comparable> mcProps) { + Map, Object> props = new TreeMap<>(Comparator.comparing(Property::getName)); + for (Map.Entry, Comparable> prop : mcProps.entrySet()) { + Object value = prop.getValue(); + if (prop.getKey() instanceof DirectionProperty) { + value = adaptEnumFacing((EnumFacing) value); + } else if (prop.getKey() instanceof net.minecraft.state.EnumProperty) { + value = ((IStringSerializable) value).getName(); + } + props.put(block.getProperty(prop.getKey().getName()), value); + } + return props; + } + + private static IBlockState applyProperties(StateContainer stateContainer, IBlockState newState, Map, Object> states) { + for (Map.Entry, Object> state : states.entrySet()) { + IProperty property = stateContainer.getProperty(state.getKey().getName()); + Comparable value = (Comparable) state.getValue(); + // we may need to adapt this value, depending on the source prop + if (property instanceof DirectionProperty) { + Direction dir = (Direction) value; + value = ForgeAdapter.adapt(dir); + } else if (property instanceof net.minecraft.state.EnumProperty) { + String enumName = (String) value; + value = ((net.minecraft.state.EnumProperty) property).parseValue((String) value).orElseGet(() -> { + throw new IllegalStateException("Enum property " + property.getName() + " does not contain " + enumName); + }); + } + + newState = newState.with(property, value); + } + return newState; + } + + public static IBlockState adapt(BlockState blockState) { + Block mcBlock = ForgeAdapter.adapt(blockState.getBlockType()); + IBlockState newState = mcBlock.getDefaultState(); + Map, Object> states = blockState.getStates(); + return applyProperties(mcBlock.getStateContainer(), newState, states); + } + + public static BlockState adapt(IBlockState blockState) { + BlockType blockType = adapt(blockState.getBlock()); + return blockType.getState(ForgeAdapter.adaptProperties(blockType, blockState.getValues())); + } + + public static Block adapt(BlockType blockType) { + return ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockType.getId())); + } + + public static BlockType adapt(Block block) { + return BlockTypes.get(ForgeRegistries.BLOCKS.getKey(block).toString()); + } + + public static Item adapt(ItemType itemType) { + return ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemType.getId())); + } + + public static ItemType adapt(Item item) { + return ItemTypes.get(ForgeRegistries.ITEMS.getKey(item).toString()); + } + + public static ItemStack adapt(BaseItemStack baseItemStack) { + NBTTagCompound forgeCompound = null; + if (baseItemStack.getNbtData() != null) { + forgeCompound = NBTConverter.toNative(baseItemStack.getNbtData()); + } + return new ItemStack(adapt(baseItemStack.getType()), baseItemStack.getAmount(), forgeCompound); + } + + public static BaseItemStack adapt(ItemStack itemStack) { + CompoundTag tag = NBTConverter.fromNative(itemStack.serializeNBT()); + return new BaseItemStack(adapt(itemStack.getItem()), tag, itemStack.getCount()); + } + + /** + * Get the WorldEdit proxy for the given player. + * + * @param player the player + * @return the WorldEdit player + */ + public static ForgePlayer adaptPlayer(EntityPlayerMP player) { + checkNotNull(player); + return new ForgePlayer(player); + } } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBiomeRegistry.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBiomeRegistry.java index 06a11ea76..e0337d735 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBiomeRegistry.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBiomeRegistry.java @@ -19,36 +19,19 @@ package com.sk89q.worldedit.forge; -import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BiomeData; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.registry.BiomeRegistry; import net.minecraft.world.biome.Biome; -import java.util.ArrayList; -import java.util.List; - /** * Provides access to biome data in Forge. */ class ForgeBiomeRegistry implements BiomeRegistry { @Override - public BaseBiome createFromId(int id) { - return new BaseBiome(id); - } - - @Override - public List getBiomes() { - List list = new ArrayList<>(); - for (Biome biome : Biome.REGISTRY) { - list.add(new BaseBiome(Biome.getIdForBiome(biome))); - } - return list; - } - - @Override - public BiomeData getData(BaseBiome biome) { - return new ForgeBiomeData(Biome.getBiome(biome.getId())); + public BiomeData getData(BiomeType biome) { + return new ForgeBiomeData(ForgeAdapter.adapt(biome)); } /** @@ -68,7 +51,7 @@ class ForgeBiomeRegistry implements BiomeRegistry { @Override public String getName() { - return biome.getBiomeName(); + return biome.getDisplayName().getString(); } } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBlockMaterial.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBlockMaterial.java index 9d98f39ef..5f15a683b 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBlockMaterial.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBlockMaterial.java @@ -63,12 +63,12 @@ public class ForgeBlockMaterial extends PassthroughBlockMaterial { @Override public boolean isFragileWhenPushed() { - return delegate.getMobilityFlag() == EnumPushReaction.DESTROY; + return delegate.getPushReaction() == EnumPushReaction.DESTROY; } @Override public boolean isUnpushable() { - return delegate.getMobilityFlag() == EnumPushReaction.BLOCK; + return delegate.getPushReaction() == EnumPushReaction.BLOCK; } @Override @@ -78,7 +78,7 @@ public class ForgeBlockMaterial extends PassthroughBlockMaterial { @Override public boolean isBurnable() { - return delegate.getCanBurn(); + return delegate.isFlammable(); } @Override diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBlockRegistry.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBlockRegistry.java index ddf3762bb..290642abb 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBlockRegistry.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBlockRegistry.java @@ -23,11 +23,11 @@ import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.BundledBlockRegistry; - import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.util.ResourceLocation; +import net.minecraft.state.IProperty; import java.util.Collection; import java.util.HashMap; @@ -43,21 +43,31 @@ public class ForgeBlockRegistry extends BundledBlockRegistry { @Nullable @Override public String getName(BlockType blockType) { - return Block.REGISTRY.getObject(new ResourceLocation(blockType.getId())).getLocalizedName(); + Block block = ForgeAdapter.adapt(blockType); + if (block != null) { + return block.getNameTextComponent().getFormattedText(); + } else { + return super.getName(blockType); + } } @Override public BlockMaterial getMaterial(BlockType blockType) { - return materialMap.computeIfAbsent(Block.getBlockFromName(blockType.getId()).getDefaultState().getMaterial(), + Block block = ForgeAdapter.adapt(blockType); + if (block == null) { + return super.getMaterial(blockType); + } + return materialMap.computeIfAbsent(block.getDefaultState().getMaterial(), m -> new ForgeBlockMaterial(m, super.getMaterial(blockType))); } @Override public Map> getProperties(BlockType blockType) { + Block block = ForgeAdapter.adapt(blockType); Map> map = new TreeMap<>(); - Collection> propertyKeys = Block.getBlockFromName(blockType.getId()) + Collection> propertyKeys = block .getDefaultState() - .getPropertyKeys(); + .getProperties(); for (IProperty key : propertyKeys) { map.put(key.getName(), ForgeAdapter.adaptProperty(key)); } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntity.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntity.java index e4b391fe0..96e97cf29 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntity.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntity.java @@ -29,8 +29,8 @@ import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.NullWorld; import com.sk89q.worldedit.world.entity.EntityTypes; -import net.minecraft.entity.EntityList; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; import java.lang.ref.WeakReference; @@ -49,11 +49,11 @@ class ForgeEntity implements Entity { public BaseEntity getState() { net.minecraft.entity.Entity entity = entityRef.get(); if (entity != null) { - String id = EntityList.getEntityString(entity); + ResourceLocation id = entity.getType().getRegistryName(); if (id != null) { NBTTagCompound tag = new NBTTagCompound(); - entity.writeToNBT(tag); - return new BaseEntity(EntityTypes.get(id), NBTConverter.fromNative(tag)); + entity.writeWithoutTypeId(tag); + return new BaseEntity(EntityTypes.get(id.toString()), NBTConverter.fromNative(tag)); } else { return null; } @@ -96,7 +96,7 @@ class ForgeEntity implements Entity { public boolean remove() { net.minecraft.entity.Entity entity = entityRef.get(); if (entity != null) { - entity.setDead(); + entity.remove(); } return true; } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntityProperties.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntityProperties.java index bf6a16ae2..6e07e18ad 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntityProperties.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeEntityProperties.java @@ -136,7 +136,7 @@ public class ForgeEntityProperties implements EntityProperties { @Override public boolean isTagged() { - return entity instanceof EntityLiving && ((EntityLiving) entity).hasCustomName(); + return entity.hasCustomName(); } @Override diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemRegistry.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemRegistry.java index b1ba36198..4af39eb46 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemRegistry.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemRegistry.java @@ -19,26 +19,11 @@ package com.sk89q.worldedit.forge; -<<<<<<< HEAD import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.registry.ItemRegistry; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; - -import javax.annotation.Nullable; - -public class ForgeItemRegistry implements ItemRegistry { - @Nullable - @Override - public BaseItem createFromId(String id) { - Item match = Item.REGISTRY.getObject(new ResourceLocation(id)); - if (match != null) { - return new BaseItem(ItemTypes.get(id)); - } else { - return null; - } -======= import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.registry.BundledItemRegistry; @@ -50,6 +35,5 @@ public class ForgeItemRegistry extends BundledItemRegistry { @Override public String getName(ItemType itemType) { return super.getName(itemType); // TODO ->>>>>>> b75d5149... Fixed the bundle being directly used outside of the registry system. } } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePermissionsProvider.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePermissionsProvider.java index bc6820c0d..6129cb31b 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePermissionsProvider.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePermissionsProvider.java @@ -19,17 +19,15 @@ package com.sk89q.worldedit.forge; -import net.minecraft.command.ICommand; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.world.GameType; -import net.minecraftforge.fml.common.FMLCommonHandler; -import org.spongepowered.api.entity.living.player.Player; +import net.minecraftforge.fml.server.ServerLifecycleHooks; public interface ForgePermissionsProvider { boolean hasPermission(EntityPlayerMP player, String permission); - void registerPermission(ICommand command, String permission); + void registerPermission(String permission); class VanillaPermissionsProvider implements ForgePermissionsProvider { @@ -43,24 +41,25 @@ public interface ForgePermissionsProvider { public boolean hasPermission(EntityPlayerMP player, String permission) { ForgeConfiguration configuration = platform.getConfiguration(); return configuration.cheatMode || - FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().canSendCommands(player.getGameProfile()) || + ServerLifecycleHooks.getCurrentServer().getPlayerList().canSendCommands(player.getGameProfile()) || (configuration.creativeEnable && player.interactionManager.getGameType() == GameType.CREATIVE); } @Override - public void registerPermission(ICommand command, String permission) {} + public void registerPermission(String permission) {} } - class SpongePermissionsProvider implements ForgePermissionsProvider { - - @Override - public boolean hasPermission(EntityPlayerMP player, String permission) { - return ((Player) player).hasPermission(permission); - } - - @Override - public void registerPermission(ICommand command, String permission) { - - } - } + // TODO Re-add when Sponge for 1.13 is out +// class SpongePermissionsProvider implements ForgePermissionsProvider { +// +// @Override +// public boolean hasPermission(EntityPlayerMP player, String permission) { +// return ((Player) player).hasPermission(permission); +// } +// +// @Override +// public void registerPermission(ICommand command, String permission) { +// +// } +// } } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java index 2eb66bf14..0530acc54 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java @@ -29,24 +29,21 @@ import com.sk89q.worldedit.util.command.CommandMapping; import com.sk89q.worldedit.util.command.Dispatcher; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.registry.Registries; -import net.minecraft.command.ServerCommandManager; -import net.minecraft.entity.EntityList; +import net.minecraft.command.Commands; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.server.management.PlayerList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.WorldServer; -import net.minecraftforge.common.DimensionManager; -import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.server.ServerLifecycleHooks; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Collection; import java.util.EnumMap; import java.util.List; import java.util.Map; -import javax.annotation.Nullable; - class ForgePlatform extends AbstractPlatform implements MultiUserPlatform { private final ForgeWorldEdit mod; @@ -55,7 +52,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform { ForgePlatform(ForgeWorldEdit mod) { this.mod = mod; - this.server = FMLCommonHandler.instance().getMinecraftServerInstance(); + this.server = ServerLifecycleHooks.getCurrentServer(); } boolean isHookingEvents() { @@ -69,7 +66,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform { @Override public boolean isValidMobType(String type) { - return EntityList.isRegistered(new ResourceLocation(type)); + return net.minecraftforge.registries.ForgeRegistries.ENTITIES.containsKey(new ResourceLocation(type)); } @Override @@ -84,8 +81,8 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform { @Override public List getWorlds() { - WorldServer[] worlds = DimensionManager.getWorlds(); - List ret = new ArrayList<>(worlds.length); + Iterable worlds = server.getWorlds(); + List ret = new ArrayList<>(); for (WorldServer world : worlds) { ret.add(new ForgeWorld(world)); } @@ -109,7 +106,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform { if (world instanceof ForgeWorld) { return world; } else { - for (WorldServer ws : DimensionManager.getWorlds()) { + for (WorldServer ws : server.getWorlds()) { if (ws.getWorldInfo().getWorldName().equals(world.getName())) { return new ForgeWorld(ws); } @@ -122,15 +119,13 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform { @Override public void registerCommands(Dispatcher dispatcher) { if (server == null) return; - ServerCommandManager mcMan = (ServerCommandManager) server.getCommandManager(); + Commands mcMan = server.getCommandManager(); for (final CommandMapping command : dispatcher.getCommands()) { - CommandWrapper wrapper = new CommandWrapper(command); - mcMan.registerCommand(wrapper); + CommandWrapper.register(mcMan.getDispatcher(), command); if (command.getDescription().getPermissions().size() > 0) { - ForgeWorldEdit.inst.getPermissionsProvider().registerPermission(wrapper, command.getDescription().getPermissions().get(0)); for (int i = 1; i < command.getDescription().getPermissions().size(); i++) { - ForgeWorldEdit.inst.getPermissionsProvider().registerPermission(null, command.getDescription().getPermissions().get(i)); + ForgeWorldEdit.inst.getPermissionsProvider().registerPermission(command.getDescription().getPermissions().get(i)); } } } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java index fadddd904..4e466312c 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java @@ -24,23 +24,25 @@ import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.extension.platform.AbstractPlayerActor; import com.sk89q.worldedit.extent.inventory.BlockBag; +import com.sk89q.worldedit.forge.net.handler.WECUIPacketHandler; import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.world.item.ItemTypes; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockStateHolder; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; import net.minecraft.network.play.server.SPacketCustomPayload; import net.minecraft.util.EnumHand; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.common.registry.ForgeRegistries; import java.util.UUID; @@ -65,12 +67,12 @@ public class ForgePlayer extends AbstractPlayerActor { @Override public BaseItemStack getItemInHand(HandSide handSide) { ItemStack is = this.player.getHeldItem(handSide == HandSide.MAIN_HAND ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND); - return new BaseItemStack(ItemTypes.get(ForgeRegistries.ITEMS.getKey(is.getItem()).toString())); + return ForgeAdapter.adapt(is); } @Override public String getName() { - return this.player.getName(); + return this.player.getName().getFormattedText(); } @Override @@ -101,8 +103,7 @@ public class ForgePlayer extends AbstractPlayerActor { @Override public void giveItem(BaseItemStack itemStack) { - this.player.inventory.addItemStackToInventory( - new ItemStack(Item.getByNameOrId(itemStack.getType().getId()), itemStack.getAmount(), 0)); + this.player.inventory.addItemStackToInventory(ForgeAdapter.adapt(itemStack)); } @Override @@ -113,7 +114,7 @@ public class ForgePlayer extends AbstractPlayerActor { send = send + "|" + StringUtil.joinString(params, "|"); } PacketBuffer buffer = new PacketBuffer(Unpooled.copiedBuffer(send.getBytes(WECUIPacketHandler.UTF_8_CHARSET))); - SPacketCustomPayload packet = new SPacketCustomPayload(ForgeWorldEdit.CUI_PLUGIN_CHANNEL, buffer); + SPacketCustomPayload packet = new SPacketCustomPayload(new ResourceLocation(ForgeWorldEdit.CUI_PLUGIN_CHANNEL), buffer); this.player.connection.sendPacket(packet); } @@ -174,13 +175,7 @@ public class ForgePlayer extends AbstractPlayerActor { } @Override -<<<<<<< HEAD -<<<<<<< HEAD -======= - public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) { -======= public > void sendFakeBlock(BlockVector3 pos, B block) { ->>>>>>> 3fefcbf9... Remove all raw usages of BSH, improve API generics BlockPos loc = ForgeAdapter.toBlockPos(pos); if (block == null) { // TODO @@ -198,9 +193,8 @@ public class ForgePlayer extends AbstractPlayerActor { } @Override ->>>>>>> 399e0ad5... Refactor vector system to be cleaner public SessionKey getSessionKey() { - return new SessionKeyImpl(player.getUniqueID(), player.getName()); + return new SessionKeyImpl(player.getUniqueID(), player.getName().getString()); } private static class SessionKeyImpl implements SessionKey { diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java index a2c960f26..43a9399b9 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java @@ -21,93 +21,70 @@ package com.sk89q.worldedit.forge; import static com.google.common.base.Preconditions.checkNotNull; -import com.google.common.io.Files; import com.sk89q.jnbt.CompoundTag; -import com.sk89q.worldedit.BlockVector; -import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.math.BlockVector2; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.internal.Constants; -import com.sk89q.worldedit.regions.CuboidRegion; +import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.TreeGenerator.TreeType; import com.sk89q.worldedit.world.AbstractWorld; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherTypes; - -import net.minecraft.block.Block; import net.minecraft.block.BlockLeaves; -import net.minecraft.block.BlockOldLeaf; -import net.minecraft.block.BlockOldLog; -import net.minecraft.block.BlockPlanks; -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.properties.PropertyDirection; -import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityType; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUseContext; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.IStringSerializable; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.WorldServer; -import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.IChunkProvider; -import net.minecraft.world.chunk.storage.AnvilSaveHandler; -import net.minecraft.world.gen.ChunkProviderServer; -import net.minecraft.world.gen.feature.WorldGenBigMushroom; -import net.minecraft.world.gen.feature.WorldGenBigTree; -import net.minecraft.world.gen.feature.WorldGenBirchTree; -import net.minecraft.world.gen.feature.WorldGenCanopyTree; -import net.minecraft.world.gen.feature.WorldGenMegaJungle; -import net.minecraft.world.gen.feature.WorldGenMegaPineTree; -import net.minecraft.world.gen.feature.WorldGenSavannaTree; -import net.minecraft.world.gen.feature.WorldGenShrub; -import net.minecraft.world.gen.feature.WorldGenSwamp; -import net.minecraft.world.gen.feature.WorldGenTaiga1; -import net.minecraft.world.gen.feature.WorldGenTaiga2; -import net.minecraft.world.gen.feature.WorldGenTrees; -import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraft.world.gen.feature.BigBrownMushroomFeature; +import net.minecraft.world.gen.feature.BigRedMushroomFeature; +import net.minecraft.world.gen.feature.BigTreeFeature; +import net.minecraft.world.gen.feature.BirchTreeFeature; +import net.minecraft.world.gen.feature.CanopyTreeFeature; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.JungleTreeFeature; +import net.minecraft.world.gen.feature.MegaJungleFeature; +import net.minecraft.world.gen.feature.MegaPineTree; +import net.minecraft.world.gen.feature.NoFeatureConfig; +import net.minecraft.world.gen.feature.PointyTaigaTreeFeature; +import net.minecraft.world.gen.feature.SavannaTreeFeature; +import net.minecraft.world.gen.feature.ShrubFeature; +import net.minecraft.world.gen.feature.SwampTreeFeature; +import net.minecraft.world.gen.feature.TallTaigaTreeFeature; +import net.minecraft.world.gen.feature.TreeFeature; import net.minecraft.world.storage.WorldInfo; -import net.minecraftforge.common.DimensionManager; -import java.io.File; import java.lang.ref.WeakReference; import java.util.ArrayList; -import java.util.Comparator; import java.util.List; -import java.util.Map; import java.util.Random; -import java.util.TreeMap; +import java.util.concurrent.ThreadLocalRandom; import javax.annotation.Nullable; @@ -119,9 +96,9 @@ public class ForgeWorld extends AbstractWorld { private static final Random random = new Random(); private static final int UPDATE = 1, NOTIFY = 2; - private static final IBlockState JUNGLE_LOG = Blocks.LOG.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.JUNGLE); - private static final IBlockState JUNGLE_LEAF = Blocks.LEAVES.getDefaultState().withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.JUNGLE).withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false)); - private static final IBlockState JUNGLE_SHRUB = Blocks.LEAVES.getDefaultState().withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.OAK).withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false)); + private static final IBlockState JUNGLE_LOG = Blocks.JUNGLE_LOG.getDefaultState(); + private static final IBlockState JUNGLE_LEAF = Blocks.JUNGLE_LEAVES.getDefaultState().with(BlockLeaves.PERSISTENT, Boolean.TRUE); + private static final IBlockState JUNGLE_SHRUB = Blocks.OAK_LEAVES.getDefaultState().with(BlockLeaves.PERSISTENT, Boolean.TRUE); private final WeakReference worldRef; @@ -181,32 +158,27 @@ public class ForgeWorld extends AbstractWorld { int z = position.getBlockZ(); // First set the block - Chunk chunk = world.getChunkFromChunkCoords(x >> 4, z >> 4); + Chunk chunk = world.getChunk(x >> 4, z >> 4); BlockPos pos = new BlockPos(x, y, z); IBlockState old = chunk.getBlockState(pos); - Block mcBlock = Block.getBlockFromName(block.getBlockType().getId()); - IBlockState newState = mcBlock.getDefaultState(); - Map, Object> states = block.getStates(); - newState = applyProperties(mcBlock.getBlockState(), newState, states); - IBlockState successState = chunk.setBlockState(pos, newState); + IBlockState newState = ForgeAdapter.adapt(block.toImmutableState()); + IBlockState successState = chunk.setBlockState(pos, newState, false); boolean successful = successState != null; // Create the TileEntity - if (successful) { - if (block instanceof BaseBlock && ((BaseBlock) block).hasNbtData()) { - // Kill the old TileEntity - world.removeTileEntity(pos); - NBTTagCompound nativeTag = NBTConverter.toNative(((BaseBlock) block).getNbtData()); - nativeTag.setString("id", ((BaseBlock) block).getNbtId()); - TileEntityUtils.setTileEntity(world, position, nativeTag); + if (successful || old == newState) { + if (block instanceof BaseBlock) { + CompoundTag tag = ((BaseBlock) block).getNbtData(); + if (tag != null) { + NBTTagCompound nativeTag = NBTConverter.toNative(tag); + nativeTag.putString("id", ((BaseBlock) block).getNbtId()); + TileEntityUtils.setTileEntity(world, position, nativeTag); + } } } - if (notifyAndLight) { - if (!successful) { - newState = old; - } - world.checkLight(pos); + if (successful && notifyAndLight) { + //world.checkLight(pos); world.markAndNotifyBlock(pos, chunk, old, newState, UPDATE | NOTIFY); } @@ -215,43 +187,21 @@ public class ForgeWorld extends AbstractWorld { @Override public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException { - // TODO Implement - return false; - } - - // Can't get the "Object" to be right for withProperty w/o this - @SuppressWarnings({ "rawtypes", "unchecked" }) - private IBlockState applyProperties(BlockStateContainer stateContainer, IBlockState newState, Map, Object> states) { - for (Map.Entry, Object> state : states.entrySet()) { - - IProperty property = stateContainer.getProperty(state.getKey().getName()); - Comparable value = (Comparable) state.getValue(); - // we may need to adapt this value, depending on the source prop - if (property instanceof PropertyDirection) { - Direction dir = (Direction) value; - value = ForgeAdapter.adapt(dir); - } else if (property instanceof PropertyEnum) { - String enumName = (String) value; - value = ((PropertyEnum) property).parseValue((String) value).or(() -> { - throw new IllegalStateException("Enum property " + property.getName() + " does not contain " + enumName); - }); - } - - newState = newState.withProperty(property, value); - } - return newState; + BlockPos pos = new BlockPos(position.getX(), position.getY(), position.getZ()); + getWorld().notifyBlockUpdate(pos, ForgeAdapter.adapt(previousType), getWorld().getBlockState(pos), 1 | 2); + return true; } @Override public int getBlockLightLevel(BlockVector3 position) { checkNotNull(position); - return getWorld().getLight(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ())); + return getWorld().getLight(ForgeAdapter.toBlockPos(position)); } @Override public boolean clearContainerBlockContents(BlockVector3 position) { checkNotNull(position); - TileEntity tile = getWorld().getTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ())); + TileEntity tile = getWorld().getTileEntity(ForgeAdapter.toBlockPos(position)); if ((tile instanceof IInventory)) { IInventory inv = (IInventory) tile; int size = inv.getSizeInventory(); @@ -264,19 +214,19 @@ public class ForgeWorld extends AbstractWorld { } @Override - public BaseBiome getBiome(BlockVector2 position) { + public BiomeType getBiome(BlockVector2 position) { checkNotNull(position); - return new BaseBiome(Biome.getIdForBiome(getWorld().getBiomeForCoordsBody(new BlockPos(position.getBlockX(), 0, position.getBlockZ())))); + return ForgeAdapter.adapt(getWorld().getBiomeBody(new BlockPos(position.getBlockX(), 0, position.getBlockZ()))); } @Override - public boolean setBiome(BlockVector2 position, BaseBiome biome) { + public boolean setBiome(BlockVector2 position, BiomeType biome) { checkNotNull(position); checkNotNull(biome); - Chunk chunk = getWorld().getChunkFromBlockCoords(new BlockPos(position.getBlockX(), 0, position.getBlockZ())); + Chunk chunk = getWorld().getChunk(new BlockPos(position.getBlockX(), 0, position.getBlockZ())); if (chunk.isLoaded()) { - chunk.getBiomeArray()[((position.getBlockZ() & 0xF) << 4 | position.getBlockX() & 0xF)] = (byte) biome.getId(); + chunk.getBiomes()[((position.getBlockZ() & 0xF) << 4 | position.getBlockX() & 0xF)] = ForgeAdapter.adapt(biome); return true; } @@ -285,16 +235,24 @@ public class ForgeWorld extends AbstractWorld { @Override public boolean useItem(BlockVector3 position, BaseItem item, Direction face) { - Item nativeItem = Item.getByNameOrId(item.getType().getId()); - ItemStack stack = null; + Item nativeItem = ForgeAdapter.adapt(item.getType()); + ItemStack stack; if (item.getNbtData() == null) { - stack = new ItemStack(nativeItem, 1, 0); + stack = new ItemStack(nativeItem, 1); } else { - stack = new ItemStack(nativeItem, 1, 0, NBTConverter.toNative(item.getNbtData())); + stack = new ItemStack(nativeItem, 1, NBTConverter.toNative(item.getNbtData())); } World world = getWorld(); - EnumActionResult used = stack.onItemUse(new WorldEditFakePlayer((WorldServer) world), world, ForgeAdapter.toBlockPos(position), - EnumHand.MAIN_HAND, ForgeAdapter.adapt(face), 0, 0, 0); + ItemUseContext itemUseContext = new ItemUseContext( + new WorldEditFakePlayer((WorldServer) world), + stack, + ForgeAdapter.toBlockPos(position), + ForgeAdapter.adapt(face), + 0f, + 0f, + 0f + ); + EnumActionResult used = stack.onItemUse(itemUseContext); return used != EnumActionResult.FAIL; } @@ -307,7 +265,7 @@ public class ForgeWorld extends AbstractWorld { return; } - EntityItem entity = new EntityItem(getWorld(), position.getX(), position.getY(), position.getZ(), ForgeWorldEdit.toForgeItemStack(item)); + EntityItem entity = new EntityItem(getWorld(), position.getX(), position.getY(), position.getZ(), ForgeAdapter.adapt(item)); entity.setPickupDelay(10); getWorld().spawnEntity(entity); } @@ -316,75 +274,75 @@ public class ForgeWorld extends AbstractWorld { public void simulateBlockMine(BlockVector3 position) { BlockPos pos = ForgeAdapter.toBlockPos(position); IBlockState state = getWorld().getBlockState(pos); - state.getBlock().dropBlockAsItem(getWorld(), pos, state, 0); - getWorld().setBlockToAir(pos); + state.dropBlockAsItem(getWorld(), pos, 0); + getWorld().removeBlock(pos); } @Override public boolean regenerate(Region region, EditSession editSession) { - // Don't even try to regen if it's going to fail. - IChunkProvider provider = getWorld().getChunkProvider(); - if (!(provider instanceof ChunkProviderServer)) { - return false; - } - - File saveFolder = Files.createTempDir(); - // register this just in case something goes wrong - // normally it should be deleted at the end of this method - saveFolder.deleteOnExit(); - - WorldServer originalWorld = (WorldServer) getWorld(); - - MinecraftServer server = originalWorld.getMinecraftServer(); - AnvilSaveHandler saveHandler = new AnvilSaveHandler(saveFolder, - originalWorld.getSaveHandler().getWorldDirectory().getName(), true, server.getDataFixer()); - World freshWorld = new WorldServer(server, saveHandler, originalWorld.getWorldInfo(), - originalWorld.provider.getDimension(), originalWorld.profiler).init(); - - // Pre-gen all the chunks - // We need to also pull one more chunk in every direction - CuboidRegion expandedPreGen = new CuboidRegion(region.getMinimumPoint().subtract(16, 0, 16), region.getMaximumPoint().add(16, 0, 16)); - for (BlockVector2 chunk : expandedPreGen.getChunks()) { - freshWorld.getChunkFromChunkCoords(chunk.getBlockX(), chunk.getBlockZ()); - } - - ForgeWorld from = new ForgeWorld(freshWorld); - try { - for (BlockVector3 vec : region) { - editSession.setBlock(vec, from.getFullBlock(vec)); - } - } catch (MaxChangedBlocksException e) { - throw new RuntimeException(e); - } finally { - saveFolder.delete(); - DimensionManager.setWorld(originalWorld.provider.getDimension(), null, server); - DimensionManager.setWorld(originalWorld.provider.getDimension(), originalWorld, server); - } - - return true; + // TODO Fix for 1.13 + return false; +// // Don't even try to regen if it's going to fail. +// IChunkProvider provider = getWorld().getChunkProvider(); +// if (!(provider instanceof ChunkProviderServer)) { +// return false; +// } +// +// File saveFolder = Files.createTempDir(); +// // register this just in case something goes wrong +// // normally it should be deleted at the end of this method +// saveFolder.deleteOnExit(); +// +// WorldServer originalWorld = (WorldServer) getWorld(); +// +// MinecraftServer server = originalWorld.getServer(); +// AnvilSaveHandler saveHandler = new AnvilSaveHandler(saveFolder, originalWorld.getSaveHandler().getWorldDirectory().getName(), server, server.getDataFixer()); +// World freshWorld = new WorldServer(server, saveHandler, originalWorld.getSavedDataStorage(), originalWorld.getWorldInfo(), originalWorld.dimension.getType(), originalWorld.profiler).func_212251_i__(); +// +// // Pre-gen all the chunks +// // We need to also pull one more chunk in every direction +// CuboidRegion expandedPreGen = new CuboidRegion(region.getMinimumPoint().subtract(16, 0, 16), region.getMaximumPoint().add(16, 0, 16)); +// for (BlockVector2 chunk : expandedPreGen.getChunks()) { +// freshWorld.getChunk(chunk.getBlockX(), chunk.getBlockZ()); +// } +// +// ForgeWorld from = new ForgeWorld(freshWorld); +// try { +// for (BlockVector3 vec : region) { +// editSession.setBlock(vec, from.getFullBlock(vec)); +// } +// } catch (MaxChangedBlocksException e) { +// throw new RuntimeException(e); +// } finally { +// saveFolder.delete(); +// DimensionManager.setWorld(originalWorld.dimension.getType(), null, server); +// DimensionManager.setWorld(originalWorld.dimension.getType(), originalWorld, server); +// } +// +// return true; } @Nullable - private static WorldGenerator createWorldGenerator(TreeType type) { + private static Feature createTreeFeatureGenerator(TreeType type) { switch (type) { - case TREE: return new WorldGenTrees(true); - case BIG_TREE: return new WorldGenBigTree(true); - case REDWOOD: return new WorldGenTaiga2(true); - case TALL_REDWOOD: return new WorldGenTaiga1(); - case BIRCH: return new WorldGenBirchTree(true, false); - case JUNGLE: return new WorldGenMegaJungle(true, 10, 20, JUNGLE_LOG, JUNGLE_LEAF); - case SMALL_JUNGLE: return new WorldGenTrees(true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, false); - case SHORT_JUNGLE: return new WorldGenTrees(true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, true); - case JUNGLE_BUSH: return new WorldGenShrub(JUNGLE_LOG, JUNGLE_SHRUB); - case RED_MUSHROOM: return new WorldGenBigMushroom(Blocks.BROWN_MUSHROOM_BLOCK); - case BROWN_MUSHROOM: return new WorldGenBigMushroom(Blocks.RED_MUSHROOM_BLOCK); - case SWAMP: return new WorldGenSwamp(); - case ACACIA: return new WorldGenSavannaTree(true); - case DARK_OAK: return new WorldGenCanopyTree(true); - case MEGA_REDWOOD: return new WorldGenMegaPineTree(false, random.nextBoolean()); - case TALL_BIRCH: return new WorldGenBirchTree(true, true); - case RANDOM: + case TREE: return new TreeFeature(true); + case BIG_TREE: return new BigTreeFeature(true); case PINE: + case REDWOOD: return new PointyTaigaTreeFeature(); + case TALL_REDWOOD: return new TallTaigaTreeFeature(true); + case BIRCH: return new BirchTreeFeature(true, false); + case JUNGLE: return new MegaJungleFeature(true, 10, 20, JUNGLE_LOG, JUNGLE_LEAF); + case SMALL_JUNGLE: return new JungleTreeFeature(true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, false); + case SHORT_JUNGLE: return new JungleTreeFeature(true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, true); + case JUNGLE_BUSH: return new ShrubFeature(JUNGLE_LOG, JUNGLE_SHRUB); + case RED_MUSHROOM: return new BigBrownMushroomFeature(); + case BROWN_MUSHROOM: return new BigRedMushroomFeature(); + case SWAMP: return new SwampTreeFeature(); + case ACACIA: return new SavannaTreeFeature(true); + case DARK_OAK: return new CanopyTreeFeature(true); + case MEGA_REDWOOD: return new MegaPineTree(false, random.nextBoolean()); + case TALL_BIRCH: return new BirchTreeFeature(true, true); + case RANDOM: return createTreeFeatureGenerator(TreeType.values()[ThreadLocalRandom.current().nextInt(TreeType.values().length)]); case RANDOM_REDWOOD: default: return null; @@ -393,13 +351,13 @@ public class ForgeWorld extends AbstractWorld { @Override public boolean generateTree(TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException { - WorldGenerator generator = createWorldGenerator(type); - return generator != null && generator.generate(getWorld(), random, ForgeAdapter.toBlockPos(position)); + Feature generator = createTreeFeatureGenerator(type); + return generator != null && generator.place(getWorld(), getWorld().getChunkProvider().getChunkGenerator(), random, ForgeAdapter.toBlockPos(position), new NoFeatureConfig()); } @Override public void checkLoadedChunk(BlockVector3 pt) { - getWorld().getChunkFromBlockCoords(ForgeAdapter.toBlockPos(pt)); + getWorld().getChunk(ForgeAdapter.toBlockPos(pt)); } @Override @@ -411,7 +369,7 @@ public class ForgeWorld extends AbstractWorld { public void fixLighting(Iterable chunks) { World world = getWorld(); for (BlockVector2 chunk : chunks) { - world.getChunkFromChunkCoords(chunk.getBlockX(), chunk.getBlockZ()).resetRelightChecks(); + world.getChunk(chunk.getBlockX(), chunk.getBlockZ()).resetRelightChecks(); } } @@ -442,7 +400,7 @@ public class ForgeWorld extends AbstractWorld { if (info.isRaining()) { return info.getRainTime(); } - return info.getCleanWeatherTime(); + return info.getClearWeatherTime(); } @Override @@ -453,18 +411,18 @@ public class ForgeWorld extends AbstractWorld { @Override public void setWeather(WeatherType weatherType, long duration) { WorldInfo info = getWorld().getWorldInfo(); - if (WeatherTypes.THUNDER_STORM.equals(weatherType)) { - info.setCleanWeatherTime(0); + if (weatherType == WeatherTypes.THUNDER_STORM) { + info.setClearWeatherTime(0); info.setThundering(true); info.setThunderTime((int) duration); - } else if (WeatherTypes.RAIN.equals(weatherType)) { - info.setCleanWeatherTime(0); + } else if (weatherType == WeatherTypes.RAIN) { + info.setClearWeatherTime(0); info.setRaining(true); info.setRainTime((int) duration); - } else if (WeatherTypes.CLEAR.equals(weatherType)) { + } else if (weatherType == WeatherTypes.CLEAR) { info.setRaining(false); info.setThundering(false); - info.setCleanWeatherTime((int) duration); + info.setClearWeatherTime((int) duration); } } @@ -475,26 +433,13 @@ public class ForgeWorld extends AbstractWorld { @Override public BlockState getBlock(BlockVector3 position) { - World world = getWorld(); - BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()); - IBlockState mcState = world.getBlockState(pos); + IBlockState mcState = getWorld().getChunk(position.getBlockX() >> 4, position.getBlockZ() >> 4).getBlockState( + position.getBlockX(), + position.getBlockY(), + position.getBlockZ() + ); - BlockType blockType = BlockType.REGISTRY.get(Block.REGISTRY.getNameForObject(mcState.getBlock()).toString()); - return blockType.getState(adaptProperties(blockType, mcState.getProperties())); - } - - private Map, Object> adaptProperties(BlockType block, Map, Comparable> mcProps) { - Map, Object> props = new TreeMap<>(Comparator.comparing(Property::getName)); - for (Map.Entry, Comparable> prop : mcProps.entrySet()) { - Object value = prop.getValue(); - if (prop.getKey() instanceof PropertyDirection) { - value = ForgeAdapter.adaptEnumFacing((EnumFacing) value); - } else if (prop.getKey() instanceof PropertyEnum) { - value = ((IStringSerializable) value).getName(); - } - props.put(block.getProperty(prop.getKey().getName()), value); - } - return props; + return ForgeAdapter.adapt(mcState); } @Override @@ -554,15 +499,15 @@ public class ForgeWorld extends AbstractWorld { @Override public Entity createEntity(Location location, BaseEntity entity) { World world = getWorld(); - net.minecraft.entity.Entity createdEntity = EntityList.createEntityByIDFromName(new ResourceLocation(entity.getType().getId()), world); + net.minecraft.entity.Entity createdEntity = EntityType.create(world, new ResourceLocation(entity.getType().getId())); if (createdEntity != null) { CompoundTag nativeTag = entity.getNbtData(); if (nativeTag != null) { NBTTagCompound tag = NBTConverter.toNative(entity.getNbtData()); for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) { - tag.removeTag(name); + tag.remove(name); } - createdEntity.readFromNBT(tag); + createdEntity.read(tag); } createdEntity.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java index d2198ade9..44e4974f6 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java @@ -20,150 +20,201 @@ package com.sk89q.worldedit.forge; import static com.google.common.base.Preconditions.checkNotNull; +import static com.sk89q.worldedit.forge.ForgeAdapter.adaptPlayer; -import com.google.common.base.Joiner; +import com.mojang.brigadier.ParseResults; +import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.event.platform.PlatformReadyEvent; import com.sk89q.worldedit.extension.platform.Platform; -import com.sk89q.worldedit.forge.net.LeftClickAirEventMessage; +import com.sk89q.worldedit.forge.net.handler.InternalPacketHandler; +import com.sk89q.worldedit.forge.net.handler.WECUIPacketHandler; +import com.sk89q.worldedit.forge.net.packet.LeftClickAirEventMessage; +import com.sk89q.worldedit.forge.proxy.ClientProxy; +import com.sk89q.worldedit.forge.proxy.CommonProxy; +import com.sk89q.worldedit.forge.proxy.ServerProxy; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; +import com.sk89q.worldedit.world.entity.EntityType; +import com.sk89q.worldedit.world.item.ItemCategory; import com.sk89q.worldedit.world.item.ItemType; -import com.sk89q.worldedit.world.item.ItemTypes; -import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.command.CommandSource; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.CommandEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickEmpty; -import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.DistExecutor; +import net.minecraftforge.fml.ModContainer; +import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.Mod.Instance; -import net.minecraftforge.fml.common.SidedProxy; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.event.FMLServerAboutToStartEvent; -import net.minecraftforge.fml.common.event.FMLServerStartedEvent; -import net.minecraftforge.fml.common.event.FMLServerStoppingEvent; -import net.minecraftforge.fml.common.eventhandler.Event.Result; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; +import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; +import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent; +import net.minecraftforge.fml.event.server.FMLServerStartedEvent; +import net.minecraftforge.fml.event.server.FMLServerStoppingEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.fml.loading.FMLPaths; +import net.minecraftforge.registries.ForgeRegistries; +import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.File; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Path; /** * The Forge implementation of WorldEdit. */ -@Mod(modid = ForgeWorldEdit.MOD_ID, name = "WorldEdit", version = "%VERSION%", acceptableRemoteVersions = "*") +@Mod(ForgeWorldEdit.MOD_ID) public class ForgeWorldEdit { - public static Logger logger; + private static final Logger LOGGER = LogManager.getLogger(); public static final String MOD_ID = "worldedit"; - public static final String CUI_PLUGIN_CHANNEL = "worldedit:cui"; + public static final String CUI_PLUGIN_CHANNEL = "cui"; private ForgePermissionsProvider provider; - @Instance(MOD_ID) public static ForgeWorldEdit inst; - @SidedProxy(serverSide = "com.sk89q.worldedit.forge.CommonProxy", clientSide = "com.sk89q.worldedit.forge.ClientProxy") - public static CommonProxy proxy; + public static CommonProxy proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> ServerProxy::new); private ForgePlatform platform; private ForgeConfiguration config; - private File workingDir; + private Path workingDir; - @EventHandler - public void preInit(FMLPreInitializationEvent event) { - logger = event.getModLog(); - // Setup working directory - workingDir = new File(event.getModConfigurationDirectory() + File.separator + "worldedit"); - workingDir.mkdir(); + private ModContainer container; - config = new ForgeConfiguration(this); - config.load(); + public ForgeWorldEdit() { + inst = this; + + IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus(); + modBus.addListener(this::init); + modBus.addListener(this::load); MinecraftForge.EVENT_BUS.register(ThreadSafeCache.getInstance()); + MinecraftForge.EVENT_BUS.register(this); } - @EventHandler - public void init(FMLInitializationEvent event) { - MinecraftForge.EVENT_BUS.register(this); + private void init(FMLCommonSetupEvent event) { + this.container = ModLoadingContext.get().getActiveContainer(); + + // Setup working directory + workingDir = FMLPaths.CONFIGDIR.get().resolve("worldedit"); + if (!Files.exists(workingDir)) { + try { + Files.createDirectory(workingDir); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + WECUIPacketHandler.init(); InternalPacketHandler.init(); proxy.registerHandlers(); + + LOGGER.info("WorldEdit for Forge (version " + getInternalVersion() + ") is loaded"); } - @EventHandler - public void postInit(FMLPostInitializationEvent event) { - logger.info("WorldEdit for Forge (version " + getInternalVersion() + ") is loaded"); + private void load(FMLLoadCompleteEvent event) { + if (FMLLoader.getDist() == Dist.CLIENT) { + // we want to setup platform before we hit the main menu + // but this event is async -- so we must delay until the first game loop: + Minecraft.getInstance().addScheduledTask(this::setupPlatform); + } } - @EventHandler + @SubscribeEvent public void serverAboutToStart(FMLServerAboutToStartEvent event) { if (this.platform != null) { - logger.warn("FMLServerStartingEvent occurred when FMLServerStoppingEvent hasn't"); + LOGGER.warn("FMLServerStartingEvent occurred when FMLServerStoppingEvent hasn't"); WorldEdit.getInstance().getPlatformManager().unregister(platform); } + setupPlatform(); + } + + private void setupPlatform() { this.platform = new ForgePlatform(this); WorldEdit.getInstance().getPlatformManager().register(platform); - if (Loader.isModLoaded("sponge")) { - this.provider = new ForgePermissionsProvider.SpongePermissionsProvider(); - } else { - this.provider = new ForgePermissionsProvider.VanillaPermissionsProvider(platform); - } +// TODO if (ModList.get().isLoaded("sponge")) { +// this.provider = new ForgePermissionsProvider.SpongePermissionsProvider(); +// } else { + this.provider = new ForgePermissionsProvider.VanillaPermissionsProvider(platform); +// } - for (ResourceLocation name : Block.REGISTRY.getKeys()) { - String nameStr = name.toString(); - if (!BlockType.REGISTRY.keySet().contains(nameStr)) { - BlockTypes.register(new BlockType(nameStr)); + setupRegistries(); + + config = new ForgeConfiguration(this); + config.load(); + } + + private void setupRegistries() { + // Blocks + for (ResourceLocation name : ForgeRegistries.BLOCKS.getKeys()) { + if (BlockType.REGISTRY.get(name.toString()) == null) { + BlockType.REGISTRY.register(name.toString(), new BlockType(name.toString(), + input -> ForgeAdapter.adapt(ForgeAdapter.adapt(input.getBlockType()).getDefaultState()))); } } - - for (ResourceLocation name : Item.REGISTRY.getKeys()) { - String nameStr = name.toString(); - if (!ItemType.REGISTRY.keySet().contains(nameStr)) { - ItemTypes.register(new ItemType(nameStr)); + // Items + for (ResourceLocation name : ForgeRegistries.ITEMS.getKeys()) { + if (ItemType.REGISTRY.get(name.toString()) == null) { + ItemType.REGISTRY.register(name.toString(), new ItemType(name.toString())); + } + } + // Entities + for (ResourceLocation name : ForgeRegistries.ENTITIES.getKeys()) { + if (EntityType.REGISTRY.get(name.toString()) == null) { + EntityType.REGISTRY.register(name.toString(), new EntityType(name.toString())); + } + } + // Biomes + for (ResourceLocation name : ForgeRegistries.BIOMES.getKeys()) { + if (BiomeType.REGISTRY.get(name.toString()) == null) { + BiomeType.REGISTRY.register(name.toString(), new BiomeType(name.toString())); + } + } + // Tags + for (ResourceLocation name : BlockTags.getCollection().getRegisteredTags()) { + if (BlockCategory.REGISTRY.get(name.toString()) == null) { + BlockCategory.REGISTRY.register(name.toString(), new BlockCategory(name.toString())); + } + } + for (ResourceLocation name : ItemTags.getCollection().getRegisteredTags()) { + if (ItemCategory.REGISTRY.get(name.toString()) == null) { + ItemCategory.REGISTRY.register(name.toString(), new ItemCategory(name.toString())); } } } - @EventHandler + @SubscribeEvent public void serverStopping(FMLServerStoppingEvent event) { WorldEdit.getInstance().getPlatformManager().unregister(platform); } - @EventHandler + @SubscribeEvent public void serverStarted(FMLServerStartedEvent event) { WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent()); } - @SubscribeEvent - public void onCommandEvent(CommandEvent event) { - if ((event.getSender() instanceof EntityPlayerMP)) { - if (((EntityPlayerMP) event.getSender()).world.isRemote) return; - String[] split = new String[event.getParameters().length + 1]; - System.arraycopy(event.getParameters(), 0, split, 1, event.getParameters().length); - split[0] = event.getCommand().getName(); - com.sk89q.worldedit.event.platform.CommandEvent weEvent = - new com.sk89q.worldedit.event.platform.CommandEvent(wrap((EntityPlayerMP) event.getSender()), Joiner.on(" ").join(split)); - WorldEdit.getInstance().getEventBus().post(weEvent); - } - } - @SubscribeEvent public void onPlayerInteract(PlayerInteractEvent event) { if (platform == null) { @@ -175,23 +226,23 @@ public class ForgeWorldEdit { if (event.getWorld().isRemote && event instanceof LeftClickEmpty) { // catch LCE, pass it to server - InternalPacketHandler.CHANNEL.sendToServer(new LeftClickAirEventMessage()); + InternalPacketHandler.HANDLER.sendToServer(new LeftClickAirEventMessage()); return; } boolean isLeftDeny = event instanceof PlayerInteractEvent.LeftClickBlock && ((PlayerInteractEvent.LeftClickBlock) event) - .getUseItem() == Result.DENY; + .getUseItem() == Event.Result.DENY; boolean isRightDeny = event instanceof PlayerInteractEvent.RightClickBlock && ((PlayerInteractEvent.RightClickBlock) event) - .getUseItem() == Result.DENY; + .getUseItem() == Event.Result.DENY; if (isLeftDeny || isRightDeny || event.getEntity().world.isRemote) { return; } WorldEdit we = WorldEdit.getInstance(); - ForgePlayer player = wrap((EntityPlayerMP) event.getEntityPlayer()); + ForgePlayer player = adaptPlayer((EntityPlayerMP) event.getEntityPlayer()); ForgeWorld world = getWorld(event.getEntityPlayer().world); if (event instanceof PlayerInteractEvent.LeftClickEmpty) { @@ -226,12 +277,24 @@ public class ForgeWorldEdit { } } - public static ItemStack toForgeItemStack(BaseItemStack item) { - NBTTagCompound forgeCompound = null; - if (item.getNbtData() != null) { - forgeCompound = NBTConverter.toNative(item.getNbtData()); + @SubscribeEvent + public void onCommandEvent(CommandEvent event) throws CommandSyntaxException { + ParseResults parseResults = event.getParseResults(); + if (!(parseResults.getContext().getSource().getEntity() instanceof EntityPlayerMP)) { + return; } - return new ItemStack(Item.getByNameOrId(item.getType().getId()), item.getAmount(), 0, forgeCompound); + EntityPlayerMP player = parseResults.getContext().getSource().asPlayer(); + if (player.world.isRemote()) { + return; + } + if (parseResults.getContext().getCommand() != CommandWrapper.FAKE_COMMAND) { + return; + } + event.setCanceled(true); + WorldEdit.getInstance().getEventBus().post(new com.sk89q.worldedit.event.platform.CommandEvent( + adaptPlayer(parseResults.getContext().getSource().asPlayer()), + parseResults.getReader().getString() + )); } /** @@ -243,17 +306,6 @@ public class ForgeWorldEdit { return this.config; } - /** - * Get the WorldEdit proxy for the given player. - * - * @param player the player - * @return the WorldEdit player - */ - public ForgePlayer wrap(EntityPlayerMP player) { - checkNotNull(player); - return new ForgePlayer(player); - } - /** * Get the session for a player. * @@ -262,7 +314,7 @@ public class ForgeWorldEdit { */ public LocalSession getSession(EntityPlayerMP player) { checkNotNull(player); - return WorldEdit.getInstance().getSessionManager().get(wrap(player)); + return WorldEdit.getInstance().getSessionManager().get(adaptPlayer(player)); } /** @@ -291,7 +343,7 @@ public class ForgeWorldEdit { * @return the working directory */ public File getWorkingDir() { - return this.workingDir; + return this.workingDir.toFile(); } /** @@ -300,7 +352,7 @@ public class ForgeWorldEdit { * @return a version string */ String getInternalVersion() { - return ForgeWorldEdit.class.getAnnotation(Mod.class).version(); + return container.getModInfo().getVersion().toString(); } public void setPermissionsProvider(ForgePermissionsProvider provider) { diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/IPropertyAdapter.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/IPropertyAdapter.java index 0ac900a55..e024f6e93 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/IPropertyAdapter.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/IPropertyAdapter.java @@ -21,13 +21,12 @@ package com.sk89q.worldedit.forge; import static com.google.common.base.Preconditions.checkArgument; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.registry.state.Property; - -import net.minecraft.block.properties.IProperty; +import net.minecraft.state.IProperty; import java.util.List; +import java.util.Optional; class IPropertyAdapter> implements Property { diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/KeyHandler.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/KeyHandler.java index 76e726884..06c59eb7f 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/KeyHandler.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/KeyHandler.java @@ -19,18 +19,18 @@ package com.sk89q.worldedit.forge; -import com.sk89q.worldedit.forge.gui.GuiHandler; +import com.sk89q.worldedit.forge.gui.GuiReferenceCard; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.client.registry.ClientRegistry; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent; -import org.lwjgl.input.Keyboard; +import org.lwjgl.glfw.GLFW; public class KeyHandler { - private static Minecraft mc = Minecraft.getMinecraft(); - private static KeyBinding mainKey = new KeyBinding("WorldEdit Reference", Keyboard.KEY_L, "WorldEdit"); + private static Minecraft mc = Minecraft.getInstance(); + private static KeyBinding mainKey = new KeyBinding("WorldEdit Reference", GLFW.GLFW_KEY_L, "WorldEdit"); public KeyHandler() { ClientRegistry.registerKeyBinding(mainKey); @@ -39,7 +39,9 @@ public class KeyHandler { @SubscribeEvent public void onKey(KeyInputEvent evt) { if (mc.player != null && mc.world != null && mainKey.isPressed()) { - mc.player.openGui(ForgeWorldEdit.inst, GuiHandler.REFERENCE_ID, mc.world, 0, 0, 0); + mc.displayGuiScreen(new GuiReferenceCard()); + // TODO Seems GuiHandlers don't work on client right now +// NetworkHooks.openGui(mc.player, new ResourceLocationInteractionObject(ServerProxy.REFERENCE_GUI)); } } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/NBTConverter.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/NBTConverter.java index 0992d3d4f..bae43851c 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/NBTConverter.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/NBTConverter.java @@ -32,7 +32,7 @@ import com.sk89q.jnbt.LongTag; import com.sk89q.jnbt.ShortTag; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; -import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.INBTBase; import net.minecraft.nbt.NBTTagByte; import net.minecraft.nbt.NBTTagByteArray; import net.minecraft.nbt.NBTTagCompound; @@ -62,7 +62,7 @@ final class NBTConverter { private NBTConverter() { } - public static NBTBase toNative(Tag tag) { + public static INBTBase toNative(Tag tag) { if (tag instanceof IntArrayTag) { return toNative((IntArrayTag) tag); @@ -111,7 +111,7 @@ final class NBTConverter { if (child instanceof EndTag) { continue; } - list.appendTag(toNative(child)); + list.add(toNative(child)); } return list; } @@ -140,7 +140,7 @@ final class NBTConverter { public static NBTTagCompound toNative(CompoundTag tag) { NBTTagCompound compound = new NBTTagCompound(); for (Entry child : tag.getValue().entrySet()) { - compound.setTag(child.getKey(), toNative(child.getValue())); + compound.put(child.getKey(), toNative(child.getValue())); } return compound; } @@ -157,7 +157,7 @@ final class NBTConverter { return new NBTTagDouble(tag.getValue()); } - public static Tag fromNative(NBTBase other) { + public static Tag fromNative(INBTBase other) { if (other instanceof NBTTagIntArray) { return fromNative((NBTTagIntArray) other); @@ -207,9 +207,9 @@ final class NBTConverter { other = other.copy(); List list = new ArrayList<>(); Class listClass = StringTag.class; - int tags = other.tagCount(); + int tags = other.size(); for (int i = 0; i < tags; i++) { - Tag child = fromNative(other.removeTag(0)); + Tag child = fromNative(other.remove(0)); list.add(child); listClass = child.getClass(); } @@ -242,10 +242,10 @@ final class NBTConverter { } public static CompoundTag fromNative(NBTTagCompound other) { - Set tags = other.getKeySet(); + Set tags = other.keySet(); Map map = new HashMap<>(); for (String tagName : tags) { - map.put(tagName, fromNative(other.getTag(tagName))); + map.put(tagName, fromNative(other.get(tagName))); } return new CompoundTag(map); } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ThreadSafeCache.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ThreadSafeCache.java index a52233564..5f80516eb 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ThreadSafeCache.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ThreadSafeCache.java @@ -21,9 +21,9 @@ package com.sk89q.worldedit.forge; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; +import net.minecraftforge.fml.server.ServerLifecycleHooks; import java.util.Collections; import java.util.HashSet; @@ -57,7 +57,7 @@ public class ThreadSafeCache { if (now - lastRefresh > REFRESH_DELAY) { Set onlineIds = new HashSet<>(); - MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); + MinecraftServer server = ServerLifecycleHooks.getCurrentServer(); if (server == null || server.getPlayerList() == null) { return; } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/TileEntityUtils.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/TileEntityUtils.java index 4147d835c..41ec90f66 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/TileEntityUtils.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/TileEntityUtils.java @@ -29,8 +29,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import java.lang.reflect.Constructor; - import javax.annotation.Nullable; /** @@ -46,45 +44,14 @@ final class TileEntityUtils { * * @param tag the tag * @param position the position - * @return a tag compound */ - private static NBTTagCompound updateForSet(NBTTagCompound tag, BlockVector3 position) { + private static void updateForSet(NBTTagCompound tag, BlockVector3 position) { checkNotNull(tag); checkNotNull(position); - tag.setTag("x", new NBTTagInt(position.getBlockX())); - tag.setTag("y", new NBTTagInt(position.getBlockY())); - tag.setTag("z", new NBTTagInt(position.getBlockZ())); - - return tag; - } - - /** - * Set a tile entity at the given location. - * - * @param world the world - * @param position the position - * @param clazz the tile entity class - * @param tag the tag for the tile entity (may be null to not set NBT data) - */ - static void setTileEntity(World world, BlockVector3 position, Class clazz, @Nullable NBTTagCompound tag) { - checkNotNull(world); - checkNotNull(position); - checkNotNull(clazz); - - TileEntity tileEntity = constructTileEntity(world, position, clazz); - - if (tileEntity == null) { - return; - } - - if (tag != null) { - // Set X, Y, Z - updateForSet(tag, position); - tileEntity.readFromNBT(tag); - } - - world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity); + tag.put("x", new NBTTagInt(position.getBlockX())); + tag.put("y", new NBTTagInt(position.getBlockY())); + tag.put("z", new NBTTagInt(position.getBlockZ())); } /** @@ -98,52 +65,16 @@ final class TileEntityUtils { static void setTileEntity(World world, BlockVector3 position, @Nullable NBTTagCompound tag) { if (tag != null) { updateForSet(tag, position); - TileEntity tileEntity = TileEntity.create(world, tag); + TileEntity tileEntity = TileEntity.create(tag); if (tileEntity != null) { world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity); } } } - /** - * Construct a tile entity from the given class. - * - * @param world the world - * @param position the position - * @param clazz the class - * @return a tile entity (may be null if it failed) - */ - @Nullable - static TileEntity constructTileEntity(World world, BlockVector3 position, Class clazz) { - Constructor baseConstructor; - try { - baseConstructor = clazz.getConstructor(); // creates "blank" TE - } catch (Throwable e) { - return null; // every TE *should* have this constructor, so this isn't necessary - } - - TileEntity genericTE; - try { - genericTE = baseConstructor.newInstance(); - } catch (Throwable e) { - return null; - } - - /* - genericTE.blockType = Block.blocksList[block.getId()]; - genericTE.blockMetadata = block.getData(); - genericTE.xCoord = pt.getBlockX(); - genericTE.yCoord = pt.getBlockY(); - genericTE.zCoord = pt.getBlockZ(); - genericTE.worldObj = world; - */ // handled by internal code - - return genericTE; - } - public static NBTTagCompound copyNbtData(TileEntity tile) { NBTTagCompound tag = new NBTTagCompound(); - tile.writeToNBT(tag); + tile.write(tag); return tag; } } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/WECUIPacketHandler.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/WECUIPacketHandler.java deleted file mode 100644 index c6cf673e4..000000000 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/WECUIPacketHandler.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.forge; - -import com.sk89q.worldedit.LocalSession; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.network.NetHandlerPlayServer; -import net.minecraft.network.PacketBuffer; -import net.minecraft.network.ThreadQuickExitException; -import net.minecraft.network.play.server.SPacketCustomPayload; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.network.FMLEventChannel; -import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent; -import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent; -import net.minecraftforge.fml.common.network.NetworkRegistry; - -import java.nio.charset.Charset; - -public class WECUIPacketHandler { - public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8"); - public static FMLEventChannel WECUI_CHANNEL; - - public static void init() { - WECUI_CHANNEL = NetworkRegistry.INSTANCE.newEventDrivenChannel(ForgeWorldEdit.CUI_PLUGIN_CHANNEL); - WECUI_CHANNEL.register(new WECUIPacketHandler()); - } - - @SubscribeEvent - public void onPacketData(ServerCustomPacketEvent event) { - if (event.getPacket().channel().equals(ForgeWorldEdit.CUI_PLUGIN_CHANNEL)) { - EntityPlayerMP player = getPlayerFromEvent(event); - LocalSession session = ForgeWorldEdit.inst.getSession(player); - - if (session.hasCUISupport()) { - return; - } - - String text = event.getPacket().payload().toString(UTF_8_CHARSET); - session.handleCUIInitializationMessage(text); - session.describeCUI(ForgeWorldEdit.inst.wrap(player)); - } - } - - @SubscribeEvent - public void callProcessPacket(ClientCustomPacketEvent event) { - try { - new SPacketCustomPayload(event.getPacket().channel(), new PacketBuffer(event.getPacket().payload())).processPacket(event.getHandler()); - } catch (ThreadQuickExitException suppress) { - } - } - - private static EntityPlayerMP getPlayerFromEvent(ServerCustomPacketEvent event) { - return ((NetHandlerPlayServer) event.getHandler()).player; - } -} \ No newline at end of file diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/gui/GuiReferenceCard.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/gui/GuiReferenceCard.java index a9e53d36d..a3b9756af 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/gui/GuiReferenceCard.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/gui/GuiReferenceCard.java @@ -23,8 +23,11 @@ import com.sk89q.worldedit.forge.ForgeWorldEdit; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import org.lwjgl.opengl.GL11; +@OnlyIn(Dist.CLIENT) public class GuiReferenceCard extends GuiScreen { private GuiButton closeButton; @@ -33,25 +36,26 @@ public class GuiReferenceCard extends GuiScreen { @Override public void initGui() { - this.buttonList.add(this.closeButton = new GuiButton(0, (this.width - this.backgroundWidth + 100) / 2, (this.height + this.backgroundHeight - 60) / 2, this.backgroundWidth - 100, 20, "Close")); + this.closeButton = new GuiButton(0, (this.width - this.backgroundWidth + 100) / 2, + (this.height + this.backgroundHeight - 60) / 2, this.backgroundWidth - 100, 20, "Close") { + @Override + public void onClick(double mouseX, double mouseY) { + super.onClick(mouseX, mouseY); + + mc.player.closeScreen(); + } + }; } @Override - public void drawScreen(int mouseX, int mouseY, float par3) { + public void render(int mouseX, int mouseY, float par3) { int x = (this.width - this.backgroundWidth) / 2; int y = (this.height - this.backgroundHeight) / 2 - this.closeButton.height; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.renderEngine.bindTexture(new ResourceLocation(ForgeWorldEdit.MOD_ID, "textures/gui/reference.png")); + this.mc.textureManager.bindTexture(new ResourceLocation(ForgeWorldEdit.MOD_ID, "textures/gui/reference.png")); this.drawTexturedModalRect(x, y, 0, 0, this.backgroundWidth, this.backgroundHeight); - super.drawScreen(mouseX, mouseY, par3); - } - - @Override - protected void actionPerformed(GuiButton button) { - if (button.id == 0) { - this.mc.player.closeScreen(); - } + super.render(mouseX, mouseY, par3); } @Override diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/gui/ResourceLocationInteractionObject.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/gui/ResourceLocationInteractionObject.java new file mode 100644 index 000000000..6e11d02dd --- /dev/null +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/gui/ResourceLocationInteractionObject.java @@ -0,0 +1,65 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.forge.gui; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.world.IInteractionObject; + +import javax.annotation.Nullable; + +public class ResourceLocationInteractionObject implements IInteractionObject { + + private ResourceLocation resourceLocation; + + public ResourceLocationInteractionObject(ResourceLocation resourceLocation) { + this.resourceLocation = resourceLocation; + } + + @Override + public Container createContainer(InventoryPlayer inventoryPlayer, EntityPlayer entityPlayer) { + throw new UnsupportedOperationException(); + } + + @Override + public String getGuiID() { + return resourceLocation.toString(); + } + + @Override + public ITextComponent getName() { + return new TextComponentString(resourceLocation.toString()); + } + + @Override + public boolean hasCustomName() { + return false; + } + + @Nullable + @Override + public ITextComponent getCustomName() { + return null; + } +} diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/net/handler/InternalPacketHandler.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/net/handler/InternalPacketHandler.java new file mode 100644 index 000000000..17b81a852 --- /dev/null +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/net/handler/InternalPacketHandler.java @@ -0,0 +1,45 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.forge.net.handler; + +import com.sk89q.worldedit.forge.ForgeWorldEdit; +import com.sk89q.worldedit.forge.net.packet.LeftClickAirEventMessage; +import com.sk89q.worldedit.forge.net.packet.LeftClickAirEventMessage.Handler; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.network.NetworkRegistry.ChannelBuilder; +import net.minecraftforge.fml.network.simple.SimpleChannel; + +public final class InternalPacketHandler { + private static final String PROTOCOL_VERSION = Integer.toString(1); + public static SimpleChannel HANDLER = ChannelBuilder + .named(new ResourceLocation(ForgeWorldEdit.MOD_ID, "internal")) + .clientAcceptedVersions(PROTOCOL_VERSION::equals) + .serverAcceptedVersions(PROTOCOL_VERSION::equals) + .networkProtocolVersion(() -> PROTOCOL_VERSION) + .simpleChannel(); + + private InternalPacketHandler() { + } + + public static void init() { + HANDLER.registerMessage(0, LeftClickAirEventMessage.class, + LeftClickAirEventMessage::encode, LeftClickAirEventMessage::decode, Handler::handle); + } +} diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/net/handler/WECUIPacketHandler.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/net/handler/WECUIPacketHandler.java new file mode 100644 index 000000000..541577e1f --- /dev/null +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/net/handler/WECUIPacketHandler.java @@ -0,0 +1,78 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.forge.net.handler; + +import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.forge.ForgeWorldEdit; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.ThreadQuickExitException; +import net.minecraft.network.play.server.SPacketCustomPayload; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.network.NetworkEvent.ClientCustomPayloadEvent; +import net.minecraftforge.fml.network.NetworkEvent.ServerCustomPayloadEvent; +import net.minecraftforge.fml.network.NetworkRegistry.ChannelBuilder; +import net.minecraftforge.fml.network.event.EventNetworkChannel; + +import java.nio.charset.Charset; + +import static com.sk89q.worldedit.forge.ForgeAdapter.adaptPlayer; + +public final class WECUIPacketHandler { + private WECUIPacketHandler() { + } + + public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8"); + private static final String PROTOCOL_VERSION = Integer.toString(1); + public static EventNetworkChannel HANDLER = ChannelBuilder + .named(new ResourceLocation(ForgeWorldEdit.MOD_ID, ForgeWorldEdit.CUI_PLUGIN_CHANNEL)) + .clientAcceptedVersions(PROTOCOL_VERSION::equals) + .serverAcceptedVersions(PROTOCOL_VERSION::equals) + .networkProtocolVersion(() -> PROTOCOL_VERSION) + .eventNetworkChannel(); + + public static void init() { + HANDLER.addListener(WECUIPacketHandler::onPacketData); + HANDLER.addListener(WECUIPacketHandler::callProcessPacket); + } + + public static void onPacketData(ServerCustomPayloadEvent event) { + EntityPlayerMP player = event.getSource().get().getSender(); + LocalSession session = ForgeWorldEdit.inst.getSession(player); + + if (session.hasCUISupport()) { + return; + } + + String text = event.getPayload().toString(UTF_8_CHARSET); + session.handleCUIInitializationMessage(text); + session.describeCUI(adaptPlayer(player)); + } + + public static void callProcessPacket(ClientCustomPayloadEvent event) { + try { + new SPacketCustomPayload( + new ResourceLocation(ForgeWorldEdit.MOD_ID, ForgeWorldEdit.CUI_PLUGIN_CHANNEL), + event.getPayload() + ).processPacket(Minecraft.getInstance().player.connection); + } catch (ThreadQuickExitException ignored) { + } + } +} \ No newline at end of file diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/net/LeftClickAirEventMessage.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/net/packet/LeftClickAirEventMessage.java similarity index 53% rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/net/LeftClickAirEventMessage.java rename to worldedit-forge/src/main/java/com/sk89q/worldedit/forge/net/packet/LeftClickAirEventMessage.java index 1e3b2b20e..e5e5d8cdc 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/net/LeftClickAirEventMessage.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/net/packet/LeftClickAirEventMessage.java @@ -17,34 +17,32 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.forge.net; +package com.sk89q.worldedit.forge.net.packet; import com.sk89q.worldedit.forge.ForgeWorldEdit; import io.netty.buffer.ByteBuf; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.fml.common.network.simpleimpl.IMessage; -import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; +import net.minecraft.network.PacketBuffer; +import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickEmpty; +import net.minecraftforge.fml.network.NetworkEvent.Context; -public class LeftClickAirEventMessage implements IMessage { +import java.util.Objects; +import java.util.function.Supplier; - public static final class Handler implements IMessageHandler { +@SuppressWarnings({"NonFinalUtilityClass", "checkstyle:hideutilityclassconstructor"}) +public class LeftClickAirEventMessage { - @Override - public IMessage onMessage(LeftClickAirEventMessage message, final MessageContext ctx) { - ctx.getServerHandler().player.mcServer.addScheduledTask( - () -> ForgeWorldEdit.inst.onPlayerInteract(new PlayerInteractEvent.LeftClickEmpty(ctx.getServerHandler().player))); - return null; + public static final class Handler { + public static void handle(final LeftClickAirEventMessage message, Supplier ctx) { + Context context = ctx.get(); + context.enqueueWork(() -> ForgeWorldEdit.inst.onPlayerInteract(new LeftClickEmpty(Objects.requireNonNull(context.getSender())))); } - } - @Override - public void fromBytes(ByteBuf buf) { + public static LeftClickAirEventMessage decode(ByteBuf buf) { + return new LeftClickAirEventMessage(); } - @Override - public void toBytes(ByteBuf buf) { + public static void encode(LeftClickAirEventMessage msg, PacketBuffer buf) { } } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ClientProxy.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/proxy/ClientProxy.java similarity index 79% rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ClientProxy.java rename to worldedit-forge/src/main/java/com/sk89q/worldedit/forge/proxy/ClientProxy.java index 688728a63..fab4e7d67 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ClientProxy.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/proxy/ClientProxy.java @@ -17,15 +17,18 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.forge; +package com.sk89q.worldedit.forge.proxy; +import com.sk89q.worldedit.forge.KeyHandler; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; -public class ClientProxy extends CommonProxy { +@OnlyIn(Dist.CLIENT) +public class ClientProxy implements CommonProxy { @Override public void registerHandlers() { - super.registerHandlers(); MinecraftForge.EVENT_BUS.register(new KeyHandler()); } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/proxy/CommonProxy.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/proxy/CommonProxy.java new file mode 100644 index 000000000..9f4c166b3 --- /dev/null +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/proxy/CommonProxy.java @@ -0,0 +1,25 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.forge.proxy; + +public interface CommonProxy { + + void registerHandlers(); +} diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/InternalPacketHandler.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/proxy/ServerProxy.java similarity index 52% rename from worldedit-forge/src/main/java/com/sk89q/worldedit/forge/InternalPacketHandler.java rename to worldedit-forge/src/main/java/com/sk89q/worldedit/forge/proxy/ServerProxy.java index afac351ac..9ec84e328 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/InternalPacketHandler.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/proxy/ServerProxy.java @@ -17,24 +17,24 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.forge; +package com.sk89q.worldedit.forge.proxy; -import com.sk89q.worldedit.forge.net.LeftClickAirEventMessage; -import net.minecraftforge.fml.common.network.NetworkRegistry; -import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; -import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; -import java.nio.charset.Charset; +@OnlyIn(Dist.DEDICATED_SERVER) +public class ServerProxy implements CommonProxy { -public class InternalPacketHandler { - public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8"); - public static SimpleNetworkWrapper CHANNEL; +// public static ResourceLocation REFERENCE_GUI = new ResourceLocation("worldedit", "resource_gui"); - public static void init() { - CHANNEL = NetworkRegistry.INSTANCE.newSimpleChannel(ForgeWorldEdit.MOD_ID); - CHANNEL.registerMessage(LeftClickAirEventMessage.Handler.class, LeftClickAirEventMessage.class, 0, Side.SERVER); + @Override + public void registerHandlers() { +// ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.GUIFACTORY, () -> openContainer -> { +// if (openContainer.getId().equals(REFERENCE_GUI)) { +// return new GuiReferenceCard(); +// } +// return null; +// }); } - private InternalPacketHandler() { - } } diff --git a/worldedit-forge/src/main/resources/META-INF/mods.toml b/worldedit-forge/src/main/resources/META-INF/mods.toml new file mode 100644 index 000000000..07b5ff1a0 --- /dev/null +++ b/worldedit-forge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,36 @@ +# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml +modLoader="javafml" +# A version range to match for said mod loader - for regular FML @Mod it will be the minecraft version (without the 1.) +loaderVersion="[24,)" +# A URL to refer people to when problems occur with this mod +issueTrackerURL="https://discord.gg/enginehub" +# A URL for the "homepage" for this mod, displayed in the mod UI +displayURL="http://wiki.sk89q.com/wiki/WorldEdit/" +# A file name (in the root of the mod JAR) containing a logo for display +logoFile="worldedit-icon.png" +# A text field displayed in the mod UI +authors="sk89q, wizjany, TomyLobo, kenzierocks, Me4502" +# A list of mods - how many allowed here is determined by the individual mod loader +[[mods]] +# The modid of the mod +modId="worldedit" +# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it +version="${version}" + # A display name for the mod +displayName="WorldEdit" +# The description text for the mod (multi line!) +description=''' +WorldEdit is an easy-to-use in-game world editor for Minecraft, supporting both single- and multi-player. +''' +[[dependencies.worldedit]] + modId="forge" + mandatory=true + versionRange="[${forgeVersion},)" + ordering="NONE" + side="BOTH" +[[dependencies.worldedit]] + modId="sponge" + mandatory=false + versionRange="[1.13]" + ordering="BEFORE" + side="SERVER" \ No newline at end of file diff --git a/worldedit-forge/src/main/resources/defaults/worldedit.properties b/worldedit-forge/src/main/resources/defaults/worldedit.properties index 4fa5671d5..d0296c15c 100644 --- a/worldedit-forge/src/main/resources/defaults/worldedit.properties +++ b/worldedit-forge/src/main/resources/defaults/worldedit.properties @@ -1,13 +1,13 @@ #Don't put comments; they get removed default-max-polygon-points=-1 schematic-save-dir=schematics -allow-extra-data-values=false super-pickaxe-many-drop-items=true register-help=true nav-wand-item=minecraft:compass profile=false +trace-unflushed-sessions=false super-pickaxe-drop-items=true -disallowed-blocks=minecraft:oak_sapling,minecraft:jungle_sapling,minecraft:dark_oak_sapling:,minecraft:spruce_sapling,minecraft:birch_sapling,minecraft:acacia_sapling,minecraft:black_bed,minecraft:blue_bed,minecraft:brown_bed,minecraft:cyan_bed,minecraft:gray_bed,minecraft:green_bed,minecraft:light_blue_bed,minecraft:light_gray_bed,minecraft:lime_bed,minecraft:magenta_bed,minecraft:orange_bed,minecraft:pink_bed,minecraft:purple_bed,minecraft:red_bed,minecraft:white_bed,minecraft:yellow_bed,minecraft:powered_rail,minecraft:detector_rail,minecraft:grass,minecraft:dead_bush,minecraft:moving_piston,minecraft:piston_head,minecraft:sunflower,minecraft:rose_bush,minecraft:dandelion,minecraft:poppy,minecraft:brown_mushroom,minecraft:red_mushroom,minecraft:tnt,minecraft:torch,minecraft:fire,minecraft:redstone_wire,minecraft:wheat,minecraft:potatoes,minecraft:carrots,minecraft:melon_stem,minecraft:pumpkin_stem,minecraft:beetroots,minecraft:rail,minecraft:lever,minecraft:redstone_torch,minecraft:redstone_wall_torch,minecraft:repeater,minecraft:comparator,minecraft:stone_button,minecraft:birch_button,minecraft:acacia_button,minecraft:dark_oak_button,minecraft:jungle_button,minecraft:oak_button,minecraft:spruce_button,minecraft:cactus,minecraft:sugar_cane,minecraft:bedrock +disallowed-blocks=minecraft:oak_sapling,minecraft:jungle_sapling,minecraft:dark_oak_sapling,minecraft:spruce_sapling,minecraft:birch_sapling,minecraft:acacia_sapling,minecraft:black_bed,minecraft:blue_bed,minecraft:brown_bed,minecraft:cyan_bed,minecraft:gray_bed,minecraft:green_bed,minecraft:light_blue_bed,minecraft:light_gray_bed,minecraft:lime_bed,minecraft:magenta_bed,minecraft:orange_bed,minecraft:pink_bed,minecraft:purple_bed,minecraft:red_bed,minecraft:white_bed,minecraft:yellow_bed,minecraft:powered_rail,minecraft:detector_rail,minecraft:grass,minecraft:dead_bush,minecraft:moving_piston,minecraft:piston_head,minecraft:sunflower,minecraft:rose_bush,minecraft:dandelion,minecraft:poppy,minecraft:brown_mushroom,minecraft:red_mushroom,minecraft:tnt,minecraft:torch,minecraft:fire,minecraft:redstone_wire,minecraft:wheat,minecraft:potatoes,minecraft:carrots,minecraft:melon_stem,minecraft:pumpkin_stem,minecraft:beetroots,minecraft:rail,minecraft:lever,minecraft:redstone_torch,minecraft:redstone_wall_torch,minecraft:repeater,minecraft:comparator,minecraft:stone_button,minecraft:birch_button,minecraft:acacia_button,minecraft:dark_oak_button,minecraft:jungle_button,minecraft:oak_button,minecraft:spruce_button,minecraft:cactus,minecraft:sugar_cane,minecraft:bedrock max-super-pickaxe-size=5 max-brush-radius=10 craftscript-dir=craftscripts diff --git a/worldedit-forge/src/main/resources/mcmod.info b/worldedit-forge/src/main/resources/mcmod.info deleted file mode 100644 index bcee1cd4a..000000000 --- a/worldedit-forge/src/main/resources/mcmod.info +++ /dev/null @@ -1,21 +0,0 @@ -[{ - "modid": "worldedit", - "name": "WorldEdit", - "description": "WorldEdit is an easy-to-use in-game world editor for Minecraft, supporting both single player and multiplayer.", - "version": "${internalVersion}", - "mcversion": "${mcVersion}", - "url": "http://wiki.sk89q.com/wiki/WorldEdit", - "updateUrl": "", - "authors": [ "sk89q", "wizjany", "TomyLobo", "kenzierocks", "Me4502" ], - "credits": "", - "logoFile": "", - "screenshots": [], - "requiredMods": [ - "Forge@[${forgeVersion},)" - ], - "dependencies": [ - "Forge@[${forgeVersion},)", - "sponge" - ], - "dependants": [] -}] diff --git a/worldedit-forge/src/main/resources/pack.mcmeta b/worldedit-forge/src/main/resources/pack.mcmeta new file mode 100644 index 000000000..b48da3b7d --- /dev/null +++ b/worldedit-forge/src/main/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "WorldEdit Resources", + "pack_format": 4 + } +} \ No newline at end of file diff --git a/worldedit-forge/src/main/resources/worldedit-icon.png b/worldedit-forge/src/main/resources/worldedit-icon.png new file mode 100644 index 000000000..dc269dcf7 Binary files /dev/null and b/worldedit-forge/src/main/resources/worldedit-icon.png differ diff --git a/worldedit-sponge/build.gradle b/worldedit-sponge/build.gradle index 1e011ee8c..bd21cd568 100644 --- a/worldedit-sponge/build.gradle +++ b/worldedit-sponge/build.gradle @@ -63,6 +63,7 @@ task copyFiles { shadowJar { dependencies { include(dependency(':worldedit-core')) + include(dependency('org.bstats:bstats-sponge:1.4')) } archiveName = "${parent.name}-${project.name.replaceAll("worldedit-", "")}-${parent.version}.jar" destinationDir = file '../target' diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeAdapter.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeAdapter.java index f5df77298..d8dc2760f 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeAdapter.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeAdapter.java @@ -26,6 +26,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.World; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.biome.BiomeTypes; import org.spongepowered.api.Sponge; import org.spongepowered.api.entity.living.player.Player; @@ -103,6 +105,14 @@ public class SpongeAdapter { } } + public static BiomeType adapt(org.spongepowered.api.world.biome.BiomeType biomeType) { + return BiomeTypes.get(biomeType.getId()); + } + + public static org.spongepowered.api.world.biome.BiomeType adapt(BiomeType biomeType) { + return Sponge.getRegistry().getType(org.spongepowered.api.world.biome.BiomeType.class, biomeType.getId()).orElse(null); + } + /** * Create a WorldEdit location from a Sponge location. * diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeBiomeRegistry.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeBiomeRegistry.java index 1b1955bdb..b44d13aae 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeBiomeRegistry.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeBiomeRegistry.java @@ -19,15 +19,10 @@ package com.sk89q.worldedit.sponge; -import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BiomeData; import com.sk89q.worldedit.world.registry.BiomeRegistry; -import org.spongepowered.api.Sponge; import org.spongepowered.api.world.biome.BiomeType; -import java.util.ArrayList; -import java.util.List; - import javax.annotation.Nullable; /** @@ -37,23 +32,8 @@ class SpongeBiomeRegistry implements BiomeRegistry { @Nullable @Override - public BaseBiome createFromId(int id) { - return new BaseBiome(id); - } - - @Override - public List getBiomes() { - List list = new ArrayList<>(); - for (BiomeType biome : Sponge.getGame().getRegistry().getAllOf(BiomeType.class)) { - list.add(new BaseBiome(SpongeWorldEdit.inst().getAdapter().resolve(biome))); - } - return list; - } - - @Nullable - @Override - public BiomeData getData(BaseBiome biome) { - return new SpongeBiomeData(SpongeWorldEdit.inst().getAdapter().resolveBiome(biome.getId())); + public BiomeData getData(com.sk89q.worldedit.world.biome.BiomeType biome) { + return new SpongeBiomeData(SpongeAdapter.adapt(biome)); } private static class SpongeBiomeData implements BiomeData { diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java index fa088ee86..743bf7198 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java @@ -25,7 +25,6 @@ import com.flowpowered.math.vector.Vector3d; import com.flowpowered.math.vector.Vector3i; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; @@ -36,7 +35,7 @@ import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.AbstractWorld; -import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.item.ItemTypes; @@ -193,17 +192,17 @@ public abstract class SpongeWorld extends AbstractWorld { } @Override - public BaseBiome getBiome(BlockVector2 position) { + public BiomeType getBiome(BlockVector2 position) { checkNotNull(position); - return new BaseBiome(SpongeWorldEdit.inst().getAdapter().resolve(getWorld().getBiome(position.getBlockX(), 0, position.getBlockZ()))); + return SpongeAdapter.adapt(getWorld().getBiome(position.getBlockX(), 0, position.getBlockZ())); } @Override - public boolean setBiome(BlockVector2 position, BaseBiome biome) { + public boolean setBiome(BlockVector2 position, BiomeType biome) { checkNotNull(position); checkNotNull(biome); - getWorld().setBiome(position.getBlockX(), 0, position.getBlockZ(), SpongeWorldEdit.inst().getAdapter().resolveBiome(biome.getId())); + getWorld().setBiome(position.getBlockX(), 0, position.getBlockZ(), SpongeAdapter.adapt(biome)); return true; } diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorldEdit.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorldEdit.java index 0e1e79b32..98bcb95e4 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorldEdit.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorldEdit.java @@ -33,7 +33,6 @@ import com.sk89q.worldedit.sponge.adapter.AdapterLoadException; import com.sk89q.worldedit.sponge.adapter.SpongeImplAdapter; import com.sk89q.worldedit.sponge.adapter.SpongeImplLoader; import com.sk89q.worldedit.sponge.config.SpongeConfiguration; -import com.sk89q.worldedit.world.item.ItemTypes; import org.bstats.sponge.Metrics2; import org.slf4j.Logger; import org.spongepowered.api.Sponge; @@ -141,14 +140,14 @@ public class SpongeWorldEdit { // TODO Handle blockstate stuff String id = blockType.getId(); if (!com.sk89q.worldedit.world.block.BlockType.REGISTRY.keySet().contains(id)) { - com.sk89q.worldedit.world.block.BlockTypes.register(new com.sk89q.worldedit.world.block.BlockType(id)); + com.sk89q.worldedit.world.block.BlockType.REGISTRY.register(id, new com.sk89q.worldedit.world.block.BlockType(id)); } } for (ItemType itemType : Sponge.getRegistry().getAllOf(ItemType.class)) { String id = itemType.getId(); if (!com.sk89q.worldedit.world.item.ItemType.REGISTRY.keySet().contains(id)) { - ItemTypes.register(new com.sk89q.worldedit.world.item.ItemType(id)); + com.sk89q.worldedit.world.item.ItemType.REGISTRY.register(id, new com.sk89q.worldedit.world.item.ItemType(id)); } } diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplAdapter.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplAdapter.java index d6cb96f8e..d2ddf99e5 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplAdapter.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplAdapter.java @@ -36,16 +36,6 @@ import org.spongepowered.api.world.biome.BiomeType; */ public interface SpongeImplAdapter { - /** - * Resolves the numerical ID from this {@link BiomeType} - * - * @param type The biometype - * @return The numerical ID - */ - int resolve(BiomeType type); - - BiomeType resolveBiome(int intID); - BaseEntity createBaseEntity(Entity entity); ItemStack makeSpongeStack(BaseItemStack itemStack); diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplLoader.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplLoader.java index dac72425e..7f5bb0f84 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplLoader.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplLoader.java @@ -21,6 +21,8 @@ package com.sk89q.worldedit.sponge.adapter; import com.google.common.collect.Lists; import com.sk89q.worldedit.util.io.Closer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; @@ -30,15 +32,13 @@ import java.util.Enumeration; import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarFile; -import java.util.logging.Level; -import java.util.logging.Logger; /** * Loads Sponge implementation adapters. */ public class SpongeImplLoader { - private static final Logger log = Logger.getLogger(SpongeImplLoader.class.getCanonicalName()); + private static final Logger log = LoggerFactory.getLogger(SpongeImplLoader.class); private final List adapterCandidates = new ArrayList<>(); private String customCandidate; @@ -71,7 +71,7 @@ public class SpongeImplLoader { if (className != null) { customCandidate = className; adapterCandidates.add(className); - log.log(Level.INFO, "-Dworldedit.sponge.adapter used to add " + className + " to the list of available Sponge adapters"); + log.info("-Dworldedit.sponge.adapter used to add " + className + " to the list of available Sponge adapters"); } } @@ -157,18 +157,18 @@ public class SpongeImplLoader { if (SpongeImplAdapter.class.isAssignableFrom(cls)) { suitableAdapters.add((SpongeImplAdapter) cls.newInstance()); } else { - log.log(Level.WARNING, "Failed to load the Sponge adapter class '" + className + + log.warn("Failed to load the Sponge adapter class '" + className + "' because it does not implement " + SpongeImplAdapter.class.getCanonicalName()); } } catch (ClassNotFoundException e) { - log.log(Level.WARNING, "Failed to load the Sponge adapter class '" + className + + log.warn("Failed to load the Sponge adapter class '" + className + "' that is not supposed to be missing", e); } catch (IllegalAccessException e) { - log.log(Level.WARNING, "Failed to load the Sponge adapter class '" + className + + log.warn("Failed to load the Sponge adapter class '" + className + "' that is not supposed to be raising this error", e); } catch (Throwable e) { if (className.equals(customCandidate)) { - log.log(Level.WARNING, "Failed to load the Sponge adapter class '" + className + "'", e); + log.warn("Failed to load the Sponge adapter class '" + className + "'", e); } } } diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java index 6e1786132..45d4169e4 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java @@ -59,6 +59,7 @@ public class ConfigurateConfiguration extends LocalConfiguration { } profile = node.getNode("debug").getBoolean(profile); + traceUnflushedSessions = node.getNode("debugging", "trace-unflushed-sessions").getBoolean(traceUnflushedSessions); wandItem = node.getNode("wand-item").getString(wandItem); try { wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).getId();