diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBallBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBallBrush.java index 1da2ec01d..634fb2654 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBallBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendBallBrush.java @@ -1,5 +1,6 @@ package com.thevoxelbox.voxelsniper.brush; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Undo; @@ -82,7 +83,7 @@ public class BlendBallBrush extends BlendBrushBase } // Find most common neighboring material. - for (BlockTypes type : BlockTypes.values) + for (BlockType type : BlockTypes.values) { int i = type.getInternalId(); if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) @@ -94,7 +95,7 @@ public class BlendBallBrush extends BlendBrushBase // Make sure there'world not a tie for most common for (int i = 0; i < modeMatId; i++) { - BlockTypes type = BlockTypes.get(i); + BlockType type = BlockTypes.get(i); if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) { tiecheck = false; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendDiscBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendDiscBrush.java index 75130f9e9..876ffa7d8 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendDiscBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendDiscBrush.java @@ -1,5 +1,6 @@ package com.thevoxelbox.voxelsniper.brush; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Undo; @@ -69,7 +70,7 @@ public class BlendDiscBrush extends BlendBrushBase } // Find most common neighboring material. - for (BlockTypes type : BlockTypes.values) + for (BlockType type : BlockTypes.values) { int i = type.getInternalId(); if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) @@ -81,7 +82,7 @@ public class BlendDiscBrush extends BlendBrushBase // Make sure there'world not a tie for most common for (int i = 0; i < modeMatId; i++) { - BlockTypes type = BlockTypes.get(i); + BlockType type = BlockTypes.get(i); if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) { tiecheck = false; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelBrush.java index 30cf38268..e0e8fe943 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelBrush.java @@ -1,5 +1,6 @@ package com.thevoxelbox.voxelsniper.brush; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Undo; @@ -82,7 +83,7 @@ public class BlendVoxelBrush extends BlendBrushBase } // Find most common neighboring material. - for (BlockTypes type : BlockTypes.values) + for (BlockType type : BlockTypes.values) { int i = type.getInternalId(); if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) @@ -94,7 +95,7 @@ public class BlendVoxelBrush extends BlendBrushBase // Make sure there'world not a tie for most common for (int i = 0; i < modeMatId; i++) { - BlockTypes type = BlockTypes.get(i); + BlockType type = BlockTypes.get(i); if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) { tiecheck = false; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelDiscBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelDiscBrush.java index 56a670f0b..d0abbc680 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelDiscBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/BlendVoxelDiscBrush.java @@ -1,5 +1,6 @@ package com.thevoxelbox.voxelsniper.brush; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.thevoxelbox.voxelsniper.SnipeData; import com.thevoxelbox.voxelsniper.Undo; @@ -69,7 +70,7 @@ public class BlendVoxelDiscBrush extends BlendBrushBase } // Find most common neighboring material. - for (BlockTypes type : BlockTypes.values) + for (BlockType type : BlockTypes.values) { int i = type.getInternalId(); if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) @@ -81,7 +82,7 @@ public class BlendVoxelDiscBrush extends BlendBrushBase // Make sure there'world not a tie for most common for (int i = 0; i < modeMatId; i++) { - BlockTypes type = BlockTypes.get(i); + BlockType type = BlockTypes.get(i); if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER))) { tiecheck = false; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OverlayBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OverlayBrush.java index 20d31a1d6..fac816721 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OverlayBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/OverlayBrush.java @@ -1,5 +1,6 @@ package com.thevoxelbox.voxelsniper.brush; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.registry.BlockMaterial; import com.thevoxelbox.voxelsniper.Message; @@ -72,11 +73,11 @@ public class OverlayBrush extends PerformBrush @SuppressWarnings("deprecation") private boolean isIgnoredBlock(int materialId) { - BlockTypes type = BlockTypes.get(materialId); - switch (type) { - case WATER: - case LAVA: - case CACTUS: + BlockType type = BlockTypes.get(materialId); + switch (type.getResource().toUpperCase()) { + case "WATER": + case "LAVA": + case "CACTUS": return true; } BlockMaterial mat = type.getMaterial(); @@ -123,7 +124,7 @@ public class OverlayBrush extends PerformBrush if (!this.allBlocks) { // if the override parameter has not been activated, go to the switch that filters out manmade stuff. - BlockTypes type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z)); + BlockType type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z)); BlockMaterial mat = type.getMaterial(); if (mat.isSolid() && mat.isFullCube() && !mat.hasContainer()) { for (int d = 1; (d < this.depth + 1); d++) { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnowConeBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnowConeBrush.java index b68eccd8d..330af9a27 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnowConeBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SnowConeBrush.java @@ -95,14 +95,14 @@ public class SnowConeBrush extends Brush if (snowData > snowconeData[x][z]) { - switch (BlockTypes.get(snowcone[x][z])) + switch (BlockTypes.get(snowcone[x][z]).getResource().toUpperCase()) { - case AIR: - case CAVE_AIR: - case VOID_AIR: + case "AIR": + case "CAVE_AIR": + case "VOID_AIR": snowconeData[x][z] = snowData; snowcone[x][z] = BlockTypes.SNOW.getInternalId(); - case SNOW_BLOCK: + case "SNOW_BLOCK": snowconeData[x][z] = snowData; break; default: diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SpiralStaircaseBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SpiralStaircaseBrush.java index b803ac117..3edd3729a 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SpiralStaircaseBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SpiralStaircaseBrush.java @@ -2,6 +2,7 @@ package com.thevoxelbox.voxelsniper.brush; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.extension.input.InputParseException; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.registry.LegacyMapper; import com.thevoxelbox.voxelsniper.Message; @@ -724,7 +725,7 @@ public class SpiralStaircaseBrush extends Brush // step/slab try { - BlockTypes type = BlockTypes.parse(par[i]); + BlockType type = BlockTypes.parse(par[i]); this.stairtype = par[i].toLowerCase().intern(); v.sendMessage(ChatColor.BLUE + "Staircase type: " + this.stairtype); return; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterOverlayBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterOverlayBrush.java index c74e4aaf7..d11666de7 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterOverlayBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/SplatterOverlayBrush.java @@ -1,5 +1,6 @@ package com.thevoxelbox.voxelsniper.brush; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.registry.BlockMaterial; import com.thevoxelbox.voxelsniper.Message; @@ -135,7 +136,7 @@ public class SplatterOverlayBrush extends PerformBrush if (!this.allBlocks) { // if the override parameter has not been activated, go to the switch that filters out manmade stuff. - BlockTypes type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z)); + BlockType type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z)); BlockMaterial mat = type.getMaterial(); if (mat.isSolid() && mat.isFullCube() && !mat.hasContainer()) { final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth; @@ -268,7 +269,7 @@ public class SplatterOverlayBrush extends PerformBrush if (!this.allBlocks) { // if the override parameter has not been activated, go to the switch that filters out manmade stuff. - BlockTypes type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z)); + BlockType type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z)); BlockMaterial mat = type.getMaterial(); if (mat.isSolid() && mat.isFullCube() && !mat.hasContainer()) { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelReplaceCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelReplaceCommand.java index d3674f374..0e040ce4e 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelReplaceCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelReplaceCommand.java @@ -2,6 +2,7 @@ package com.thevoxelbox.voxelsniper.command; import com.bekvon.bukkit.residence.commands.material; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.thevoxelbox.voxelsniper.RangeBlockHelper; import com.thevoxelbox.voxelsniper.SnipeData; @@ -39,7 +40,7 @@ public class VoxelReplaceCommand extends VoxelCommand return true; } - BlockTypes weType = BlockTypes.parse(args[0]); + BlockType weType = BlockTypes.parse(args[0]); if (weType != null) { snipeData.setReplaceId(weType.getInternalId()); diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelVoxelCommand.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelVoxelCommand.java index cbd8b52fe..162f77747 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelVoxelCommand.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/command/VoxelVoxelCommand.java @@ -29,6 +29,7 @@ import com.bekvon.bukkit.residence.commands.material; import com.boydti.fawe.bukkit.favs.PatternUtil; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.thevoxelbox.voxelsniper.RangeBlockHelper; import com.thevoxelbox.voxelsniper.SnipeData; @@ -53,7 +54,7 @@ public class VoxelVoxelCommand extends VoxelCommand { Block block = (new RangeBlockHelper(player, sniper.getWorld())).getTargetBlock(); Material blockType = block.getType(); - BlockTypes weType = BukkitAdapter.adapt(blockType); + BlockType weType = BukkitAdapter.adapt(blockType); if(!player.hasPermission("voxelsniper.ignorelimitations") && WorldEdit.getInstance().getConfiguration().disallowedBlocks.contains(weType)) { player.sendMessage("You are not allowed to use " + blockType.name() + ". (WorldEdit config.yml)"); return true; @@ -65,7 +66,7 @@ public class VoxelVoxelCommand extends VoxelCommand { return true; } else { - BlockTypes weType = BlockTypes.parse(args[0]); + BlockType weType = BlockTypes.parse(args[0]); if(weType != null) { if(!player.hasPermission("voxelsniper.ignorelimitations") && WorldEdit.getInstance().getConfiguration().disallowedBlocks.contains(weType)) { player.sendMessage("You are not allowed to use " + weType + "."); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java index 2c0e3f18d..f030e2873 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java @@ -190,7 +190,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit @Override public BlockMaterial getMaterial(BlockState state) { - BlockTypes type = state.getBlockType(); + BlockType type = state.getBlockType(); IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState(); return new BlockMaterial_1_13(bs.getBlock(), bs); } @@ -233,7 +233,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit if (te != null) { NBTTagCompound tag = new NBTTagCompound(); readTileEntityIntoTag(te, tag); // Load data - return new BaseBlock(state, (CompoundTag) toNative(tag)); + return new BaseBlock(state, (CompoundTag) toNative(tag)).toImmutableState(); } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitChunk_All.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitChunk_All.java index 37d588604..2325413cf 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitChunk_All.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitChunk_All.java @@ -232,12 +232,12 @@ public class BukkitChunk_All extends IntFaweChunk { if (combined == 0) continue; int xx = bx + x; - BlockTypes type = BlockTypes.getFromStateId(combined); + BlockType type = BlockTypes.getFromStateId(combined); if (type == BlockTypes.__RESERVED__) continue; - switch (type) { - case AIR: - case CAVE_AIR: - case VOID_AIR: + switch (type.getResource().toUpperCase()) { + case "AIR": + case "CAVE_AIR": + case "VOID_AIR": if (!place) { mutableLoc.setX(xx); mutableLoc.setY(yy); @@ -277,12 +277,12 @@ public class BukkitChunk_All extends IntFaweChunk { for (;index < 4096; index++) { int j = place ? index : 4095 - index; int combined = newArray[j]; - BlockTypes type = BlockTypes.getFromStateId(combined); + BlockType type = BlockTypes.getFromStateId(combined); if (type == BlockTypes.__RESERVED__) continue; - switch (type) { - case AIR: - case CAVE_AIR: - case VOID_AIR: + switch (type.getResource().toUpperCase()) { + case "AIR": + case "CAVE_AIR": + case "VOID_AIR": if (!place) { int x = cacheX[j]; int z = cacheZ[j]; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java index 6dd902195..6a6b49ee1 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java @@ -9,6 +9,7 @@ import java.util.Collection; import java.util.List; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import org.bukkit.FluidCollisionMode; @@ -214,10 +215,10 @@ public class AsyncBlock implements Block { @Override public AsyncBlockState getState() { int combined = queue.getCombinedId4Data(x, y, z, 0); - BlockTypes type = BlockTypes.getFromStateId(combined); - switch (type) { - case SIGN: - case WALL_SIGN: + BlockType type = BlockTypes.getFromStateId(combined); + switch (type.getResource().toUpperCase()) { + case "SIGN": + case "WALL_SIGN": return new AsyncSign(this, combined); } return new AsyncBlockState(this, combined); @@ -284,7 +285,7 @@ public class AsyncBlock implements Block { @Override public boolean isLiquid() { int combined = queue.getCombinedId4Data(x, y, z, 0); - BlockTypes type = BlockTypes.getFromStateId(combined); + BlockType type = BlockTypes.getFromStateId(combined); return type.getMaterial().isLiquid(); } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java index a34885550..13dc25d1b 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java @@ -22,6 +22,7 @@ import java.util.concurrent.CompletableFuture; import java.util.function.Predicate; import java.util.function.Supplier; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import org.bukkit.*; import org.bukkit.block.Biome; @@ -272,7 +273,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue public int getHighestBlockYAt(int x, int z) { for (int y = getMaxHeight() - 1; y >= 0; y--) { int stateId = queue.getCachedCombinedId4Data(x, y, z, BlockTypes.AIR.getInternalId()); - BlockTypes type = BlockTypes.getFromStateId(stateId); + BlockType type = BlockTypes.getFromStateId(stateId); if (!type.getMaterial().isAir()) return y; } return 0; 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 3e92817dd..87d84d8eb 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 @@ -142,7 +142,7 @@ public enum BukkitAdapter { return getAdapter().adapt(blockData); } - public static BlockTypes adapt(Material material) { + public static BlockType adapt(Material material) { return getAdapter().adapt(material); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java index eca570603..0264ba49e 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java @@ -83,7 +83,7 @@ public class BukkitBlockRegistry extends BundledBlockRegistry { @Nullable @Override - public Map getProperties(BlockType blockType) { + public Map> getProperties(BlockType blockType) { BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); if (adapter != null) { return adapter.getProperties(blockType); 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 6bc79ff09..9875901de 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 @@ -96,7 +96,7 @@ public class BukkitPlayer extends AbstractPlayerActor { public void giveItem(BaseItemStack itemStack) { final PlayerInventory inv = player.getInventory(); ItemStack newItem = BukkitAdapter.adapt(itemStack); - if (itemStack.getType() == WorldEdit.getInstance().getConfiguration().wandItem) { + if (itemStack.getType().getId().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) { inv.remove(newItem); } final ItemStack item = player.getItemInHand(); 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 47e52ee35..930995e2b 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 @@ -478,10 +478,10 @@ public class BukkitWorld extends AbstractWorld { } @Override - public com.sk89q.worldedit.world.block.BlockState getFullBlock(BlockVector3 position) { + public BaseBlock getFullBlock(BlockVector3 position) { BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); if (adapter != null) { - return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position)); + return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position)).toBaseBlock(); } else { return getBlock(position).toBaseBlock(); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/CachedBukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/CachedBukkitAdapter.java index fe3009b9f..c62dbc75b 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/CachedBukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/CachedBukkitAdapter.java @@ -5,6 +5,7 @@ import com.sk89q.worldedit.bukkit.adapter.IBukkitAdapter; import com.sk89q.worldedit.registry.state.Property; 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 com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; @@ -52,17 +53,17 @@ public abstract class CachedBukkitAdapter implements IBukkitAdapter { @Override public ItemType asItemType(Material material) { try { - return ItemTypes.values[itemTypes[material.ordinal()]]; + return ItemTypes.get(itemTypes[material.ordinal()]); } catch (NullPointerException e) { if (init()) return asItemType(material); - return ItemTypes.values[itemTypes[material.ordinal()]]; + return ItemTypes.get(itemTypes[material.ordinal()]); } } @Override - public BlockTypes adapt(Material material) { + public BlockType adapt(Material material) { try { - return BlockTypes.values[blockTypes[material.ordinal()]]; + return BlockTypes.values[blockTypes[material.ordinal()]]; } catch (NullPointerException e) { if (init()) return adapt(material); throw e; @@ -80,7 +81,7 @@ public abstract class CachedBukkitAdapter implements IBukkitAdapter { try { checkNotNull(blockData); Material material = blockData.getMaterial(); - BlockTypes type = BlockTypes.getFromStateId(blockTypes[material.ordinal()]); + BlockType type = BlockTypes.getFromStateId(blockTypes[material.ordinal()]); List propList = type.getProperties(); if (propList.size() == 0) return type.getDefaultState(); String properties = blockData.getAsString(); diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java index b273f47b4..242e61796 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java @@ -284,7 +284,7 @@ public interface IBukkitAdapter { */ BlockState adapt(BlockData blockData); - BlockTypes adapt(Material material); + BlockType adapt(Material material); /** * Create a Bukkit BlockData from a WorldEdit BlockStateHolder diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/SimpleBukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/SimpleBukkitAdapter.java index 19891fa7d..79a9b947e 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/SimpleBukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/SimpleBukkitAdapter.java @@ -1,6 +1,7 @@ package com.sk89q.worldedit.bukkit.adapter; import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -31,7 +32,7 @@ public class SimpleBukkitAdapter extends CachedBukkitAdapter { int typeId = block.getInternalBlockTypeId(); BlockData[] dataCache = blockDataCache[typeId]; if (dataCache == null) { - BlockTypes type = BlockTypes.get(typeId); + BlockType type = BlockTypes.get(typeId); blockDataCache[typeId] = dataCache = new BlockData[type.getMaxStateId() + 1]; } int propId = block.getInternalPropertiesId(); diff --git a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/LazyBlock.java b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/LazyBlock.java index 853af45c1..6a3c496eb 100644 --- a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/LazyBlock.java +++ b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/LazyBlock.java @@ -79,7 +79,7 @@ public class LazyBlock extends BaseBlock { @Override public CompoundTag getNbtData() { if (!loaded) { - BlockState loadedBlock = extent.getFullBlock(position); + BlockState loadedBlock = extent.getFullBlock(position).toImmutableState(); this.nbtData = loadedBlock.getNbtData(); loaded = true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java index a05e5d697..9f90f2d70 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java @@ -31,6 +31,7 @@ import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.internal.registry.AbstractFactory; import com.sk89q.worldedit.internal.registry.InputParser; import com.sk89q.worldedit.math.BlockVector3; @@ -222,7 +223,7 @@ public class FaweAPI { * @see com.boydti.fawe.object.schematic.Schematic */ public static Schematic load(File file) throws IOException { - return ClipboardFormat.SCHEMATIC.load(file); + return ClipboardFormats.findByFile(file).load(file); } /** diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java index 61e6f2ee8..c4a1be496 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java @@ -22,7 +22,6 @@ import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.worldedit.*; import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.RandomPattern; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java index b31c6abfe..b818f1f6a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java @@ -36,7 +36,9 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; @@ -502,7 +504,7 @@ public class CFICommands extends MethodCommands { HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); World world = fp.getWorld(); - MultiClipboardHolder multi = ClipboardFormat.SCHEMATIC.loadAllFromInput(fp.getPlayer(), schematic, null, true); + MultiClipboardHolder multi = ClipboardFormats.loadAllFromInput(fp.getPlayer(), schematic, null, true); if (multi == null) { return; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/example/IntFaweChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/example/IntFaweChunk.java index 8b284ab89..df1b1aa8a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/example/IntFaweChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/example/IntFaweChunk.java @@ -202,10 +202,10 @@ public abstract class IntFaweChunk extends FaweChunk } vs[j] = combinedId; this.count[i]++; - switch (BlockTypes.getFromStateId(combinedId)) { - case AIR: - case CAVE_AIR: - case VOID_AIR: + switch (BlockTypes.getFromStateId(combinedId).getResource().toUpperCase()) { + case "AIR": + case "CAVE_AIR": + case "VOID_AIR": this.air[i]++; return; default: diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java index 0d963c199..8194e3a41 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java @@ -201,25 +201,25 @@ public class SchematicStreamer extends NBTStreamer { fc.forEach(new FaweClipboard.BlockReader() { @Override public void run(int x, int y, int z, BlockState block) { - BlockTypes type = block.getBlockType(); - switch (type) { - case ACACIA_STAIRS: - case BIRCH_STAIRS: - case BRICK_STAIRS: - case COBBLESTONE_STAIRS: - case DARK_OAK_STAIRS: - case DARK_PRISMARINE_STAIRS: - case JUNGLE_STAIRS: - case NETHER_BRICK_STAIRS: - case OAK_STAIRS: - case PRISMARINE_BRICK_STAIRS: - case PRISMARINE_STAIRS: - case PURPUR_STAIRS: - case QUARTZ_STAIRS: - case RED_SANDSTONE_STAIRS: - case SANDSTONE_STAIRS: - case SPRUCE_STAIRS: - case STONE_BRICK_STAIRS: + BlockType type = block.getBlockType(); + switch (type.getResource().toUpperCase()) { + case "ACACIA_STAIRS": + case "BIRCH_STAIRS": + case "BRICK_STAIRS": + case "COBBLESTONE_STAIRS": + case "DARK_OAK_STAIRS": + case "DARK_PRISMARINE_STAIRS": + case "JUNGLE_STAIRS": + case "NETHER_BRICK_STAIRS": + case "OAK_STAIRS": + case "PRISMARINE_BRICK_STAIRS": + case "PRISMARINE_STAIRS": + case "PURPUR_STAIRS": + case "QUARTZ_STAIRS": + case "RED_SANDSTONE_STAIRS": + case "SANDSTONE_STAIRS": + case "SPRUCE_STAIRS": + case "STONE_BRICK_STAIRS": Object half = block.getState(PropertyKey.HALF); Direction facing = block.getState(PropertyKey.FACING); @@ -228,19 +228,19 @@ public class SchematicStreamer extends NBTStreamer { Direction right = facing.getRight(); BlockStateHolder forwardBlock = fc.getBlock(x + forward.getBlockX(), y + forward.getBlockY(), z + forward.getBlockZ()); - BlockTypes forwardType = forwardBlock.getBlockType(); + BlockType forwardType = forwardBlock.getBlockType(); if (forwardType.hasProperty(PropertyKey.SHAPE) && forwardType.hasProperty(PropertyKey.FACING)) { Direction forwardFacing = (Direction) forwardBlock.getState(PropertyKey.FACING); if (forwardFacing == left) { BlockStateHolder rightBlock = fc.getBlock(x + right.getBlockX(), y + right.getBlockY(), z + right.getBlockZ()); - BlockTypes rightType = rightBlock.getBlockType(); + BlockType rightType = rightBlock.getBlockType(); if (!rightType.hasProperty(PropertyKey.SHAPE) || rightBlock.getState(PropertyKey.FACING) != facing) { fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "inner_left")); } return; } else if (forwardFacing == right) { BlockStateHolder leftBlock = fc.getBlock(x + left.getBlockX(), y + left.getBlockY(), z + left.getBlockZ()); - BlockTypes leftType = leftBlock.getBlockType(); + BlockType leftType = leftBlock.getBlockType(); if (!leftType.hasProperty(PropertyKey.SHAPE) || leftBlock.getState(PropertyKey.FACING) != facing) { fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "inner_right")); } @@ -249,19 +249,19 @@ public class SchematicStreamer extends NBTStreamer { } BlockStateHolder backwardsBlock = fc.getBlock(x - forward.getBlockX(), y - forward.getBlockY(), z - forward.getBlockZ()); - BlockTypes backwardsType = backwardsBlock.getBlockType(); + BlockType backwardsType = backwardsBlock.getBlockType(); if (backwardsType.hasProperty(PropertyKey.SHAPE) && backwardsType.hasProperty(PropertyKey.FACING)) { Direction backwardsFacing = (Direction) backwardsBlock.getState(PropertyKey.FACING); if (backwardsFacing == left) { BlockStateHolder rightBlock = fc.getBlock(x + right.getBlockX(), y + right.getBlockY(), z + right.getBlockZ()); - BlockTypes rightType = rightBlock.getBlockType(); + BlockType rightType = rightBlock.getBlockType(); if (!rightType.hasProperty(PropertyKey.SHAPE) || rightBlock.getState(PropertyKey.FACING) != facing) { fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "outer_left")); } return; } else if (backwardsFacing == right) { BlockStateHolder leftBlock = fc.getBlock(x + left.getBlockX(), y + left.getBlockY(), z + left.getBlockZ()); - BlockTypes leftType = leftBlock.getBlockType(); + BlockType leftType = leftBlock.getBlockType(); if (!leftType.hasProperty(PropertyKey.SHAPE) || leftBlock.getState(PropertyKey.FACING) != facing) { fc.setBlock(x, y, z, block.with(PropertyKey.SHAPE, "outer_right")); } @@ -301,43 +301,43 @@ public class SchematicStreamer extends NBTStreamer { private boolean merge(int group, int x, int y, int z) { BlockStateHolder block = fc.getBlock(x, y, z); - BlockTypes type = block.getBlockType(); + BlockType type = block.getBlockType(); return group(type) == group || fullCube.apply(type); } - private int group(BlockTypes type) { - switch (type) { - case ACACIA_FENCE: - case BIRCH_FENCE: - case DARK_OAK_FENCE: - case JUNGLE_FENCE: - case OAK_FENCE: - case SPRUCE_FENCE: + private int group(BlockType type) { + switch (type.getResource().toUpperCase()) { + case "ACACIA_FENCE": + case "BIRCH_FENCE": + case "DARK_OAK_FENCE": + case "JUNGLE_FENCE": + case "OAK_FENCE": + case "SPRUCE_FENCE": return 0; - case NETHER_BRICK_FENCE: + case "NETHER_BRICK_FENCE": return 1; - case COBBLESTONE_WALL: - case MOSSY_COBBLESTONE_WALL: + case "COBBLESTONE_WALL": + case "MOSSY_COBBLESTONE_WALL": return 2; - case IRON_BARS: - case BLACK_STAINED_GLASS_PANE: - case BLUE_STAINED_GLASS_PANE: - case BROWN_MUSHROOM_BLOCK: - case BROWN_STAINED_GLASS_PANE: - case CYAN_STAINED_GLASS_PANE: - case GLASS_PANE: - case GRAY_STAINED_GLASS_PANE: - case GREEN_STAINED_GLASS_PANE: - case LIGHT_BLUE_STAINED_GLASS_PANE: - case LIGHT_GRAY_STAINED_GLASS_PANE: - case LIME_STAINED_GLASS_PANE: - case MAGENTA_STAINED_GLASS_PANE: - case ORANGE_STAINED_GLASS_PANE: - case PINK_STAINED_GLASS_PANE: - case PURPLE_STAINED_GLASS_PANE: - case RED_STAINED_GLASS_PANE: - case WHITE_STAINED_GLASS_PANE: - case YELLOW_STAINED_GLASS_PANE: + case "IRON_BARS": + case "BLACK_STAINED_GLASS_PANE": + case "BLUE_STAINED_GLASS_PANE": + case "BROWN_MUSHROOM_BLOCK": + case "BROWN_STAINED_GLASS_PANE": + case "CYAN_STAINED_GLASS_PANE": + case "GLASS_PANE": + case "GRAY_STAINED_GLASS_PANE": + case "GREEN_STAINED_GLASS_PANE": + case "LIGHT_BLUE_STAINED_GLASS_PANE": + case "LIGHT_GRAY_STAINED_GLASS_PANE": + case "LIME_STAINED_GLASS_PANE": + case "MAGENTA_STAINED_GLASS_PANE": + case "ORANGE_STAINED_GLASS_PANE": + case "PINK_STAINED_GLASS_PANE": + case "PURPLE_STAINED_GLASS_PANE": + case "RED_STAINED_GLASS_PANE": + case "WHITE_STAINED_GLASS_PANE": + case "YELLOW_STAINED_GLASS_PANE": return 3; default: return -1; @@ -450,6 +450,7 @@ public class SchematicStreamer extends NBTStreamer { public Clipboard getClipboard() throws IOException { try { + setupClipboard(0); addDimensionReaders(); addBlockReaders(); readFully(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCADrawer.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCADrawer.java index baa7db80d..b85e64926 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCADrawer.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCADrawer.java @@ -4,6 +4,7 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.TextureUtil; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import java.awt.image.BufferedImage; @@ -80,12 +81,12 @@ public final class HeightMapMCADrawer { if (height + 1 < waterHeight) { int waterId = gen.primtives.waterId; int waterColor = 0; - BlockTypes waterType = BlockTypes.get(waterId); - switch (waterType) { - case WATER: + BlockType waterType = BlockTypes.get(waterId); + switch (waterType.getResource().toUpperCase()) { + case "WATER": color = tu.averageColor((0x11 << 16) + (0x66 << 8) + (0xCC), color); break; - case LAVA: + case "LAVA": color = (0xCC << 16) + (0x33 << 8) + (0); break; default: diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java index 3e5a0cdd4..6c48fe39f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java @@ -445,9 +445,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr private final void setLayerHeight(int index, int blockHeight, int layerHeight) { int floorState = floor.get()[index]; - switch (BlockTypes.getFromStateId(floorState)) { - case SNOW: - case SNOW_BLOCK: + switch (BlockTypes.getFromStateId(floorState).getResource().toUpperCase()) { + case "SNOW": + case "SNOW_BLOCK": if (layerHeight != 0) { this.heights.setByte(index, (byte) (blockHeight + 1)); this.floor.setInt(index, (BlockTypes.SNOW.getInternalId() + layerHeight)); @@ -470,9 +470,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr private final void setLayerHeightRaw(int index, int blockHeight, int layerHeight) { int floorState = floor.get()[index]; - switch (BlockTypes.getFromStateId(floorState)) { - case SNOW: - case SNOW_BLOCK: + switch (BlockTypes.getFromStateId(floorState).getResource().toUpperCase()) { + case "SNOW": + case "SNOW_BLOCK": if (layerHeight != 0) { this.heights.getByteArray()[index] = (byte) (blockHeight + 1); this.floor.getIntArray()[index] = (BlockTypes.SNOW.getInternalId() + layerHeight); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/CavesGen.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/CavesGen.java index e79821725..4d9c316d2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/CavesGen.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/generator/CavesGen.java @@ -172,9 +172,9 @@ public class CavesGen extends GenBase { if ((d11 > -0.7D) && (d9 * d9 + d11 * d11 + d10 * d10 < 1.0D)) { BlockStateHolder material = chunk.getLazyBlock(bx + local_x, local_y, bz + local_z); BlockStateHolder materialAbove = chunk.getLazyBlock(bx + local_x, local_y + 1, bz + local_z); - switch (material.getBlockType()) { - case GRASS: - case MYCELIUM: + switch (material.getBlockType().getResource().toUpperCase()) { + case "GRASS": + case "MYCELIUM": grassFound = true; break; } @@ -205,13 +205,13 @@ public class CavesGen extends GenBase { } protected boolean isSuitableBlock(BlockStateHolder material, BlockStateHolder materialAbove) { - switch (material.getBlockType()) { - case AIR: - case CAVE_AIR: - case VOID_AIR: - case WATER: - case LAVA: - case BEDROCK: + switch (material.getBlockType().getResource().toUpperCase()) { + case "AIR": + case "CAVE_AIR": + case "VOID_AIR": + case "WATER": + case "LAVA": + case "BEDROCK": return false; default: return true; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/ChangeSetFaweQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/object/ChangeSetFaweQueue.java index af427589e..0fa79e911 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/ChangeSetFaweQueue.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/ChangeSetFaweQueue.java @@ -5,6 +5,7 @@ import com.boydti.fawe.object.changeset.FaweChangeSet; import com.boydti.fawe.object.queue.DelegateFaweQueue; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; public class ChangeSetFaweQueue extends DelegateFaweQueue { @@ -28,7 +29,7 @@ public class ChangeSetFaweQueue extends DelegateFaweQueue { if (super.setBlock(x, y, z, combinedId)) { int combinedFrom = getParent().getCombinedId4Data(x, y, z); - BlockTypes typeFrom = BlockTypes.getFromStateId(combinedFrom); + BlockType typeFrom = BlockTypes.getFromStateId(combinedFrom); if (typeFrom.getMaterial().hasContainer()) { CompoundTag nbt = getParent().getTileEntity(x, y, z); if (nbt != null) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweChunk.java index e9d06ffd8..a3af9b5f0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweChunk.java @@ -120,7 +120,7 @@ public abstract class FaweChunk implements Callable { try { CompoundTag tile = getTile(x & 15, y, z & 15); if (tile != null) { - return BaseBlock.getFromInternalId(combined, tile); + return BaseBlock.getFromInternalId(combined, tile).toImmutableState(); } } catch (Throwable e) { MainUtil.handleError(e); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweQueue.java index 198b0a94c..56e6dec1b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweQueue.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweQueue.java @@ -23,6 +23,7 @@ import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import java.io.File; @@ -78,7 +79,7 @@ public interface FaweQueue extends HasFaweQueue, Extent { if (state.getMaterial().hasContainer()) { CompoundTag tile = getTileEntity(x, y, z); if (tile != null) { - return BaseBlock.getFromInternalId(combinedId4Data, tile); + return BaseBlock.getFromInternalId(combinedId4Data, tile).toImmutableState(); } } return state; @@ -94,8 +95,8 @@ public interface FaweQueue extends HasFaweQueue, Extent { } @Override - default BlockState getFullBlock(BlockVector3 position) { - return getLazyBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ()); + default BaseBlock getFullBlock(BlockVector3 position) { + return getLazyBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ()).toBaseBlock(); } @Override @@ -275,18 +276,18 @@ public interface FaweQueue extends HasFaweQueue, Extent { for (int y = 0; y <= getMaxY(); y++) { int combined = getCombinedId4Data(xx, y, zz); BlockState state = BlockState.getFromInternalId(combined); - BlockTypes type = state.getBlockType(); - switch (type.getTypeEnum()) { - case AIR: - case VOID_AIR: - case CAVE_AIR: + BlockType type = state.getBlockType(); + switch (type.getResource().toUpperCase()) { + case "AIR": + case "VOID_AIR": + case "CAVE_AIR": continue; } mutable.mutY(y); CompoundTag tile = getTileEntity(x, y, z); if (tile != null) { BaseBlock block = BaseBlock.getFromInternalId(combined, tile); - onEach.run(mutable.toBlockVector3(), block); + onEach.run(mutable.toBlockVector3(), block.toImmutableState()); } else { onEach.run(mutable.toBlockVector3(), state); } @@ -308,7 +309,7 @@ public interface FaweQueue extends HasFaweQueue, Extent { if (combined == 0) { continue; } - BlockTypes type = BlockTypes.getFromStateId(combined); + BlockType type = BlockTypes.getFromStateId(combined); if (type.getMaterial().hasContainer()) { CompoundTag tile = getTileEntity(x, y, z); if (tile != null) { @@ -316,7 +317,7 @@ public interface FaweQueue extends HasFaweQueue, Extent { mutable.mutZ(zz); mutable.mutY(y); BaseBlock block = BaseBlock.getFromInternalId(combined, tile); - onEach.run(mutable.toBlockVector3(), block); + onEach.run(mutable.toBlockVector3(), block.toImmutableState()); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/scroll/ScrollAction.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/scroll/ScrollAction.java index 12ebb41dd..8a8677169 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/scroll/ScrollAction.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/scroll/ScrollAction.java @@ -10,6 +10,7 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.pattern.Pattern; import java.io.IOException; @@ -34,7 +35,7 @@ public abstract class ScrollAction implements ScrollTool { } String filename = split[1]; try { - MultiClipboardHolder multi = ClipboardFormat.SCHEMATIC.loadAllFromInput(player, filename, null, message); + MultiClipboardHolder multi = ClipboardFormats.loadAllFromInput(player, filename, null, message); if (multi == null) { return null; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VirtualWorld.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VirtualWorld.java index db9be1e55..4eb958fcb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VirtualWorld.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VirtualWorld.java @@ -10,6 +10,7 @@ import com.sk89q.worldedit.event.platform.PlayerInputEvent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.world.SimpleWorld; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -22,8 +23,8 @@ public interface VirtualWorld extends SimpleWorld, FaweQueue, Closeable { FaweChunk getSnapshot(int chunkX, int chunkZ); @Override - default BlockState getFullBlock(BlockVector3 position) { - return getLazyBlock(position); + default BaseBlock getFullBlock(BlockVector3 position) { + return getLazyBlock(position).toBaseBlock(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualChunk.java index 4a6a8155d..1ce779754 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualChunk.java @@ -115,10 +115,10 @@ public class VisualChunk extends FaweChunk { public void setBlock(int x, int y, int z, int combinedId) { int index = getIndex(x, y, z); try { - switch (BlockTypes.getFromStateId(combinedId)) { - case AIR: - case CAVE_AIR: - case VOID_AIR: + switch (BlockTypes.getFromStateId(combinedId).getResource().toUpperCase()) { + case "AIR": + case "CAVE_AIR": + case "VOID_AIR": add.clear(index); remove.set(index); break; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableFullBlockChange.java b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableFullBlockChange.java index a74cec6fe..504af840a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableFullBlockChange.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableFullBlockChange.java @@ -11,6 +11,7 @@ import com.sk89q.worldedit.extent.inventory.BlockBagException; import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.history.change.Change; import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; public class MutableFullBlockChange implements Change { @@ -60,9 +61,9 @@ public class MutableFullBlockChange implements Change { } public void perform(FaweQueue queue) { - BlockTypes idFrom = BlockTypes.getFromStateId(from); + BlockType idFrom = BlockTypes.getFromStateId(from); if (blockBag != null) { - BlockTypes idTo = BlockTypes.getFromStateId(to); + BlockType idTo = BlockTypes.getFromStateId(to); if (idFrom != idTo) { if (allowFetch && from != 0) { try { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java index dec9add94..9e7d5d2ed 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java @@ -17,6 +17,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BaseBiome; 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; @@ -147,12 +148,12 @@ public class CPUOptimizedClipboard extends FaweClipboard { @Override public BlockState getBlock(int index) { int combinedId = states[index]; - BlockTypes type = BlockTypes.getFromStateId(combinedId); + BlockType type = BlockTypes.getFromStateId(combinedId); BlockState state = type.withStateId(combinedId); if (type.getMaterial().hasContainer()) { CompoundTag nbt = getTag(index); if (nbt != null) { - return new BaseBlock(state, nbt); + return new BaseBlock(state, nbt).toImmutableState(); } } return state; @@ -174,10 +175,10 @@ public class CPUOptimizedClipboard extends FaweClipboard { for (int z = 0; z < length; z++) { for (int x = 0; x < width; x++, index++) { BlockState block = getBlock(index); - switch (block.getBlockType()) { - case AIR: - case CAVE_AIR: - case VOID_AIR: + switch (block.getBlockType().getResource().toUpperCase()) { + case "AIR": + case "CAVE_AIR": + case "VOID_AIR": continue; default: task.run(x, y, z, block); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java index fee906b1d..ecb4a8708 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java @@ -21,6 +21,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import java.io.Closeable; @@ -371,14 +372,14 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { for (int z = 0; z < length; z++) { for (int x = 0; x < width; x++, pos += 4) { int combinedId = mbb.getInt(pos); - BlockTypes type = BlockTypes.getFromStateId(combinedId); + BlockType type = BlockTypes.getFromStateId(combinedId); BlockState state = type.withStateId(combinedId); if (type.getMaterial().hasContainer()) { trio.set(x, y, z); CompoundTag nbt = nbtMap.get(trio); if (nbt != null) { BaseBlock block = new BaseBlock(state, nbt); - task.run(x, y, z, block); + task.run(x, y, z, block.toImmutableState()); continue; } } @@ -402,11 +403,11 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { for (int z = 0; z < length; z++) { for (int x = 0; x < width; x++, pos += 4) { int combinedId = mbb.getInt(pos); - BlockTypes type = BlockTypes.getFromStateId(combinedId); - switch (type) { - case AIR: - case CAVE_AIR: - case VOID_AIR: + BlockType type = BlockTypes.getFromStateId(combinedId); + switch (type.getResource().toUpperCase()) { + case "AIR": + case "CAVE_AIR": + case "VOID_AIR": continue; default: BlockState state = type.withStateId(combinedId); @@ -415,7 +416,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { CompoundTag nbt = nbtMap.get(trio); if (nbt != null) { BaseBlock block = new BaseBlock(state, nbt); - task.run(x, y, z, block); + task.run(x, y, z, block.toImmutableState()); continue; } } @@ -436,12 +437,12 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { try { int index = HEADER_SIZE + (getIndex(x, y, z) << 2); int combinedId = mbb.getInt(index); - BlockTypes type = BlockTypes.getFromStateId(combinedId); + BlockType type = BlockTypes.getFromStateId(combinedId); BlockState state = type.withStateId(combinedId); if (type.getMaterial().hasContainer() && !nbtMap.isEmpty()) { CompoundTag nbt = nbtMap.get(new IntegerTrio(x, y, z)); if (nbt != null) { - return new BaseBlock(state, nbt); + return new BaseBlock(state, nbt).toImmutableState(); } } return state; @@ -458,7 +459,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { try { int diskIndex = (HEADER_SIZE) + (i << 2); int combinedId = mbb.getInt(diskIndex); - BlockTypes type = BlockTypes.getFromStateId(combinedId); + BlockType type = BlockTypes.getFromStateId(combinedId); BlockState state = type.withStateId(combinedId); if (type.getMaterial().hasContainer() && !nbtMap.isEmpty()) { CompoundTag nbt; @@ -481,7 +482,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { nbt = nbtMap.get(new IntegerTrio(x, y, z)); } if (nbt != null) { - return new BaseBlock(state, nbt); + return new BaseBlock(state, nbt).toImmutableState(); } } return state; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.java index 797304906..c77892562 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/EmptyClipboard.java @@ -2,6 +2,7 @@ package com.boydti.fawe.object.clipboard; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; @@ -73,8 +74,8 @@ public class EmptyClipboard implements Clipboard { } @Override - public BlockState getFullBlock(BlockVector3 position) { - return EditSession.nullBlock; + public BaseBlock getFullBlock(BlockVector3 position) { + return EditSession.nullBlock.toBaseBlock(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java index 0f8d1c665..806941840 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java @@ -18,6 +18,7 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import net.jpountz.util.SafeUtils; @@ -203,10 +204,11 @@ public class MemoryOptimizedClipboard extends FaweClipboard { } } if (lastCombinedIds == null) { - switch (BlockTypes.getFromStateId(v)) { - case AIR: - case CAVE_AIR: - case VOID_AIR: + BlockType bt = BlockTypes.getFromStateId(v); + switch (bt.getResource().toUpperCase()) { + case "AIR": + case "CAVE_AIR": + case "VOID_AIR": return; } lastCombinedIds = new byte[BLOCK_SIZE]; @@ -270,12 +272,12 @@ public class MemoryOptimizedClipboard extends FaweClipboard { @Override public BlockState getBlock(int index) { int combinedId = getCombinedId(index); - BlockTypes type = BlockTypes.getFromStateId(combinedId); + BlockType type = BlockTypes.getFromStateId(combinedId); BlockState state = type.withStateId(combinedId); if (type.getMaterial().hasContainer()) { CompoundTag nbt = getTag(index); if (nbt != null) { - return new BaseBlock(state, nbt); + return new BaseBlock(state, nbt).toImmutableState(); } } return state; @@ -297,10 +299,10 @@ public class MemoryOptimizedClipboard extends FaweClipboard { for (int z = 0; z < length; z++) { for (int x = 0; x < width; x++, index++) { BlockState block = getBlock(index); - switch (block.getBlockType()) { - case AIR: - case CAVE_AIR: - case VOID_AIR: + switch (block.getBlockType().getResource().toUpperCase()) { + case "AIR": + case "CAVE_AIR": + case "VOID_AIR": continue; default: task.run(x, y, z, block); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/EmptyExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/EmptyExtent.java index ad7b7a5c5..123b12387 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/EmptyExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/EmptyExtent.java @@ -2,6 +2,7 @@ package com.boydti.fawe.object.extent; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; @@ -44,8 +45,8 @@ public class EmptyExtent implements Extent { } @Override - public BlockState getFullBlock(BlockVector3 position) { - return EditSession.nullBlock; + public BaseBlock getFullBlock(BlockVector3 position) { + return EditSession.nullBlock.toBaseBlock(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FastWorldEditExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FastWorldEditExtent.java index fd547331f..57cab3f72 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FastWorldEditExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FastWorldEditExtent.java @@ -123,12 +123,12 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa @Override public BlockState getLazyBlock(int x, int y, int z) { int combinedId4Data = queue.getCombinedId4Data(x, y, z, 0); - BlockTypes type = BlockTypes.getFromStateId(combinedId4Data); + BlockType type = BlockTypes.getFromStateId(combinedId4Data); BlockState state = type.withStateId(combinedId4Data); if (type.getMaterial().hasContainer()) { CompoundTag tile = queue.getTileEntity(x, y, z); if (tile != null) { - return new BaseBlock(state, tile); + return new BaseBlock(state, tile).toImmutableState(); } } return state; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java index d9de67ee4..cf48c7527 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/NullExtent.java @@ -53,12 +53,12 @@ public class NullExtent extends FaweRegionExtent { } @Override - public BaseBlock getBlock(final BlockVector3 arg0) { + public BlockState getBlock(final BlockVector3 arg0) { throw new FaweException(reason); } @Override - public BaseBlock getLazyBlock(final BlockVector3 arg0) { + public BlockState getLazyBlock(final BlockVector3 arg0) { throw new FaweException(reason); } @@ -78,7 +78,7 @@ public class NullExtent extends FaweRegionExtent { } @Override - public BaseBlock getLazyBlock(int x, int y, int z) { + public BlockState getLazyBlock(int x, int y, int z) { throw new FaweException(reason); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java index 8ad82a1c4..a06eab224 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/TransformExtent.java @@ -1,6 +1,7 @@ package com.boydti.fawe.object.extent; import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.transform.BlockTransformExtent; @@ -80,17 +81,22 @@ public class TransformExtent extends BlockTransformExtent { @Override public BlockState getLazyBlock(int x, int y, int z) { - return transformFast(super.getLazyBlock(getPos(x, y, z))); + return transformFast(super.getLazyBlock(getPos(x, y, z))).toImmutableState(); } @Override public BlockState getLazyBlock(BlockVector3 position) { - return transformFast(super.getLazyBlock(getPos(position))); + return transformFast(super.getLazyBlock(getPos(position))).toImmutableState(); } @Override public BlockState getBlock(BlockVector3 position) { - return transformFast(super.getBlock(getPos(position))); + return transformFast(super.getBlock(getPos(position))).toImmutableState(); + } + + @Override + public BaseBlock getFullBlock(BlockVector3 position) { + return transformFast(super.getFullBlock(getPos(position)).toImmutableState()); } @Override @@ -102,14 +108,14 @@ public class TransformExtent extends BlockTransformExtent { } @Override - public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException { - return super.setBlock(getPos(x, y, z), transformFastInverse((BlockState) block)); + public > boolean setBlock(int x, int y, int z, B block) throws WorldEditException { + return super.setBlock(getPos(x, y, z), transformFastInverse((BlockState)block)); } @Override - public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { - return super.setBlock(getPos(location), transformFastInverse((BlockState) block)); + public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { + return super.setBlock(getPos(location), transformFastInverse((BlockState)block)); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternExtent.java index 6374ae191..62d31ad5b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternExtent.java @@ -1,7 +1,7 @@ package com.boydti.fawe.object.pattern; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; @@ -97,8 +97,8 @@ public class PatternExtent extends AbstractPattern implements Extent { } @Override - public BlockState getFullBlock(BlockVector3 position) { - return getBlock(position); + public BaseBlock getFullBlock(BlockVector3 position) { + return getBlock(position).toBaseBlock(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PropertyPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PropertyPattern.java index 1a479e94e..54ee2f950 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PropertyPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PropertyPattern.java @@ -62,7 +62,7 @@ public class PropertyPattern extends AbstractExtentPattern { } } - private void add(BlockTypes type, PropertyKey key, Operator operator, MutableCharSequence value, boolean wrap) { + private void add(BlockType type, PropertyKey key, Operator operator, MutableCharSequence value, boolean wrap) { if (!type.hasProperty(key)) return; AbstractProperty property = (AbstractProperty) type.getProperty(key); BlockState defaultState = type.getDefaultState(); @@ -129,14 +129,14 @@ public class PropertyPattern extends AbstractExtentPattern { charSequence.setString(input); charSequence.setSubstring(0, propStart); - BlockTypes type = null; - List blockTypeList = null; + BlockType type = null; + List blockTypeList = null; if (StringMan.isAlphanumericUnd(charSequence)) { type = BlockTypes.get(charSequence); } else { String regex = charSequence.toString(); blockTypeList = new ArrayList<>(); - for (BlockTypes myType : BlockTypes.values) { + for (BlockType myType : BlockTypes.values) { if (myType.getId().matches(regex)) { blockTypeList.add(myType); } @@ -164,7 +164,7 @@ public class PropertyPattern extends AbstractExtentPattern { char firstChar = input.charAt(last + 1); if (type != null) add(type, key, operator, charSequence, wrap); else { - for (BlockTypes myType : blockTypeList) { + for (BlockType myType : blockTypeList) { add(myType, key, operator, charSequence, wrap); } } @@ -203,7 +203,7 @@ public class PropertyPattern extends AbstractExtentPattern { if (newOrdinal != ordinal) { CompoundTag nbt = block.getNbtData(); BlockState newState = BlockState.getFromOrdinal(newOrdinal); - return nbt != null ? new BaseBlock(newState, nbt) : newState; + return nbt != null ? new BaseBlock(newState, nbt).toImmutableState() : newState; } return orDefault; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java index b7b103a53..395b22ce9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java @@ -4,7 +4,6 @@ import com.boydti.fawe.FaweCache; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.SolidBlockMask; import com.sk89q.worldedit.function.pattern.AbstractPattern; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/StructureFormat.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/StructureFormat.java index 853d5de9a..413f458a8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/StructureFormat.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/StructureFormat.java @@ -178,14 +178,9 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter { for (BlockVector3 point : region) { BlockStateHolder block = clipboard.getBlock(point); int combined = block.getInternalId(); - BlockTypes type = block.getBlockType(); + BlockType type = block.getBlockType(); - switch (type) { - case STRUCTURE_VOID: - continue; - default: - } - if (indexes.containsKey(combined)) { + if (type == BlockTypes.STRUCTURE_VOID || indexes.containsKey(combined)) { continue; } @@ -194,7 +189,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter { paletteEntry.put("Name", type.getId()); if (block.getInternalId() != type.getInternalId()) { Map properties = null; - for (AbstractProperty property : (List) type.getProperties()) { + for (AbstractProperty property : (List>) type.getProperties()) { int propIndex = property.getIndex(block.getInternalId()); if (propIndex != 0) { if (properties == null) properties = new HashMap<>(); @@ -218,8 +213,8 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter { BlockVector3 min = region.getMinimumPoint(); for (BlockVector3 point : region) { BlockStateHolder block = clipboard.getBlock(point); - switch (block.getBlockType()) { - case STRUCTURE_VOID: + switch (block.getBlockType().getResource().toUpperCase()) { + case "STRUCTURE_VOID": continue; default: int combined = block.getInternalId(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java index 75fe331e1..fe23832ed 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java @@ -23,6 +23,7 @@ import com.sk89q.worldedit.event.platform.InputType; import com.sk89q.worldedit.event.platform.PlayerInputEvent; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; @@ -128,7 +129,7 @@ public class SchemVis extends ImmutableVirtualWorld { File file = new File(cachedFile.getParentFile(), filename.substring(1, filename.length() - 7)); URI uri = file.toURI(); - ClipboardFormat format = ClipboardFormat.findByFile(file); + ClipboardFormat format = ClipboardFormats.findByFile(file); format.hold(player, uri, new FileInputStream(file)); BBC.SCHEMATIC_LOADED.send(player, filename); session.setVirtualWorld(null); @@ -144,7 +145,7 @@ public class SchemVis extends ImmutableVirtualWorld { File file = new File(clicked.getParentFile(), filename.substring(1, filename.length() - 7)); URI uri = file.toURI(); - ClipboardFormat format = ClipboardFormat.findByFile(file); + ClipboardFormat format = ClipboardFormats.findByFile(file); boolean contains = existing instanceof URIClipboardHolder && ((URIClipboardHolder) existing).contains(uri); if (contains) { @@ -386,7 +387,7 @@ public class SchemVis extends ImmutableVirtualWorld { player.sendMessage(BBC.getPrefix() + "Converting: " + file); cached.createNewFile(); try (FileInputStream in = new FileInputStream(file)) { - ClipboardFormat format = ClipboardFormat.findByFile(file); + ClipboardFormat format = ClipboardFormats.findByFile(file); if (format != null) { ClipboardReader reader = format.getReader(in); Clipboard clipboard = reader.read(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/CachedTextureUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/CachedTextureUtil.java index 43413bc19..a9ae2f2cb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/CachedTextureUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/CachedTextureUtil.java @@ -10,9 +10,9 @@ import java.io.FileNotFoundException; public class CachedTextureUtil extends DelegateTextureUtil { private final TextureUtil parent; - private transient Int2ObjectOpenHashMap colorBlockMap; + private transient Int2ObjectOpenHashMap colorBlockMap; private transient Int2ObjectOpenHashMap colorBiomeMap; - private transient Int2ObjectOpenHashMap colorLayerMap; + private transient Int2ObjectOpenHashMap colorLayerMap; public CachedTextureUtil(TextureUtil parent) throws FileNotFoundException { super(parent); @@ -23,8 +23,8 @@ public class CachedTextureUtil extends DelegateTextureUtil { } @Override - public BlockTypes[] getNearestLayer(int color) { - BlockTypes[] closest = colorLayerMap.get(color); + public BlockType[] getNearestLayer(int color) { + BlockType[] closest = colorLayerMap.get(color); if (closest != null) { return closest; } @@ -49,12 +49,12 @@ public class CachedTextureUtil extends DelegateTextureUtil { } @Override - public BlockTypes getNearestBlock(int color) { - BlockTypes value = colorBlockMap.get(color); + public BlockType getNearestBlock(int color) { + BlockType value = colorBlockMap.get(color); if (value != null) { return value; } - BlockTypes result = parent.getNearestBlock(color); + BlockType result = parent.getNearestBlock(color); if (result != null) { colorBlockMap.put((int) color, result); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/DelegateTextureUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/DelegateTextureUtil.java index e5ae5c030..5aa095f62 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/DelegateTextureUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/DelegateTextureUtil.java @@ -19,7 +19,7 @@ public class DelegateTextureUtil extends TextureUtil { } @Override - public BlockTypes getNearestBlock(int color) { + public BlockType getNearestBlock(int color) { return parent.getNearestBlock(color); } @@ -34,7 +34,7 @@ public class DelegateTextureUtil extends TextureUtil { } @Override - public BlockTypes[] getNearestLayer(int color) { + public BlockType[] getNearestLayer(int color) { return parent.getNearestLayer(color); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/FilteredTextureUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/FilteredTextureUtil.java index e9e491cea..25a711786 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/FilteredTextureUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/FilteredTextureUtil.java @@ -26,14 +26,14 @@ public class FilteredTextureUtil extends TextureUtil { this.validBlockIds = new int[distances.length]; int num = 0; for (int i = 0; i < parent.validBlockIds.length; i++) { - BlockTypes block = BlockTypes.get(parent.validBlockIds[i]); + BlockType block = BlockTypes.get(parent.validBlockIds[i]); if (blocks.contains(block)) num++; } this.validBlockIds = new int[num]; this.validColors = new int[num]; num = 0; for (int i = 0; i < parent.validBlockIds.length; i++) { - BlockTypes block = BlockTypes.get(parent.validBlockIds[i]); + BlockType block = BlockTypes.get(parent.validBlockIds[i]); if (blocks.contains(block)) { validBlockIds[num] = parent.validBlockIds[i]; validColors[num++] = parent.validColors[i]; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java index 90d60c551..20ada4eb8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/MainUtil.java @@ -12,6 +12,7 @@ import com.github.luben.zstd.ZstdOutputStream; import com.sk89q.jnbt.*; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.history.changeset.ChangeSet; import com.sk89q.worldedit.util.Location; import java.awt.Graphics2D; @@ -889,7 +890,7 @@ public class MainUtil { public static File resolve(File dir, String filename, @Nullable ClipboardFormat format, boolean allowDir) { if (format != null) { if (!filename.matches(".*\\.[\\w].*")) { - filename = filename + "." + format.getExtension(); + filename = filename + "." + format.getPrimaryFileExtension(); } return MainUtil.resolveRelative(new File(dir, filename)); } @@ -897,8 +898,8 @@ public class MainUtil { File file = MainUtil.resolveRelative(new File(dir, filename)); if (file.exists() && file.isDirectory()) return file; } - for (ClipboardFormat f : ClipboardFormat.values) { - File file = MainUtil.resolveRelative(new File(dir, filename + "." + f.getExtension())); + for (ClipboardFormat f : ClipboardFormats.getAll()) { + File file = MainUtil.resolveRelative(new File(dir, filename + "." + f.getPrimaryFileExtension())); if (file.exists()) return file; } return null; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/RandomTextureUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/RandomTextureUtil.java index d4841d92b..3b3c271c8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/RandomTextureUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/RandomTextureUtil.java @@ -79,14 +79,14 @@ public class RandomTextureUtil extends CachedTextureUtil { } @Override - public BlockTypes getNearestBlock(int color) { + public BlockType getNearestBlock(int color) { int offsetColor = offsets.getOrDefault(color, 0); if (offsetColor != 0) { offsetColor = addRandomColor(color, offsetColor); } else { offsetColor = color; } - BlockTypes res = super.getNearestBlock(offsetColor); + BlockType res = super.getNearestBlock(offsetColor); if (res == null) return null; int newColor = getColor(res); { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java index fa9ad46fb..d7216c891 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java @@ -372,7 +372,7 @@ public class TextureUtil implements TextureHolder{ } } - public BlockTypes getNearestBlock(int color) { + public BlockType getNearestBlock(int color) { long min = Long.MAX_VALUE; int closest = 0; int red1 = (color >> 16) & 0xFF; @@ -420,7 +420,7 @@ public class TextureUtil implements TextureHolder{ return BlockTypes.get(closest); } - private BlockTypes[] layerBuffer = new BlockTypes[2]; + private BlockType[] layerBuffer = new BlockType[2]; /** * Returns the block combined ids as an array @@ -428,7 +428,7 @@ public class TextureUtil implements TextureHolder{ * @param color * @return */ - public BlockTypes[] getNearestLayer(int color) { + public BlockType[] getNearestLayer(int color) { int[] closest = null; long min = Long.MAX_VALUE; int red1 = (color >> 16) & 0xFF; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java index 9ea0b558b..ef330d00f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java @@ -6,9 +6,9 @@ import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.TaskManager; import com.sk89q.worldedit.*; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.blocks.BaseItemStack; -import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.AbstractPlayerActor; @@ -51,7 +51,7 @@ public class PlayerWrapper extends AbstractPlayerActor { } @Override - public BlockState getBlockInHand(HandSide handSide) throws WorldEditException { + public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException { return parent.getBlockInHand(handSide); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java index 8559998ff..710286f3d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java @@ -20,6 +20,7 @@ import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.world.AbstractWorld; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BaseBiome; +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; @@ -240,7 +241,7 @@ public class WorldWrapper extends AbstractWorld { } @Override - public BlockState getFullBlock(BlockVector3 position) { + public BaseBlock getFullBlock(BlockVector3 position) { return parent.getFullBlock(position); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java index e79465ca9..5c42c0cf0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java @@ -28,6 +28,7 @@ import com.sk89q.worldedit.command.SchematicCommands; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.Operations; @@ -149,7 +150,7 @@ public class CuboidClipboard { } private BaseBlock adapt(BlockState state) { - if (state instanceof BaseBlock) return (BaseBlock) state; +// if (state instanceof BaseBlock) return (BaseBlock) state; return new BaseBlock(state); } @@ -173,7 +174,7 @@ public class CuboidClipboard { } public boolean setBlock(int x, int y, int z, BaseBlock block) { - return setBlock(x, y, z, (BlockState) block); + return setBlock(x, y, z, block.toImmutableState()); } public boolean setBlock(int x, int y, int z, BlockState block) { @@ -270,7 +271,7 @@ public class CuboidClipboard { if (region.contains(pt)) { setBlock(x, y, z, editSession.getBlock(pt)); } else { - setBlock(x, y, z, null); + setBlock(x, y, z, (BlockState)null); } } } @@ -435,7 +436,7 @@ public class CuboidClipboard { Operations.completeLegacy(result.copyTo(target)); this.clipboard = target; } - new Schematic(clipboard).save(path, ClipboardFormat.SPONGE_SCHEMATIC); + new Schematic(clipboard).save(path, BuiltInClipboardFormat.SPONGE_SCHEMATIC); } /** @@ -450,7 +451,7 @@ public class CuboidClipboard { @Deprecated public static CuboidClipboard loadSchematic(File path) throws DataException, IOException { checkNotNull(path); - return new CuboidClipboard((BlockVector3) ClipboardFormat.SCHEMATIC.load(path).getClipboard()); + return new CuboidClipboard((BlockVector3) BuiltInClipboardFormat.MCEDIT_SCHEMATIC.load(path).getClipboard()); } /** 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 a995eda9d..b462f3f0c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -981,7 +981,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } @Override - public BlockState getFullBlock(BlockVector3 position) { + public BaseBlock getFullBlock(BlockVector3 position) { return world.getFullBlock(position); } @@ -1094,12 +1094,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } @Deprecated public boolean setBlock(int x, int y, int z, BaseBlock block) { - return setBlock(x, y, z, (BlockState) block); + return setBlock(x, y, z, block.toImmutableState()); } @Deprecated public boolean setBlock(BlockVector3 position, BaseBlock block) throws MaxChangedBlocksException { - return setBlock(position, (BlockState) block); + return setBlock(position, block.toImmutableState()); } @SuppressWarnings("deprecation") @@ -2502,16 +2502,16 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } for (int y = maxY; y >= 1; --y) { final BlockType type = getBlockType(x, y, z); - switch (type.getTypeEnum()) { - case ICE: + switch (type.getResource().toUpperCase()) { + case "ICE": this.setBlock(x, y, z, BlockTypes.WATER.getDefaultState()); break; - case SNOW: + case "SNOW": this.setBlock(x, y, z, BlockTypes.AIR.getDefaultState()); break; - case CAVE_AIR: - case VOID_AIR: - case AIR: + case "CAVE_AIR": + case "VOID_AIR": + case "AIR": continue; default: break; @@ -2574,20 +2574,20 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, outer: for (int y = maxY; y >= 1; --y) { BlockType type = getBlockType(x, y, z); - switch (type.getTypeEnum()) { - case AIR: - case CAVE_AIR: - case VOID_AIR: + switch (type.getResource().toUpperCase()) { + case "AIR": + case "CAVE_AIR": + case "VOID_AIR": continue; - case WATER: + case "WATER": this.setBlock(x, y, z, BlockTypes.ICE.getDefaultState()); break outer; - case ACACIA_LEAVES: // TODO FIXME get leaves dynamically - case BIRCH_LEAVES: - case DARK_OAK_LEAVES: - case JUNGLE_LEAVES: - case OAK_LEAVES: - case SPRUCE_LEAVES: + case "ACACIA_LEAVES": // TODO FIXME get leaves dynamically + case "BIRCH_LEAVES": + case "DARK_OAK_LEAVES": + case "JUNGLE_LEAVES": + case "OAK_LEAVES": + case "SPRUCE_LEAVES": // int ceilRadius = (int) Math.ceil(radius); // for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) { // for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) { @@ -2670,12 +2670,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, loop: for (int y = maxY; y >= 1; --y) { BlockType block = getBlockType(x, y, z); - switch (block.getTypeEnum()) { - case DIRT: + switch (block.getResource().toUpperCase()) { + case "DIRT": this.setBlock(x, y, z, BlockTypes.GRASS_BLOCK.getDefaultState()); break loop; - case WATER: - case LAVA: + case "WATER": + case "LAVA": break loop; default: if (block.getMaterial().isMovementBlocker()) { @@ -2770,18 +2770,18 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, this.changes++; for (int y = basePosition.getBlockY(); y >= (basePosition.getBlockY() - 10); --y) { BlockType type = getBlockType(x, y, z); - switch (type.getTypeEnum()) { - case GRASS: - case DIRT: + switch (type.getResource().toUpperCase()) { + case "GRASS": + case "DIRT": treeType.generate(this, BlockVector3.at(x, y + 1, z)); this.changes++; break; - case SNOW: + case "SNOW": setBlock(BlockVector3.at(x, y, z), BlockTypes.AIR.getDefaultState()); break; - case AIR: - case CAVE_AIR: - case VOID_AIR: + case "AIR": + case "CAVE_AIR": + case "VOID_AIR": continue; default: break; 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 09459c761..71b84d441 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit; import com.sk89q.worldedit.util.logging.LogFormat; 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 com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.snapshot.SnapshotRepository; @@ -53,7 +54,7 @@ public abstract class LocalConfiguration { public String logFile = ""; public String logFormat = LogFormat.DEFAULT_FORMAT; public boolean registerHelp = true; // what is the point of this, it's not even used - public ItemTypes wandItem = ItemTypes.WOODEN_AXE; + public String wandItem = ItemTypes.WOODEN_AXE.getId(); public boolean superPickaxeDrop = true; public boolean superPickaxeManyDrop = true; public boolean noDoubleSlash = false; @@ -61,7 +62,7 @@ public abstract class LocalConfiguration { public boolean useInventoryOverride = false; public boolean useInventoryCreativeOverride = false; public boolean navigationUseGlass = true; - public ItemTypes navigationWand = ItemTypes.COMPASS; + public String navigationWand = ItemTypes.COMPASS.getId(); public int navigationWandMaxDistance = 50; public int scriptTimeout = 3000; public Set allowedDataCycleBlocks = new HashSet<>(); 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 04fe41592..b9dcbe074 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -1030,12 +1030,12 @@ public class LocalSession implements TextureHolder { } public void setTool(BaseItem item, @Nullable Tool tool, Player player) throws InvalidToolBindException { - ItemTypes type = item.getType(); + ItemType type = item.getType(); if (type.hasBlockType() && type.getBlockType().getMaterial().isAir()) { throw new InvalidToolBindException(type, "Blocks can't be used"); - } else if (type == config.wandItem) { + } else if (type.getId().equalsIgnoreCase(config.wandItem)) { throw new InvalidToolBindException(type, "Already used for the wand"); - } else if (type == config.navigationWand) { + } else if (type.getId().equalsIgnoreCase(config.navigationWand)) { throw new InvalidToolBindException(type, "Already used for the navigation wand"); } Tool previous; 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 38d70cfe2..47283f582 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 @@ -69,8 +69,8 @@ public class BaseItem implements NbtValued { * * @return the type */ - public ItemTypes getType() { - return (ItemTypes) this.itemType; + public ItemType getType() { + return this.itemType; } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java deleted file mode 100644 index e76f61aa0..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java +++ /dev/null @@ -1,220 +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.blocks; - -import com.sk89q.worldedit.registry.state.PropertyGroup; -import com.sk89q.worldedit.registry.state.PropertyKey; -import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.block.BlockTypes; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Block types. - * - * {@deprecated Please use {@link com.sk89q.worldedit.world.block.BlockType }} - */ -@Deprecated -public class BlockType { - - public static double centralTopLimit(com.sk89q.worldedit.world.block.BlockType type) { - checkNotNull(type); - return centralTopLimit(type.getDefaultState()); - } - - public static double centralBottomLimit(BlockStateHolder block) { - checkNotNull(block); - BlockTypes type = block.getBlockType(); - switch (type) { - case CREEPER_WALL_HEAD: - case DRAGON_WALL_HEAD: - case PLAYER_WALL_HEAD: - case ZOMBIE_WALL_HEAD: return 0.25; - case ACACIA_SLAB: - case BIRCH_SLAB: - case BRICK_SLAB: - case COBBLESTONE_SLAB: - case DARK_OAK_SLAB: - case DARK_PRISMARINE_SLAB: - case JUNGLE_SLAB: - case NETHER_BRICK_SLAB: - case OAK_SLAB: - case PETRIFIED_OAK_SLAB: - case PRISMARINE_BRICK_SLAB: - case PRISMARINE_SLAB: - case PURPUR_SLAB: - case QUARTZ_SLAB: - case RED_SANDSTONE_SLAB: - case SANDSTONE_SLAB: - case SPRUCE_SLAB: - case STONE_BRICK_SLAB: - case STONE_SLAB: { - String state = (String) block.getState(PropertyKey.TYPE); - if (state == null) return 0; - switch (state) { - case "double": - case "bottom": - return 0; - case "top": - return 0.5; - } - } - case ACACIA_TRAPDOOR: - case BIRCH_TRAPDOOR: - case DARK_OAK_TRAPDOOR: - case IRON_TRAPDOOR: - case JUNGLE_TRAPDOOR: - case OAK_TRAPDOOR: - case SPRUCE_TRAPDOOR: - if (block.getState(PropertyKey.OPEN) == Boolean.TRUE) { - return 1; - } else if ("bottom".equals(block.getState(PropertyKey.HALF))) { - return 0.8125; - } else { - return 0; - } - case ACACIA_FENCE_GATE: - case BIRCH_FENCE_GATE: - case DARK_OAK_FENCE_GATE: - case JUNGLE_FENCE_GATE: - case OAK_FENCE_GATE: - case SPRUCE_FENCE_GATE: return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 1 : 0; - default: - if (type.getMaterial().isMovementBlocker()) return 0; - return 1; - } - } - - /** - * Returns the y offset a player falls to when falling onto the top of a block at xp+0.5/zp+0.5. - * - * @param block the block - * @return the y offset - */ - public static double centralTopLimit(BlockStateHolder block) { - checkNotNull(block); - BlockTypes type = block.getBlockType(); - switch (type) { - case BLACK_BED: - case BLUE_BED: - case BROWN_BED: - case CYAN_BED: - case GRAY_BED: - case GREEN_BED: - case LIGHT_BLUE_BED: - case LIGHT_GRAY_BED: - case LIME_BED: - case MAGENTA_BED: - case ORANGE_BED: - case PINK_BED: - case PURPLE_BED: - case RED_BED: - case WHITE_BED: - case YELLOW_BED: return 0.5625; - case BREWING_STAND: return 0.875; - case CAKE: return (block.getState(PropertyKey.BITES) == (Integer) 6) ? 0 : 0.4375; - case CAULDRON: return 0.3125; - case COCOA: return 0.750; - case ENCHANTING_TABLE: return 0.75; - case END_PORTAL_FRAME: return block.getState(PropertyKey.EYE) == Boolean.TRUE ? 1 : 0.8125; - case CREEPER_HEAD: - case DRAGON_HEAD: - case PISTON_HEAD: - case PLAYER_HEAD: - case ZOMBIE_HEAD: return 0.5; - case CREEPER_WALL_HEAD: - case DRAGON_WALL_HEAD: - case PLAYER_WALL_HEAD: - case ZOMBIE_WALL_HEAD: return 0.75; - case ACACIA_FENCE: - case BIRCH_FENCE: - case DARK_OAK_FENCE: - case JUNGLE_FENCE: - case NETHER_BRICK_FENCE: - case OAK_FENCE: - case SPRUCE_FENCE: return 1.5; - case ACACIA_SLAB: - case BIRCH_SLAB: - case BRICK_SLAB: - case COBBLESTONE_SLAB: - case DARK_OAK_SLAB: - case DARK_PRISMARINE_SLAB: - case JUNGLE_SLAB: - case NETHER_BRICK_SLAB: - case OAK_SLAB: - case PETRIFIED_OAK_SLAB: - case PRISMARINE_BRICK_SLAB: - case PRISMARINE_SLAB: - case PURPUR_SLAB: - case QUARTZ_SLAB: - case RED_SANDSTONE_SLAB: - case SANDSTONE_SLAB: - case SPRUCE_SLAB: - case STONE_BRICK_SLAB: - case STONE_SLAB: { - String state = (String) block.getState(PropertyKey.TYPE); - if (state == null) return 0.5; - switch (state) { - case "bottom": - return 0.5; - case "top": - case "double": - return 1; - } - } - case LILY_PAD: return 0.015625; - case REPEATER: return 0.125; - case SOUL_SAND: return 0.875; - case COBBLESTONE_WALL: - case MOSSY_COBBLESTONE_WALL: return 1.5; - case FLOWER_POT: return 0.375; - case COMPARATOR: return 0.125; - case DAYLIGHT_DETECTOR: return 0.375; - case HOPPER: return 0.625; - case ACACIA_TRAPDOOR: - case BIRCH_TRAPDOOR: - case DARK_OAK_TRAPDOOR: - case IRON_TRAPDOOR: - case JUNGLE_TRAPDOOR: - case OAK_TRAPDOOR: - case SPRUCE_TRAPDOOR: - if (block.getState(PropertyKey.OPEN) == Boolean.TRUE) { - return 0; - } else if ("top".equals(block.getState(PropertyKey.HALF))) { - return 1; - } else { - return 0.1875; - } - case ACACIA_FENCE_GATE: - case BIRCH_FENCE_GATE: - case DARK_OAK_FENCE_GATE: - case JUNGLE_FENCE_GATE: - case OAK_FENCE_GATE: - case SPRUCE_FENCE_GATE: return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 0 : 1.5; - default: - if (type.hasProperty(PropertyKey.LAYERS)) { - return PropertyGroup.LEVEL.get(block) * 0.0625; - } - if (!type.getMaterial().isMovementBlocker()) return 0; - return 1; - - } - } -} 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 143865310..030395cb1 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 @@ -57,6 +57,7 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.SingleBlockTypeMask; @@ -469,7 +470,7 @@ public class BrushCommands extends BrushProcessor { try { - MultiClipboardHolder clipboards = ClipboardFormat.SCHEMATIC.loadAllFromInput(player, clipboard, null, true); + MultiClipboardHolder clipboards = ClipboardFormats.loadAllFromInput(player, clipboard, null, true); if (clipboards == null) { BBC.SCHEMATIC_NOT_FOUND.send(player, clipboard); return null; 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 a11220650..88d81278d 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 @@ -55,7 +55,9 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.extent.PasteEvent; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; import com.sk89q.worldedit.function.block.BlockReplace; import com.sk89q.worldedit.function.mask.Mask; @@ -296,7 +298,7 @@ public class ClipboardCommands extends MethodCommands { @Deprecated @CommandPermissions({"worldedit.clipboard.download"}) public void download(final Player player, final LocalSession session, @Optional("schematic") final String formatName) throws CommandException, WorldEditException { - final ClipboardFormat format = ClipboardFormat.findByAlias(formatName); + final ClipboardFormat format = ClipboardFormats.findByAlias(formatName); if (format == null) { BBC.CLIPBOARD_INVALID_FORMAT.send(player, formatName); return; @@ -356,8 +358,8 @@ public class ClipboardCommands extends MethodCommands { } else { target = clipboard; } - switch (format) { - case PNG: + switch (format.getName()) { + case "PNG": try { FastByteArrayOutputStream baos = new FastByteArrayOutputStream(Short.MAX_VALUE); ClipboardWriter writer = format.getWriter(baos); @@ -369,7 +371,7 @@ public class ClipboardCommands extends MethodCommands { url = null; } break; - case SCHEMATIC: + case "SCHEMATIC": if (Settings.IMP.WEB.URL.isEmpty()) { BBC.SETTING_DISABLE.send(player, "web.url"); return; @@ -380,30 +382,30 @@ public class ClipboardCommands extends MethodCommands { url = null; break; } - } - if (url == null) { - BBC.GENERATING_LINK_FAILED.send(player); - } else { - String urlText = url.toString(); - if (Settings.IMP.WEB.SHORTEN_URLS) { - try { - urlText = MainUtil.getText("https://empcraft.com/s/?" + URLEncoder.encode(url.toString(), "UTF-8")); - } catch (IOException e) { - e.printStackTrace(); - } - } - if (Fawe.imp().getPlatform().equalsIgnoreCase("nukkit")) { - FormBuilder form = Fawe.imp().getFormBuilder(); - FawePlayer fp = FawePlayer.wrap(player); - if (form != null && fp != FakePlayer.getConsole().toFawePlayer()) { - form.setTitle("Download Clipboard"); - form.addInput("url:", urlText, urlText); - form.display(fp); - return; - } - } - BBC.DOWNLOAD_LINK.send(player, urlText); - } + if (url == null) { + BBC.GENERATING_LINK_FAILED.send(player); + } else { + String urlText = url.toString(); + if (Settings.IMP.WEB.SHORTEN_URLS) { + try { + urlText = MainUtil.getText("https://empcraft.com/s/?" + URLEncoder.encode(url.toString(), "UTF-8")); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (Fawe.imp().getPlatform().equalsIgnoreCase("nukkit")) { + FormBuilder form = Fawe.imp().getFormBuilder(); + FawePlayer fp = FawePlayer.wrap(player); + if (form != null && fp != FakePlayer.getConsole().toFawePlayer()) { + form.setTitle("Download Clipboard"); + form.addInput("url:", urlText, urlText); + form.display(fp); + return; + } + } + BBC.DOWNLOAD_LINK.send(player, urlText); + } + } } @Command( @@ -416,7 +418,7 @@ public class ClipboardCommands extends MethodCommands { ) @CommandPermissions({"worldedit.clipboard.asset"}) public void asset(final Player player, final LocalSession session, String category) throws CommandException, WorldEditException { - final ClipboardFormat format = ClipboardFormat.SCHEMATIC; + final ClipboardFormat format = BuiltInClipboardFormat.MCEDIT_SCHEMATIC; ClipboardHolder holder = session.getClipboard(); Clipboard clipboard = holder.getClipboard(); final Transform transform = holder.getTransform(); @@ -430,7 +432,7 @@ public class ClipboardCommands extends MethodCommands { } else { target = clipboard; } - BBC.GENERATING_LINK.send(player, format.name()); + BBC.GENERATING_LINK.send(player, format.getName()); if (Settings.IMP.WEB.ASSETS.isEmpty()) { BBC.SETTING_DISABLE.send(player, "web.assets"); return; @@ -478,7 +480,7 @@ public class ClipboardCommands extends MethodCommands { } Clipboard clipboard = holder.getClipboard(); Region region = clipboard.getRegion(); -BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player); + BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player); checkPaste(player, editSession, to, holder, clipboard); Operation operation = holder .createPaste(editSession) 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 6daf351d0..279eb792a 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 @@ -187,7 +187,7 @@ public class GeneralCommands { int found = 0; - for (ItemType searchType : ItemTypes.values) { + for (ItemType searchType : ItemTypes.values()) { if (found >= 15) { actor.print(BBC.getPrefix() + "Too many results!"); break; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/OptionsCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/OptionsCommands.java index 23b6c8324..238220940 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/OptionsCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/OptionsCommands.java @@ -284,7 +284,7 @@ public class OptionsCommands { int found = 0; - for (ItemType searchType : ItemTypes.values) { + for (ItemType searchType : ItemTypes.values()) { if (found >= 15) { actor.print(BBC.getPrefix() + "Too many results!"); break; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java index 339656187..c21371e6e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java @@ -16,6 +16,7 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.pattern.ClipboardPattern; import com.sk89q.worldedit.function.pattern.Pattern; @@ -191,7 +192,7 @@ public class PatternCommands extends MethodCommands { clipboards = Collections.singletonList(clipboard); break; default: - MultiClipboardHolder multi = ClipboardFormat.SCHEMATIC.loadAllFromInput(player, location, null, true); + MultiClipboardHolder multi = ClipboardFormats.loadAllFromInput(player, location, null, true); clipboards = multi != null ? multi.getHolders() : null; break; } 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 d7686aa8c..404ac187f 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 @@ -45,6 +45,7 @@ import com.sk89q.worldedit.event.extent.PlayerSaveClipboardEvent; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; @@ -99,13 +100,13 @@ public class SchematicCommands extends MethodCommands { @Deprecated @CommandPermissions({"worldedit.clipboard.load", "worldedit.schematic.load", "worldedit.schematic.load.web", "worldedit.schematic.load.asset"}) public void loadall(final Player player, final LocalSession session, @Optional("schematic") final String formatName, final String filename, @Switch('r') boolean randomRotate) throws FilenameException { - final ClipboardFormat format = ClipboardFormat.findByAlias(formatName); + final ClipboardFormat format = ClipboardFormats.findByAlias(formatName); if (format == null) { BBC.CLIPBOARD_INVALID_FORMAT.send(player, formatName); return; } try { - MultiClipboardHolder all = format.loadAllFromInput(player, filename, null, true); + MultiClipboardHolder all = ClipboardFormats.loadAllFromInput(player, filename, null, true); if (all != null) { session.addClipboard(all); BBC.SCHEMATIC_LOADED.send(player, filename); @@ -192,7 +193,7 @@ public class SchematicCommands extends MethodCommands { @CommandPermissions({"worldedit.clipboard.load", "worldedit.schematic.load", "worldedit.schematic.load.asset", "worldedit.schematic.load.web", "worldedit.schematic.load.other"}) public void load(final Player player, final LocalSession session, @Optional() final String formatName, String filename) throws FilenameException { final LocalConfiguration config = this.worldEdit.getConfiguration(); - ClipboardFormat format = formatName == null ? null : ClipboardFormat.findByAlias(formatName); + ClipboardFormat format = formatName == null ? null : ClipboardFormats.findByAlias(formatName); InputStream in = null; try { URI uri; @@ -207,7 +208,7 @@ public class SchematicCommands extends MethodCommands { ReadableByteChannel rbc = Channels.newChannel(url.openStream()); in = Channels.newInputStream(rbc); uri = url.toURI(); - if (format == null) format = ClipboardFormat.SCHEMATIC; + if (format == null) format = BuiltInClipboardFormat.MCEDIT_SCHEMATIC; } else { if (!player.hasPermission("worldedit.schematic.load") && !player.hasPermission("worldedit.clipboard.load")) { BBC.NO_PERM.send(player, "worldedit.clipboard.load"); @@ -235,7 +236,7 @@ public class SchematicCommands extends MethodCommands { } if (format == null && filename.matches(".*\\.[\\w].*")) { String extension = filename.substring(filename.lastIndexOf('.') + 1, filename.length()); - format = ClipboardFormat.findByExtension(extension); + format = ClipboardFormats.findByExtension(extension); } f = MainUtil.resolve(dir, filename, format, false); } @@ -250,7 +251,7 @@ public class SchematicCommands extends MethodCommands { return; } if (format == null) { - format = ClipboardFormat.findByFile(f); + format = ClipboardFormats.findByFile(f); if (format == null) { BBC.CLIPBOARD_INVALID_FORMAT.send(player, f.getName()); return; @@ -281,7 +282,7 @@ public class SchematicCommands extends MethodCommands { @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 { final LocalConfiguration config = this.worldEdit.getConfiguration(); - final ClipboardFormat format = ClipboardFormat.findByAlias(formatName); + final ClipboardFormat format = ClipboardFormats.findByAlias(formatName); if (format == null) { player.printError("Unknown schematic format: " + formatName); return; @@ -298,14 +299,14 @@ public class SchematicCommands extends MethodCommands { filename = filename.substring(3); } } - File f = this.worldEdit.getSafeSaveFile(player, dir, filename, format.getExtension(), format.getExtension()); - if (f.getName().replaceAll("." + format.getExtension(), "").isEmpty()) { + File f = this.worldEdit.getSafeSaveFile(player, dir, filename, format.getPrimaryFileExtension(), format.getPrimaryFileExtension()); + if (f.getName().replaceAll("." + format.getPrimaryFileExtension(), "").isEmpty()) { File directory = f.getParentFile(); if (directory.exists()) { int max = MainUtil.getMaxFileId(directory); - f = new File(directory, max + "." + format.getExtension()); + f = new File(directory, max + "." + format.getPrimaryFileExtension()); } else { - f = new File(directory, "1." + format.getExtension()); + f = new File(directory, "1." + format.getPrimaryFileExtension()); } } final File parent = f.getParentFile(); @@ -477,9 +478,9 @@ public class SchematicCommands extends MethodCommands { Message m = new Message(BBC.SCHEMATIC_FORMAT).newline(); String baseCmd = Commands.getAlias(SchematicCommands.class, "schematic") + " " + Commands.getAlias(SchematicCommands.class, "save"); boolean first = true; - for (final ClipboardFormat format : ClipboardFormat.values) { + for (final ClipboardFormat format : ClipboardFormats.getAll()) { StringBuilder builder = new StringBuilder(); - builder.append(format.name()).append(": "); + builder.append(format.getName()).append(": "); for (final String lookupName : format.getAliases()) { if (!first) { builder.append(", "); @@ -487,7 +488,7 @@ public class SchematicCommands extends MethodCommands { builder.append(lookupName); first = false; } - String cmd = baseCmd + " " + format.name() + " "; + String cmd = baseCmd + " " + format.getName() + " "; m.text(builder).suggestTip(cmd).newline(); first = true; } 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 4b82b5b91..ae620d6e4 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 @@ -37,7 +37,6 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.blocks.BaseItemStack; -import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits; @@ -287,7 +286,7 @@ public class SelectionCommands { ) @CommandPermissions("worldedit.wand") public void wand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { - player.giveItem(new BaseItemStack(we.getConfiguration().wandItem, 1)); + player.giveItem(new BaseItemStack(ItemTypes.parse(we.getConfiguration().wandItem), 1)); BBC.SELECTION_WAND.send(player); if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_SEL_LIST.or(BBC.TIP_SELECT_CONNECTED, BBC.TIP_SET_POS1, BBC.TIP_FARWAND, BBC.TIP_DISCORD).send(player); 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 65c2ff9da..a846dd0f6 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 @@ -67,6 +67,7 @@ import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.CommandManager; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.operation.Operations; @@ -903,7 +904,7 @@ public class UtilityCommands extends MethodCommands { } if (formatName != null) { - final ClipboardFormat cf = ClipboardFormat.findByAlias(formatName); + final ClipboardFormat cf = ClipboardFormats.findByAlias(formatName); forEachFile = new DelegateConsumer(forEachFile) { @Override public void accept(File file) { @@ -1013,7 +1014,7 @@ public class UtilityCommands extends MethodCommands { dir = root; } - ClipboardFormat format = ClipboardFormat.findByFile(file); + ClipboardFormat format = ClipboardFormats.findByFile(file); URI relative = dir.toURI().relativize(file.toURI()); StringBuilder name = new StringBuilder(); if (relative.isAbsolute()) { 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 d1859ba49..2703c195e 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 @@ -132,12 +132,12 @@ public class FloatingTreeRemover implements BlockTool { if (visited.add(next)) { BlockState state = world.getBlock(next); - BlockTypes type = state.getBlockType(); - switch (type) { - case AIR: - case CAVE_AIR: - case VOID_AIR: - case SNOW: + BlockType type = state.getBlockType(); + switch (type.getResource().toUpperCase()) { + case "AIR": + case "CAVE_AIR": + case "VOID_AIR": + case "SNOW": continue; } if (isTreeBlock(state.getBlockType())) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java index d903c2b80..5b9d72397 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java @@ -75,7 +75,7 @@ public interface Player extends Entity, Actor { * * @return the item id of the item the player is holding */ - BlockState getBlockInHand(HandSide handSide) throws WorldEditException; + BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException; /** * Gives the player an item. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java index 94c73dd4c..c4a7c3c94 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java @@ -55,6 +55,7 @@ import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.world.World; 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 com.sk89q.worldedit.world.registry.LegacyMapper; @@ -77,7 +78,7 @@ public class DefaultBlockParser extends InputParser { private static BlockState getBlockInHand(Actor actor, HandSide handSide) throws InputParseException { if (actor instanceof Player) { try { - return ((Player) actor).getBlockInHand(handSide); + return ((Player) actor).getBlockInHand(handSide).toImmutableState(); } catch (NotABlockException e) { throw new InputParseException("You're not holding a block!"); } catch (WorldEditException e) { @@ -179,7 +180,7 @@ public class DefaultBlockParser extends InputParser { } else if (MathMan.isInteger(split[0])) { state = LegacyMapper.getInstance().getBlockFromLegacy(Integer.parseInt(split[0]), Integer.parseInt(split[1])); } else { - BlockTypes type = BlockTypes.get(split[0].toLowerCase()); + BlockType type = BlockTypes.get(split[0].toLowerCase()); if (type != null) { state = LegacyMapper.getInstance().getBlockFromLegacy(type.getLegacyCombinedId() >> 4, Integer.parseInt(split[1])); } @@ -238,7 +239,7 @@ public class DefaultBlockParser extends InputParser { state = item.getType().getBlockType().getDefaultState(); nbt = item.getNbtData(); } else { - BlockTypes type = BlockTypes.parse(typeString.toLowerCase()); + BlockType type = BlockTypes.parse(typeString.toLowerCase()); if (type != null) state = type.getDefaultState(); if (state == null) { throw new NoMatchException("Does not match a valid block type: '" + input + "'"); @@ -261,7 +262,7 @@ public class DefaultBlockParser extends InputParser { } // Check if the item is allowed - BlockTypes blockType = state.getBlockType(); + BlockType blockType = state.getBlockType(); if (context.isRestricted()) { Actor actor = context.requireActor(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultItemParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultItemParser.java index 523ea1898..30022cfe9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultItemParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultItemParser.java @@ -53,7 +53,7 @@ public class DefaultItemParser extends InputParser { if (type != null) { Integer legacy = LegacyMapper.getInstance().getLegacyCombined(type); if (legacy != null) { - ItemTypes newType = LegacyMapper.getInstance().getItemFromLegacy(legacy >> 4, Integer.parseInt(split[1])); + ItemType newType = LegacyMapper.getInstance().getItemFromLegacy(legacy >> 4, Integer.parseInt(split[1])); if (newType != null) type = newType; } } 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 724ec37bd..e29b19fa2 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 @@ -33,8 +33,9 @@ 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.BlockState; -import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockType; +import com.sk89q.worldedit.world.block.BlockTypeUtil; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.gamemode.GameMode; @@ -125,7 +126,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { if (y - 1 != origY) { final BlockVector3 pos = BlockVector3.at(x, y - 2, z); final BlockStateHolder state = world.getBlock(pos); - setPosition(Vector3.at(x + 0.5, y - 2 + BlockType.centralTopLimit(state), z + 0.5)); + 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)); } @@ -147,7 +148,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { final BlockVector3 pos = BlockVector3.at(x, y, z); final BlockState id = world.getBlock(pos); if (id.getBlockType().getMaterial().isMovementBlocker()) { - setPosition(Vector3.at(x + 0.5, y + + BlockType.centralTopLimit(id), z + 0.5)); + setPosition(Vector3.at(x + 0.5, y + + BlockTypeUtil.centralTopLimit(id), z + 0.5)); return; } @@ -182,18 +183,18 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { BlockState state; if (level >= maxY) state = BlockTypes.VOID_AIR.getDefaultState(); else state = world.getBlock(BlockVector3.at(x, level, z)); - BlockTypes type = state.getBlockType(); + BlockType type = state.getBlockType(); BlockMaterial material = type.getMaterial(); if (!material.isFullCube() || !material.isMovementBlocker()) { if (!lastState) { - lastState = BlockType.centralBottomLimit(state) != 1; + lastState = BlockTypeUtil.centralBottomLimit(state) != 1; continue; } if (freeStart == -1) { - freeStart = level + BlockType.centralTopLimit(state); + freeStart = level + BlockTypeUtil.centralTopLimit(state); } else { - double bottomLimit = BlockType.centralBottomLimit(state); + double bottomLimit = BlockTypeUtil.centralBottomLimit(state); double space = level + bottomLimit - freeStart; if (space >= height) { setPosition(Vector3.at(x + 0.5, freeStart, z + 0.5)); @@ -234,18 +235,18 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { BlockState state; if (level >= maxY) state = BlockTypes.VOID_AIR.getDefaultState(); else state = world.getBlock(BlockVector3.at(x, level, z)); - BlockTypes type = state.getBlockType(); + BlockType type = state.getBlockType(); BlockMaterial material = type.getMaterial(); if (!material.isFullCube() || !material.isMovementBlocker()) { if (!lastState) { - lastState = BlockType.centralTopLimit(state) != 0; + lastState = BlockTypeUtil.centralTopLimit(state) != 0; continue; } if (freeEnd == -1) { - freeEnd = level + BlockType.centralBottomLimit(state); + freeEnd = level + BlockTypeUtil.centralBottomLimit(state); } else { - double topLimit = BlockType.centralTopLimit(state); + double topLimit = BlockTypeUtil.centralTopLimit(state); double freeStart = level + topLimit; double space = freeEnd - freeStart; if (space >= height) { @@ -398,7 +399,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { } @Override - public BlockState getBlockInHand(HandSide handSide) throws WorldEditException { + public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException { final ItemType typeId = getItemInHand(handSide).getType(); if (typeId.hasBlockType()) { return typeId.getBlockType().getDefaultState().toBaseBlock(); 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 12c960118..8cdd9394b 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 @@ -319,7 +319,7 @@ public class PlatformManager { } if (event.getType() == Interaction.HIT) { - if (session.isToolControlEnabled() && playerActor.getItemInHand(HandSide.MAIN_HAND).getType().equals(getConfiguration().wandItem)) { + if (session.isToolControlEnabled() && playerActor.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) { FawePlayer fp = FawePlayer.wrap(playerActor); if (!actor.hasPermission("worldedit.selection.pos")) { return; @@ -378,7 +378,7 @@ public class PlatformManager { //>>>>>>> 399e0ad5... Refactor vector system to be cleaner } } else if (event.getType() == Interaction.OPEN) { - if (session.isToolControlEnabled() && playerActor.getItemInHand(HandSide.MAIN_HAND).getType().equals(getConfiguration().wandItem)) { + if (session.isToolControlEnabled() && playerActor.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) { FawePlayer fp = FawePlayer.wrap(playerActor); if (!actor.hasPermission("worldedit.selection.pos")) { return; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java index dd03e6295..c0156f4f8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java @@ -20,7 +20,7 @@ package com.sk89q.worldedit.extension.platform; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -70,7 +70,7 @@ public class PlayerProxy extends AbstractPlayerActor { @Override - public BlockState getBlockInHand(HandSide handSide) throws WorldEditException { + public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException { return basePlayer.getBlockInHand(handSide); } 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 5d14fd526..2f6167d74 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 @@ -81,7 +81,7 @@ public class AbstractDelegateExtent implements LightingExtent { } @Override - public BlockState getFullBlock(BlockVector3 position) { + public BaseBlock getFullBlock(BlockVector3 position) { return extent.getFullBlock(position); } @@ -138,7 +138,7 @@ public class AbstractDelegateExtent implements LightingExtent { } @Override - public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(int x, int y, int z, T block) throws WorldEditException { // mutable.mutX(x); // mutable.mutY(y); // mutable.mutZ(z); @@ -150,7 +150,7 @@ public class AbstractDelegateExtent implements LightingExtent { } @Override - public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(BlockVector3 location, T block) throws WorldEditException { return extent.setBlock(location, block); } 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 f074c8334..cca0e4075 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 @@ -118,19 +118,19 @@ public interface Extent extends InputExtent, OutputExtent { @Override default BlockState getBlock(BlockVector3 position) { - return getFullBlock(position); + return getFullBlock(position).toImmutableState(); } @Override default BlockState getLazyBlock(BlockVector3 position) { - return getFullBlock(position); + return getFullBlock(position).toImmutableState(); } default BlockState getLazyBlock(int x, int y, int z) { return getLazyBlock(BlockVector3.at(x, y, z)); } - default boolean setBlock(int x, int y, int z, BlockStateHolder state) throws WorldEditException { + default > boolean setBlock(int x, int y, int z, T state) throws WorldEditException { return setBlock(BlockVector3.at(x, y, z), state); } 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 c87f03820..34a0994fa 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 @@ -80,7 +80,7 @@ public interface InputExtent { * @param position position of the block * @return the block */ - BlockState getFullBlock(BlockVector3 position); + BaseBlock getFullBlock(BlockVector3 position); /** * Get the biome at the given location. 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 002ed755b..18f7f1675 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 @@ -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, BlockStateHolder block) throws WorldEditException; + > boolean setBlock(BlockVector3 position, T block) throws WorldEditException; /** * Set the biome. 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 5582f478e..6613ef820 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 @@ -234,8 +234,8 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable //>>>>>>> 399e0ad5... Refactor vector system to be cleaner @Override - public BlockState getFullBlock(BlockVector3 position) { - return getLazyBlock(position); + public BaseBlock getFullBlock(BlockVector3 position) { + return getLazyBlock(position).toBaseBlock(); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java index 24ceded83..fc167ac0e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java @@ -19,28 +19,220 @@ package com.sk89q.worldedit.extent.clipboard.io; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Map; +import java.util.Set; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; + +import com.boydti.fawe.object.clipboard.AbstractClipboardFormat; +import com.boydti.fawe.object.io.PGZIPOutputStream; +import com.boydti.fawe.object.io.ResettableFileInputStream; +import com.boydti.fawe.object.schematic.PNGWriter; +import com.boydti.fawe.object.schematic.StructureFormat; +import com.google.common.collect.ImmutableSet; +import com.sk89q.jnbt.CompoundTag; +import com.sk89q.jnbt.NBTConstants; +import com.sk89q.jnbt.NBTInputStream; +import com.sk89q.jnbt.NBTOutputStream; +import com.sk89q.jnbt.NamedTag; +import com.sk89q.jnbt.Tag; + /** * A collection of supported clipboard formats. */ -@Deprecated -public class BuiltInClipboardFormat { - public static final ClipboardFormat MCEDIT_SCHEMATIC = ClipboardFormat.SCHEMATIC; - public static final ClipboardFormat SPONGE_SCHEMATIC = ClipboardFormat.SPONGE_SCHEMATIC; - public static final ClipboardFormat STRUCTURE = ClipboardFormat.STRUCTURE; - public static final ClipboardFormat PNG = ClipboardFormat.PNG; - +public enum BuiltInClipboardFormat implements ClipboardFormat{ + /** + * The Schematic format used by many software. + */ @Deprecated - public static final ClipboardFormat[] values() { - return ClipboardFormat.values; - } - - @Deprecated - public static ClipboardFormat valueOf(String value) { - switch (value) { - case "MCEDIT_SCHEMATIC": - value = "SCHEMATIC"; - break; + MCEDIT_SCHEMATIC("mcedit", "mce", "schematic") { + @Override + public ClipboardReader getReader(InputStream inputStream) throws IOException { + if (inputStream instanceof FileInputStream) { + inputStream = new ResettableFileInputStream((FileInputStream) inputStream); + } + BufferedInputStream buffered = new BufferedInputStream(inputStream); + NBTInputStream nbtStream = new NBTInputStream(new BufferedInputStream(new GZIPInputStream(buffered))); + SchematicReader input = new SchematicReader(nbtStream); + input.setUnderlyingStream(inputStream); + return input; } - return ClipboardFormat.valueOf(value); + + @Override + public ClipboardWriter getWriter(OutputStream outputStream) throws IOException { + throw new UnsupportedOperationException("No longer supported."); + } + + @Override + public boolean isFormat(File file) { + try (NBTInputStream str = new NBTInputStream(new GZIPInputStream(new FileInputStream(file)))) { + NamedTag rootTag = str.readNamedTag(); + if (!rootTag.getName().equals("Schematic")) { + return false; + } + CompoundTag schematicTag = (CompoundTag) rootTag.getTag(); + + // Check + Map schematic = schematicTag.getValue(); + if (!schematic.containsKey("Materials")) { + return false; + } + } catch (Exception e) { + return false; + } + return true; + } + + @Override + public String getPrimaryFileExtension() { + return "schematic"; + } + }, + + @Deprecated + SPONGE_SCHEMATIC("sponge", "schem") { + @Override + public ClipboardReader getReader(InputStream inputStream) throws IOException { + if (inputStream instanceof FileInputStream) { + inputStream = new ResettableFileInputStream((FileInputStream) inputStream); + } + BufferedInputStream buffered = new BufferedInputStream(inputStream); + NBTInputStream nbtStream = new NBTInputStream(new BufferedInputStream(new GZIPInputStream(buffered))); + SpongeSchematicReader input = new SpongeSchematicReader(nbtStream); + return input; + } + + @Override + public ClipboardWriter getWriter(OutputStream outputStream) throws IOException { + OutputStream gzip; + if (outputStream instanceof PGZIPOutputStream || outputStream instanceof GZIPOutputStream) { + gzip = outputStream; + } else { + outputStream = new BufferedOutputStream(outputStream); + PGZIPOutputStream pigz = new PGZIPOutputStream(outputStream); + gzip = pigz; + } + NBTOutputStream nbtStream = new NBTOutputStream(new BufferedOutputStream(gzip)); + return new SpongeSchematicWriter(nbtStream); + } + + @Override + public boolean isFormat(File file) { + try (NBTInputStream str = new NBTInputStream(new GZIPInputStream(new FileInputStream(file)))) { + NamedTag rootTag = str.readNamedTag(); + if (!rootTag.getName().equals("Schematic")) { + return false; + } + CompoundTag schematicTag = (CompoundTag) rootTag.getTag(); + + // Check + Map schematic = schematicTag.getValue(); + if (!schematic.containsKey("Version")) { + return false; + } + } catch (Exception e) { + return false; + } + + return true; + } + + @Override + public String getPrimaryFileExtension() { + return "schem"; + } + }, + + /** + * The structure block format: + * http://minecraft.gamepedia.com/Structure_block_file_format + */ + STRUCTURE("structure", "nbt") { + @Override + public ClipboardReader getReader(InputStream inputStream) throws IOException { + inputStream = new BufferedInputStream(inputStream); + NBTInputStream nbtStream = new NBTInputStream(new BufferedInputStream(new GZIPInputStream(inputStream))); + return new StructureFormat(nbtStream); + } + + @Override + public ClipboardWriter getWriter(OutputStream outputStream) throws IOException { + outputStream = new BufferedOutputStream(outputStream); + OutputStream gzip; + if (outputStream instanceof PGZIPOutputStream || outputStream instanceof GZIPOutputStream) { + gzip = outputStream; + } else { + PGZIPOutputStream pigz = new PGZIPOutputStream(outputStream); + gzip = pigz; + } + NBTOutputStream nbtStream = new NBTOutputStream(new BufferedOutputStream(gzip)); + return new StructureFormat(nbtStream); + } + + @Override + public boolean isFormat(File file) { + return file.getName().endsWith(".nbt"); + } + + @Override + public String getPrimaryFileExtension() { + return "nbt"; + } + }, + + /** + * Isometric PNG writer + */ + PNG("png", "image") { + + @Override + public ClipboardReader getReader(InputStream inputStream) throws IOException { + return null; + } + + @Override + public ClipboardWriter getWriter(OutputStream outputStream) throws IOException { + return new PNGWriter(new BufferedOutputStream(outputStream)); + } + + @Override + public boolean isFormat(File file) { + return file.getName().endsWith(".png"); + } + + @Override + public String getPrimaryFileExtension() { + return "png"; + } + }; + + private final ImmutableSet aliases; + + BuiltInClipboardFormat(String... aliases) { + this.aliases = ImmutableSet.copyOf(aliases); } + + @Override + public String getName() { + return name(); + } + + @Override + public Set getAliases() { + return this.aliases; + } + + @Override + public Set getFileExtensions() { + return ImmutableSet.of(getPrimaryFileExtension()); + } + } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java index 419e28310..4b735c7b5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java @@ -19,275 +19,84 @@ package com.sk89q.worldedit.extent.clipboard.io; -import com.boydti.fawe.config.BBC; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URI; +import java.net.URL; +import java.util.HashMap; +import java.util.Set; + +import static com.google.common.base.Preconditions.checkNotNull; + + import com.boydti.fawe.config.Settings; -import com.boydti.fawe.jnbt.NBTStreamer; import com.boydti.fawe.object.RunnableVal; -import com.boydti.fawe.object.clipboard.*; -import com.boydti.fawe.object.io.FastByteArrayOutputStream; +import com.boydti.fawe.object.clipboard.URIClipboardHolder; import com.boydti.fawe.object.io.PGZIPOutputStream; -import com.boydti.fawe.object.io.ResettableFileInputStream; -import com.boydti.fawe.object.schematic.PNGWriter; import com.boydti.fawe.object.schematic.Schematic; -import com.boydti.fawe.object.schematic.StructureFormat; import com.boydti.fawe.util.MainUtil; -import com.boydti.fawe.util.ReflectionUtils; -import com.google.common.io.ByteSource; -import com.google.common.io.Files; import com.google.gson.Gson; -import com.sk89q.jnbt.*; -import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.entity.Player; -import com.sk89q.worldedit.extension.platform.Actor; -import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.session.ClipboardHolder; -import com.sk89q.worldedit.world.block.BlockTypes; - -import java.io.*; -import java.lang.reflect.Array; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.regex.Pattern; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; -import javax.annotation.Nullable; - - -import static com.google.common.base.Preconditions.checkNotNull; /** * A collection of supported clipboard formats. */ -public enum ClipboardFormat { - - /** - * The Schematic format used by many software. - */ - @Deprecated - SCHEMATIC(new AbstractClipboardFormat("SCHEMATIC", "mcedit", "mce", "schematic") { - @Override - public ClipboardReader getReader(InputStream inputStream) throws IOException { - if (inputStream instanceof FileInputStream) { - inputStream = new ResettableFileInputStream((FileInputStream) inputStream); - } - BufferedInputStream buffered = new BufferedInputStream(inputStream); - NBTInputStream nbtStream = new NBTInputStream(new BufferedInputStream(new GZIPInputStream(buffered))); - SchematicReader input = new SchematicReader(nbtStream); - input.setUnderlyingStream(inputStream); - return input; - } - - @Override - public ClipboardWriter getWriter(OutputStream outputStream) throws IOException { - throw new UnsupportedOperationException("No longer supported."); - } - - @Override - public boolean isFormat(File file) { - if (!file.getName().toLowerCase().endsWith(".schematic")) return false; - DataInputStream str = null; - try { - str = new DataInputStream(new GZIPInputStream(new FileInputStream(file))); - if ((str.readByte() & 0xFF) != NBTConstants.TYPE_COMPOUND) { - return false; - } - byte[] nameBytes = new byte[str.readShort() & 0xFFFF]; - str.readFully(nameBytes); - String name = new String(nameBytes, NBTConstants.CHARSET); - return name.equals("Schematic"); - } catch (IOException e) { - return false; - } finally { - if (str != null) { - try { - str.close(); - } catch (IOException ignored) { - } - } - } - } - - @Override - public String getExtension() { - return "schematic"; - } - }), - - @Deprecated - SPONGE_SCHEMATIC(new AbstractClipboardFormat("SPONGE", "sponge", "schem") { - @Override - public ClipboardReader getReader(InputStream inputStream) throws IOException { - if (inputStream instanceof FileInputStream) { - inputStream = new ResettableFileInputStream((FileInputStream) inputStream); - } - BufferedInputStream buffered = new BufferedInputStream(inputStream); - NBTInputStream nbtStream = new NBTInputStream(new BufferedInputStream(new GZIPInputStream(buffered))); - SpongeSchematicReader input = new SpongeSchematicReader(nbtStream); - return input; - } - - @Override - public ClipboardWriter getWriter(OutputStream outputStream) throws IOException { - OutputStream gzip; - if (outputStream instanceof PGZIPOutputStream || outputStream instanceof GZIPOutputStream) { - gzip = outputStream; - } else { - outputStream = new BufferedOutputStream(outputStream); - PGZIPOutputStream pigz = new PGZIPOutputStream(outputStream); - gzip = pigz; - } - NBTOutputStream nbtStream = new NBTOutputStream(new BufferedOutputStream(gzip)); - return new SpongeSchematicWriter(nbtStream); - } - - @Override - public boolean isFormat(File file) { - if (!file.getName().toLowerCase().endsWith(".schem")) return false; - DataInputStream str = null; - try { - str = new DataInputStream(new GZIPInputStream(new FileInputStream(file))); - if ((str.readByte() & 0xFF) != NBTConstants.TYPE_COMPOUND) { - return false; - } - byte[] nameBytes = new byte[str.readShort() & 0xFFFF]; - str.readFully(nameBytes); - String name = new String(nameBytes, NBTConstants.CHARSET); - return name.equals("Schematic"); - } catch (IOException e) { - return false; - } finally { - if (str != null) { - try { - str.close(); - } catch (IOException ignored) { - } - } - } - } - - @Override - public String getExtension() { - return "schem"; - } - }), - - /** - * The structure block format: - * http://minecraft.gamepedia.com/Structure_block_file_format - */ - STRUCTURE(new AbstractClipboardFormat("STRUCTURE", "structure", "nbt") { - @Override - public ClipboardReader getReader(InputStream inputStream) throws IOException { - inputStream = new BufferedInputStream(inputStream); - NBTInputStream nbtStream = new NBTInputStream(new BufferedInputStream(new GZIPInputStream(inputStream))); - return new StructureFormat(nbtStream); - } - - @Override - public ClipboardWriter getWriter(OutputStream outputStream) throws IOException { - outputStream = new BufferedOutputStream(outputStream); - OutputStream gzip; - if (outputStream instanceof PGZIPOutputStream || outputStream instanceof GZIPOutputStream) { - gzip = outputStream; - } else { - PGZIPOutputStream pigz = new PGZIPOutputStream(outputStream); - gzip = pigz; - } - NBTOutputStream nbtStream = new NBTOutputStream(new BufferedOutputStream(gzip)); - return new StructureFormat(nbtStream); - } - - @Override - public boolean isFormat(File file) { - return file.getName().endsWith(".nbt"); - } - - @Override - public String getExtension() { - return "nbt"; - } - }), - - /** - * Isometric PNG writer - */ - PNG(new AbstractClipboardFormat("PNG", "png", "image") { - - @Override - public ClipboardReader getReader(InputStream inputStream) throws IOException { - return null; - } - - @Override - public ClipboardWriter getWriter(OutputStream outputStream) throws IOException { - return new PNGWriter(new BufferedOutputStream(outputStream)); - } - - @Override - public boolean isFormat(File file) { - return file.getName().endsWith(".png"); - } - - @Override - public String getExtension() { - return "png"; - } - }), - - ; - - public static final ClipboardFormat[] values; - - private static final Map aliasMap; - - static { - aliasMap = new ConcurrentHashMap<>(8, 0.9f, 1); - for (ClipboardFormat emum : ClipboardFormat.values()) { - for (String alias : emum.getAliases()) { - aliasMap.put(alias, emum); - } - } - values = values(); - } - - private IClipboardFormat format; - - ClipboardFormat() { - - } - - ClipboardFormat(IClipboardFormat format) { - this.format = format; - } +public interface ClipboardFormat { /** * Returns the name of this format. * * @return The name of the format */ - public String getName() { - return name(); - } + String getName(); + + /** + * Get a set of aliases. + * + * @return a set of aliases + */ + Set getAliases(); + + /** + * Create a reader. + * + * @param inputStream the input stream + * @return a reader + * @throws IOException thrown on I/O error + */ + ClipboardReader getReader(InputStream inputStream) throws IOException; + + /** + * Create a writer. + * + * @param outputStream the output stream + * @return a writer + * @throws IOException thrown on I/O error + */ + ClipboardWriter getWriter(OutputStream outputStream) throws IOException; + + /** + * Return whether the given file is of this format. + * + * @param file the file + * @return true if the given file is of this format + */ + boolean isFormat(File file); /** * Get the file extension this format primarily uses. * * @return The primary file extension */ - public String getPrimaryFileExtension() { - return getExtension(); - } + String getPrimaryFileExtension(); /** * Get the file extensions this format is commonly known to use. This should @@ -295,12 +104,43 @@ public enum ClipboardFormat { * * @return The file extensions this format might be known by */ - public Set getFileExtensions() { - return Collections.singleton(getPrimaryFileExtension()); + Set getFileExtensions(); + + /** + * Set the player's clipboard + * @param player + * @param uri + * @param in + * @return the held clipboard + * @throws IOException + */ + default ClipboardHolder hold(Player player, URI uri, InputStream in) throws IOException { + checkNotNull(player); + checkNotNull(uri); + checkNotNull(in); + + final ClipboardReader reader = getReader(in); + + final Clipboard clipboard; + + LocalSession session = WorldEdit.getInstance().getSessionManager().get(player); + session.setClipboard(null); + clipboard = reader.read(player.getUniqueId()); + URIClipboardHolder holder = new URIClipboardHolder(uri, clipboard); + session.setClipboard(holder); + return holder; + } + + default Schematic load(File file) throws IOException { + return load(new FileInputStream(file)); } - - public URL uploadPublic(final Clipboard clipboard, String category, String user) { + default Schematic load(InputStream stream) throws IOException { + return new Schematic(getReader(stream).read()); + } + + + default URL uploadPublic(final Clipboard clipboard, String category, String user) { // summary // blocks HashMap map = new HashMap(); @@ -318,158 +158,20 @@ public enum ClipboardFormat { } }); } - - public static MultiClipboardHolder loadAllFromInput(Actor player, String input, ClipboardFormat format, boolean message) throws IOException { - checkNotNull(player); - checkNotNull(input); - WorldEdit worldEdit = WorldEdit.getInstance(); - LocalConfiguration config = worldEdit.getConfiguration(); - if (input.startsWith("url:")) { - if (!player.hasPermission("worldedit.schematic.load.web")) { - if (message) BBC.NO_PERM.send(player, "worldedit.schematic.load.web"); - return null; + + default URL uploadAnonymous(final Clipboard clipboard) { + return MainUtil.upload(null, null, getPrimaryFileExtension(), new RunnableVal() { + @Override + public void run(OutputStream value) { + write(value, clipboard); } - URL base = new URL(Settings.IMP.WEB.URL); - input = new URL(base, "uploads/" + input.substring(4) + ".schematic").toString(); - } - if (input.startsWith("http")) { - if (!player.hasPermission("worldedit.schematic.load.asset")) { - if (message) BBC.NO_PERM.send(player, "worldedit.schematic.load.asset"); - return null; - } - URL url = new URL(input); - URL webInterface = new URL(Settings.IMP.WEB.ASSETS); - if (!url.getHost().equalsIgnoreCase(webInterface.getHost())) { - if (message) BBC.WEB_UNAUTHORIZED.send(player, url); - return null; - } - MultiClipboardHolder clipboards = loadAllFromUrl(url); - return clipboards; - } else { - if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) { - BBC.NO_PERM.send(player, "worldedit.schematic.load.other"); - return null; - } - File working = worldEdit.getWorkingDirectoryFile(config.saveDir); - File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working; - File f; - if (input.startsWith("#")) { - String[] extensions; - if (format != null) { - extensions = format.getFileExtensions().toArray(new String[0]); - } else { - extensions = ClipboardFormats.getFileExtensionArray(); - } - f = player.openFileOpenDialog(extensions); - if (f == null || !f.exists()) { - if (message) player.printError("Schematic " + input + " does not exist! (" + f + ")"); - return null; - } - } else { - if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) { - if (message) BBC.NO_PERM.send(player, "worldedit.schematic.load.other"); - return null; - } - if (format == null && input.matches(".*\\.[\\w].*")) { - String extension = input.substring(input.lastIndexOf('.') + 1, input.length()); - format = ClipboardFormat.findByExtension(extension); - } - f = MainUtil.resolve(dir, input, format, true); - } - if (f == null || !f.exists()) { - if (!input.contains("../")) { - dir = worldEdit.getWorkingDirectoryFile(config.saveDir); - f = MainUtil.resolve(dir, input, format, true); - } - } - if (f == null || !f.exists() || !MainUtil.isInSubDirectory(working, f)) { - if (message) player.printError("Schematic " + input + " does not exist! (" + ((f == null) ? false : f.exists()) + "|" + f + "|" + (f == null ? false : !MainUtil.isInSubDirectory(working, f)) + ")"); - return null; - } - if (format == null && f.isFile()) { - format = ClipboardFormat.findByFile(f); - if (format == null) { - BBC.CLIPBOARD_INVALID_FORMAT.send(player, f.getName()); - return null; - } - } - if (!f.exists()) { - if (message) BBC.SCHEMATIC_NOT_FOUND.send(player, input); - return null; - } - if (!f.isDirectory()) { - ByteSource source = Files.asByteSource(f); - URI uri = f.toURI(); - return new MultiClipboardHolder(uri, new LazyClipboardHolder(f.toURI(), source, format, null)); - } - URIClipboardHolder[] clipboards = loadAllFromDirectory(f); - if (clipboards.length < 1) { - if (message) BBC.SCHEMATIC_NOT_FOUND.send(player, input); - return null; - } - return new MultiClipboardHolder(f.toURI(), clipboards); - } - } - - public static URIClipboardHolder[] loadAllFromDirectory(File dir) { - HashSet extensions = new HashSet<>(Arrays.asList(ClipboardFormats.getFileExtensionArray())); - File[] files = dir.listFiles(pathname -> { - String input = pathname.getName(); - String extension = input.substring(input.lastIndexOf('.') + 1, input.length()); - return (extensions.contains(extension.toLowerCase())); }); - LazyClipboardHolder[] clipboards = new LazyClipboardHolder[files.length]; - for (int i = 0; i < files.length; i++) { - File file = files[i]; - ByteSource source = Files.asByteSource(file); - ClipboardFormat format = ClipboardFormat.findByFile(file); - clipboards[i] = new LazyClipboardHolder(file.toURI(), source, format, null); - } - return clipboards; } - - public static MultiClipboardHolder loadAllFromUrl(URL url) throws IOException { - List clipboards = new ArrayList<>(); - try (ReadableByteChannel rbc = Channels.newChannel(url.openStream())) { - try (InputStream in = Channels.newInputStream(rbc)) { - try (ZipInputStream zip = new ZipInputStream(in)) { - ZipEntry entry; - byte[] buffer = new byte[8192]; - while ((entry = zip.getNextEntry()) != null) { - String filename = entry.getName(); - String extension = filename.substring(filename.lastIndexOf('.') + 1, filename.length()); - ClipboardFormat format = findByExtension(filename); - if (format != null) { - FastByteArrayOutputStream out = new FastByteArrayOutputStream(); - int len = 0; - while ((len = zip.read(buffer)) > 0) { - out.write(buffer, 0, len); - } - byte[] array = out.toByteArray(); - ByteSource source = ByteSource.wrap(array); - LazyClipboardHolder clipboard = new LazyClipboardHolder(url.toURI(), source, format, null); - clipboards.add(clipboard); - } - } - } catch (URISyntaxException e) { - e.printStackTrace(); - } - } - } - LazyClipboardHolder[] arr = clipboards.toArray(new LazyClipboardHolder[clipboards.size()]); - try { - MultiClipboardHolder multi = new MultiClipboardHolder(url.toURI()); - for (LazyClipboardHolder h : arr) multi.add(h); - return multi; - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } - - private void write(OutputStream value, Clipboard clipboard) { + + default void write(OutputStream value, Clipboard clipboard) { try { try (PGZIPOutputStream gzip = new PGZIPOutputStream(value)) { - try (ClipboardWriter writer = format.getWriter(gzip)) { + try (ClipboardWriter writer = getWriter(gzip)) { writer.write(clipboard); } } @@ -477,164 +179,4 @@ public enum ClipboardFormat { e.printStackTrace(); } } - - public URL uploadAnonymous(final Clipboard clipboard) { - return MainUtil.upload(null, null, format.getExtension(), new RunnableVal() { - @Override - public void run(OutputStream value) { - write(value, clipboard); - } - }); - } - - public IClipboardFormat getFormat() { - return format; - } - - /** - * Get a set of aliases. - * - * @return a set of aliases - */ - public Set getAliases() { - return format.getAliases(); - } - - /** - * Create a reader. - * - * @param inputStream the input stream - * @return a reader - * @throws IOException thrown on I/O error - */ - public ClipboardReader getReader(InputStream inputStream) throws IOException { - return format.getReader(inputStream); - } - - /** - * Create a writer. - * - * @param outputStream the output stream - * @return a writer - * @throws IOException thrown on I/O error - */ - public ClipboardWriter getWriter(OutputStream outputStream) throws IOException { - return format.getWriter(outputStream); - } - - /** - * Set the player's clipboard - * @param player - * @param uri - * @param in - * @return the held clipboard - * @throws IOException - */ - public ClipboardHolder hold(Player player, URI uri, InputStream in) throws IOException { - checkNotNull(player); - checkNotNull(uri); - checkNotNull(in); - - final ClipboardReader reader = getReader(in); - - final Clipboard clipboard; - - LocalSession session = WorldEdit.getInstance().getSessionManager().get(player); - session.setClipboard(null); - clipboard = reader.read(player.getUniqueId()); - URIClipboardHolder holder = new URIClipboardHolder(uri, clipboard); - session.setClipboard(holder); - return holder; - } - - public Schematic load(File file) throws IOException { - return load(new FileInputStream(file)); - } - - public Schematic load(InputStream stream) throws IOException { - return new Schematic(this.getReader(stream).read()); - } - - /** - * Get the file extension used - * - * @return file extension string - */ - public String getExtension() { - return format.getExtension(); - } - - /** - * Return whether the given file is of this format. - * - * @param file the file - * @return true if the given file is of this format - */ - public boolean isFormat(File file) { - return format.isFormat(file); - } - - /** - * Find the clipboard format named by the given alias. - * - * @param alias the alias - * @return the format, otherwise null if none is matched - */ - @Nullable - public static ClipboardFormat findByAlias(String alias) { - checkNotNull(alias); - return aliasMap.get(alias.toLowerCase(Locale.ENGLISH).trim()); - } - - @Nullable - public static ClipboardFormat findByExtension(String extension) { - checkNotNull(extension); - extension = extension.toLowerCase(); - for (ClipboardFormat format : values) { - if (format.getFileExtensions().contains(extension)) { - return format; - } - } - return null; - } - - /** - * Detect the format given a file. - * - * @param file the file - * @return the format, otherwise null if one cannot be detected - */ - @Nullable - public static ClipboardFormat findByFile(File file) { - checkNotNull(file); - for (ClipboardFormat format : EnumSet.allOf(ClipboardFormat.class)) { - if (format.isFormat(file)) { - return format; - } - } - - return null; - } - - public static ClipboardFormat addFormat(IClipboardFormat instance) { - ClipboardFormat newEnum = ReflectionUtils.addEnum(ClipboardFormat.class, instance.getName()); - newEnum.format = instance; - for (String alias : newEnum.getAliases()) { - aliasMap.put(alias, newEnum); - } - - ArrayList newValues = new ArrayList<>(Arrays.asList(values)); - newValues.add(newEnum); - ClipboardFormat[] newValuesArray = newValues.toArray(new ClipboardFormat[newValues.size()]); - try { - ReflectionUtils.setFailsafeFieldValue(ClipboardFormat.class.getDeclaredField("values"), null, newValuesArray); - } catch (NoSuchFieldException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - return newEnum; - } - - } \ No newline at end of file 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 cdc0e0461..e2598b3f8 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 @@ -19,17 +19,77 @@ package com.sk89q.worldedit.extent.clipboard.io; +import static com.google.common.base.Preconditions.checkNotNull; + +import com.boydti.fawe.config.BBC; +import com.boydti.fawe.config.Settings; +import com.boydti.fawe.object.clipboard.LazyClipboardHolder; +import com.boydti.fawe.object.clipboard.MultiClipboardHolder; +import com.boydti.fawe.object.clipboard.URIClipboardHolder; +import com.boydti.fawe.object.io.FastByteArrayOutputStream; +import com.boydti.fawe.util.MainUtil; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; +import com.google.common.io.ByteSource; +import com.google.common.io.Files; +import com.sk89q.worldedit.LocalConfiguration; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.platform.Actor; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.regex.Pattern; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; import javax.annotation.Nullable; -import java.io.File; -import java.util.*; - -import static com.google.common.base.Preconditions.checkNotNull; public class ClipboardFormats { + + private static final Map aliasMap = new HashMap<>(); + private static final Multimap fileExtensionMap = HashMultimap.create(); + private static final List registeredFormats = new ArrayList<>(); + + public static void registerClipboardFormat(ClipboardFormat format) { + checkNotNull(format); + + for (String key : format.getAliases()) { + String lowKey = key.toLowerCase(Locale.ENGLISH); + 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()); + } + } + for (String ext : format.getFileExtensions()) { + String lowExt = ext.toLowerCase(Locale.ENGLISH); + fileExtensionMap.put(lowExt, format); + } + registeredFormats.add(format); + } + + static { + for (BuiltInClipboardFormat format : BuiltInClipboardFormat.values()) { + registerClipboardFormat(format); + } + } + /** * Find the clipboard format named by the given alias. * @@ -39,7 +99,8 @@ public class ClipboardFormats { */ @Nullable public static ClipboardFormat findByAlias(String alias) { - return ClipboardFormat.findByAlias(alias); + checkNotNull(alias); + return aliasMap.get(alias.toLowerCase(Locale.ENGLISH).trim()); } /** @@ -53,7 +114,7 @@ public class ClipboardFormats { public static ClipboardFormat findByFile(File file) { checkNotNull(file); - for (ClipboardFormat format : ClipboardFormat.values) { + for (ClipboardFormat format : registeredFormats) { if (format.isFormat(file)) { return format; } @@ -61,22 +122,36 @@ public class ClipboardFormats { return null; } + + /** + * Detect the format using the given extension + * @param string + * the extension + * @return the format, otherwise null if one cannot be detected + */ + @Nullable + public static ClipboardFormat findByExtension(String extension) { + checkNotNull(extension); + + Collection> entries = getFileExtensionMap().entries(); + for(Map.Entry entry : entries) { + if(entry.getKey().equalsIgnoreCase(extension)) { + return entry.getValue(); + } + } + return null; + + } /** * @return a multimap from a file extension to the potential matching formats. */ public static Multimap getFileExtensionMap() { - HashMultimap map = HashMultimap.create(); - for (ClipboardFormat format : ClipboardFormat.values) { - for (String ext : format.getFileExtensions()) { - map.put(ext, format); - } - } - return map; + return Multimaps.unmodifiableMultimap(fileExtensionMap); } public static Collection getAll() { - return Arrays.asList(ClipboardFormat.values); + return Collections.unmodifiableCollection(registeredFormats); } /** @@ -84,13 +159,156 @@ public class ClipboardFormats { * It is not in SchematicCommands because it may rely on internal register calls. */ public static String[] getFileExtensionArray() { - List exts = new ArrayList<>(); - HashMultimap map = HashMultimap.create(); - for (ClipboardFormat format : ClipboardFormat.values) { - exts.addAll(format.getFileExtensions()); - } - return exts.toArray(new String[exts.size()]); + return fileExtensionMap.keySet().toArray(new String[fileExtensionMap.keySet().size()]); } - private ClipboardFormats() {} + private ClipboardFormats() { + } + + public static MultiClipboardHolder loadAllFromInput(Actor player, String input, ClipboardFormat format, boolean message) throws IOException { + checkNotNull(player); + checkNotNull(input); + WorldEdit worldEdit = WorldEdit.getInstance(); + LocalConfiguration config = worldEdit.getConfiguration(); + if (input.startsWith("url:")) { + if (!player.hasPermission("worldedit.schematic.load.web")) { + if (message) BBC.NO_PERM.send(player, "worldedit.schematic.load.web"); + return null; + } + URL base = new URL(Settings.IMP.WEB.URL); + input = new URL(base, "uploads/" + input.substring(4) + ".schematic").toString(); + } + if (input.startsWith("http")) { + if (!player.hasPermission("worldedit.schematic.load.asset")) { + if (message) BBC.NO_PERM.send(player, "worldedit.schematic.load.asset"); + return null; + } + URL url = new URL(input); + URL webInterface = new URL(Settings.IMP.WEB.ASSETS); + if (!url.getHost().equalsIgnoreCase(webInterface.getHost())) { + if (message) BBC.WEB_UNAUTHORIZED.send(player, url); + return null; + } + MultiClipboardHolder clipboards = loadAllFromUrl(url); + return clipboards; + } else { + if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) { + BBC.NO_PERM.send(player, "worldedit.schematic.load.other"); + return null; + } + File working = worldEdit.getWorkingDirectoryFile(config.saveDir); + File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working; + File f; + if (input.startsWith("#")) { + String[] extensions; + if (format != null) { + extensions = format.getFileExtensions().toArray(new String[0]); + } else { + extensions = ClipboardFormats.getFileExtensionArray(); + } + f = player.openFileOpenDialog(extensions); + if (f == null || !f.exists()) { + if (message) player.printError("Schematic " + input + " does not exist! (" + f + ")"); + return null; + } + } else { + if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) { + if (message) BBC.NO_PERM.send(player, "worldedit.schematic.load.other"); + return null; + } + if (format == null && input.matches(".*\\.[\\w].*")) { + String extension = input.substring(input.lastIndexOf('.') + 1, input.length()); + format = findByExtension(extension); + } + f = MainUtil.resolve(dir, input, format, true); + } + if (f == null || !f.exists()) { + if (!input.contains("../")) { + dir = worldEdit.getWorkingDirectoryFile(config.saveDir); + f = MainUtil.resolve(dir, input, format, true); + } + } + if (f == null || !f.exists() || !MainUtil.isInSubDirectory(working, f)) { + if (message) player.printError("Schematic " + input + " does not exist! (" + ((f == null) ? false : f.exists()) + "|" + f + "|" + (f == null ? false : !MainUtil.isInSubDirectory(working, f)) + ")"); + return null; + } + if (format == null && f.isFile()) { + format = findByFile(f); + if (format == null) { + BBC.CLIPBOARD_INVALID_FORMAT.send(player, f.getName()); + return null; + } + } + if (!f.exists()) { + if (message) BBC.SCHEMATIC_NOT_FOUND.send(player, input); + return null; + } + if (!f.isDirectory()) { + ByteSource source = Files.asByteSource(f); + URI uri = f.toURI(); + return new MultiClipboardHolder(uri, new LazyClipboardHolder(f.toURI(), source, format, null)); + } + URIClipboardHolder[] clipboards = loadAllFromDirectory(f); + if (clipboards.length < 1) { + if (message) BBC.SCHEMATIC_NOT_FOUND.send(player, input); + return null; + } + return new MultiClipboardHolder(f.toURI(), clipboards); + } + } + + public static URIClipboardHolder[] loadAllFromDirectory(File dir) { + HashSet extensions = new HashSet<>(Arrays.asList(ClipboardFormats.getFileExtensionArray())); + File[] files = dir.listFiles(pathname -> { + String input = pathname.getName(); + String extension = input.substring(input.lastIndexOf('.') + 1, input.length()); + return (extensions.contains(extension.toLowerCase())); + }); + LazyClipboardHolder[] clipboards = new LazyClipboardHolder[files.length]; + for (int i = 0; i < files.length; i++) { + File file = files[i]; + ByteSource source = Files.asByteSource(file); + ClipboardFormat format = findByFile(file); + clipboards[i] = new LazyClipboardHolder(file.toURI(), source, format, null); + } + return clipboards; + } + + public static MultiClipboardHolder loadAllFromUrl(URL url) throws IOException { + List clipboards = new ArrayList<>(); + try (ReadableByteChannel rbc = Channels.newChannel(url.openStream())) { + try (InputStream in = Channels.newInputStream(rbc)) { + try (ZipInputStream zip = new ZipInputStream(in)) { + ZipEntry entry; + byte[] buffer = new byte[8192]; + while ((entry = zip.getNextEntry()) != null) { + String filename = entry.getName(); + String extension = filename.substring(filename.lastIndexOf('.') + 1, filename.length()); + ClipboardFormat format = findByExtension(filename); + if (format != null) { + FastByteArrayOutputStream out = new FastByteArrayOutputStream(); + int len = 0; + while ((len = zip.read(buffer)) > 0) { + out.write(buffer, 0, len); + } + byte[] array = out.toByteArray(); + ByteSource source = ByteSource.wrap(array); + LazyClipboardHolder clipboard = new LazyClipboardHolder(url.toURI(), source, format, null); + clipboards.add(clipboard); + } + } + } catch (URISyntaxException e) { + e.printStackTrace(); + } + } + } + LazyClipboardHolder[] arr = clipboards.toArray(new LazyClipboardHolder[clipboards.size()]); + try { + MultiClipboardHolder multi = new MultiClipboardHolder(url.toURI()); + for (LazyClipboardHolder h : arr) multi.add(h); + return multi; + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } } \ 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 fc96ff461..bc6887475 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 @@ -1,335 +1,330 @@ +/* + * 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.transform; +import static com.google.common.base.Preconditions.checkNotNull; + import com.boydti.fawe.object.extent.ResettableExtent; import com.boydti.fawe.util.ReflectionUtils; +import com.google.common.collect.Sets; import com.sk89q.jnbt.ByteTag; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.WorldEditException; - -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.internal.helper.MCDirections; -import com.sk89q.worldedit.math.transform.AffineTransform; -import com.sk89q.worldedit.math.transform.Transform; -import com.sk89q.worldedit.registry.state.AbstractProperty; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.collect.Sets; -import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; +import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.registry.state.BooleanProperty; import com.sk89q.worldedit.registry.state.DirectionalProperty; +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.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.block.BlockTypes; -import javax.annotation.Nullable; -import java.util.Arrays; -import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.OptionalInt; import java.util.Set; +import java.util.stream.Collectors; + +import javax.annotation.Nullable; /** * Transforms blocks themselves (but not their position) according to a * given transform. */ public class BlockTransformExtent extends ResettableExtent { - private Transform transform; - private Transform transformInverse; - private int[] BLOCK_ROTATION_BITMASK; - private int[][] BLOCK_TRANSFORM; - private int[][] BLOCK_TRANSFORM_INVERSE; - private int[] ALL = new int[0]; + private Transform transform; + + public BlockTransformExtent(Extent parent) { this(parent, new AffineTransform()); } - public BlockTransformExtent(Extent parent, Transform transform) { - super(parent); + /** + * Create a new instance. + * + * @param extent the extent + */ + public BlockTransformExtent(Extent extent, Transform transform) { + super(extent); + checkNotNull(transform); this.transform = transform; - this.transformInverse = this.transform.inverse(); - cache(); } - private List getDirections(AbstractProperty property) { - if (property instanceof DirectionalProperty) { - DirectionalProperty directional = (DirectionalProperty) property; - directional.getValues(); - } else { - switch (property.getKey()) { - case HALF: - - case ROTATION: - - case AXIS: - - case FACING: - - case SHAPE: - - case NORTH: - case EAST: - case SOUTH: - case WEST: - } - } - return null; + /** + * Get the transform. + * + * @return the transform + */ + public Transform getTransform() { + return transform; + } + + /** + * Set the transform + * @param affine + */ + public void setTransform(Transform affine) { + this.transform = affine; } -// @Override -// public BlockState getBlock(BlockVector3 position) { -// return transformBlock(super.getBlock(position), false); -// } -// -// @Override -// public BaseBlock getFullBlock(BlockVector3 position) { -// return transformBlock(super.getFullBlock(position), false); -// } - -// @Override -// public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { -// return super.setBlock(location, transformBlock(block, true)); -// } -// /** -// * Transform the given block using the given transform. -// * -// *

The provided block is modified.

-// * -// * @param block the block -// * @param transform the transform -// * @return the same block -// */ -// public static T transform(T block, Transform transform) { -// return transform(block, transform, block); -// } + /** + * Transform a block without making a copy. + * + * @param block the block + * @param reverse true to transform in the opposite direction + * @return the same block + */ + private > T transformBlock(T block, boolean reverse) { + return transform(block, reverse ? transform.inverse() : transform); + } + + @Override + public BlockState getLazyBlock(BlockVector3 position) { + return transformFast(super.getLazyBlock(position)).toImmutableState(); + } + + @Override + public BlockState getLazyBlock(int x, int y, int z) { + return transformFast(super.getLazyBlock(x, y, z)).toImmutableState(); + } + + @Override + public BlockState getBlock(BlockVector3 position) { + return transformFast(super.getBlock(position)).toImmutableState(); + } + + @Override + public BaseBlock getFullBlock(BlockVector3 position) { + return transformFast(super.getFullBlock(position).toImmutableState()); + } + + @Override + public > boolean setBlock(int x, int y, int z, B block) throws WorldEditException { + return super.setBlock(x, y, z, transformFastInverse((BlockState)block)); + } + + @Override + public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { + return super.setBlock(location, transformFastInverse((BlockState)block)); + } private static final Set directionNames = Sets.newHashSet("north", "south", "east", "west"); -// /** -// * Transform the given block using the given transform. -// * -// * @param block the block -// * @param transform the transform -// * @param changedBlock the block to change -// * @return the changed block -// */ -// private static T transform(T block, Transform transform, T changedBlock) { -// checkNotNull(block); -// checkNotNull(transform); -// -// List properties = block.getBlockType().getProperties(); -// -// for (Property property : properties) { -// if (property instanceof DirectionalProperty) { -// Direction value = (Direction) block.getState(property); -// if (value != null) { -// Vector3 newValue = getNewStateValue((DirectionalProperty) property, transform, value.toVector()); -// if (newValue != null) { -// changedBlock = (T) changedBlock.with(property, Direction.findClosest(newValue, Direction.Flag.ALL)); -// } -// } -// } -// } + /** + * Transform the given block using the given transform. + * + *

The provided block is not modified.

+ * + * @param block the block + * @param transform the transform + * @return the same block + */ + public static > B transform(B block, Transform transform) { + checkNotNull(block); + checkNotNull(transform); + B result = block; + List> properties = block.getBlockType().getProperties(); + for (Property property : properties) { + if (property instanceof DirectionalProperty) { + DirectionalProperty dirProp = (DirectionalProperty) property; + Direction value = (Direction) block.getState(property); + if (value != null) { + Vector3 newValue = getNewStateValue(dirProp.getValues(), transform, value.toVector()); + if (newValue != null) { + result = result.with(dirProp, Direction.findClosest(newValue, Direction.Flag.ALL)); + } + } + } else if (property instanceof EnumProperty) { + EnumProperty enumProp = (EnumProperty) property; + if (property.getName().equals("axis")) { + // We have an axis - this is something we can do the rotations to :sunglasses: + Direction value = null; + switch ((String) block.getState(property)) { + case "x": + value = Direction.EAST; + break; + case "y": + value = Direction.UP; + break; + case "z": + value = Direction.NORTH; + break; + } + if (value != null) { + Vector3 newValue = getNewStateValue(Direction.valuesOf(Direction.Flag.UPRIGHT | Direction.Flag.CARDINAL), transform, value.toVector()); + if (newValue != null) { + String axis = null; + Direction newDir = Direction.findClosest(newValue, Direction.Flag.UPRIGHT | Direction.Flag.CARDINAL); + if (newDir == Direction.NORTH || newDir == Direction.SOUTH) { + axis = "z"; + } else if (newDir == Direction.EAST || newDir == Direction.WEST) { + axis = "x"; + } else if (newDir == Direction.UP || newDir == Direction.DOWN) { + axis = "y"; + } + if (axis != null) { + result = result.with(enumProp, axis); + } + } + } + } + } else if (property instanceof IntegerProperty) { + IntegerProperty intProp = (IntegerProperty) property; + if (property.getName().equals("rotation")) { + if (intProp.getValues().size() == 16) { + Optional direction = Direction.fromRotationIndex(block.getState(intProp)); + int horizontalFlags = Direction.Flag.CARDINAL | Direction.Flag.ORDINAL | Direction.Flag.SECONDARY_ORDINAL; + if (direction.isPresent()) { + Vector3 vec = getNewStateValue(Direction.valuesOf(horizontalFlags), transform, direction.get().toVector()); + if (vec != null) { + OptionalInt newRotation = Direction.findClosest(vec, horizontalFlags).toRotationIndex(); + if (newRotation.isPresent()) { + result = result.with(intProp, newRotation.getAsInt()); + } + } + } + } + } + } + } + List directionalProperties = properties.stream() + .filter(prop -> prop instanceof BooleanProperty) + .filter(prop -> directionNames.contains(prop.getName())) + .filter(property -> (Boolean) block.getState(property)) + .map(Property::getName) + .map(String::toUpperCase) + .map(Direction::valueOf) + .map(dir -> Direction.findClosest(transform.apply(dir.toVector()), Direction.Flag.CARDINAL)) + .filter(Objects::nonNull) + .map(Direction::name) + .map(String::toLowerCase) + .collect(Collectors.toList()); + if (directionalProperties.size() > 0) { + for (String directionName : directionNames) { + result = result.with(block.getBlockType().getProperty(directionName), directionalProperties.contains(directionName)); + } + } + return result; + } + + public final BaseBlock transformFast(BlockState block) { + BaseBlock transformed = transformBlock(block, false).toBaseBlock(); + if (block.hasNbtData()) { + CompoundTag tag = block.getNbtData(); + if (tag.containsKey("Rot")) { + int rot = tag.asInt("Rot"); + + Direction direction = Direction.fromRotationIndex(rot).get(); + + if (direction != null) { + Vector3 applyAbsolute = transform.apply(direction.toVector()); + Vector3 applyOrigin = transform.apply(Vector3.ZERO); + Vector3 newAbsolute = Vector3.at(applyAbsolute.getX() - applyOrigin.getX(), applyAbsolute.getY() - applyOrigin.getY(), applyAbsolute.getZ() - applyOrigin.getZ()); + + Direction newDirection = Direction.findClosest(newAbsolute, Direction.Flag.CARDINAL | Direction.Flag.ORDINAL | Direction.Flag.SECONDARY_ORDINAL); + + if (newDirection != null) { + Map values = ReflectionUtils.getMap(tag.getValue()); + values.put("Rot", new ByteTag((byte) newDirection.toRotationIndex().getAsInt())); + } + } + transformed.setNbtData(tag); + } + } + return transformed; + } + + public final BaseBlock transformFastInverse(BlockState block) { + BaseBlock transformed = transformBlock(block, true).toBaseBlock(); + if (block.hasNbtData()) { + CompoundTag tag = block.getNbtData(); + if (tag.containsKey("Rot")) { + int rot = tag.asInt("Rot"); + + Direction direction = Direction.fromRotationIndex(rot).get(); + + if (direction != null) { + Vector3 applyAbsolute = getTransform().inverse().apply(direction.toVector()); + Vector3 applyOrigin = getTransform().inverse().apply(Vector3.ZERO); + + Vector3 newAbsolute = Vector3.at(applyAbsolute.getX() - applyOrigin.getX(), applyAbsolute.getY() - applyOrigin.getY(), applyAbsolute.getZ() - applyOrigin.getZ()); + + Direction newDirection = Direction.findClosest(newAbsolute, Direction.Flag.CARDINAL | Direction.Flag.ORDINAL | Direction.Flag.SECONDARY_ORDINAL); + + if (newDirection != null) { + Map values = ReflectionUtils.getMap(tag.getValue()); + values.put("Rot", new ByteTag((byte) newDirection.toRotationIndex().getAsInt())); + } + } + } + transformed.setNbtData(tag); + } + return transformed; + } + + /** + * Get the new value with the transformed direction. + * + * @param allowedStates the allowed states + * @param transform the transform + * @param oldDirection the old direction to transform + * @return a new state or null if none could be found + */ @Nullable -//<<<<<<< HEAD - private static Integer getNewStateIndex(Transform transform, List directions, int oldIndex) { - Direction oldDirection = directions.get(oldIndex); - Vector3 oldVector = oldDirection.toVector(); - Vector3 newVector = transform.apply(oldVector).subtract(transform.apply(Vector3.ZERO)).normalize(); - int newIndex = oldIndex; - double closest = oldVector.normalize().dot(newVector); -//======= -// private static Vector3 getNewStateValue(DirectionalProperty state, Transform transform, Vector3 oldDirection) { -// Vector3 newDirection = transform.apply(oldDirection).subtract(transform.apply(Vector3.ZERO)).normalize(); -// Vector3 newValue = null; -// double closest = -2; -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner + private static Vector3 getNewStateValue(List allowedStates, Transform transform, Vector3 oldDirection) { + Vector3 newDirection = transform.apply(oldDirection).subtract(transform.apply(Vector3.ZERO)).normalize(); + Vector3 newValue = null; + double closest = -2; boolean found = false; - for (int i = 0; i < directions.size(); i++) { - Direction v = directions.get(i); - double dot = v.toVector().normalize().dot(newVector); - if (dot > closest) { + for (Direction v : allowedStates) { + double dot = v.toVector().normalize().dot(newDirection); + if (dot >= closest) { closest = dot; - newIndex = i; + newValue = v.toVector(); found = true; } } if (found) { - return newIndex; + return newValue; } else { return null; } } - private void cache() { - BLOCK_ROTATION_BITMASK = new int[BlockTypes.size()]; - BLOCK_TRANSFORM = new int[BlockTypes.size()][]; - BLOCK_TRANSFORM_INVERSE = new int[BlockTypes.size()][]; - outer: - for (int i = 0; i < BLOCK_TRANSFORM.length; i++) { - BLOCK_TRANSFORM[i] = ALL; - BLOCK_TRANSFORM_INVERSE[i] = ALL; - BlockTypes type = BlockTypes.get(i); - int bitMask = 0; - for (AbstractProperty property : (Collection) type.getProperties()) { - Collection directions = getDirections(property); - if (directions != null) { - BLOCK_TRANSFORM[i] = null; - BLOCK_TRANSFORM_INVERSE[i] = null; - bitMask |= property.getBitMask(); - } - } - if (bitMask != 0) { - BLOCK_ROTATION_BITMASK[i] = bitMask; - } - } - } - - @Override - public ResettableExtent setExtent(Extent extent) { - return super.setExtent(extent); - } - - public Transform getTransform() { - return transform; - } - - public void setTransform(Transform affine) { - this.transform = affine; - this.transformInverse = this.transform.inverse(); - cache(); - } - - private final BlockState transform(BlockState state, int[][] transformArray, Transform transform) { - int typeId = state.getInternalBlockTypeId(); - int[] arr = transformArray[typeId]; - if (arr == ALL) return state; - if (arr == null) { - arr = transformArray[typeId] = new int[state.getBlockType().getMaxStateId() + 1]; - Arrays.fill(arr, -1); - } - int mask = BLOCK_ROTATION_BITMASK[typeId]; - int internalId = state.getInternalId(); - - int maskedId = internalId & mask; - int newMaskedId = arr[maskedId]; - if (newMaskedId != -1) { - return BlockState.getFromInternalId(newMaskedId | (internalId & (~mask))); - } - newMaskedId = state.getInternalId(); - - BlockTypes type = state.getBlockType(); - for (AbstractProperty property : (Collection) type.getProperties()) { - List directions = getDirections(property); - if (directions != null) { - Integer newIndex = getNewStateIndex(transform, directions, property.getIndex(state.getInternalId())); - if (newIndex != null) { - newMaskedId = property.modifyIndex(newMaskedId, newIndex); - } - } - } - arr[maskedId] = newMaskedId & mask; - return BlockState.getFromInternalId(newMaskedId); - } - - public final BlockState transformFast(BlockState block) { - BlockState transformed = transform(block, BLOCK_TRANSFORM, transform); - if (block.hasNbtData()) { - CompoundTag tag = block.getNbtData(); - if (tag.containsKey("Rot")) { - int rot = tag.asInt("Rot"); - - Direction direction = MCDirections.fromRotation(rot); - - if (direction != null) { - Vector3 applyAbsolute = transform.apply(direction.toVector()); - Vector3 applyOrigin = transform.apply(Vector3.ZERO); - - Direction newDirection = Direction.findClosest(applyAbsolute.subtract(applyOrigin), Direction.Flag.CARDINAL | Direction.Flag.ORDINAL | Direction.Flag.SECONDARY_ORDINAL); - - if (newDirection != null) { - Map values = ReflectionUtils.getMap(tag.getValue()); - values.put("Rot", new ByteTag((byte) MCDirections.toRotation(newDirection))); - } - } - transformed = new BaseBlock(transformed, tag); - } - } - return transformed; - } - - public final BlockState transformFastInverse(BlockState block) { - BlockState transformed = transform(block, BLOCK_TRANSFORM_INVERSE, transformInverse); - if (block.hasNbtData()) { - CompoundTag tag = block.getNbtData(); - if (tag.containsKey("Rot")) { - int rot = tag.asInt("Rot"); - - Direction direction = MCDirections.fromRotation(rot); - - if (direction != null) { - Vector3 applyAbsolute = transformInverse.apply(direction.toVector()); - Vector3 applyOrigin = transformInverse.apply(Vector3.ZERO); - - Direction newDirection = Direction.findClosest(applyAbsolute.subtract(applyOrigin), Direction.Flag.CARDINAL | Direction.Flag.ORDINAL | Direction.Flag.SECONDARY_ORDINAL); - - if (newDirection != null) { - Map values = ReflectionUtils.getMap(tag.getValue()); - values.put("Rot", new ByteTag((byte) MCDirections.toRotation(newDirection))); - } - } - } - transformed = new BaseBlock(transformed, tag); - } - return transformed; - } - - @Override - public BlockState getLazyBlock(int x, int y, int z) { - return transformFast(super.getLazyBlock(x, y, z)); - } - - @Override - public BlockState getLazyBlock(BlockVector3 position) { - return transformFast(super.getLazyBlock(position)); - } - - @Override - public BlockState getBlock(BlockVector3 position) { - return transformFast(super.getBlock(position)); - } - - @Override - public BaseBiome getBiome(BlockVector2 position) { - return super.getBiome(position); - } - - @Override - public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException { - return super.setBlock(x, y, z, transformFastInverse((BlockState) block)); - } - - - @Override - public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { - return super.setBlock(location, transformFastInverse((BlockState) block)); - } - - } \ No newline at end of file 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 039c4ffbd..bcd424e9d 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 @@ -62,7 +62,7 @@ public class BlockMask extends AbstractExtentMask { for (int i = 0; i < bitSets.length; i++) { if (bitSets[i] != null) { long[] set = bitSets[i]; - BlockTypes type = BlockTypes.get(i); + BlockType type = BlockTypes.get(i); if (set == ALL) { strings.add(type.getId()); } else { @@ -137,7 +137,7 @@ public class BlockMask extends AbstractExtentMask { boolean single = true; int and = type.getInternalId(); List properties = type.getProperties(); - for (AbstractProperty prop : (List) type.getProperties()) { + for (AbstractProperty prop : (List>) type.getProperties()) { List values = prop.getValues(); int numSet = 0; for (int i = 0; i < values.size(); i++) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java index cc4bf7b19..7c3d86caf 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java @@ -90,15 +90,15 @@ public class BlockMaskBuilder { charSequence.setString(input); charSequence.setSubstring(0, propStart); - BlockTypes type = null; - List blockTypeList = null; + BlockType type = null; + List blockTypeList = null; if (StringMan.isAlphanumericUnd(charSequence)) { type = BlockTypes.parse(charSequence.toString()); add(type); } else { String regex = charSequence.toString(); blockTypeList = new ArrayList<>(); - for (BlockTypes myType : BlockTypes.values) { + for (BlockType myType : BlockTypes.values) { if (myType.getId().matches(regex)) { blockTypeList.add(myType); add(myType); @@ -135,14 +135,14 @@ public class BlockMaskBuilder { filtered = filterRegexOrOperator(type, key, operator, charSequence); } else { - for (BlockTypes myType : blockTypeList) { + for (BlockType myType : blockTypeList) { filtered |= filterRegexOrOperator(myType, key, operator, charSequence); } } if (!filtered) { String value = charSequence.toString(); final PropertyKey fKey = key; - Collection types = type != null ? Collections.singleton(type) : blockTypeList; + Collection types = type != null ? Collections.singleton(type) : blockTypeList; throw new SuggestInputParseException("No value for " + input, input, () -> { HashSet values = new HashSet<>(); types.forEach(t -> { @@ -206,7 +206,7 @@ public class BlockMaskBuilder { if (StringMan.isAlphanumericUnd(input)) { add(BlockTypes.parse(input)); } else { - for (BlockTypes myType : BlockTypes.values) { + for (BlockType myType : BlockTypes.values) { if (myType.getId().matches(input)) { add(myType); } @@ -225,7 +225,7 @@ public class BlockMaskBuilder { return (states == BlockMask.ALL || FastBitSet.get(states, localI)); } - private void suggest(String input, String property, Collection finalTypes) throws InputParseException { + private void suggest(String input, String property, Collection finalTypes) throws InputParseException { throw new SuggestInputParseException(input + " does not have: " + property, input, () -> { Set keys = new HashSet<>(); finalTypes.forEach(t -> t.getProperties().stream().forEach(p -> keys.add(p.getKey()))); @@ -346,7 +346,7 @@ public class BlockMaskBuilder { bitSets[i] = null; continue; } - List properties = (List) type.getProperties(); + List> properties = (List>) type.getProperties(); for (AbstractProperty prop : properties) { List values = prop.getValues(); for (int j = 0; j < values.size(); j++) { @@ -425,7 +425,7 @@ public class BlockMaskBuilder { if (!typePredicate.test(type)) { continue; } - for (AbstractProperty prop : (List) type.getProperties()) { + for (AbstractProperty prop : (List>) type.getProperties()) { List values = prop.getValues(); for (int j = 0; j < values.size(); j++) { int localI = j << prop.getBitOffset() >> BlockTypes.BIT_OFFSET; @@ -533,7 +533,7 @@ public class BlockMaskBuilder { } int set = 0; int clear = 0; - for (AbstractProperty prop : (List) type.getProperties()) { + for (AbstractProperty prop : (List>) type.getProperties()) { List values = prop.getValues(); for (int j = 0; j < values.size(); j++) { int localI = j << prop.getBitOffset() >> BlockTypes.BIT_OFFSET; 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 951f85741..8ba70fc5d 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 @@ -4,7 +4,7 @@ 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; -import com.sk89q.worldedit.blocks.BlockType; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.world.block.BlockTypes; @@ -14,7 +14,7 @@ public class SolidBlockMask extends BlockTypeMask { public static boolean[] getTypes() { boolean[] types = new boolean[BlockTypes.size()]; - for (BlockTypes type : BlockTypes.values) { + for (BlockType type : BlockTypes.values) { types[type.getInternalId()] = type.getMaterial().isSolid(); } return types; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java index 999ad1ef3..68549980a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java @@ -90,13 +90,8 @@ public class ForwardExtentCopy implements Operation { * @param source the source extent * @param region the region to copy * @param destination the destination extent -<<<<<<< HEAD - * @param to the destination position - * @see #ForwardExtentCopy(Extent, Region, Vector, Extent, Vector) the main constructor -======= * @param to the destination position * @see #ForwardExtentCopy(Extent, Region, BlockVector3, Extent, BlockVector3) the main constructor ->>>>>>> 399e0ad5... Refactor vector system to be cleaner */ public ForwardExtentCopy(Extent source, Region region, Extent destination, BlockVector3 to) { this(source, region, region.getMinimumPoint(), destination, to); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java index bfc82f5c6..143d12fc0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java @@ -131,6 +131,7 @@ public class PasteBuilder { if (ignoreAirBlocks) { copy.setSourceMask(new ExistingBlockMask(clipboard)); } + System.out.println("PasteBuilder info: extent: " + extent.toString() + "; copy: " + copy + "; transform: " + transform); return copy; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java index 47d6ae1c0..4363b3c4b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java @@ -22,8 +22,13 @@ package com.sk89q.worldedit.util; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; -import javax.annotation.Nullable; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; +import java.util.Optional; +import java.util.OptionalInt; + +import javax.annotation.Nullable; /** * A collection of cardinal, ordinal, and secondary-ordinal directions. @@ -55,12 +60,9 @@ public enum Direction { private final Vector3 direction; private final BlockVector3 blockVector; private final int flags, left, right; - - + private static HashMap map = new HashMap<>(); - public static final Direction[] values = values(); - public static final Direction[] cardinal = new Direction[]{ NORTH, EAST, SOUTH, WEST }; - + static { for (Direction dir : Direction.values()) { map.put(dir.name(), dir); @@ -68,24 +70,24 @@ public enum Direction { } } - private Direction(Vector3 vector, int flags, int left, int right) { + Direction(Vector3 vector, int flags, int left, int right) { this.direction = vector.normalize(); this.blockVector = BlockVector3.at(Math.signum(vector.getX()), Math.signum(vector.getY()), Math.signum(vector.getZ())); this.flags = flags; this.left = left; this.right = right; } - + public static Direction get(CharSequence sequence) { return map.get(sequence); } - + public Direction getLeft() { - return left != -1 ? values[left] : null; + return left != -1 ? values()[left] : null; } public Direction getRight() { - return right != -1 ? values[right] : null; + return right != -1 ? values()[right] : null; } public double getX() { @@ -163,11 +165,6 @@ public enum Direction { return direction; } - @Override - public String toString() { - return name().toLowerCase(); - } - /** * Get the vector. * @@ -208,6 +205,110 @@ public enum Direction { return closest; } + /** + * Gets all directions with the given flags. + * + * @param flags The flags + * @return The directions that fit the flags + */ + public static List valuesOf(int flags) { + List directions = new ArrayList<>(); + for (Direction direction : values()) { + if ((~flags & direction.flags) == 0) { + directions.add(direction); + } + } + + return directions; + } + + /** + * Converts a rotation index into a Direction. + * + *

+ * Rotation indexes are used in BlockStates, such as sign posts. + *

+ * + * @param rotation The rotation index + * @return The direction, if applicable + */ + public static Optional fromRotationIndex(int rotation) { + switch (rotation) { + case 0: + return Optional.of(SOUTH); + case 1: + return Optional.of(SOUTH_SOUTHWEST); + case 2: + return Optional.of(SOUTHWEST); + case 3: + return Optional.of(WEST_SOUTHWEST); + case 4: + return Optional.of(WEST); + case 5: + return Optional.of(WEST_NORTHWEST); + case 6: + return Optional.of(NORTHWEST); + case 7: + return Optional.of(NORTH_NORTHWEST); + case 8: + return Optional.of(NORTH); + case 9: + return Optional.of(NORTH_NORTHEAST); + case 10: + return Optional.of(NORTHEAST); + case 11: + return Optional.of(EAST_NORTHEAST); + case 12: + return Optional.of(EAST); + case 13: + return Optional.of(EAST_SOUTHEAST); + case 14: + return Optional.of(SOUTHEAST); + case 15: + return Optional.of(SOUTH_SOUTHEAST); + } + + return Optional.empty(); + } + + public OptionalInt toRotationIndex() { + switch (this) { + case SOUTH: + return OptionalInt.of(0); + case SOUTH_SOUTHWEST: + return OptionalInt.of(1); + case SOUTHWEST: + return OptionalInt.of(2); + case WEST_SOUTHWEST: + return OptionalInt.of(3); + case WEST: + return OptionalInt.of(4); + case WEST_NORTHWEST: + return OptionalInt.of(5); + case NORTHWEST: + return OptionalInt.of(6); + case NORTH_NORTHWEST: + return OptionalInt.of(7); + case NORTH: + return OptionalInt.of(8); + case NORTH_NORTHEAST: + return OptionalInt.of(9); + case NORTHEAST: + return OptionalInt.of(10); + case EAST_NORTHEAST: + return OptionalInt.of(11); + case EAST: + return OptionalInt.of(12); + case EAST_SOUTHEAST: + return OptionalInt.of(13); + case SOUTHEAST: + return OptionalInt.of(14); + case SOUTH_SOUTHEAST: + return OptionalInt.of(15); + } + return OptionalInt.empty(); + } + /** * Flags to use with {@link #findClosest(Vector3, int)}. */ @@ -224,4 +325,3 @@ public enum Direction { } } - 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 df235ceb9..65023b4a5 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 @@ -100,14 +100,20 @@ public class PropertiesConfiguration extends LocalConfiguration { logFile = getString("log-file", logFile); logFormat = getString("log-format", logFormat); registerHelp = getBool("register-help", registerHelp); - wandItem = ItemTypes.parse(getString("wand-item", wandItem.getId())); + 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 = ItemTypes.parse(getString("navigation-wand.item", navigationWand.getId())); + 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); 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 fc7b0c860..8c0cb2095 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 @@ -57,7 +57,7 @@ public class YAMLConfiguration extends LocalConfiguration { } profile = config.getBoolean("debug", profile); - wandItem = ItemTypes.parse(config.getString("wand-item", wandItem.getId())); + wandItem = ItemTypes.parse(config.getString("wand-item", wandItem)).getId(); defaultChangeLimit = Math.max(-1, config.getInt( "limits.max-blocks-changed.default", defaultChangeLimit)); @@ -105,7 +105,7 @@ public class YAMLConfiguration extends LocalConfiguration { useInventoryCreativeOverride = config.getBoolean("use-inventory.creative-mode-overrides", useInventoryCreativeOverride); - navigationWand = ItemTypes.parse(config.getString("navigation-wand.item", navigationWand.getId())); + navigationWand = ItemTypes.parse(config.getString("navigation-wand.item", navigationWand)).getId(); navigationWandMaxDistance = config.getInt("navigation-wand.max-distance", navigationWandMaxDistance); navigationUseGlass = config.getBoolean("navigation.use-glass", navigationUseGlass); 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 3dab47ed6..e83476347 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)); + return new BaseBlock(getBlock(position)).toImmutableState(); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/SimpleWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/SimpleWorld.java index bc5f21d3e..7ea6d0e24 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/SimpleWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/SimpleWorld.java @@ -59,8 +59,8 @@ public interface SimpleWorld extends World { } @Override - default BlockState getFullBlock(BlockVector3 position) { - return getLazyBlock(position); + default BaseBlock getFullBlock(BlockVector3 position) { + return getLazyBlock(position).toBaseBlock(); } @Override 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 2db95dab0..764b378cb 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 @@ -34,9 +34,15 @@ import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.blocks.TileEntityBlock; import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.function.mask.SingleBlockStateMask; +import com.sk89q.worldedit.function.mask.SingleBlockTypeMask; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.Property; +import com.sk89q.worldedit.registry.state.PropertyKey; import javax.annotation.Nullable; + +import java.util.Map; import java.util.Objects; /** @@ -48,7 +54,7 @@ import java.util.Objects; * snapshot of blocks correctly, so, for example, the NBT data for a block * may be missing.

*/ -public class BaseBlock extends BlockState { +public class BaseBlock implements BlockStateHolder, TileEntityBlock { private final BlockState blockState; @Nullable @@ -69,11 +75,6 @@ public class BaseBlock extends BlockState { // this(blockState, blockState.getNbtData()); // } - @Deprecated - public BaseBlock(BlockTypes id) { - this(id.getDefaultState()); - } - /** * Construct a block with the given type and default data. * @deprecated Just use the BlockType.getDefaultState() @@ -101,7 +102,6 @@ public class BaseBlock extends BlockState { * @param nbtData NBT data, which must be provided */ public BaseBlock(BlockState state, CompoundTag nbtData) { -// super(state.getBlockType()); checkNotNull(nbtData); this.blockState = state; this.nbtData = nbtData; @@ -145,11 +145,6 @@ public class BaseBlock extends BlockState { this(other.toImmutableState(), other.getNbtData()); } - @Override - public BlockState toFuzzy() { - return blockState; - } - @Override public String getNbtId() { CompoundTag nbtData = getNbtData(); @@ -181,12 +176,15 @@ public class BaseBlock extends BlockState { @Override public boolean equals(Object o) { if (!(o instanceof BaseBlock)) { + if (!hasNbtData() && o instanceof BlockStateHolder) { + return Objects.equals(toImmutableState(), ((BlockStateHolder) o).toImmutableState()); + } return false; } final BaseBlock otherBlock = (BaseBlock) o; - return this.equals(otherBlock) && Objects.equals(getNbtData(), otherBlock.getNbtData()); + return this.blockState.equalsFuzzy(otherBlock.blockState) && Objects.equals(getNbtData(), otherBlock.getNbtData()); } @Override @@ -205,7 +203,7 @@ public class BaseBlock extends BlockState { } @Override - public BlockTypes getBlockType() { + public BlockType getBlockType() { return blockState.getBlockType(); } @@ -244,4 +242,65 @@ public class BaseBlock extends BlockState { } } + @Override + public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean hasNbtData() { + return this.nbtData != null; + } + + @Override + public BlockStateHolder withPropertyId(int propertyId) { + return getBlockType().withPropertyId(propertyId); + } + + @Override + public int getInternalBlockTypeId() { + return toImmutableState().getInternalBlockTypeId(); + } + + @Override + public int getInternalPropertiesId() { + return toImmutableState().getInternalPropertiesId(); + } + + @Override + public Mask toMask(Extent extent) { + return new SingleBlockStateMask(extent, toImmutableState()); + } + + @Override + public BaseBlock with(Property property, V value) { + return toImmutableState().with(property, value).toBaseBlock(); + } + + @Override + public BlockStateHolder with(PropertyKey property, V value) { + return toImmutableState().with(property, value); + } + + @Override + public V getState(Property property) { + return toImmutableState().getState(property); + } + + @Override + public V getState(PropertyKey property) { + return toImmutableState().getState(property); + } + + @Override + public Map, Object> getStates() { + return toImmutableState().getStates(); + } + + @Override + public boolean equalsFuzzy(BlockStateHolder o) { + return toImmutableState().equalsFuzzy(o); + } + } 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 5b87172ee..331cbb8cf 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 @@ -39,6 +39,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.AbstractProperty; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.PropertyKey; +import com.sk89q.worldedit.world.registry.BlockMaterial; import javax.annotation.Nullable; import java.util.*; @@ -49,13 +50,26 @@ import java.util.stream.Stream; * An immutable class that represents the state a block can be in. */ @SuppressWarnings("unchecked") -public abstract class BlockState implements BlockStateHolder { +public class BlockState implements BlockStateHolder { + private final BlockType blockType; + private BaseBlock emptyBaseBlock; + BlockState(BlockType blockType) { + this.blockType = blockType; + this.emptyBaseBlock = new BaseBlock(this); + } + + BlockState(BlockType blockType, BaseBlock baseBlock){ + this.blockType = blockType; + this.emptyBaseBlock = baseBlock; + } + /** * Returns a temporary BlockState for a given internal id * @param combinedId * @deprecated magic number * @return BlockState */ + @Deprecated public static BlockState getFromInternalId(int combinedId) throws InputParseException { return BlockTypes.getFromStateId(combinedId).withStateId(combinedId); @@ -85,17 +99,6 @@ public abstract class BlockState implements BlockStateHolder { public static BlockState get(@Nullable BlockType type, String state) throws InputParseException { return get(type, state, null); } -// private BlockTypes blockType; -// private BaseBlock emptyBaseBlock; - - // Neighbouring state table. - private Table, Object, BlockState> states; - -// protected BlockState(BlockTypes blockType) { -//// protected BlockState() { -// this.blockType = blockType; -// this.emptyBaseBlock = new BaseBlock(this); -// } /** * Returns a temporary BlockState for a given type and string @@ -265,7 +268,7 @@ public abstract class BlockState implements BlockStateHolder { @Override public BlockState with(final Property property, final V value) { try { - BlockTypes type = getBlockType(); + BlockType type = getBlockType(); int newState = ((AbstractProperty) property).modify(this.getInternalId(), value); return newState != this.getInternalId() ? type.withStateId(newState) : this; } catch (ClassCastException e) { @@ -276,7 +279,7 @@ public abstract class BlockState implements BlockStateHolder { @Override public BlockState with(final PropertyKey property, final V value) { try { - BlockTypes type = getBlockType(); + BlockType type = getBlockType(); int newState = ((AbstractProperty) type.getProperty(property)).modify(this.getInternalId(), value); return newState != this.getInternalId() ? type.withStateId(newState) : this; } catch (ClassCastException e) { @@ -309,13 +312,10 @@ public abstract class BlockState implements BlockStateHolder { return (Map, Object>) map; } -// @Override -// public BaseBlock toBaseBlock() { -//// if (this.fuzzy) { -//// throw new IllegalArgumentException("Can't create a BaseBlock from a fuzzy BlockState!"); -//// } -// return this.emptyBaseBlock; -// } + @Override + public BaseBlock toBaseBlock() { + return this.emptyBaseBlock; + } @Override public BaseBlock toBaseBlock(CompoundTag compoundTag) { @@ -325,10 +325,10 @@ public abstract class BlockState implements BlockStateHolder { return new BaseBlock(this, compoundTag); } -// @Override -// public BlockTypes getBlockType() { -// return this.blockType; -// } + @Override + public BlockType getBlockType() { + return this.blockType; + } /** * Deprecated, use masks - not try to this fuzzy/non fuzzy state nonsense @@ -364,4 +364,20 @@ public abstract class BlockState implements BlockStateHolder { public String toString() { return getAsString(); } + + @Override + public int getInternalId() { + return blockType.getInternalId(); + } + + @Override + public BlockMaterial getMaterial() { + return blockType.getMaterial(); + } + + @Override + public int getOrdinal() { + //? + return 0; + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java index 6424f32dc..882d044ae 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java @@ -38,7 +38,7 @@ public interface BlockStateHolder extends FawePatter * * @return The type */ - BlockTypes getBlockType(); + BlockType getBlockType(); /** * Magic number (legacy uses) @@ -46,9 +46,7 @@ public interface BlockStateHolder extends FawePatter * @return */ @Deprecated - default BlockStateHolder withPropertyId(int propertyId) { - return getBlockType().withPropertyId(propertyId); - } + BlockStateHolder withPropertyId(int propertyId); /** * Get combined id (legacy uses) @@ -60,18 +58,13 @@ public interface BlockStateHolder extends FawePatter @Deprecated int getOrdinal(); - default BlockMaterial getMaterial() { - return getBlockType().getMaterial(); - } - + BlockMaterial getMaterial(); /** * Get type id (legacy uses) * @return */ @Deprecated - default int getInternalBlockTypeId() { - return getBlockType().getInternalId(); - } + int getInternalBlockTypeId(); /** * Get the block data (legacy uses) @@ -132,11 +125,7 @@ public interface BlockStateHolder extends FawePatter boolean equalsFuzzy(BlockStateHolder o); /** -<<<<<<< HEAD - * Returns an immutable BlockStateHolder from this BlockStateHolder. -======= * Returns an immutable {@link BlockState} from this BlockStateHolder. ->>>>>>> f54d6afb... Make BaseBlock more memory efficient, and make it clear in the API that it's not intended to be used for every single block. * * @return A BlockState */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateImpl.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateImpl.java index 44d330401..6569d1666 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateImpl.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateImpl.java @@ -7,12 +7,12 @@ import com.sk89q.worldedit.world.registry.BlockMaterial; public class BlockStateImpl extends BlockState { private final int internalId; private final int ordinal; - private final BlockTypes type; + private final BlockType type; private BlockMaterial material; private BaseBlock baseBlock; - protected BlockStateImpl(BlockTypes type, int internalId, int ordinal) { -// super(type); + protected BlockStateImpl(BlockType type, int internalId, int ordinal) { + super(type); this.type = type; this.internalId = internalId; this.ordinal = ordinal; @@ -44,7 +44,7 @@ public class BlockStateImpl extends BlockState { } @Override - public final BlockTypes getBlockType() { + public final BlockType getBlockType() { return type; } 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 6259c0692..4f2f2e129 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 @@ -33,6 +33,7 @@ import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.registry.NamespacedRegistry; +import com.sk89q.worldedit.registry.state.AbstractProperty; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.world.item.ItemType; @@ -40,30 +41,55 @@ import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.registry.BundledBlockData; import com.sk89q.worldedit.world.registry.LegacyMapper; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.IntStream; -public interface BlockType extends FawePattern, Comparable { - - default BlockTypes getTypeEnum() { - return (BlockTypes) this; - } +public class BlockType implements FawePattern { + + public static final NamespacedRegistry REGISTRY = new NamespacedRegistry<>("block type"); + + private final @Nonnull String id; + private ArrayList states; + public final Function defaultValue; + private BlockTypes.Settings settings; + private BlockMaterial material; + public BlockType(@Nonnull String id) { + this(id, null); + } + + public BlockType(@Nonnull String id, Function defaultValue) { + this.id = id; + this.defaultValue = defaultValue; + } + + public void setStates(ArrayList states) { + this.states = states; + } + + public void setSettings(BlockTypes.Settings settings) { + this.settings = settings; + } + + public BlockTypes.Settings getSettings(){ + return settings; + } + + public ArrayList updateStates(){ + if(settings != null) { + return settings.localStates = new ArrayList(settings.localStates.stream().map(state -> new BlockStateImpl(this, state.getInternalId(), state.getOrdinal())).collect(Collectors.toList())); + }else { + return null; + } + } + @Deprecated - int getMaxStateId(); - - @Override - default boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { - return extent.setBlock(set, this.getDefaultState()); - } - - @Override - default BlockStateHolder apply(BlockVector3 position) { - return this.getDefaultState(); - } - - default Mask toMask(Extent extent) { - return new SingleBlockTypeMask(extent, this); + public int getMaxStateId() { + return settings.permutations; } /** @@ -71,15 +97,17 @@ public interface BlockType extends FawePattern, Comparable { * * @return The id */ - String getId(); + public String getId() { + return this.id; + } - default String getNamespace() { + public String getNamespace() { String id = getId(); int i = id.indexOf(':'); return i == -1 ? "minecraft" : id.substring(0, i); } - default String getResource() { + public String getResource() { String id = getId(); return id.substring(id.indexOf(':') + 1); } @@ -89,7 +117,7 @@ public interface BlockType extends FawePattern, Comparable { * * @return The name, or ID */ - default String getName() { + public String getName() { BundledBlockData.BlockEntry entry = BundledBlockData.getInstance().findById(this.getId()); if (entry == null) { return getId(); @@ -99,28 +127,41 @@ public interface BlockType extends FawePattern, Comparable { } @Deprecated - default BlockState withPropertyId(int internalPropertiesId) { - if (internalPropertiesId == 0) return getDefaultState(); - return BlockState.getFromInternalId(getInternalId() + (internalPropertiesId << BlockTypes.BIT_OFFSET)); + public BlockState withPropertyId(int propertyId) { + if (settings.stateOrdinals == null) return settings.defaultState; + return states.get(settings.stateOrdinals[propertyId]); + } + + @Deprecated + public BlockState withStateId(int internalStateId) { + return this.withPropertyId(internalStateId >> BlockTypes.BIT_OFFSET); } /** - * Gets the properties of this BlockType in a {@code key->property} mapping. + * Properties string in the form property1=foo,prop2=bar + * @param properties + * @return + */ + public BlockState withProperties(String properties) { + int id = getInternalId(); + for (String keyPair : properties.split(",")) { + String[] split = keyPair.split("="); + String name = split[0]; + String value = split[1]; + AbstractProperty btp = settings.propertiesMap.get(name); + id = btp.modify(id, btp.getValueFor(value)); + } + return withStateId(id); + } + + /** + * Gets the properties of this BlockType in a key->property mapping. * * @return The properties map */ @Deprecated - default Map getPropertyMap() { - List properties = getProperties(); - if (properties.isEmpty()) { - return Collections.emptyMap(); - } - - Map map = new HashMap<>(properties.size()); - for (Property property : properties) { - map.put(property.getName(), property); - } - return map; + public Map> getPropertyMap() { + return this.settings.propertiesMap; } /** @@ -129,11 +170,13 @@ public interface BlockType extends FawePattern, Comparable { * @return the properties */ @Deprecated - List getProperties(); + public List> getProperties() { + return this.settings.propertiesList; + } @Deprecated - default Set getPropertiesSet() { - return new HashSet<>(getProperties()); + public Set> getPropertiesSet() { + return this.settings.propertiesSet; } /** @@ -143,20 +186,22 @@ public interface BlockType extends FawePattern, Comparable { * @return The property */ @Deprecated - default Property getProperty(String name) { - Property property = getPropertyMap().get(name); - checkArgument(property != null, "%s has no property named %s", this, name); - return property; + public Property getProperty(String name) { + checkArgument(this.settings.propertiesMap.get(name) != null, "%s has no property named %s", this, name); + return (Property) this.settings.propertiesMap.get(name); } - default boolean hasProperty(PropertyKey key) { - return getPropertyMap().containsKey(key.getId()); + public boolean hasProperty(PropertyKey key) { + int ordinal = key.ordinal(); + return this.settings.propertiesMapArr.length > ordinal ? this.settings.propertiesMapArr[ordinal] != null : false; } - - default Property getProperty(PropertyKey key) { - Property property = getPropertyMap().get(key.getId()); - checkArgument(property != null, "%s has no property named %s", this, key.getId()); - return property; + + public Property getProperty(PropertyKey key) { + try { + return (Property) this.settings.propertiesMapArr[key.ordinal()]; + } catch (IndexOutOfBoundsException ignore) { + return null; + } } /** @@ -164,28 +209,54 @@ public interface BlockType extends FawePattern, Comparable { * * @return The default state */ - BlockState getDefaultState(); + public BlockState getDefaultState() { + BlockState defaultState = this.settings.defaultState; + if (defaultValue != null) { + defaultState = defaultValue.apply(defaultState); + } + return defaultState; + } /** - * Gets a list of all possible states for this BlockType. - * - * @return All possible states + * Slow + * @return collection of states */ - List getAllStates(); + @Deprecated + public List getAllStates() { + if (settings.stateOrdinals == null) return Collections.singletonList(getDefaultState()); + return IntStream.of(settings.stateOrdinals).filter(i -> i != -1).mapToObj(i -> states.get(i)).collect(Collectors.toList()); + } /** * Gets a state of this BlockType with the given properties. * * @return The state, if it exists */ - BlockState getState(Map, Object> key); + public BlockState getState(Map, Object> key) { + int id = getInternalId(); + for (Map.Entry, Object> iter : key.entrySet()) { + Property prop = iter.getKey(); + Object value = iter.getValue(); + + /* + * TODO: + * This is likely wrong. The only place this seems to currently (Dec 23 2018) + * be invoked is via ForgeWorld, and value is a String when invoked there... + */ + AbstractProperty btp = this.settings.propertiesMap.get(prop.getName()); + checkArgument(btp != null, "%s has no property named %s", this, prop.getName()); + id = btp.modify(id, btp.getValueFor((String)value)); + } + return withStateId(id); + } + /** * Gets whether this block type has an item representation. * * @return If it has an item */ - default boolean hasItemType() { + public boolean hasItemType() { return getItemType() != null; } @@ -195,8 +266,8 @@ public interface BlockType extends FawePattern, Comparable { * @return The item representation */ @Nullable - default ItemType getItemType() { - return ItemTypes.get(this.getTypeEnum()); + public ItemType getItemType() { + return ItemTypes.get(this); } /** @@ -204,7 +275,11 @@ public interface BlockType extends FawePattern, Comparable { * * @return The material */ - BlockMaterial getMaterial(); + public BlockMaterial getMaterial() { + return this.material == null ? + WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getMaterial(this) + : this.material; + } /** * Gets the legacy ID. Needed for legacy reasons. @@ -213,7 +288,7 @@ public interface BlockType extends FawePattern, Comparable { * * @return legacy id or 0, if unknown */ - default int getLegacyCombinedId() { + public int getLegacyCombinedId() { Integer combinedId = LegacyMapper.getInstance().getLegacyCombined(this); return combinedId == null ? 0 : combinedId; } @@ -225,16 +300,43 @@ public interface BlockType extends FawePattern, Comparable { * * @return internal id */ - int getInternalId(); + public int getInternalId() { + return this.settings.internalId; + } @Override - boolean equals(Object obj); + public int hashCode() { + return this.id.hashCode(); + } @Override - int hashCode(); + public boolean equals(Object obj) { + return obj instanceof BlockType && this.id.equals(((BlockType) obj).id); + } + + @Override + public String toString() { + return getId(); + } + + + @Override + public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { + return extent.setBlock(set, this.getDefaultState()); + } + + @Override + public BlockStateHolder apply(BlockVector3 position) { + return this.getDefaultState(); + } + + public Mask toMask(Extent extent) { + return new SingleBlockTypeMask(extent, this); + } + @Deprecated - default int getLegacyId() { + public int getLegacyId() { Integer id = LegacyMapper.getInstance().getLegacyCombined(this.getDefaultState()); if (id != null) { return id >> 4; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeSwitchBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeSwitchBuilder.java index 4a7a9efbf..4d385e0b3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeSwitchBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeSwitchBuilder.java @@ -17,7 +17,7 @@ public class BlockTypeSwitchBuilder { } public BlockTypeSwitchBuilder add(Predicate predicate, T task) { - for (BlockTypes type : BlockTypes.values) { + for (BlockType type : BlockTypes.values) { if (predicate.test(type)) { this.runnables[type.getInternalId()] = task; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeUtil.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeUtil.java new file mode 100644 index 000000000..864a53bcb --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypeUtil.java @@ -0,0 +1,214 @@ +/* + * 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.block; + +import com.sk89q.worldedit.registry.state.PropertyGroup; +import com.sk89q.worldedit.registry.state.PropertyKey; +import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockTypes; + +import static com.google.common.base.Preconditions.checkNotNull; + +public class BlockTypeUtil { + + public static double centralTopLimit(com.sk89q.worldedit.world.block.BlockType type) { + checkNotNull(type); + return centralTopLimit(type.getDefaultState()); + } + + public static double centralBottomLimit(BlockStateHolder block) { + checkNotNull(block); + BlockType type = block.getBlockType(); + switch (type.getResource().toUpperCase()) { + case "CREEPER_WALL_HEAD": + case "DRAGON_WALL_HEAD": + case "PLAYER_WALL_HEAD": + case "ZOMBIE_WALL_HEAD": return 0.25; + case "ACACIA_SLAB": + case "BIRCH_SLAB": + case "BRICK_SLAB": + case "COBBLESTONE_SLAB": + case "DARK_OAK_SLAB": + case "DARK_PRISMARINE_SLAB": + case "JUNGLE_SLAB": + case "NETHER_BRICK_SLAB": + case "OAK_SLAB": + case "PETRIFIED_OAK_SLAB": + case "PRISMARINE_BRICK_SLAB": + case "PRISMARINE_SLAB": + case "PURPUR_SLAB": + case "QUARTZ_SLAB": + case "RED_SANDSTONE_SLAB": + case "SANDSTONE_SLAB": + case "SPRUCE_SLAB": + case "STONE_BRICK_SLAB": + case "STONE_SLAB": { + String state = (String) block.getState(PropertyKey.TYPE); + if (state == null) return 0; + switch (state) { + case "double": + case "bottom": + return 0; + case "top": + return 0.5; + } + } + case "ACACIA_TRAPDOOR": + case "BIRCH_TRAPDOOR": + case "DARK_OAK_TRAPDOOR": + case "IRON_TRAPDOOR": + case "JUNGLE_TRAPDOOR": + case "OAK_TRAPDOOR": + case "SPRUCE_TRAPDOOR": + if (block.getState(PropertyKey.OPEN) == Boolean.TRUE) { + return 1; + } else if ("bottom".equals(block.getState(PropertyKey.HALF))) { + return 0.8125; + } else { + return 0; + } + case "ACACIA_FENCE_GATE": + case "BIRCH_FENCE_GATE": + case "DARK_OAK_FENCE_GATE": + case "JUNGLE_FENCE_GATE": + case "OAK_FENCE_GATE": + case "SPRUCE_FENCE_GATE": return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 1 : 0; + default: + if (type.getMaterial().isMovementBlocker()) return 0; + return 1; + } + } + + /** + * Returns the y offset a player falls to when falling onto the top of a block at xp+0.5/zp+0.5. + * + * @param block the block + * @return the y offset + */ + public static double centralTopLimit(BlockStateHolder block) { + checkNotNull(block); + BlockType type = block.getBlockType(); + switch (type.getResource().toUpperCase()) { + case "BLACK_BED": + case "BLUE_BED": + case "BROWN_BED": + case "CYAN_BED": + case "GRAY_BED": + case "GREEN_BED": + case "LIGHT_BLUE_BED": + case "LIGHT_GRAY_BED": + case "LIME_BED": + case "MAGENTA_BED": + case "ORANGE_BED": + case "PINK_BED": + case "PURPLE_BED": + case "RED_BED": + case "WHITE_BED": + case "YELLOW_BED": return 0.5625; + case "BREWING_STAND": return 0.875; + case "CAKE": return (block.getState(PropertyKey.BITES) == (Integer) 6) ? 0 : 0.4375; + case "CAULDRON": return 0.3125; + case "COCOA": return 0.750; + case "ENCHANTING_TABLE": return 0.75; + case "END_PORTAL_FRAME": return block.getState(PropertyKey.EYE) == Boolean.TRUE ? 1 : 0.8125; + case "CREEPER_HEAD": + case "DRAGON_HEAD": + case "PISTON_HEAD": + case "PLAYER_HEAD": + case "ZOMBIE_HEAD": return 0.5; + case "CREEPER_WALL_HEAD": + case "DRAGON_WALL_HEAD": + case "PLAYER_WALL_HEAD": + case "ZOMBIE_WALL_HEAD": return 0.75; + case "ACACIA_FENCE": + case "BIRCH_FENCE": + case "DARK_OAK_FENCE": + case "JUNGLE_FENCE": + case "NETHER_BRICK_FENCE": + case "OAK_FENCE": + case "SPRUCE_FENCE": return 1.5; + case "ACACIA_SLAB": + case "BIRCH_SLAB": + case "BRICK_SLAB": + case "COBBLESTONE_SLAB": + case "DARK_OAK_SLAB": + case "DARK_PRISMARINE_SLAB": + case "JUNGLE_SLAB": + case "NETHER_BRICK_SLAB": + case "OAK_SLAB": + case "PETRIFIED_OAK_SLAB": + case "PRISMARINE_BRICK_SLAB": + case "PRISMARINE_SLAB": + case "PURPUR_SLAB": + case "QUARTZ_SLAB": + case "RED_SANDSTONE_SLAB": + case "SANDSTONE_SLAB": + case "SPRUCE_SLAB": + case "STONE_BRICK_SLAB": + case "STONE_SLAB": { + String state = (String) block.getState(PropertyKey.TYPE); + if (state == null) return 0.5; + switch (state) { + case "bottom": + return 0.5; + case "top": + case "double": + return 1; + } + } + case "LILY_PAD": return 0.015625; + case "REPEATER": return 0.125; + case "SOUL_SAND": return 0.875; + case "COBBLESTONE_WALL": + case "MOSSY_COBBLESTONE_WALL": return 1.5; + case "FLOWER_POT": return 0.375; + case "COMPARATOR": return 0.125; + case "DAYLIGHT_DETECTOR": return 0.375; + case "HOPPER": return 0.625; + case "ACACIA_TRAPDOOR": + case "BIRCH_TRAPDOOR": + case "DARK_OAK_TRAPDOOR": + case "IRON_TRAPDOOR": + case "JUNGLE_TRAPDOOR": + case "OAK_TRAPDOOR": + case "SPRUCE_TRAPDOOR": + if (block.getState(PropertyKey.OPEN) == Boolean.TRUE) { + return 0; + } else if ("top".equals(block.getState(PropertyKey.HALF))) { + return 1; + } else { + return 0.1875; + } + case "ACACIA_FENCE_GATE": + case "BIRCH_FENCE_GATE": + case "DARK_OAK_FENCE_GATE": + case "JUNGLE_FENCE_GATE": + case "OAK_FENCE_GATE": + case "SPRUCE_FENCE_GATE": return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 0 : 1.5; + default: + if (type.hasProperty(PropertyKey.LAYERS)) { + return PropertyGroup.LEVEL.get(block) * 0.0625; + } + if (!type.getMaterial().isMovementBlocker()) return 0; + return 1; + + } + } +} \ No newline at end of file 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 0afa1720c..adf5dcaf1 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 @@ -39,6 +39,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.AbstractProperty; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.PropertyKey; +import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.registry.BlockMaterial; @@ -48,6 +49,7 @@ import it.unimi.dsi.fastutil.ints.IntCollections; import javax.annotation.Nullable; import java.util.*; +import java.util.function.Function; import java.util.function.IntPredicate; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -56,642 +58,690 @@ import java.util.stream.Stream; /** * Stores a list of common Block String IDs. */ -public enum BlockTypes implements BlockType { +@SuppressWarnings("deprecation") +public class BlockTypes{ /* ----------------------------------------------------- Replaced at runtime by the block registry ----------------------------------------------------- */ - __RESERVED__, - ACACIA_BUTTON, - ACACIA_DOOR, - ACACIA_FENCE, - ACACIA_FENCE_GATE, - ACACIA_LEAVES, - ACACIA_LOG, - ACACIA_PLANKS, - ACACIA_PRESSURE_PLATE, - ACACIA_SAPLING, - ACACIA_SLAB, - ACACIA_STAIRS, - ACACIA_TRAPDOOR, - ACACIA_WOOD, - ACTIVATOR_RAIL, - AIR, - ALLIUM, - ANDESITE, - ANVIL, - ATTACHED_MELON_STEM, - ATTACHED_PUMPKIN_STEM, - AZURE_BLUET, - BARRIER, - BEACON, - BEDROCK, - BEETROOTS, - BIRCH_BUTTON, - BIRCH_DOOR, - BIRCH_FENCE, - BIRCH_FENCE_GATE, - BIRCH_LEAVES, - BIRCH_LOG, - BIRCH_PLANKS, - BIRCH_PRESSURE_PLATE, - BIRCH_SAPLING, - BIRCH_SLAB, - BIRCH_STAIRS, - BIRCH_TRAPDOOR, - BIRCH_WOOD, - BLACK_BANNER, - BLACK_BED, - BLACK_CARPET, - BLACK_CONCRETE, - BLACK_CONCRETE_POWDER, - BLACK_GLAZED_TERRACOTTA, - BLACK_SHULKER_BOX, - BLACK_STAINED_GLASS, - BLACK_STAINED_GLASS_PANE, - BLACK_TERRACOTTA, - BLACK_WALL_BANNER, - BLACK_WOOL, - BLUE_BANNER, - BLUE_BED, - BLUE_CARPET, - BLUE_CONCRETE, - BLUE_CONCRETE_POWDER, - BLUE_GLAZED_TERRACOTTA, - BLUE_ICE, - BLUE_ORCHID, - BLUE_SHULKER_BOX, - BLUE_STAINED_GLASS, - BLUE_STAINED_GLASS_PANE, - BLUE_TERRACOTTA, - BLUE_WALL_BANNER, - BLUE_WOOL, - BONE_BLOCK, - BOOKSHELF, - BRAIN_CORAL, - BRAIN_CORAL_BLOCK, - BRAIN_CORAL_FAN, - BRAIN_CORAL_WALL_FAN, - BREWING_STAND, - BRICK_SLAB, - BRICK_STAIRS, - BRICKS, - BROWN_BANNER, - BROWN_BED, - BROWN_CARPET, - BROWN_CONCRETE, - BROWN_CONCRETE_POWDER, - BROWN_GLAZED_TERRACOTTA, - BROWN_MUSHROOM, - BROWN_MUSHROOM_BLOCK, - BROWN_SHULKER_BOX, - BROWN_STAINED_GLASS, - BROWN_STAINED_GLASS_PANE, - BROWN_TERRACOTTA, - BROWN_WALL_BANNER, - BROWN_WOOL, - BUBBLE_COLUMN, - BUBBLE_CORAL, - BUBBLE_CORAL_BLOCK, - BUBBLE_CORAL_FAN, - BUBBLE_CORAL_WALL_FAN, - CACTUS, - CAKE, - CARROTS, - CARVED_PUMPKIN, - CAULDRON, - CAVE_AIR, - CHAIN_COMMAND_BLOCK, - CHEST, - CHIPPED_ANVIL, - CHISELED_QUARTZ_BLOCK, - CHISELED_RED_SANDSTONE, - CHISELED_SANDSTONE, - CHISELED_STONE_BRICKS, - CHORUS_FLOWER, - CHORUS_PLANT, - CLAY, - COAL_BLOCK, - COAL_ORE, - COARSE_DIRT, - COBBLESTONE, - COBBLESTONE_SLAB, - COBBLESTONE_STAIRS, - COBBLESTONE_WALL, - COBWEB, - COCOA, - COMMAND_BLOCK, - COMPARATOR, - CONDUIT, - CRACKED_STONE_BRICKS, - CRAFTING_TABLE, - CREEPER_HEAD, - CREEPER_WALL_HEAD, - CUT_RED_SANDSTONE, - CUT_SANDSTONE, - CYAN_BANNER, - CYAN_BED, - CYAN_CARPET, - CYAN_CONCRETE, - CYAN_CONCRETE_POWDER, - CYAN_GLAZED_TERRACOTTA, - CYAN_SHULKER_BOX, - CYAN_STAINED_GLASS, - CYAN_STAINED_GLASS_PANE, - CYAN_TERRACOTTA, - CYAN_WALL_BANNER, - CYAN_WOOL, - DAMAGED_ANVIL, - DANDELION, - DARK_OAK_BUTTON, - DARK_OAK_DOOR, - DARK_OAK_FENCE, - DARK_OAK_FENCE_GATE, - DARK_OAK_LEAVES, - DARK_OAK_LOG, - DARK_OAK_PLANKS, - DARK_OAK_PRESSURE_PLATE, - DARK_OAK_SAPLING, - DARK_OAK_SLAB, - DARK_OAK_STAIRS, - DARK_OAK_TRAPDOOR, - DARK_OAK_WOOD, - DARK_PRISMARINE, - DARK_PRISMARINE_SLAB, - DARK_PRISMARINE_STAIRS, - DAYLIGHT_DETECTOR, - DEAD_BRAIN_CORAL, - DEAD_BRAIN_CORAL_BLOCK, - DEAD_BRAIN_CORAL_FAN, - DEAD_BRAIN_CORAL_WALL_FAN, - DEAD_BUBBLE_CORAL, - DEAD_BUBBLE_CORAL_BLOCK, - DEAD_BUBBLE_CORAL_FAN, - DEAD_BUBBLE_CORAL_WALL_FAN, - DEAD_BUSH, - DEAD_FIRE_CORAL, - DEAD_FIRE_CORAL_BLOCK, - DEAD_FIRE_CORAL_FAN, - DEAD_FIRE_CORAL_WALL_FAN, - DEAD_HORN_CORAL, - DEAD_HORN_CORAL_BLOCK, - DEAD_HORN_CORAL_FAN, - DEAD_HORN_CORAL_WALL_FAN, - DEAD_TUBE_CORAL, - DEAD_TUBE_CORAL_BLOCK, - DEAD_TUBE_CORAL_FAN, - DEAD_TUBE_CORAL_WALL_FAN, - DETECTOR_RAIL, - DIAMOND_BLOCK, - DIAMOND_ORE, - DIORITE, - DIRT, - DISPENSER, - DRAGON_EGG, - DRAGON_HEAD, - DRAGON_WALL_HEAD, - DRIED_KELP_BLOCK, - DROPPER, - EMERALD_BLOCK, - EMERALD_ORE, - ENCHANTING_TABLE, - END_GATEWAY, - END_PORTAL, - END_PORTAL_FRAME, - END_ROD, - END_STONE, - END_STONE_BRICKS, - ENDER_CHEST, - FARMLAND, - FERN, - FIRE, - FIRE_CORAL, - FIRE_CORAL_BLOCK, - FIRE_CORAL_FAN, - FIRE_CORAL_WALL_FAN, - FLOWER_POT, - FROSTED_ICE, - FURNACE, - GLASS, - GLASS_PANE, - GLOWSTONE, - GOLD_BLOCK, - GOLD_ORE, - GRANITE, - GRASS, - GRASS_BLOCK, - GRASS_PATH, - GRAVEL, - GRAY_BANNER, - GRAY_BED, - GRAY_CARPET, - GRAY_CONCRETE, - GRAY_CONCRETE_POWDER, - GRAY_GLAZED_TERRACOTTA, - GRAY_SHULKER_BOX, - GRAY_STAINED_GLASS, - GRAY_STAINED_GLASS_PANE, - GRAY_TERRACOTTA, - GRAY_WALL_BANNER, - GRAY_WOOL, - GREEN_BANNER, - GREEN_BED, - GREEN_CARPET, - GREEN_CONCRETE, - GREEN_CONCRETE_POWDER, - GREEN_GLAZED_TERRACOTTA, - GREEN_SHULKER_BOX, - GREEN_STAINED_GLASS, - GREEN_STAINED_GLASS_PANE, - GREEN_TERRACOTTA, - GREEN_WALL_BANNER, - GREEN_WOOL, - HAY_BLOCK, - HEAVY_WEIGHTED_PRESSURE_PLATE, - HOPPER, - HORN_CORAL, - HORN_CORAL_BLOCK, - HORN_CORAL_FAN, - HORN_CORAL_WALL_FAN, - ICE, - INFESTED_CHISELED_STONE_BRICKS, - INFESTED_COBBLESTONE, - INFESTED_CRACKED_STONE_BRICKS, - INFESTED_MOSSY_STONE_BRICKS, - INFESTED_STONE, - INFESTED_STONE_BRICKS, - IRON_BARS, - IRON_BLOCK, - IRON_DOOR, - IRON_ORE, - IRON_TRAPDOOR, - JACK_O_LANTERN, - JUKEBOX, - JUNGLE_BUTTON, - JUNGLE_DOOR, - JUNGLE_FENCE, - JUNGLE_FENCE_GATE, - JUNGLE_LEAVES, - JUNGLE_LOG, - JUNGLE_PLANKS, - JUNGLE_PRESSURE_PLATE, - JUNGLE_SAPLING, - JUNGLE_SLAB, - JUNGLE_STAIRS, - JUNGLE_TRAPDOOR, - JUNGLE_WOOD, - KELP, - KELP_PLANT, - LADDER, - LAPIS_BLOCK, - LAPIS_ORE, - LARGE_FERN, - LAVA, - LEVER, - LIGHT_BLUE_BANNER, - LIGHT_BLUE_BED, - LIGHT_BLUE_CARPET, - LIGHT_BLUE_CONCRETE, - LIGHT_BLUE_CONCRETE_POWDER, - LIGHT_BLUE_GLAZED_TERRACOTTA, - LIGHT_BLUE_SHULKER_BOX, - LIGHT_BLUE_STAINED_GLASS, - LIGHT_BLUE_STAINED_GLASS_PANE, - LIGHT_BLUE_TERRACOTTA, - LIGHT_BLUE_WALL_BANNER, - LIGHT_BLUE_WOOL, - LIGHT_GRAY_BANNER, - LIGHT_GRAY_BED, - LIGHT_GRAY_CARPET, - LIGHT_GRAY_CONCRETE, - LIGHT_GRAY_CONCRETE_POWDER, - LIGHT_GRAY_GLAZED_TERRACOTTA, - LIGHT_GRAY_SHULKER_BOX, - LIGHT_GRAY_STAINED_GLASS, - LIGHT_GRAY_STAINED_GLASS_PANE, - LIGHT_GRAY_TERRACOTTA, - LIGHT_GRAY_WALL_BANNER, - LIGHT_GRAY_WOOL, - LIGHT_WEIGHTED_PRESSURE_PLATE, - LILAC, - LILY_PAD, - LIME_BANNER, - LIME_BED, - LIME_CARPET, - LIME_CONCRETE, - LIME_CONCRETE_POWDER, - LIME_GLAZED_TERRACOTTA, - LIME_SHULKER_BOX, - LIME_STAINED_GLASS, - LIME_STAINED_GLASS_PANE, - LIME_TERRACOTTA, - LIME_WALL_BANNER, - LIME_WOOL, - MAGENTA_BANNER, - MAGENTA_BED, - MAGENTA_CARPET, - MAGENTA_CONCRETE, - MAGENTA_CONCRETE_POWDER, - MAGENTA_GLAZED_TERRACOTTA, - MAGENTA_SHULKER_BOX, - MAGENTA_STAINED_GLASS, - MAGENTA_STAINED_GLASS_PANE, - MAGENTA_TERRACOTTA, - MAGENTA_WALL_BANNER, - MAGENTA_WOOL, - MAGMA_BLOCK, - MELON, - MELON_STEM, - MOSSY_COBBLESTONE, - MOSSY_COBBLESTONE_WALL, - MOSSY_STONE_BRICKS, - MOVING_PISTON, - MUSHROOM_STEM, - MYCELIUM, - NETHER_BRICK_FENCE, - NETHER_BRICK_SLAB, - NETHER_BRICK_STAIRS, - NETHER_BRICKS, - NETHER_PORTAL, - NETHER_QUARTZ_ORE, - NETHER_WART, - NETHER_WART_BLOCK, - NETHERRACK, - NOTE_BLOCK, - OAK_BUTTON, - OAK_DOOR, - OAK_FENCE, - OAK_FENCE_GATE, - OAK_LEAVES, - OAK_LOG, - OAK_PLANKS, - OAK_PRESSURE_PLATE, - OAK_SAPLING, - OAK_SLAB, - OAK_STAIRS, - OAK_TRAPDOOR, - OAK_WOOD, - OBSERVER, - OBSIDIAN, - ORANGE_BANNER, - ORANGE_BED, - ORANGE_CARPET, - ORANGE_CONCRETE, - ORANGE_CONCRETE_POWDER, - ORANGE_GLAZED_TERRACOTTA, - ORANGE_SHULKER_BOX, - ORANGE_STAINED_GLASS, - ORANGE_STAINED_GLASS_PANE, - ORANGE_TERRACOTTA, - ORANGE_TULIP, - ORANGE_WALL_BANNER, - ORANGE_WOOL, - OXEYE_DAISY, - PACKED_ICE, - PEONY, - PETRIFIED_OAK_SLAB, - PINK_BANNER, - PINK_BED, - PINK_CARPET, - PINK_CONCRETE, - PINK_CONCRETE_POWDER, - PINK_GLAZED_TERRACOTTA, - PINK_SHULKER_BOX, - PINK_STAINED_GLASS, - PINK_STAINED_GLASS_PANE, - PINK_TERRACOTTA, - PINK_TULIP, - PINK_WALL_BANNER, - PINK_WOOL, - PISTON, - PISTON_HEAD, - PLAYER_HEAD, - PLAYER_WALL_HEAD, - PODZOL, - POLISHED_ANDESITE, - POLISHED_DIORITE, - POLISHED_GRANITE, - POPPY, - POTATOES, - POTTED_ACACIA_SAPLING, - POTTED_ALLIUM, - POTTED_AZURE_BLUET, - POTTED_BIRCH_SAPLING, - POTTED_BLUE_ORCHID, - POTTED_BROWN_MUSHROOM, - POTTED_CACTUS, - POTTED_DANDELION, - POTTED_DARK_OAK_SAPLING, - POTTED_DEAD_BUSH, - POTTED_FERN, - POTTED_JUNGLE_SAPLING, - POTTED_OAK_SAPLING, - POTTED_ORANGE_TULIP, - POTTED_OXEYE_DAISY, - POTTED_PINK_TULIP, - POTTED_POPPY, - POTTED_RED_MUSHROOM, - POTTED_RED_TULIP, - POTTED_SPRUCE_SAPLING, - POTTED_WHITE_TULIP, - POWERED_RAIL, - PRISMARINE, - PRISMARINE_BRICK_SLAB, - PRISMARINE_BRICK_STAIRS, - PRISMARINE_BRICKS, - PRISMARINE_SLAB, - PRISMARINE_STAIRS, - PUMPKIN, - PUMPKIN_STEM, - PURPLE_BANNER, - PURPLE_BED, - PURPLE_CARPET, - PURPLE_CONCRETE, - PURPLE_CONCRETE_POWDER, - PURPLE_GLAZED_TERRACOTTA, - PURPLE_SHULKER_BOX, - PURPLE_STAINED_GLASS, - PURPLE_STAINED_GLASS_PANE, - PURPLE_TERRACOTTA, - PURPLE_WALL_BANNER, - PURPLE_WOOL, - PURPUR_BLOCK, - PURPUR_PILLAR, - PURPUR_SLAB, - PURPUR_STAIRS, - QUARTZ_BLOCK, - QUARTZ_PILLAR, - QUARTZ_SLAB, - QUARTZ_STAIRS, - RAIL, - RED_BANNER, - RED_BED, - RED_CARPET, - RED_CONCRETE, - RED_CONCRETE_POWDER, - RED_GLAZED_TERRACOTTA, - RED_MUSHROOM, - RED_MUSHROOM_BLOCK, - RED_NETHER_BRICKS, - RED_SAND, - RED_SANDSTONE, - RED_SANDSTONE_SLAB, - RED_SANDSTONE_STAIRS, - RED_SHULKER_BOX, - RED_STAINED_GLASS, - RED_STAINED_GLASS_PANE, - RED_TERRACOTTA, - RED_TULIP, - RED_WALL_BANNER, - RED_WOOL, - REDSTONE_BLOCK, - REDSTONE_LAMP, - REDSTONE_ORE, - REDSTONE_TORCH, - REDSTONE_WALL_TORCH, - REDSTONE_WIRE, - REPEATER, - REPEATING_COMMAND_BLOCK, - ROSE_BUSH, - SAND, - SANDSTONE, - SANDSTONE_SLAB, - SANDSTONE_STAIRS, - SEA_LANTERN, - SEA_PICKLE, - SEAGRASS, - SHULKER_BOX, - SIGN, - SKELETON_SKULL, - SKELETON_WALL_SKULL, - SLIME_BLOCK, - SMOOTH_QUARTZ, - SMOOTH_RED_SANDSTONE, - SMOOTH_SANDSTONE, - SMOOTH_STONE, - SNOW, - SNOW_BLOCK, - SOUL_SAND, - SPAWNER, - SPONGE, - SPRUCE_BUTTON, - SPRUCE_DOOR, - SPRUCE_FENCE, - SPRUCE_FENCE_GATE, - SPRUCE_LEAVES, - SPRUCE_LOG, - SPRUCE_PLANKS, - SPRUCE_PRESSURE_PLATE, - SPRUCE_SAPLING, - SPRUCE_SLAB, - SPRUCE_STAIRS, - SPRUCE_TRAPDOOR, - SPRUCE_WOOD, - STICKY_PISTON, - STONE, - STONE_BRICK_SLAB, - STONE_BRICK_STAIRS, - STONE_BRICKS, - STONE_BUTTON, - STONE_PRESSURE_PLATE, - STONE_SLAB, - STRIPPED_ACACIA_LOG, - STRIPPED_ACACIA_WOOD, - STRIPPED_BIRCH_LOG, - STRIPPED_BIRCH_WOOD, - STRIPPED_DARK_OAK_LOG, - STRIPPED_DARK_OAK_WOOD, - STRIPPED_JUNGLE_LOG, - STRIPPED_JUNGLE_WOOD, - STRIPPED_OAK_LOG, - STRIPPED_OAK_WOOD, - STRIPPED_SPRUCE_LOG, - STRIPPED_SPRUCE_WOOD, - STRUCTURE_BLOCK, - STRUCTURE_VOID, - SUGAR_CANE, - SUNFLOWER, - TALL_GRASS, - TALL_SEAGRASS, - TERRACOTTA, - TNT, - TORCH, - TRAPPED_CHEST, - TRIPWIRE, - TRIPWIRE_HOOK, - TUBE_CORAL, - TUBE_CORAL_BLOCK, - TUBE_CORAL_FAN, - TUBE_CORAL_WALL_FAN, - TURTLE_EGG, - VINE, - VOID_AIR, - WALL_SIGN, - WALL_TORCH, - WATER, - WET_SPONGE, - WHEAT, - WHITE_BANNER, - WHITE_BED, - WHITE_CARPET, - WHITE_CONCRETE, - WHITE_CONCRETE_POWDER, - WHITE_GLAZED_TERRACOTTA, - WHITE_SHULKER_BOX, - WHITE_STAINED_GLASS, - WHITE_STAINED_GLASS_PANE, - WHITE_TERRACOTTA, - WHITE_TULIP, - WHITE_WALL_BANNER, - WHITE_WOOL, - WITHER_SKELETON_SKULL, - WITHER_SKELETON_WALL_SKULL, - YELLOW_BANNER, - YELLOW_BED, - YELLOW_CARPET, - YELLOW_CONCRETE, - YELLOW_CONCRETE_POWDER, - YELLOW_GLAZED_TERRACOTTA, - YELLOW_SHULKER_BOX, - YELLOW_STAINED_GLASS, - YELLOW_STAINED_GLASS_PANE, - YELLOW_TERRACOTTA, - YELLOW_WALL_BANNER, - YELLOW_WOOL, - ZOMBIE_HEAD, - ZOMBIE_WALL_HEAD, + 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)); - ; + + private static BlockType register(String id) { + return register(new BlockType(id)); + } + + private static BlockType register(String id, Function values) { + return register(new BlockType(id, values)); + } + + public static BlockType register(BlockType type) { + if(sortedRegistry == null) { + sortedRegistry = new ArrayList(); + stateList = new ArrayList(); + $NAMESPACES = new LinkedHashSet(); + BIT_OFFSET = MathMan.log2nlz(WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().registerBlocks().size()); + BIT_MASK = ((1 << BIT_OFFSET) - 1); + } + if(!sortedRegistry.contains(type))sortedRegistry.add(type); + return internalRegister(type, sortedRegistry.indexOf(type)); + } + + private static ArrayList sortedRegistry; + private static ArrayList stateList; + public static BlockType[] values; + public static BlockState[] states; + private static Set $NAMESPACES; + @Deprecated public static int BIT_OFFSET; // Used internally + @Deprecated public static int BIT_MASK; // Used internally + + private static BlockType internalRegister(BlockType blockType, final int internalId) { + init(blockType, blockType.getId(), internalId, stateList); + if(BlockType.REGISTRY.get(blockType.getId()) == null) BlockType.REGISTRY.register(blockType.getId(), blockType); + $NAMESPACES.add(blockType.getNamespace()); + values = sortedRegistry.toArray(new BlockType[sortedRegistry.size()]); + states = stateList.toArray(new BlockState[stateList.size()]); + return blockType; + } + private static BlockType[] values() { + return sortedRegistry.toArray(new BlockType[sortedRegistry.size()]); + } + + private static void init(BlockType type, String id, int internalId, ArrayList states) { + try { + type.setSettings(new Settings(type, id, internalId, states)); + states.addAll(type.updateStates()); + type.setStates(states); + } catch (Throwable e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + /* ----------------------------------------------------- - Instance + Settings ----------------------------------------------------- */ - private final static class Settings { - private final int internalId; - private final ItemTypes itemType; - private final BlockState defaultState; - private final AbstractProperty[] propertiesMapArr; - private final AbstractProperty[] propertiesArr; - private final List propertiesList; - private final Map propertiesMap; - private final Set propertiesSet; - private final BlockMaterial blockMaterial; - private final int permutations; - private int[] stateOrdinals; + public final static class Settings { + protected final int internalId; + protected final ItemType itemType; + protected BlockState defaultState; + protected final AbstractProperty[] propertiesMapArr; + protected final AbstractProperty[] propertiesArr; + protected final List> propertiesList; + protected final Map> propertiesMap; + protected final Set> propertiesSet; + protected final BlockMaterial blockMaterial; + protected final int permutations; + protected int[] stateOrdinals; + protected ArrayList localStates; - Settings(BlockTypes type, String id, int internalId, List states) { + Settings(BlockType type, String id, int internalId, List states) { this.internalId = internalId; - String propertyString = null; - int propI = id.indexOf('['); - if (propI != -1) { - propertyString = id.substring(propI + 1, id.length() - 1); - } int maxInternalStateId = 0; - Map properties = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getProperties(type); + Map> properties = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getProperties(type); if (!properties.isEmpty()) { // Ensure the properties are registered int maxOrdinal = 0; @@ -701,12 +751,12 @@ public enum BlockTypes implements BlockType { this.propertiesMapArr = new AbstractProperty[maxOrdinal + 1]; int prop_arr_i = 0; this.propertiesArr = new AbstractProperty[properties.size()]; - HashMap propMap = new HashMap<>(); + HashMap> propMap = new HashMap<>(); int bitOffset = 0; - for (Map.Entry entry : properties.entrySet()) { + for (Map.Entry> entry : properties.entrySet()) { PropertyKey key = PropertyKey.getOrCreate(entry.getKey()); - AbstractProperty property = ((AbstractProperty) entry.getValue()).withOffset(bitOffset); + AbstractProperty property = ((AbstractProperty) entry.getValue()).withOffset(bitOffset); this.propertiesMapArr[key.ordinal()] = property; this.propertiesArr[prop_arr_i++] = property; propMap.put(entry.getKey(), property); @@ -725,69 +775,30 @@ public enum BlockTypes implements BlockType { this.propertiesSet = Collections.emptySet(); } this.permutations = maxInternalStateId; + this.localStates = new ArrayList(); this.blockMaterial = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getMaterial(type); this.itemType = ItemTypes.get(type); - + if (!propertiesList.isEmpty()) { this.stateOrdinals = generateStateOrdinals(internalId, states.size(), maxInternalStateId, propertiesList); for (int propId = 0; propId < this.stateOrdinals.length; propId++) { int ordinal = this.stateOrdinals[propId]; if (ordinal != -1) { int stateId = internalId + (propId << BlockTypes.BIT_OFFSET); - states.add(new BlockStateImpl(type, stateId, ordinal)); + this.localStates.add(new BlockStateImpl(type, stateId, ordinal)); } } - int defaultPropId = parseProperties(propertyString, propertiesMap) >> BlockTypes.BIT_OFFSET; - this.defaultState = states.get(this.stateOrdinals[defaultPropId]); + + this.defaultState = this.localStates.get(this.stateOrdinals[internalId >> BlockTypes.BIT_OFFSET] - states.size()); } else { - this.defaultState = new BlockStateImpl(type, internalId, states.size()); - states.add(this.defaultState); + this.defaultState = new BlockStateImpl(id.contains("minecraft:__reserved__") ? new BlockType("minecraft:air") : type, internalId, states.size()); + this.localStates.add(this.defaultState); } } - - private int parseProperties(String properties, Map propertyMap) { - int id = internalId; - for (String keyPair : properties.split(",")) { - String[] split = keyPair.split("="); - String name = split[0]; - String value = split[1]; - AbstractProperty btp = propertyMap.get(name); - id = btp.modify(id, btp.getValueFor(value)); - } - return id; - } } - - private final String id; - private final Settings settings; - - BlockTypes() { - if (name().indexOf(':') == -1) id = "minecraft:" + name().toLowerCase(); - else id = name().toLowerCase(); - settings = null; - } - - private void init(String id, int internalId, List states) { - try { - if (getId() == null) { - String name = (name().indexOf(':') == -1 ? "minecraft:" : "") + name().toLowerCase(); - ReflectionUtils.setFailsafeFieldValue(BlockTypes.class.getDeclaredField("id"), this, name); - } - Settings settings = new Settings(this, id, internalId, states); - ReflectionUtils.setFailsafeFieldValue(BlockTypes.class.getDeclaredField("settings"), this, settings); - } catch (Throwable e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - - public BlockState withPropertyId(int propertyId) { - if (settings.stateOrdinals == null) return settings.defaultState; - return states[settings.stateOrdinals[propertyId]]; - } - - private static int[] generateStateOrdinals(int internalId, int ordinal, int maxStateId, List props) { + + private static int[] generateStateOrdinals(int internalId, int ordinal, int maxStateId, List> props) { if (props.isEmpty()) return null; int[] result = new int[maxStateId + 1]; Arrays.fill(result, -1); @@ -817,256 +828,12 @@ public enum BlockTypes implements BlockType { return result; } - /** - * Slow - * @return collection of states - */ - @Deprecated - public List getAllStates() { - if (settings.stateOrdinals == null) return Collections.singletonList(getDefaultState()); - return IntStream.of(settings.stateOrdinals).filter(i -> i != -1).mapToObj(i -> states[i]).collect(Collectors.toList()); - } - - public BlockState getState(Map, Object> key) { - int id = getInternalId(); - for (Map.Entry, Object> iter : key.entrySet()) { - Property prop = iter.getKey(); - Object value = iter.getValue(); - - /* - * TODO: - * This is likely wrong. The only place this seems to currently (Dec 23 2018) - * be invoked is via ForgeWorld, and value is a String when invoked there... - */ - AbstractProperty btp = settings.propertiesMap.get(prop.getName()); - checkArgument(btp != null, "%s has no property named %s", this, prop.getName()); - id = btp.modify(id, btp.getValueFor((String)value)); - } - return withStateId(id); - } - - @Deprecated - public int getMaxStateId() { - return settings.permutations; - } - - @Override - public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { - return extent.setBlock(set, this.settings.defaultState); - } - - public Mask toMask(Extent extent) { - return new SingleBlockTypeMask(extent, this); - } - - /** - * Gets the ID of this block. - * - * @return The id - */ - public String getId() { - return this.id; - } - - /** - * Gets the name of this block, or the ID if the name cannot be found. - * - * @return The name, or ID - */ - public String getName() { - BundledBlockData.BlockEntry entry = BundledBlockData.getInstance().findById(this.id); - if (entry == null) { - return getId(); - } else { - return entry.localizedName; - } - } - - @Deprecated - public BlockState withStateId(int internalStateId) { - return this.withPropertyId(internalStateId >> BlockTypes.BIT_OFFSET); - } - - /** - * Properties string in the form property1=foo,prop2=bar - * @param properties - * @return - */ - public BlockState withProperties(String properties) { - int id = getInternalId(); - for (String keyPair : properties.split(",")) { - String[] split = keyPair.split("="); - String name = split[0]; - String value = split[1]; - AbstractProperty btp = settings.propertiesMap.get(name); - id = btp.modify(id, btp.getValueFor(value)); - } - return withStateId(id); - } - - /** - * Gets the properties of this BlockType in a key->property mapping. - * - * @return The properties map - */ - @Deprecated - public Map getPropertyMap() { - return this.settings.propertiesMap; - } - - /** - * Gets the properties of this BlockType. - * - * @return the properties - */ - @Deprecated - public List getProperties() { - return this.settings.propertiesList; - } - - @Deprecated - public Set getPropertiesSet() { - return this.settings.propertiesSet; - } - - /** - * Gets a property by name. - * - * @param name The name - * @return The property - */ - @Deprecated - public Property getProperty(String name) { - return this.settings.propertiesMap.get(name); - } - - public boolean hasProperty(PropertyKey key) { - int ordinal = key.ordinal(); - return this.settings.propertiesMapArr.length > ordinal ? this.settings.propertiesMapArr[ordinal] != null : false; - } - - public Property getProperty(PropertyKey key) { - try { - return this.settings.propertiesMapArr[key.ordinal()]; - } catch (IndexOutOfBoundsException ignore) { - return null; - } - } - - /** - * Gets the default state of this block type. - * - * @return The default state - */ - public BlockState getDefaultState() { - return this.settings.defaultState; - } - - /** - * Gets whether this block type has an item representation. - * - * @return If it has an item - */ - public boolean hasItemType() { - return getItemType() != null; - } - - /** - * Gets the item representation of this block type, if it exists. - * - * @return The item representation - */ - @Nullable - public ItemType getItemType() { - return settings.itemType; - } - - /** - * Get the material for this BlockType. - * - * @return The material - */ - public BlockMaterial getMaterial() { - return this.settings.blockMaterial; - } - - /** - * The internal index of this type. - * - * This number is not necessarily consistent across restarts. - * - * @return internal id - */ - public int getInternalId() { - return this.settings.internalId; - } - - @Override - public String toString() { - return getId(); - } - - /* - ----------------------------------------------------- - Static Initializer - ----------------------------------------------------- - */ - - @Deprecated public static final int BIT_OFFSET; // Used internally - @Deprecated public static final int BIT_MASK; // Used internally - - private static final Map $REGISTRY = new HashMap<>(); - private static int $LENGTH; - private static int $STATE_INDEX; - - public static final BlockTypes[] values; - public static final BlockState[] states; - - private static final Set $NAMESPACES = new LinkedHashSet(); - - static { - try { - Collection blocks = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().registerBlocks(); - Map blockMap = blocks.stream().collect(Collectors.toMap(item -> item.charAt(item.length() - 1) == ']' ? item.substring(0, item.indexOf('[')) : item, item -> item)); - - BlockTypes[] oldValues = BlockTypes.values(); - $LENGTH = oldValues.length; - int size = blockMap.size(); - for (BlockTypes type : oldValues) { - if (!blockMap.containsKey(type.getId())) { - type.init(type.getId(), 0, new ArrayList<>()); - if (type != __RESERVED__) Fawe.debug("Invalid block registered " + type.getId()); - size++; - } - if (type != __RESERVED__) { - $REGISTRY.put(type.name().toLowerCase(), type); - } - } - - BIT_OFFSET = MathMan.log2nlz(size); - BIT_MASK = ((1 << BIT_OFFSET) - 1); - - LinkedHashSet newValues = new LinkedHashSet<>(Arrays.asList(oldValues)); - ArrayList stateList = new ArrayList<>(); - for (String block : blocks) { - BlockTypes registered = register(block, stateList); - if (!newValues.contains(registered)) newValues.add(registered); - } - // Cache the values - values = newValues.toArray(new BlockTypes[newValues.size()]); - states = stateList.toArray(new BlockState[stateList.size()]); - } catch (Throwable e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - - public static BlockTypes parse(final String type) throws InputParseException { + public static BlockType parse(final String type) throws InputParseException { final String inputLower = type.toLowerCase(); String input = inputLower; if (!input.split("\\[", 2)[0].contains(":")) input = "minecraft:" + input; - BlockTypes result = $REGISTRY.get(input); + BlockType result = BlockType.REGISTRY.get(input); if (result != null) return result; try { @@ -1082,61 +849,35 @@ public enum BlockTypes implements BlockType { ); } - private static BlockTypes register(final String id, List states) { - // Get the enum name (remove namespace if minecraft:) - int propStart = id.indexOf('['); - String typeName = id.substring(0, propStart == -1 ? id.length() : propStart); - String enumName = (typeName.startsWith("minecraft:") ? typeName.substring(10) : typeName).toUpperCase(); - // Check existing - BlockTypes existing = null; - try { - existing = valueOf(enumName.toUpperCase()); - } catch (IllegalArgumentException ignore) {} - if (existing == null) { - Fawe.debug("Registering block " + enumName); - existing = ReflectionUtils.addEnum(BlockTypes.class, enumName); - } - int internalId = existing.ordinal(); - if (internalId == 0 && existing != __RESERVED__) { - internalId = $LENGTH++; - } - existing.init(id, internalId, states); - // register states - if (typeName.startsWith("minecraft:")) $REGISTRY.put(typeName.substring(10), existing); - $REGISTRY.put(typeName, existing); - String nameSpace = typeName.substring(0, typeName.indexOf(':')); - $NAMESPACES.add(nameSpace); - return existing; - } - public static Set getNameSpaces() { return $NAMESPACES; } - public static final @Nullable BlockTypes get(final String id) { - return $REGISTRY.get(id); - } - - public static final @Nullable BlockTypes get(final CharSequence id) { - return $REGISTRY.get(id); - } + public static final @Nullable BlockType get(final String id) { + return BlockType.REGISTRY.get(id.toLowerCase()); + } + + public static final @Nullable BlockType get(final CharSequence id) { + return BlockType.REGISTRY.get(id.toString().toLowerCase()); + } @Deprecated - public static final BlockTypes get(final int ordinal) { + public static final BlockType get(final int ordinal) { return values[ordinal]; } @Deprecated - public static final BlockTypes getFromStateId(final int internalStateId) { + public static final BlockType getFromStateId(final int internalStateId) { return values[internalStateId & BIT_MASK]; } @Deprecated - public static final BlockTypes getFromStateOrdinal(final int internalStateOrdinal) { + public static final BlockType getFromStateOrdinal(final int internalStateOrdinal) { return states[internalStateOrdinal].getBlockType(); } public static int size() { return values.length; } + } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityType.java index fbd0d6a64..8f5066617 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/entity/EntityType.java @@ -21,18 +21,46 @@ package com.sk89q.worldedit.world.entity; import com.sk89q.worldedit.registry.NamespacedRegistry; -public interface EntityType { - String getId(); +public class EntityType { + + public static final NamespacedRegistry REGISTRY = new NamespacedRegistry<>("entity type"); + + private String id; + + public EntityType(String id) { + // If it has no namespace, assume minecraft. + if (!id.contains(":")) { + id = "minecraft:" + id; + } + this.id = id; + } + + public String getId() { + return this.id; + } /** * Gets the name of this item, or the ID if the name cannot be found. * * @return The name, or ID */ - default String getName() { + public String getName() { return getId(); } - @Deprecated - public int getInternalId(); -} + @Override + public String toString() { + return getId(); + } + + @Override + public int hashCode() { + return this.id.hashCode(); + } + + @Override + public boolean equals(Object obj) { + return obj instanceof EntityType && this.id.equals(((EntityType) obj).id); + } + +} \ No newline at end of file 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 5c94bfa18..3ded2f22c 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 @@ -19,166 +19,121 @@ package com.sk89q.worldedit.world.entity; -import com.boydti.fawe.util.ReflectionUtils; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.blocks.BaseItem; -import com.sk89q.worldedit.blocks.BaseItemStack; -import com.sk89q.worldedit.entity.BaseEntity; -import com.sk89q.worldedit.extension.platform.Capability; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.sk89q.worldedit.world.item.ItemType; -import com.sk89q.worldedit.world.registry.LegacyMapper; - import javax.annotation.Nullable; -import java.util.*; -public enum EntityTypes implements EntityType { - /* - ----------------------------------------------------- - Replaced at runtime by the entity registry - ----------------------------------------------------- - */ - __RESERVED__, - AREA_EFFECT_CLOUD, - ARMOR_STAND, - ARROW, - BAT, - BLAZE, - BOAT, - CAVE_SPIDER, - CHEST_MINECART, - CHICKEN, - COD, - COMMAND_BLOCK_MINECART, - COW, - CREEPER, - DOLPHIN, - DONKEY, - DRAGON_FIREBALL, - DROWNED, - EGG, - ELDER_GUARDIAN, - END_CRYSTAL, - ENDER_DRAGON, - ENDER_PEARL, - ENDERMAN, - ENDERMITE, - EVOKER, - EVOKER_FANGS, - EXPERIENCE_BOTTLE, - EXPERIENCE_ORB, - EYE_OF_ENDER, - FALLING_BLOCK, - FIREBALL, - FIREWORK_ROCKET, - FISHING_BOBBER, - FURNACE_MINECART, - GHAST, - GIANT, - GUARDIAN, - HOPPER_MINECART, - HORSE, - HUSK, - ILLUSIONER, - IRON_GOLEM, - ITEM, - ITEM_FRAME, - LEASH_KNOT, - LIGHTNING_BOLT, - LLAMA, - LLAMA_SPIT, - MAGMA_CUBE, - MINECART, - MOOSHROOM, - MULE, - OCELOT, - PAINTING, - PARROT, - PHANTOM, - PIG, - PLAYER, - POLAR_BEAR, - POTION, - PUFFERFISH, - RABBIT, - SALMON, - SHEEP, - SHULKER, - SHULKER_BULLET, - SILVERFISH, - SKELETON, - SKELETON_HORSE, - SLIME, - SMALL_FIREBALL, - SNOW_GOLEM, - SNOWBALL, - SPAWNER_MINECART, - SPECTRAL_ARROW, - SPIDER, - SQUID, - STRAY, - TNT, - TNT_MINECART, - TRIDENT, - TROPICAL_FISH, - TURTLE, - VEX, - VILLAGER, - VINDICATOR, - WITCH, - WITHER, - WITHER_SKELETON, - WITHER_SKULL, - WOLF, - ZOMBIE, - ZOMBIE_HORSE, - ZOMBIE_PIGMAN, - ZOMBIE_VILLAGER, +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"); - private String id; - private int internalId; - - EntityTypes() { - this(null); + private EntityTypes() { } - EntityTypes(String id) { - init(id); + private static EntityType register(final String id) { + return register(new EntityType(id)); } - private void init(String id) { - if (id == null) id = "minecraft:" + name().toLowerCase(); - // If it has no namespace, assume minecraft. - else if (!id.contains(":")) { - id = "minecraft:" + id; - } - this.id = id; - this.internalId = ordinal(); + public static EntityType register(final EntityType entityType) { + return EntityType.REGISTRY.register(entityType.getId(), entityType); } - @Override - public String getId() { - return id; + public static @Nullable EntityType get(final String id) { + return EntityType.REGISTRY.get(id); } - - @Override - public String toString() { - return getId(); - } - - @Override - public int getInternalId() { - return internalId; - } - - /* - ----------------------------------------------------- - Static Initializer - ----------------------------------------------------- - */ - + public static EntityType parse(String id) { if (id.startsWith("minecraft:")) id = id.substring(10); switch (id) { @@ -246,64 +201,4 @@ public enum EntityTypes implements EntityType { } } - private static final Map $REGISTRY = new HashMap<>(); - private static int $LENGTH; - public static final EntityTypes[] values; - - static { - try { - Collection ents = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getEntityRegistry().registerEntities(); - EntityTypes[] oldValues = values(); - $LENGTH = oldValues.length; - LinkedHashSet newValues = new LinkedHashSet<>(Arrays.asList(oldValues)); - if (!ents.isEmpty()) { // No types found - use defaults - for (String ent : ents) { - EntityTypes registered = register(ent); - if (!newValues.contains(registered)) newValues.add(registered); - } - } - // Cache the values - values = newValues.toArray(new EntityTypes[newValues.size()]); - } catch (Throwable e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - - private static EntityTypes register(final String id) { - // Get the enum name (remove namespace if minecraft:) - int propStart = id.indexOf('['); - String typeName = id.substring(0, propStart == -1 ? id.length() : propStart); - String enumName = (typeName.startsWith("minecraft:") ? typeName.substring(10) : typeName).toUpperCase(); - // Check existing - EntityTypes existing = null; - try { existing = valueOf(enumName.toUpperCase()); } catch (IllegalArgumentException ignore) {} - if (existing == null) { - existing = ReflectionUtils.addEnum(EntityTypes.class, enumName); - } - int internalId = existing.ordinal(); - if (existing.id == null) { - existing.init(null); - } - if (internalId == 0 && existing != __RESERVED__) { - existing.internalId = $LENGTH++; - } - if (typeName.startsWith("minecraft:")) $REGISTRY.put(typeName.substring(10), existing); - $REGISTRY.put(typeName, existing); - return existing; - } - - public static final @Nullable EntityTypes get(final String id) { - return $REGISTRY.get(id); - } - - @Deprecated - public static final EntityTypes get(final int ordinal) { - return values[ordinal]; - } - - public static int size() { - return values.length; - } - -} +} \ No newline at end of file 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 829c62f5a..b68db45b4 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 @@ -19,29 +19,58 @@ 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; import com.sk89q.worldedit.world.block.BlockTypes; -import com.sk89q.worldedit.world.registry.LegacyMapper; import javax.annotation.Nullable; -public interface ItemType { +public class ItemType { - default ItemTypes toEnum() { - return (ItemTypes) this; + public static final NamespacedRegistry REGISTRY = new NamespacedRegistry<>("item type"); + + private String id; + private BlockType blockType; + private int internalId; + private BaseItem defaultState; + + public ItemType(String id) { + // If it has no namespace, assume minecraft. + if (!id.contains(":")) { + id = "minecraft:" + id; + } + this.id = id; + this.blockType = BlockTypes.get(this.id); } - String getId(); - - int getInternalId(); + public String getId() { + return this.id; + } + + public int getInternalId() { + return this.internalId; + } + + public void setInternalId(int internalId) { + this.internalId = internalId; + } /** * Gets the name of this item, or the ID if the name cannot be found. * * @return The name, or ID */ - String getName(); + public String getName() { + String name = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getItemRegistry().getName(this); + if (name == null) { + return getId(); + } else { + return name; + } + } /** @@ -49,7 +78,7 @@ public interface ItemType { * * @return If it has a block */ - default boolean hasBlockType() { + public boolean hasBlockType() { return getBlockType() != null; } @@ -59,11 +88,34 @@ public interface ItemType { * @return The block representation */ @Nullable - default BlockTypes getBlockType() { - return BlockTypes.get(getId()); + public BlockType getBlockType() { + return this.blockType; + } + + public void setBlockType(BlockType blockType) { + this.blockType = blockType; + } + + public BaseItem getDefaultState() { + return this.defaultState; + } + + public void setDefaultState(BaseItem defaultState) { + this.defaultState = defaultState; } - default BaseItem getDefaultState() { - return new BaseItem(this); + @Override + public String toString() { + return getId(); } -} + + @Override + public int hashCode() { + return this.id.hashCode(); + } + + @Override + public boolean equals(Object obj) { + return obj instanceof ItemType && this.id.equals(((ItemType) obj).id); + } +} \ No newline at end of file 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 61c7c1173..c35e95541 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 @@ -16,912 +16,842 @@ * 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.item; -import com.boydti.fawe.util.MathMan; -import com.boydti.fawe.util.ReflectionUtils; -import com.sk89q.util.ReflectionUtil; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; + +import javax.annotation.Nullable; + import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.extension.platform.Capability; -import com.sk89q.worldedit.registry.NamespacedRegistry; import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.sk89q.worldedit.world.entity.EntityTypes; -import com.sk89q.worldedit.world.registry.BundledItemData; import com.sk89q.worldedit.world.registry.LegacyMapper; -import javax.annotation.Nullable; -import java.lang.reflect.Field; -import java.util.*; +public final class ItemTypes { -public enum ItemTypes implements ItemType { - /* - ----------------------------------------------------- - Replaced at runtime by the item registry - ----------------------------------------------------- - */ + public static final ItemType __RESERVED__ = register("minecraft:__reserved__"); + public static final ItemType ACACIA_BOAT = register("minecraft:acacia_boat"); + public static final ItemType ACACIA_BUTTON = register("minecraft:acacia_button"); + public static final ItemType ACACIA_DOOR = register("minecraft:acacia_door"); + public static final ItemType ACACIA_FENCE = register("minecraft:acacia_fence"); + public static final ItemType ACACIA_FENCE_GATE = register("minecraft:acacia_fence_gate"); + public static final ItemType ACACIA_LEAVES = register("minecraft:acacia_leaves"); + public static final ItemType ACACIA_LOG = register("minecraft:acacia_log"); + public static final ItemType ACACIA_PLANKS = register("minecraft:acacia_planks"); + public static final ItemType ACACIA_PRESSURE_PLATE = register("minecraft:acacia_pressure_plate"); + public static final ItemType ACACIA_SAPLING = register("minecraft:acacia_sapling"); + public static final ItemType ACACIA_SLAB = register("minecraft:acacia_slab"); + public static final ItemType ACACIA_STAIRS = register("minecraft:acacia_stairs"); + public static final ItemType ACACIA_TRAPDOOR = register("minecraft:acacia_trapdoor"); + public static final ItemType ACACIA_WOOD = register("minecraft:acacia_wood"); + public static final ItemType ACTIVATOR_RAIL = register("minecraft:activator_rail"); + public static final ItemType AIR = register("minecraft:air"); + public static final ItemType ALLIUM = register("minecraft:allium"); + public static final ItemType ANDESITE = register("minecraft:andesite"); + public static final ItemType ANVIL = register("minecraft:anvil"); + public static final ItemType APPLE = register("minecraft:apple"); + public static final ItemType ARMOR_STAND = register("minecraft:armor_stand"); + public static final ItemType ARROW = register("minecraft:arrow"); + public static final ItemType AZURE_BLUET = register("minecraft:azure_bluet"); + public static final ItemType BAKED_POTATO = register("minecraft:baked_potato"); + public static final ItemType BARRIER = register("minecraft:barrier"); + public static final ItemType BAT_SPAWN_EGG = register("minecraft:bat_spawn_egg"); + public static final ItemType BEACON = register("minecraft:beacon"); + public static final ItemType BEDROCK = register("minecraft:bedrock"); + public static final ItemType BEEF = register("minecraft:beef"); + public static final ItemType BEETROOT = register("minecraft:beetroot"); + public static final ItemType BEETROOT_SEEDS = register("minecraft:beetroot_seeds"); + public static final ItemType BEETROOT_SOUP = register("minecraft:beetroot_soup"); + public static final ItemType BIRCH_BOAT = register("minecraft:birch_boat"); + public static final ItemType BIRCH_BUTTON = register("minecraft:birch_button"); + public static final ItemType BIRCH_DOOR = register("minecraft:birch_door"); + public static final ItemType BIRCH_FENCE = register("minecraft:birch_fence"); + public static final ItemType BIRCH_FENCE_GATE = register("minecraft:birch_fence_gate"); + public static final ItemType BIRCH_LEAVES = register("minecraft:birch_leaves"); + public static final ItemType BIRCH_LOG = register("minecraft:birch_log"); + public static final ItemType BIRCH_PLANKS = register("minecraft:birch_planks"); + public static final ItemType BIRCH_PRESSURE_PLATE = register("minecraft:birch_pressure_plate"); + public static final ItemType BIRCH_SAPLING = register("minecraft:birch_sapling"); + public static final ItemType BIRCH_SLAB = register("minecraft:birch_slab"); + public static final ItemType BIRCH_STAIRS = register("minecraft:birch_stairs"); + public static final ItemType BIRCH_TRAPDOOR = register("minecraft:birch_trapdoor"); + public static final ItemType BIRCH_WOOD = register("minecraft:birch_wood"); + public static final ItemType BLACK_BANNER = register("minecraft:black_banner"); + public static final ItemType BLACK_BED = register("minecraft:black_bed"); + public static final ItemType BLACK_CARPET = register("minecraft:black_carpet"); + public static final ItemType BLACK_CONCRETE = register("minecraft:black_concrete"); + public static final ItemType BLACK_CONCRETE_POWDER = register("minecraft:black_concrete_powder"); + public static final ItemType BLACK_GLAZED_TERRACOTTA = register("minecraft:black_glazed_terracotta"); + public static final ItemType BLACK_SHULKER_BOX = register("minecraft:black_shulker_box"); + public static final ItemType BLACK_STAINED_GLASS = register("minecraft:black_stained_glass"); + public static final ItemType BLACK_STAINED_GLASS_PANE = register("minecraft:black_stained_glass_pane"); + public static final ItemType BLACK_TERRACOTTA = register("minecraft:black_terracotta"); + public static final ItemType BLACK_WOOL = register("minecraft:black_wool"); + public static final ItemType BLAZE_POWDER = register("minecraft:blaze_powder"); + public static final ItemType BLAZE_ROD = register("minecraft:blaze_rod"); + public static final ItemType BLAZE_SPAWN_EGG = register("minecraft:blaze_spawn_egg"); + public static final ItemType BLUE_BANNER = register("minecraft:blue_banner"); + public static final ItemType BLUE_BED = register("minecraft:blue_bed"); + public static final ItemType BLUE_CARPET = register("minecraft:blue_carpet"); + public static final ItemType BLUE_CONCRETE = register("minecraft:blue_concrete"); + public static final ItemType BLUE_CONCRETE_POWDER = register("minecraft:blue_concrete_powder"); + public static final ItemType BLUE_GLAZED_TERRACOTTA = register("minecraft:blue_glazed_terracotta"); + public static final ItemType BLUE_ICE = register("minecraft:blue_ice"); + public static final ItemType BLUE_ORCHID = register("minecraft:blue_orchid"); + public static final ItemType BLUE_SHULKER_BOX = register("minecraft:blue_shulker_box"); + public static final ItemType BLUE_STAINED_GLASS = register("minecraft:blue_stained_glass"); + public static final ItemType BLUE_STAINED_GLASS_PANE = register("minecraft:blue_stained_glass_pane"); + public static final ItemType BLUE_TERRACOTTA = register("minecraft:blue_terracotta"); + public static final ItemType BLUE_WOOL = register("minecraft:blue_wool"); + public static final ItemType BONE = register("minecraft:bone"); + public static final ItemType BONE_BLOCK = register("minecraft:bone_block"); + public static final ItemType BONE_MEAL = register("minecraft:bone_meal"); + public static final ItemType BOOK = register("minecraft:book"); + public static final ItemType BOOKSHELF = register("minecraft:bookshelf"); + public static final ItemType BOW = register("minecraft:bow"); + public static final ItemType BOWL = register("minecraft:bowl"); + public static final ItemType BRAIN_CORAL = register("minecraft:brain_coral"); + public static final ItemType BRAIN_CORAL_BLOCK = register("minecraft:brain_coral_block"); + public static final ItemType BRAIN_CORAL_FAN = register("minecraft:brain_coral_fan"); + public static final ItemType BREAD = register("minecraft:bread"); + public static final ItemType BREWING_STAND = register("minecraft:brewing_stand"); + public static final ItemType BRICK = register("minecraft:brick"); + public static final ItemType BRICK_SLAB = register("minecraft:brick_slab"); + public static final ItemType BRICK_STAIRS = register("minecraft:brick_stairs"); + public static final ItemType BRICKS = register("minecraft:bricks"); + public static final ItemType BROWN_BANNER = register("minecraft:brown_banner"); + public static final ItemType BROWN_BED = register("minecraft:brown_bed"); + public static final ItemType BROWN_CARPET = register("minecraft:brown_carpet"); + public static final ItemType BROWN_CONCRETE = register("minecraft:brown_concrete"); + public static final ItemType BROWN_CONCRETE_POWDER = register("minecraft:brown_concrete_powder"); + public static final ItemType BROWN_GLAZED_TERRACOTTA = register("minecraft:brown_glazed_terracotta"); + public static final ItemType BROWN_MUSHROOM = register("minecraft:brown_mushroom"); + public static final ItemType BROWN_MUSHROOM_BLOCK = register("minecraft:brown_mushroom_block"); + public static final ItemType BROWN_SHULKER_BOX = register("minecraft:brown_shulker_box"); + public static final ItemType BROWN_STAINED_GLASS = register("minecraft:brown_stained_glass"); + public static final ItemType BROWN_STAINED_GLASS_PANE = register("minecraft:brown_stained_glass_pane"); + public static final ItemType BROWN_TERRACOTTA = register("minecraft:brown_terracotta"); + public static final ItemType BROWN_WOOL = register("minecraft:brown_wool"); + public static final ItemType BUBBLE_CORAL = register("minecraft:bubble_coral"); + public static final ItemType BUBBLE_CORAL_BLOCK = register("minecraft:bubble_coral_block"); + public static final ItemType BUBBLE_CORAL_FAN = register("minecraft:bubble_coral_fan"); + public static final ItemType BUCKET = register("minecraft:bucket"); + public static final ItemType CACTUS = register("minecraft:cactus"); + public static final ItemType CACTUS_GREEN = register("minecraft:cactus_green"); + public static final ItemType CAKE = register("minecraft:cake"); + public static final ItemType CARROT = register("minecraft:carrot"); + public static final ItemType CARROT_ON_A_STICK = register("minecraft:carrot_on_a_stick"); + public static final ItemType CARVED_PUMPKIN = register("minecraft:carved_pumpkin"); + public static final ItemType CAULDRON = register("minecraft:cauldron"); + public static final ItemType CAVE_SPIDER_SPAWN_EGG = register("minecraft:cave_spider_spawn_egg"); + public static final ItemType CHAIN_COMMAND_BLOCK = register("minecraft:chain_command_block"); + public static final ItemType CHAINMAIL_BOOTS = register("minecraft:chainmail_boots"); + public static final ItemType CHAINMAIL_CHESTPLATE = register("minecraft:chainmail_chestplate"); + public static final ItemType CHAINMAIL_HELMET = register("minecraft:chainmail_helmet"); + public static final ItemType CHAINMAIL_LEGGINGS = register("minecraft:chainmail_leggings"); + public static final ItemType CHARCOAL = register("minecraft:charcoal"); + public static final ItemType CHEST = register("minecraft:chest"); + public static final ItemType CHEST_MINECART = register("minecraft:chest_minecart"); + public static final ItemType CHICKEN = register("minecraft:chicken"); + public static final ItemType CHICKEN_SPAWN_EGG = register("minecraft:chicken_spawn_egg"); + public static final ItemType CHIPPED_ANVIL = register("minecraft:chipped_anvil"); + public static final ItemType CHISELED_QUARTZ_BLOCK = register("minecraft:chiseled_quartz_block"); + public static final ItemType CHISELED_RED_SANDSTONE = register("minecraft:chiseled_red_sandstone"); + public static final ItemType CHISELED_SANDSTONE = register("minecraft:chiseled_sandstone"); + public static final ItemType CHISELED_STONE_BRICKS = register("minecraft:chiseled_stone_bricks"); + public static final ItemType CHORUS_FLOWER = register("minecraft:chorus_flower"); + public static final ItemType CHORUS_FRUIT = register("minecraft:chorus_fruit"); + public static final ItemType CHORUS_PLANT = register("minecraft:chorus_plant"); + public static final ItemType CLAY = register("minecraft:clay"); + public static final ItemType CLAY_BALL = register("minecraft:clay_ball"); + public static final ItemType CLOCK = register("minecraft:clock"); + public static final ItemType COAL = register("minecraft:coal"); + public static final ItemType COAL_BLOCK = register("minecraft:coal_block"); + public static final ItemType COAL_ORE = register("minecraft:coal_ore"); + public static final ItemType COARSE_DIRT = register("minecraft:coarse_dirt"); + public static final ItemType COBBLESTONE = register("minecraft:cobblestone"); + public static final ItemType COBBLESTONE_SLAB = register("minecraft:cobblestone_slab"); + public static final ItemType COBBLESTONE_STAIRS = register("minecraft:cobblestone_stairs"); + public static final ItemType COBBLESTONE_WALL = register("minecraft:cobblestone_wall"); + public static final ItemType COBWEB = register("minecraft:cobweb"); + public static final ItemType COCOA_BEANS = register("minecraft:cocoa_beans"); + public static final ItemType COD = register("minecraft:cod"); + public static final ItemType COD_BUCKET = register("minecraft:cod_bucket"); + public static final ItemType COD_SPAWN_EGG = register("minecraft:cod_spawn_egg"); + public static final ItemType COMMAND_BLOCK = register("minecraft:command_block"); + public static final ItemType COMMAND_BLOCK_MINECART = register("minecraft:command_block_minecart"); + public static final ItemType COMPARATOR = register("minecraft:comparator"); + public static final ItemType COMPASS = register("minecraft:compass"); + public static final ItemType CONDUIT = register("minecraft:conduit"); + public static final ItemType COOKED_BEEF = register("minecraft:cooked_beef"); + public static final ItemType COOKED_CHICKEN = register("minecraft:cooked_chicken"); + public static final ItemType COOKED_COD = register("minecraft:cooked_cod"); + public static final ItemType COOKED_MUTTON = register("minecraft:cooked_mutton"); + public static final ItemType COOKED_PORKCHOP = register("minecraft:cooked_porkchop"); + public static final ItemType COOKED_RABBIT = register("minecraft:cooked_rabbit"); + public static final ItemType COOKED_SALMON = register("minecraft:cooked_salmon"); + public static final ItemType COOKIE = register("minecraft:cookie"); + public static final ItemType COW_SPAWN_EGG = register("minecraft:cow_spawn_egg"); + public static final ItemType CRACKED_STONE_BRICKS = register("minecraft:cracked_stone_bricks"); + public static final ItemType CRAFTING_TABLE = register("minecraft:crafting_table"); + public static final ItemType CREEPER_HEAD = register("minecraft:creeper_head"); + public static final ItemType CREEPER_SPAWN_EGG = register("minecraft:creeper_spawn_egg"); + public static final ItemType CUT_RED_SANDSTONE = register("minecraft:cut_red_sandstone"); + public static final ItemType CUT_SANDSTONE = register("minecraft:cut_sandstone"); + public static final ItemType CYAN_BANNER = register("minecraft:cyan_banner"); + public static final ItemType CYAN_BED = register("minecraft:cyan_bed"); + public static final ItemType CYAN_CARPET = register("minecraft:cyan_carpet"); + public static final ItemType CYAN_CONCRETE = register("minecraft:cyan_concrete"); + public static final ItemType CYAN_CONCRETE_POWDER = register("minecraft:cyan_concrete_powder"); + public static final ItemType CYAN_DYE = register("minecraft:cyan_dye"); + public static final ItemType CYAN_GLAZED_TERRACOTTA = register("minecraft:cyan_glazed_terracotta"); + public static final ItemType CYAN_SHULKER_BOX = register("minecraft:cyan_shulker_box"); + public static final ItemType CYAN_STAINED_GLASS = register("minecraft:cyan_stained_glass"); + public static final ItemType CYAN_STAINED_GLASS_PANE = register("minecraft:cyan_stained_glass_pane"); + public static final ItemType CYAN_TERRACOTTA = register("minecraft:cyan_terracotta"); + public static final ItemType CYAN_WOOL = register("minecraft:cyan_wool"); + public static final ItemType DAMAGED_ANVIL = register("minecraft:damaged_anvil"); + public static final ItemType DANDELION = register("minecraft:dandelion"); + public static final ItemType DANDELION_YELLOW = register("minecraft:dandelion_yellow"); + public static final ItemType DARK_OAK_BOAT = register("minecraft:dark_oak_boat"); + public static final ItemType DARK_OAK_BUTTON = register("minecraft:dark_oak_button"); + public static final ItemType DARK_OAK_DOOR = register("minecraft:dark_oak_door"); + public static final ItemType DARK_OAK_FENCE = register("minecraft:dark_oak_fence"); + public static final ItemType DARK_OAK_FENCE_GATE = register("minecraft:dark_oak_fence_gate"); + public static final ItemType DARK_OAK_LEAVES = register("minecraft:dark_oak_leaves"); + public static final ItemType DARK_OAK_LOG = register("minecraft:dark_oak_log"); + public static final ItemType DARK_OAK_PLANKS = register("minecraft:dark_oak_planks"); + public static final ItemType DARK_OAK_PRESSURE_PLATE = register("minecraft:dark_oak_pressure_plate"); + public static final ItemType DARK_OAK_SAPLING = register("minecraft:dark_oak_sapling"); + public static final ItemType DARK_OAK_SLAB = register("minecraft:dark_oak_slab"); + public static final ItemType DARK_OAK_STAIRS = register("minecraft:dark_oak_stairs"); + public static final ItemType DARK_OAK_TRAPDOOR = register("minecraft:dark_oak_trapdoor"); + public static final ItemType DARK_OAK_WOOD = register("minecraft:dark_oak_wood"); + public static final ItemType DARK_PRISMARINE = register("minecraft:dark_prismarine"); + public static final ItemType DARK_PRISMARINE_SLAB = register("minecraft:dark_prismarine_slab"); + public static final ItemType DARK_PRISMARINE_STAIRS = register("minecraft:dark_prismarine_stairs"); + public static final ItemType DAYLIGHT_DETECTOR = register("minecraft:daylight_detector"); + public static final ItemType DEAD_BRAIN_CORAL = register("minecraft:dead_brain_coral"); + public static final ItemType DEAD_BRAIN_CORAL_BLOCK = register("minecraft:dead_brain_coral_block"); + public static final ItemType DEAD_BRAIN_CORAL_FAN = register("minecraft:dead_brain_coral_fan"); + public static final ItemType DEAD_BUBBLE_CORAL = register("minecraft:dead_bubble_coral"); + public static final ItemType DEAD_BUBBLE_CORAL_BLOCK = register("minecraft:dead_bubble_coral_block"); + public static final ItemType DEAD_BUBBLE_CORAL_FAN = register("minecraft:dead_bubble_coral_fan"); + public static final ItemType DEAD_BUSH = register("minecraft:dead_bush"); + public static final ItemType DEAD_FIRE_CORAL = register("minecraft:dead_fire_coral"); + public static final ItemType DEAD_FIRE_CORAL_BLOCK = register("minecraft:dead_fire_coral_block"); + public static final ItemType DEAD_FIRE_CORAL_FAN = register("minecraft:dead_fire_coral_fan"); + public static final ItemType DEAD_HORN_CORAL = register("minecraft:dead_horn_coral"); + public static final ItemType DEAD_HORN_CORAL_BLOCK = register("minecraft:dead_horn_coral_block"); + public static final ItemType DEAD_HORN_CORAL_FAN = register("minecraft:dead_horn_coral_fan"); + public static final ItemType DEAD_TUBE_CORAL = register("minecraft:dead_tube_coral"); + public static final ItemType DEAD_TUBE_CORAL_BLOCK = register("minecraft:dead_tube_coral_block"); + public static final ItemType DEAD_TUBE_CORAL_FAN = register("minecraft:dead_tube_coral_fan"); + public static final ItemType DEBUG_STICK = register("minecraft:debug_stick"); + public static final ItemType DETECTOR_RAIL = register("minecraft:detector_rail"); + public static final ItemType DIAMOND = register("minecraft:diamond"); + public static final ItemType DIAMOND_AXE = register("minecraft:diamond_axe"); + public static final ItemType DIAMOND_BLOCK = register("minecraft:diamond_block"); + public static final ItemType DIAMOND_BOOTS = register("minecraft:diamond_boots"); + public static final ItemType DIAMOND_CHESTPLATE = register("minecraft:diamond_chestplate"); + public static final ItemType DIAMOND_HELMET = register("minecraft:diamond_helmet"); + public static final ItemType DIAMOND_HOE = register("minecraft:diamond_hoe"); + public static final ItemType DIAMOND_HORSE_ARMOR = register("minecraft:diamond_horse_armor"); + public static final ItemType DIAMOND_LEGGINGS = register("minecraft:diamond_leggings"); + public static final ItemType DIAMOND_ORE = register("minecraft:diamond_ore"); + public static final ItemType DIAMOND_PICKAXE = register("minecraft:diamond_pickaxe"); + public static final ItemType DIAMOND_SHOVEL = register("minecraft:diamond_shovel"); + public static final ItemType DIAMOND_SWORD = register("minecraft:diamond_sword"); + public static final ItemType DIORITE = register("minecraft:diorite"); + public static final ItemType DIRT = register("minecraft:dirt"); + public static final ItemType DISPENSER = register("minecraft:dispenser"); + public static final ItemType DOLPHIN_SPAWN_EGG = register("minecraft:dolphin_spawn_egg"); + public static final ItemType DONKEY_SPAWN_EGG = register("minecraft:donkey_spawn_egg"); + public static final ItemType DRAGON_BREATH = register("minecraft:dragon_breath"); + public static final ItemType DRAGON_EGG = register("minecraft:dragon_egg"); + public static final ItemType DRAGON_HEAD = register("minecraft:dragon_head"); + public static final ItemType DRIED_KELP = register("minecraft:dried_kelp"); + public static final ItemType DRIED_KELP_BLOCK = register("minecraft:dried_kelp_block"); + public static final ItemType DROPPER = register("minecraft:dropper"); + public static final ItemType DROWNED_SPAWN_EGG = register("minecraft:drowned_spawn_egg"); + public static final ItemType EGG = register("minecraft:egg"); + public static final ItemType ELDER_GUARDIAN_SPAWN_EGG = register("minecraft:elder_guardian_spawn_egg"); + public static final ItemType ELYTRA = register("minecraft:elytra"); + public static final ItemType EMERALD = register("minecraft:emerald"); + public static final ItemType EMERALD_BLOCK = register("minecraft:emerald_block"); + public static final ItemType EMERALD_ORE = register("minecraft:emerald_ore"); + public static final ItemType ENCHANTED_BOOK = register("minecraft:enchanted_book"); + public static final ItemType ENCHANTED_GOLDEN_APPLE = register("minecraft:enchanted_golden_apple"); + public static final ItemType ENCHANTING_TABLE = register("minecraft:enchanting_table"); + public static final ItemType END_CRYSTAL = register("minecraft:end_crystal"); + public static final ItemType END_PORTAL_FRAME = register("minecraft:end_portal_frame"); + public static final ItemType END_ROD = register("minecraft:end_rod"); + public static final ItemType END_STONE = register("minecraft:end_stone"); + public static final ItemType END_STONE_BRICKS = register("minecraft:end_stone_bricks"); + public static final ItemType ENDER_CHEST = register("minecraft:ender_chest"); + public static final ItemType ENDER_EYE = register("minecraft:ender_eye"); + public static final ItemType ENDER_PEARL = register("minecraft:ender_pearl"); + public static final ItemType ENDERMAN_SPAWN_EGG = register("minecraft:enderman_spawn_egg"); + public static final ItemType ENDERMITE_SPAWN_EGG = register("minecraft:endermite_spawn_egg"); + public static final ItemType EVOKER_SPAWN_EGG = register("minecraft:evoker_spawn_egg"); + public static final ItemType EXPERIENCE_BOTTLE = register("minecraft:experience_bottle"); + public static final ItemType FARMLAND = register("minecraft:farmland"); + public static final ItemType FEATHER = register("minecraft:feather"); + public static final ItemType FERMENTED_SPIDER_EYE = register("minecraft:fermented_spider_eye"); + public static final ItemType FERN = register("minecraft:fern"); + public static final ItemType FILLED_MAP = register("minecraft:filled_map"); + public static final ItemType FIRE_CHARGE = register("minecraft:fire_charge"); + public static final ItemType FIRE_CORAL = register("minecraft:fire_coral"); + public static final ItemType FIRE_CORAL_BLOCK = register("minecraft:fire_coral_block"); + public static final ItemType FIRE_CORAL_FAN = register("minecraft:fire_coral_fan"); + public static final ItemType FIREWORK_ROCKET = register("minecraft:firework_rocket"); + public static final ItemType FIREWORK_STAR = register("minecraft:firework_star"); + public static final ItemType FISHING_ROD = register("minecraft:fishing_rod"); + public static final ItemType FLINT = register("minecraft:flint"); + public static final ItemType FLINT_AND_STEEL = register("minecraft:flint_and_steel"); + public static final ItemType FLOWER_POT = register("minecraft:flower_pot"); + public static final ItemType FURNACE = register("minecraft:furnace"); + public static final ItemType FURNACE_MINECART = register("minecraft:furnace_minecart"); + public static final ItemType GHAST_SPAWN_EGG = register("minecraft:ghast_spawn_egg"); + public static final ItemType GHAST_TEAR = register("minecraft:ghast_tear"); + public static final ItemType GLASS = register("minecraft:glass"); + public static final ItemType GLASS_BOTTLE = register("minecraft:glass_bottle"); + public static final ItemType GLASS_PANE = register("minecraft:glass_pane"); + public static final ItemType GLISTERING_MELON_SLICE = register("minecraft:glistering_melon_slice"); + public static final ItemType GLOWSTONE = register("minecraft:glowstone"); + public static final ItemType GLOWSTONE_DUST = register("minecraft:glowstone_dust"); + public static final ItemType GOLD_BLOCK = register("minecraft:gold_block"); + public static final ItemType GOLD_INGOT = register("minecraft:gold_ingot"); + public static final ItemType GOLD_NUGGET = register("minecraft:gold_nugget"); + public static final ItemType GOLD_ORE = register("minecraft:gold_ore"); + public static final ItemType GOLDEN_APPLE = register("minecraft:golden_apple"); + public static final ItemType GOLDEN_AXE = register("minecraft:golden_axe"); + public static final ItemType GOLDEN_BOOTS = register("minecraft:golden_boots"); + public static final ItemType GOLDEN_CARROT = register("minecraft:golden_carrot"); + public static final ItemType GOLDEN_CHESTPLATE = register("minecraft:golden_chestplate"); + public static final ItemType GOLDEN_HELMET = register("minecraft:golden_helmet"); + public static final ItemType GOLDEN_HOE = register("minecraft:golden_hoe"); + public static final ItemType GOLDEN_HORSE_ARMOR = register("minecraft:golden_horse_armor"); + public static final ItemType GOLDEN_LEGGINGS = register("minecraft:golden_leggings"); + public static final ItemType GOLDEN_PICKAXE = register("minecraft:golden_pickaxe"); + public static final ItemType GOLDEN_SHOVEL = register("minecraft:golden_shovel"); + public static final ItemType GOLDEN_SWORD = register("minecraft:golden_sword"); + public static final ItemType GRANITE = register("minecraft:granite"); + public static final ItemType GRASS = register("minecraft:grass"); + public static final ItemType GRASS_BLOCK = register("minecraft:grass_block"); + public static final ItemType GRASS_PATH = register("minecraft:grass_path"); + public static final ItemType GRAVEL = register("minecraft:gravel"); + public static final ItemType GRAY_BANNER = register("minecraft:gray_banner"); + public static final ItemType GRAY_BED = register("minecraft:gray_bed"); + public static final ItemType GRAY_CARPET = register("minecraft:gray_carpet"); + public static final ItemType GRAY_CONCRETE = register("minecraft:gray_concrete"); + public static final ItemType GRAY_CONCRETE_POWDER = register("minecraft:gray_concrete_powder"); + public static final ItemType GRAY_DYE = register("minecraft:gray_dye"); + public static final ItemType GRAY_GLAZED_TERRACOTTA = register("minecraft:gray_glazed_terracotta"); + public static final ItemType GRAY_SHULKER_BOX = register("minecraft:gray_shulker_box"); + public static final ItemType GRAY_STAINED_GLASS = register("minecraft:gray_stained_glass"); + public static final ItemType GRAY_STAINED_GLASS_PANE = register("minecraft:gray_stained_glass_pane"); + public static final ItemType GRAY_TERRACOTTA = register("minecraft:gray_terracotta"); + public static final ItemType GRAY_WOOL = register("minecraft:gray_wool"); + public static final ItemType GREEN_BANNER = register("minecraft:green_banner"); + public static final ItemType GREEN_BED = register("minecraft:green_bed"); + public static final ItemType GREEN_CARPET = register("minecraft:green_carpet"); + public static final ItemType GREEN_CONCRETE = register("minecraft:green_concrete"); + public static final ItemType GREEN_CONCRETE_POWDER = register("minecraft:green_concrete_powder"); + public static final ItemType GREEN_GLAZED_TERRACOTTA = register("minecraft:green_glazed_terracotta"); + public static final ItemType GREEN_SHULKER_BOX = register("minecraft:green_shulker_box"); + public static final ItemType GREEN_STAINED_GLASS = register("minecraft:green_stained_glass"); + public static final ItemType GREEN_STAINED_GLASS_PANE = register("minecraft:green_stained_glass_pane"); + public static final ItemType GREEN_TERRACOTTA = register("minecraft:green_terracotta"); + public static final ItemType GREEN_WOOL = register("minecraft:green_wool"); + public static final ItemType GUARDIAN_SPAWN_EGG = register("minecraft:guardian_spawn_egg"); + public static final ItemType GUNPOWDER = register("minecraft:gunpowder"); + public static final ItemType HAY_BLOCK = register("minecraft:hay_block"); + public static final ItemType HEART_OF_THE_SEA = register("minecraft:heart_of_the_sea"); + public static final ItemType HEAVY_WEIGHTED_PRESSURE_PLATE = register("minecraft:heavy_weighted_pressure_plate"); + public static final ItemType HOPPER = register("minecraft:hopper"); + public static final ItemType HOPPER_MINECART = register("minecraft:hopper_minecart"); + public static final ItemType HORN_CORAL = register("minecraft:horn_coral"); + public static final ItemType HORN_CORAL_BLOCK = register("minecraft:horn_coral_block"); + public static final ItemType HORN_CORAL_FAN = register("minecraft:horn_coral_fan"); + public static final ItemType HORSE_SPAWN_EGG = register("minecraft:horse_spawn_egg"); + public static final ItemType HUSK_SPAWN_EGG = register("minecraft:husk_spawn_egg"); + public static final ItemType ICE = register("minecraft:ice"); + public static final ItemType INFESTED_CHISELED_STONE_BRICKS = register("minecraft:infested_chiseled_stone_bricks"); + public static final ItemType INFESTED_COBBLESTONE = register("minecraft:infested_cobblestone"); + public static final ItemType INFESTED_CRACKED_STONE_BRICKS = register("minecraft:infested_cracked_stone_bricks"); + public static final ItemType INFESTED_MOSSY_STONE_BRICKS = register("minecraft:infested_mossy_stone_bricks"); + public static final ItemType INFESTED_STONE = register("minecraft:infested_stone"); + public static final ItemType INFESTED_STONE_BRICKS = register("minecraft:infested_stone_bricks"); + public static final ItemType INK_SAC = register("minecraft:ink_sac"); + public static final ItemType IRON_AXE = register("minecraft:iron_axe"); + public static final ItemType IRON_BARS = register("minecraft:iron_bars"); + public static final ItemType IRON_BLOCK = register("minecraft:iron_block"); + public static final ItemType IRON_BOOTS = register("minecraft:iron_boots"); + public static final ItemType IRON_CHESTPLATE = register("minecraft:iron_chestplate"); + public static final ItemType IRON_DOOR = register("minecraft:iron_door"); + public static final ItemType IRON_HELMET = register("minecraft:iron_helmet"); + public static final ItemType IRON_HOE = register("minecraft:iron_hoe"); + public static final ItemType IRON_HORSE_ARMOR = register("minecraft:iron_horse_armor"); + public static final ItemType IRON_INGOT = register("minecraft:iron_ingot"); + public static final ItemType IRON_LEGGINGS = register("minecraft:iron_leggings"); + public static final ItemType IRON_NUGGET = register("minecraft:iron_nugget"); + public static final ItemType IRON_ORE = register("minecraft:iron_ore"); + public static final ItemType IRON_PICKAXE = register("minecraft:iron_pickaxe"); + public static final ItemType IRON_SHOVEL = register("minecraft:iron_shovel"); + public static final ItemType IRON_SWORD = register("minecraft:iron_sword"); + public static final ItemType IRON_TRAPDOOR = register("minecraft:iron_trapdoor"); + public static final ItemType ITEM_FRAME = register("minecraft:item_frame"); + public static final ItemType JACK_O_LANTERN = register("minecraft:jack_o_lantern"); + public static final ItemType JUKEBOX = register("minecraft:jukebox"); + public static final ItemType JUNGLE_BOAT = register("minecraft:jungle_boat"); + public static final ItemType JUNGLE_BUTTON = register("minecraft:jungle_button"); + public static final ItemType JUNGLE_DOOR = register("minecraft:jungle_door"); + public static final ItemType JUNGLE_FENCE = register("minecraft:jungle_fence"); + public static final ItemType JUNGLE_FENCE_GATE = register("minecraft:jungle_fence_gate"); + public static final ItemType JUNGLE_LEAVES = register("minecraft:jungle_leaves"); + public static final ItemType JUNGLE_LOG = register("minecraft:jungle_log"); + public static final ItemType JUNGLE_PLANKS = register("minecraft:jungle_planks"); + public static final ItemType JUNGLE_PRESSURE_PLATE = register("minecraft:jungle_pressure_plate"); + public static final ItemType JUNGLE_SAPLING = register("minecraft:jungle_sapling"); + public static final ItemType JUNGLE_SLAB = register("minecraft:jungle_slab"); + public static final ItemType JUNGLE_STAIRS = register("minecraft:jungle_stairs"); + public static final ItemType JUNGLE_TRAPDOOR = register("minecraft:jungle_trapdoor"); + public static final ItemType JUNGLE_WOOD = register("minecraft:jungle_wood"); + public static final ItemType KELP = register("minecraft:kelp"); + public static final ItemType KNOWLEDGE_BOOK = register("minecraft:knowledge_book"); + public static final ItemType LADDER = register("minecraft:ladder"); + public static final ItemType LAPIS_BLOCK = register("minecraft:lapis_block"); + public static final ItemType LAPIS_LAZULI = register("minecraft:lapis_lazuli"); + public static final ItemType LAPIS_ORE = register("minecraft:lapis_ore"); + public static final ItemType LARGE_FERN = register("minecraft:large_fern"); + public static final ItemType LAVA_BUCKET = register("minecraft:lava_bucket"); + public static final ItemType LEAD = register("minecraft:lead"); + public static final ItemType LEATHER = register("minecraft:leather"); + public static final ItemType LEATHER_BOOTS = register("minecraft:leather_boots"); + public static final ItemType LEATHER_CHESTPLATE = register("minecraft:leather_chestplate"); + public static final ItemType LEATHER_HELMET = register("minecraft:leather_helmet"); + public static final ItemType LEATHER_LEGGINGS = register("minecraft:leather_leggings"); + public static final ItemType LEVER = register("minecraft:lever"); + public static final ItemType LIGHT_BLUE_BANNER = register("minecraft:light_blue_banner"); + public static final ItemType LIGHT_BLUE_BED = register("minecraft:light_blue_bed"); + public static final ItemType LIGHT_BLUE_CARPET = register("minecraft:light_blue_carpet"); + public static final ItemType LIGHT_BLUE_CONCRETE = register("minecraft:light_blue_concrete"); + public static final ItemType LIGHT_BLUE_CONCRETE_POWDER = register("minecraft:light_blue_concrete_powder"); + public static final ItemType LIGHT_BLUE_DYE = register("minecraft:light_blue_dye"); + public static final ItemType LIGHT_BLUE_GLAZED_TERRACOTTA = register("minecraft:light_blue_glazed_terracotta"); + public static final ItemType LIGHT_BLUE_SHULKER_BOX = register("minecraft:light_blue_shulker_box"); + public static final ItemType LIGHT_BLUE_STAINED_GLASS = register("minecraft:light_blue_stained_glass"); + public static final ItemType LIGHT_BLUE_STAINED_GLASS_PANE = register("minecraft:light_blue_stained_glass_pane"); + public static final ItemType LIGHT_BLUE_TERRACOTTA = register("minecraft:light_blue_terracotta"); + public static final ItemType LIGHT_BLUE_WOOL = register("minecraft:light_blue_wool"); + public static final ItemType LIGHT_GRAY_BANNER = register("minecraft:light_gray_banner"); + public static final ItemType LIGHT_GRAY_BED = register("minecraft:light_gray_bed"); + public static final ItemType LIGHT_GRAY_CARPET = register("minecraft:light_gray_carpet"); + public static final ItemType LIGHT_GRAY_CONCRETE = register("minecraft:light_gray_concrete"); + public static final ItemType LIGHT_GRAY_CONCRETE_POWDER = register("minecraft:light_gray_concrete_powder"); + public static final ItemType LIGHT_GRAY_DYE = register("minecraft:light_gray_dye"); + public static final ItemType LIGHT_GRAY_GLAZED_TERRACOTTA = register("minecraft:light_gray_glazed_terracotta"); + public static final ItemType LIGHT_GRAY_SHULKER_BOX = register("minecraft:light_gray_shulker_box"); + public static final ItemType LIGHT_GRAY_STAINED_GLASS = register("minecraft:light_gray_stained_glass"); + public static final ItemType LIGHT_GRAY_STAINED_GLASS_PANE = register("minecraft:light_gray_stained_glass_pane"); + public static final ItemType LIGHT_GRAY_TERRACOTTA = register("minecraft:light_gray_terracotta"); + public static final ItemType LIGHT_GRAY_WOOL = register("minecraft:light_gray_wool"); + public static final ItemType LIGHT_WEIGHTED_PRESSURE_PLATE = register("minecraft:light_weighted_pressure_plate"); + public static final ItemType LILAC = register("minecraft:lilac"); + public static final ItemType LILY_PAD = register("minecraft:lily_pad"); + public static final ItemType LIME_BANNER = register("minecraft:lime_banner"); + public static final ItemType LIME_BED = register("minecraft:lime_bed"); + public static final ItemType LIME_CARPET = register("minecraft:lime_carpet"); + public static final ItemType LIME_CONCRETE = register("minecraft:lime_concrete"); + public static final ItemType LIME_CONCRETE_POWDER = register("minecraft:lime_concrete_powder"); + public static final ItemType LIME_DYE = register("minecraft:lime_dye"); + public static final ItemType LIME_GLAZED_TERRACOTTA = register("minecraft:lime_glazed_terracotta"); + public static final ItemType LIME_SHULKER_BOX = register("minecraft:lime_shulker_box"); + public static final ItemType LIME_STAINED_GLASS = register("minecraft:lime_stained_glass"); + public static final ItemType LIME_STAINED_GLASS_PANE = register("minecraft:lime_stained_glass_pane"); + public static final ItemType LIME_TERRACOTTA = register("minecraft:lime_terracotta"); + public static final ItemType LIME_WOOL = register("minecraft:lime_wool"); + public static final ItemType LINGERING_POTION = register("minecraft:lingering_potion"); + public static final ItemType LLAMA_SPAWN_EGG = register("minecraft:llama_spawn_egg"); + public static final ItemType MAGENTA_BANNER = register("minecraft:magenta_banner"); + public static final ItemType MAGENTA_BED = register("minecraft:magenta_bed"); + public static final ItemType MAGENTA_CARPET = register("minecraft:magenta_carpet"); + public static final ItemType MAGENTA_CONCRETE = register("minecraft:magenta_concrete"); + public static final ItemType MAGENTA_CONCRETE_POWDER = register("minecraft:magenta_concrete_powder"); + public static final ItemType MAGENTA_DYE = register("minecraft:magenta_dye"); + public static final ItemType MAGENTA_GLAZED_TERRACOTTA = register("minecraft:magenta_glazed_terracotta"); + public static final ItemType MAGENTA_SHULKER_BOX = register("minecraft:magenta_shulker_box"); + public static final ItemType MAGENTA_STAINED_GLASS = register("minecraft:magenta_stained_glass"); + public static final ItemType MAGENTA_STAINED_GLASS_PANE = register("minecraft:magenta_stained_glass_pane"); + public static final ItemType MAGENTA_TERRACOTTA = register("minecraft:magenta_terracotta"); + public static final ItemType MAGENTA_WOOL = register("minecraft:magenta_wool"); + public static final ItemType MAGMA_BLOCK = register("minecraft:magma_block"); + public static final ItemType MAGMA_CREAM = register("minecraft:magma_cream"); + public static final ItemType MAGMA_CUBE_SPAWN_EGG = register("minecraft:magma_cube_spawn_egg"); + public static final ItemType MAP = register("minecraft:map"); + public static final ItemType MELON = register("minecraft:melon"); + public static final ItemType MELON_SEEDS = register("minecraft:melon_seeds"); + public static final ItemType MELON_SLICE = register("minecraft:melon_slice"); + public static final ItemType MILK_BUCKET = register("minecraft:milk_bucket"); + public static final ItemType MINECART = register("minecraft:minecart"); + public static final ItemType MOOSHROOM_SPAWN_EGG = register("minecraft:mooshroom_spawn_egg"); + public static final ItemType MOSSY_COBBLESTONE = register("minecraft:mossy_cobblestone"); + public static final ItemType MOSSY_COBBLESTONE_WALL = register("minecraft:mossy_cobblestone_wall"); + public static final ItemType MOSSY_STONE_BRICKS = register("minecraft:mossy_stone_bricks"); + public static final ItemType MULE_SPAWN_EGG = register("minecraft:mule_spawn_egg"); + public static final ItemType MUSHROOM_STEM = register("minecraft:mushroom_stem"); + public static final ItemType MUSHROOM_STEW = register("minecraft:mushroom_stew"); + public static final ItemType MUSIC_DISC_11 = register("minecraft:music_disc_11"); + public static final ItemType MUSIC_DISC_13 = register("minecraft:music_disc_13"); + public static final ItemType MUSIC_DISC_BLOCKS = register("minecraft:music_disc_blocks"); + public static final ItemType MUSIC_DISC_CAT = register("minecraft:music_disc_cat"); + public static final ItemType MUSIC_DISC_CHIRP = register("minecraft:music_disc_chirp"); + public static final ItemType MUSIC_DISC_FAR = register("minecraft:music_disc_far"); + public static final ItemType MUSIC_DISC_MALL = register("minecraft:music_disc_mall"); + public static final ItemType MUSIC_DISC_MELLOHI = register("minecraft:music_disc_mellohi"); + public static final ItemType MUSIC_DISC_STAL = register("minecraft:music_disc_stal"); + public static final ItemType MUSIC_DISC_STRAD = register("minecraft:music_disc_strad"); + public static final ItemType MUSIC_DISC_WAIT = register("minecraft:music_disc_wait"); + public static final ItemType MUSIC_DISC_WARD = register("minecraft:music_disc_ward"); + public static final ItemType MUTTON = register("minecraft:mutton"); + public static final ItemType MYCELIUM = register("minecraft:mycelium"); + public static final ItemType NAME_TAG = register("minecraft:name_tag"); + public static final ItemType NAUTILUS_SHELL = register("minecraft:nautilus_shell"); + public static final ItemType NETHER_BRICK = register("minecraft:nether_brick"); + public static final ItemType NETHER_BRICK_FENCE = register("minecraft:nether_brick_fence"); + public static final ItemType NETHER_BRICK_SLAB = register("minecraft:nether_brick_slab"); + public static final ItemType NETHER_BRICK_STAIRS = register("minecraft:nether_brick_stairs"); + public static final ItemType NETHER_BRICKS = register("minecraft:nether_bricks"); + public static final ItemType NETHER_QUARTZ_ORE = register("minecraft:nether_quartz_ore"); + public static final ItemType NETHER_STAR = register("minecraft:nether_star"); + public static final ItemType NETHER_WART = register("minecraft:nether_wart"); + public static final ItemType NETHER_WART_BLOCK = register("minecraft:nether_wart_block"); + public static final ItemType NETHERRACK = register("minecraft:netherrack"); + public static final ItemType NOTE_BLOCK = register("minecraft:note_block"); + public static final ItemType OAK_BOAT = register("minecraft:oak_boat"); + public static final ItemType OAK_BUTTON = register("minecraft:oak_button"); + public static final ItemType OAK_DOOR = register("minecraft:oak_door"); + public static final ItemType OAK_FENCE = register("minecraft:oak_fence"); + public static final ItemType OAK_FENCE_GATE = register("minecraft:oak_fence_gate"); + public static final ItemType OAK_LEAVES = register("minecraft:oak_leaves"); + public static final ItemType OAK_LOG = register("minecraft:oak_log"); + public static final ItemType OAK_PLANKS = register("minecraft:oak_planks"); + public static final ItemType OAK_PRESSURE_PLATE = register("minecraft:oak_pressure_plate"); + public static final ItemType OAK_SAPLING = register("minecraft:oak_sapling"); + public static final ItemType OAK_SLAB = register("minecraft:oak_slab"); + public static final ItemType OAK_STAIRS = register("minecraft:oak_stairs"); + public static final ItemType OAK_TRAPDOOR = register("minecraft:oak_trapdoor"); + public static final ItemType OAK_WOOD = register("minecraft:oak_wood"); + public static final ItemType OBSERVER = register("minecraft:observer"); + public static final ItemType OBSIDIAN = register("minecraft:obsidian"); + public static final ItemType OCELOT_SPAWN_EGG = register("minecraft:ocelot_spawn_egg"); + public static final ItemType ORANGE_BANNER = register("minecraft:orange_banner"); + public static final ItemType ORANGE_BED = register("minecraft:orange_bed"); + public static final ItemType ORANGE_CARPET = register("minecraft:orange_carpet"); + public static final ItemType ORANGE_CONCRETE = register("minecraft:orange_concrete"); + public static final ItemType ORANGE_CONCRETE_POWDER = register("minecraft:orange_concrete_powder"); + public static final ItemType ORANGE_DYE = register("minecraft:orange_dye"); + public static final ItemType ORANGE_GLAZED_TERRACOTTA = register("minecraft:orange_glazed_terracotta"); + public static final ItemType ORANGE_SHULKER_BOX = register("minecraft:orange_shulker_box"); + public static final ItemType ORANGE_STAINED_GLASS = register("minecraft:orange_stained_glass"); + public static final ItemType ORANGE_STAINED_GLASS_PANE = register("minecraft:orange_stained_glass_pane"); + public static final ItemType ORANGE_TERRACOTTA = register("minecraft:orange_terracotta"); + public static final ItemType ORANGE_TULIP = register("minecraft:orange_tulip"); + public static final ItemType ORANGE_WOOL = register("minecraft:orange_wool"); + public static final ItemType OXEYE_DAISY = register("minecraft:oxeye_daisy"); + public static final ItemType PACKED_ICE = register("minecraft:packed_ice"); + public static final ItemType PAINTING = register("minecraft:painting"); + public static final ItemType PAPER = register("minecraft:paper"); + public static final ItemType PARROT_SPAWN_EGG = register("minecraft:parrot_spawn_egg"); + public static final ItemType PEONY = register("minecraft:peony"); + public static final ItemType PETRIFIED_OAK_SLAB = register("minecraft:petrified_oak_slab"); + public static final ItemType PHANTOM_MEMBRANE = register("minecraft:phantom_membrane"); + public static final ItemType PHANTOM_SPAWN_EGG = register("minecraft:phantom_spawn_egg"); + public static final ItemType PIG_SPAWN_EGG = register("minecraft:pig_spawn_egg"); + public static final ItemType PINK_BANNER = register("minecraft:pink_banner"); + public static final ItemType PINK_BED = register("minecraft:pink_bed"); + public static final ItemType PINK_CARPET = register("minecraft:pink_carpet"); + public static final ItemType PINK_CONCRETE = register("minecraft:pink_concrete"); + public static final ItemType PINK_CONCRETE_POWDER = register("minecraft:pink_concrete_powder"); + public static final ItemType PINK_DYE = register("minecraft:pink_dye"); + public static final ItemType PINK_GLAZED_TERRACOTTA = register("minecraft:pink_glazed_terracotta"); + public static final ItemType PINK_SHULKER_BOX = register("minecraft:pink_shulker_box"); + public static final ItemType PINK_STAINED_GLASS = register("minecraft:pink_stained_glass"); + public static final ItemType PINK_STAINED_GLASS_PANE = register("minecraft:pink_stained_glass_pane"); + public static final ItemType PINK_TERRACOTTA = register("minecraft:pink_terracotta"); + public static final ItemType PINK_TULIP = register("minecraft:pink_tulip"); + public static final ItemType PINK_WOOL = register("minecraft:pink_wool"); + public static final ItemType PISTON = register("minecraft:piston"); + public static final ItemType PLAYER_HEAD = register("minecraft:player_head"); + public static final ItemType PODZOL = register("minecraft:podzol"); + public static final ItemType POISONOUS_POTATO = register("minecraft:poisonous_potato"); + public static final ItemType POLAR_BEAR_SPAWN_EGG = register("minecraft:polar_bear_spawn_egg"); + public static final ItemType POLISHED_ANDESITE = register("minecraft:polished_andesite"); + public static final ItemType POLISHED_DIORITE = register("minecraft:polished_diorite"); + public static final ItemType POLISHED_GRANITE = register("minecraft:polished_granite"); + public static final ItemType POPPED_CHORUS_FRUIT = register("minecraft:popped_chorus_fruit"); + public static final ItemType POPPY = register("minecraft:poppy"); + public static final ItemType PORKCHOP = register("minecraft:porkchop"); + public static final ItemType POTATO = register("minecraft:potato"); + public static final ItemType POTION = register("minecraft:potion"); + public static final ItemType POWERED_RAIL = register("minecraft:powered_rail"); + public static final ItemType PRISMARINE = register("minecraft:prismarine"); + public static final ItemType PRISMARINE_BRICK_SLAB = register("minecraft:prismarine_brick_slab"); + public static final ItemType PRISMARINE_BRICK_STAIRS = register("minecraft:prismarine_brick_stairs"); + public static final ItemType PRISMARINE_BRICKS = register("minecraft:prismarine_bricks"); + public static final ItemType PRISMARINE_CRYSTALS = register("minecraft:prismarine_crystals"); + public static final ItemType PRISMARINE_SHARD = register("minecraft:prismarine_shard"); + public static final ItemType PRISMARINE_SLAB = register("minecraft:prismarine_slab"); + public static final ItemType PRISMARINE_STAIRS = register("minecraft:prismarine_stairs"); + public static final ItemType PUFFERFISH = register("minecraft:pufferfish"); + public static final ItemType PUFFERFISH_BUCKET = register("minecraft:pufferfish_bucket"); + public static final ItemType PUFFERFISH_SPAWN_EGG = register("minecraft:pufferfish_spawn_egg"); + public static final ItemType PUMPKIN = register("minecraft:pumpkin"); + public static final ItemType PUMPKIN_PIE = register("minecraft:pumpkin_pie"); + public static final ItemType PUMPKIN_SEEDS = register("minecraft:pumpkin_seeds"); + public static final ItemType PURPLE_BANNER = register("minecraft:purple_banner"); + public static final ItemType PURPLE_BED = register("minecraft:purple_bed"); + public static final ItemType PURPLE_CARPET = register("minecraft:purple_carpet"); + public static final ItemType PURPLE_CONCRETE = register("minecraft:purple_concrete"); + public static final ItemType PURPLE_CONCRETE_POWDER = register("minecraft:purple_concrete_powder"); + public static final ItemType PURPLE_DYE = register("minecraft:purple_dye"); + public static final ItemType PURPLE_GLAZED_TERRACOTTA = register("minecraft:purple_glazed_terracotta"); + public static final ItemType PURPLE_SHULKER_BOX = register("minecraft:purple_shulker_box"); + public static final ItemType PURPLE_STAINED_GLASS = register("minecraft:purple_stained_glass"); + public static final ItemType PURPLE_STAINED_GLASS_PANE = register("minecraft:purple_stained_glass_pane"); + public static final ItemType PURPLE_TERRACOTTA = register("minecraft:purple_terracotta"); + public static final ItemType PURPLE_WOOL = register("minecraft:purple_wool"); + public static final ItemType PURPUR_BLOCK = register("minecraft:purpur_block"); + public static final ItemType PURPUR_PILLAR = register("minecraft:purpur_pillar"); + public static final ItemType PURPUR_SLAB = register("minecraft:purpur_slab"); + public static final ItemType PURPUR_STAIRS = register("minecraft:purpur_stairs"); + public static final ItemType QUARTZ = register("minecraft:quartz"); + public static final ItemType QUARTZ_BLOCK = register("minecraft:quartz_block"); + public static final ItemType QUARTZ_PILLAR = register("minecraft:quartz_pillar"); + public static final ItemType QUARTZ_SLAB = register("minecraft:quartz_slab"); + public static final ItemType QUARTZ_STAIRS = register("minecraft:quartz_stairs"); + public static final ItemType RABBIT = register("minecraft:rabbit"); + public static final ItemType RABBIT_FOOT = register("minecraft:rabbit_foot"); + public static final ItemType RABBIT_HIDE = register("minecraft:rabbit_hide"); + public static final ItemType RABBIT_SPAWN_EGG = register("minecraft:rabbit_spawn_egg"); + public static final ItemType RABBIT_STEW = register("minecraft:rabbit_stew"); + public static final ItemType RAIL = register("minecraft:rail"); + public static final ItemType RED_BANNER = register("minecraft:red_banner"); + public static final ItemType RED_BED = register("minecraft:red_bed"); + public static final ItemType RED_CARPET = register("minecraft:red_carpet"); + public static final ItemType RED_CONCRETE = register("minecraft:red_concrete"); + public static final ItemType RED_CONCRETE_POWDER = register("minecraft:red_concrete_powder"); + public static final ItemType RED_GLAZED_TERRACOTTA = register("minecraft:red_glazed_terracotta"); + public static final ItemType RED_MUSHROOM = register("minecraft:red_mushroom"); + public static final ItemType RED_MUSHROOM_BLOCK = register("minecraft:red_mushroom_block"); + public static final ItemType RED_NETHER_BRICKS = register("minecraft:red_nether_bricks"); + public static final ItemType RED_SAND = register("minecraft:red_sand"); + public static final ItemType RED_SANDSTONE = register("minecraft:red_sandstone"); + public static final ItemType RED_SANDSTONE_SLAB = register("minecraft:red_sandstone_slab"); + public static final ItemType RED_SANDSTONE_STAIRS = register("minecraft:red_sandstone_stairs"); + public static final ItemType RED_SHULKER_BOX = register("minecraft:red_shulker_box"); + public static final ItemType RED_STAINED_GLASS = register("minecraft:red_stained_glass"); + public static final ItemType RED_STAINED_GLASS_PANE = register("minecraft:red_stained_glass_pane"); + public static final ItemType RED_TERRACOTTA = register("minecraft:red_terracotta"); + public static final ItemType RED_TULIP = register("minecraft:red_tulip"); + public static final ItemType RED_WOOL = register("minecraft:red_wool"); + public static final ItemType REDSTONE = register("minecraft:redstone"); + public static final ItemType REDSTONE_BLOCK = register("minecraft:redstone_block"); + public static final ItemType REDSTONE_LAMP = register("minecraft:redstone_lamp"); + public static final ItemType REDSTONE_ORE = register("minecraft:redstone_ore"); + public static final ItemType REDSTONE_TORCH = register("minecraft:redstone_torch"); + public static final ItemType REPEATER = register("minecraft:repeater"); + public static final ItemType REPEATING_COMMAND_BLOCK = register("minecraft:repeating_command_block"); + public static final ItemType ROSE_BUSH = register("minecraft:rose_bush"); + public static final ItemType ROSE_RED = register("minecraft:rose_red"); + public static final ItemType ROTTEN_FLESH = register("minecraft:rotten_flesh"); + public static final ItemType SADDLE = register("minecraft:saddle"); + public static final ItemType SALMON = register("minecraft:salmon"); + public static final ItemType SALMON_BUCKET = register("minecraft:salmon_bucket"); + public static final ItemType SALMON_SPAWN_EGG = register("minecraft:salmon_spawn_egg"); + public static final ItemType SAND = register("minecraft:sand"); + public static final ItemType SANDSTONE = register("minecraft:sandstone"); + public static final ItemType SANDSTONE_SLAB = register("minecraft:sandstone_slab"); + public static final ItemType SANDSTONE_STAIRS = register("minecraft:sandstone_stairs"); + public static final ItemType SCUTE = register("minecraft:scute"); + public static final ItemType SEA_LANTERN = register("minecraft:sea_lantern"); + public static final ItemType SEA_PICKLE = register("minecraft:sea_pickle"); + public static final ItemType SEAGRASS = register("minecraft:seagrass"); + public static final ItemType SHEARS = register("minecraft:shears"); + public static final ItemType SHEEP_SPAWN_EGG = register("minecraft:sheep_spawn_egg"); + public static final ItemType SHIELD = register("minecraft:shield"); + public static final ItemType SHULKER_BOX = register("minecraft:shulker_box"); + public static final ItemType SHULKER_SHELL = register("minecraft:shulker_shell"); + public static final ItemType SHULKER_SPAWN_EGG = register("minecraft:shulker_spawn_egg"); + public static final ItemType SIGN = register("minecraft:sign"); + public static final ItemType SILVERFISH_SPAWN_EGG = register("minecraft:silverfish_spawn_egg"); + public static final ItemType SKELETON_HORSE_SPAWN_EGG = register("minecraft:skeleton_horse_spawn_egg"); + public static final ItemType SKELETON_SKULL = register("minecraft:skeleton_skull"); + public static final ItemType SKELETON_SPAWN_EGG = register("minecraft:skeleton_spawn_egg"); + public static final ItemType SLIME_BALL = register("minecraft:slime_ball"); + public static final ItemType SLIME_BLOCK = register("minecraft:slime_block"); + public static final ItemType SLIME_SPAWN_EGG = register("minecraft:slime_spawn_egg"); + public static final ItemType SMOOTH_QUARTZ = register("minecraft:smooth_quartz"); + public static final ItemType SMOOTH_RED_SANDSTONE = register("minecraft:smooth_red_sandstone"); + public static final ItemType SMOOTH_SANDSTONE = register("minecraft:smooth_sandstone"); + public static final ItemType SMOOTH_STONE = register("minecraft:smooth_stone"); + public static final ItemType SNOW = register("minecraft:snow"); + public static final ItemType SNOW_BLOCK = register("minecraft:snow_block"); + public static final ItemType SNOWBALL = register("minecraft:snowball"); + public static final ItemType SOUL_SAND = register("minecraft:soul_sand"); + public static final ItemType SPAWNER = register("minecraft:spawner"); + public static final ItemType SPECTRAL_ARROW = register("minecraft:spectral_arrow"); + public static final ItemType SPIDER_EYE = register("minecraft:spider_eye"); + public static final ItemType SPIDER_SPAWN_EGG = register("minecraft:spider_spawn_egg"); + public static final ItemType SPLASH_POTION = register("minecraft:splash_potion"); + public static final ItemType SPONGE = register("minecraft:sponge"); + public static final ItemType SPRUCE_BOAT = register("minecraft:spruce_boat"); + public static final ItemType SPRUCE_BUTTON = register("minecraft:spruce_button"); + public static final ItemType SPRUCE_DOOR = register("minecraft:spruce_door"); + public static final ItemType SPRUCE_FENCE = register("minecraft:spruce_fence"); + public static final ItemType SPRUCE_FENCE_GATE = register("minecraft:spruce_fence_gate"); + public static final ItemType SPRUCE_LEAVES = register("minecraft:spruce_leaves"); + public static final ItemType SPRUCE_LOG = register("minecraft:spruce_log"); + public static final ItemType SPRUCE_PLANKS = register("minecraft:spruce_planks"); + public static final ItemType SPRUCE_PRESSURE_PLATE = register("minecraft:spruce_pressure_plate"); + public static final ItemType SPRUCE_SAPLING = register("minecraft:spruce_sapling"); + public static final ItemType SPRUCE_SLAB = register("minecraft:spruce_slab"); + public static final ItemType SPRUCE_STAIRS = register("minecraft:spruce_stairs"); + public static final ItemType SPRUCE_TRAPDOOR = register("minecraft:spruce_trapdoor"); + public static final ItemType SPRUCE_WOOD = register("minecraft:spruce_wood"); + public static final ItemType SQUID_SPAWN_EGG = register("minecraft:squid_spawn_egg"); + public static final ItemType STICK = register("minecraft:stick"); + public static final ItemType STICKY_PISTON = register("minecraft:sticky_piston"); + public static final ItemType STONE = register("minecraft:stone"); + public static final ItemType STONE_AXE = register("minecraft:stone_axe"); + public static final ItemType STONE_BRICK_SLAB = register("minecraft:stone_brick_slab"); + public static final ItemType STONE_BRICK_STAIRS = register("minecraft:stone_brick_stairs"); + public static final ItemType STONE_BRICKS = register("minecraft:stone_bricks"); + public static final ItemType STONE_BUTTON = register("minecraft:stone_button"); + public static final ItemType STONE_HOE = register("minecraft:stone_hoe"); + public static final ItemType STONE_PICKAXE = register("minecraft:stone_pickaxe"); + public static final ItemType STONE_PRESSURE_PLATE = register("minecraft:stone_pressure_plate"); + public static final ItemType STONE_SHOVEL = register("minecraft:stone_shovel"); + public static final ItemType STONE_SLAB = register("minecraft:stone_slab"); + public static final ItemType STONE_SWORD = register("minecraft:stone_sword"); + public static final ItemType STRAY_SPAWN_EGG = register("minecraft:stray_spawn_egg"); + public static final ItemType STRING = register("minecraft:string"); + public static final ItemType STRIPPED_ACACIA_LOG = register("minecraft:stripped_acacia_log"); + public static final ItemType STRIPPED_ACACIA_WOOD = register("minecraft:stripped_acacia_wood"); + public static final ItemType STRIPPED_BIRCH_LOG = register("minecraft:stripped_birch_log"); + public static final ItemType STRIPPED_BIRCH_WOOD = register("minecraft:stripped_birch_wood"); + public static final ItemType STRIPPED_DARK_OAK_LOG = register("minecraft:stripped_dark_oak_log"); + public static final ItemType STRIPPED_DARK_OAK_WOOD = register("minecraft:stripped_dark_oak_wood"); + public static final ItemType STRIPPED_JUNGLE_LOG = register("minecraft:stripped_jungle_log"); + public static final ItemType STRIPPED_JUNGLE_WOOD = register("minecraft:stripped_jungle_wood"); + public static final ItemType STRIPPED_OAK_LOG = register("minecraft:stripped_oak_log"); + public static final ItemType STRIPPED_OAK_WOOD = register("minecraft:stripped_oak_wood"); + public static final ItemType STRIPPED_SPRUCE_LOG = register("minecraft:stripped_spruce_log"); + public static final ItemType STRIPPED_SPRUCE_WOOD = register("minecraft:stripped_spruce_wood"); + public static final ItemType STRUCTURE_BLOCK = register("minecraft:structure_block"); + public static final ItemType STRUCTURE_VOID = register("minecraft:structure_void"); + public static final ItemType SUGAR = register("minecraft:sugar"); + public static final ItemType SUGAR_CANE = register("minecraft:sugar_cane"); + public static final ItemType SUNFLOWER = register("minecraft:sunflower"); + public static final ItemType TALL_GRASS = register("minecraft:tall_grass"); + public static final ItemType TERRACOTTA = register("minecraft:terracotta"); + public static final ItemType TIPPED_ARROW = register("minecraft:tipped_arrow"); + public static final ItemType TNT = register("minecraft:tnt"); + public static final ItemType TNT_MINECART = register("minecraft:tnt_minecart"); + public static final ItemType TORCH = register("minecraft:torch"); + public static final ItemType TOTEM_OF_UNDYING = register("minecraft:totem_of_undying"); + public static final ItemType TRAPPED_CHEST = register("minecraft:trapped_chest"); + public static final ItemType TRIDENT = register("minecraft:trident"); + public static final ItemType TRIPWIRE_HOOK = register("minecraft:tripwire_hook"); + public static final ItemType TROPICAL_FISH = register("minecraft:tropical_fish"); + public static final ItemType TROPICAL_FISH_BUCKET = register("minecraft:tropical_fish_bucket"); + public static final ItemType TROPICAL_FISH_SPAWN_EGG = register("minecraft:tropical_fish_spawn_egg"); + public static final ItemType TUBE_CORAL = register("minecraft:tube_coral"); + public static final ItemType TUBE_CORAL_BLOCK = register("minecraft:tube_coral_block"); + public static final ItemType TUBE_CORAL_FAN = register("minecraft:tube_coral_fan"); + public static final ItemType TURTLE_EGG = register("minecraft:turtle_egg"); + public static final ItemType TURTLE_HELMET = register("minecraft:turtle_helmet"); + public static final ItemType TURTLE_SPAWN_EGG = register("minecraft:turtle_spawn_egg"); + public static final ItemType VEX_SPAWN_EGG = register("minecraft:vex_spawn_egg"); + public static final ItemType VILLAGER_SPAWN_EGG = register("minecraft:villager_spawn_egg"); + public static final ItemType VINDICATOR_SPAWN_EGG = register("minecraft:vindicator_spawn_egg"); + public static final ItemType VINE = register("minecraft:vine"); + public static final ItemType WATER_BUCKET = register("minecraft:water_bucket"); + public static final ItemType WET_SPONGE = register("minecraft:wet_sponge"); + public static final ItemType WHEAT = register("minecraft:wheat"); + public static final ItemType WHEAT_SEEDS = register("minecraft:wheat_seeds"); + public static final ItemType WHITE_BANNER = register("minecraft:white_banner"); + public static final ItemType WHITE_BED = register("minecraft:white_bed"); + public static final ItemType WHITE_CARPET = register("minecraft:white_carpet"); + public static final ItemType WHITE_CONCRETE = register("minecraft:white_concrete"); + public static final ItemType WHITE_CONCRETE_POWDER = register("minecraft:white_concrete_powder"); + public static final ItemType WHITE_GLAZED_TERRACOTTA = register("minecraft:white_glazed_terracotta"); + public static final ItemType WHITE_SHULKER_BOX = register("minecraft:white_shulker_box"); + public static final ItemType WHITE_STAINED_GLASS = register("minecraft:white_stained_glass"); + public static final ItemType WHITE_STAINED_GLASS_PANE = register("minecraft:white_stained_glass_pane"); + public static final ItemType WHITE_TERRACOTTA = register("minecraft:white_terracotta"); + public static final ItemType WHITE_TULIP = register("minecraft:white_tulip"); + public static final ItemType WHITE_WOOL = register("minecraft:white_wool"); + public static final ItemType WITCH_SPAWN_EGG = register("minecraft:witch_spawn_egg"); + public static final ItemType WITHER_SKELETON_SKULL = register("minecraft:wither_skeleton_skull"); + public static final ItemType WITHER_SKELETON_SPAWN_EGG = register("minecraft:wither_skeleton_spawn_egg"); + public static final ItemType WOLF_SPAWN_EGG = register("minecraft:wolf_spawn_egg"); + public static final ItemType WOODEN_AXE = register("minecraft:wooden_axe"); + public static final ItemType WOODEN_HOE = register("minecraft:wooden_hoe"); + public static final ItemType WOODEN_PICKAXE = register("minecraft:wooden_pickaxe"); + public static final ItemType WOODEN_SHOVEL = register("minecraft:wooden_shovel"); + public static final ItemType WOODEN_SWORD = register("minecraft:wooden_sword"); + public static final ItemType WRITABLE_BOOK = register("minecraft:writable_book"); + public static final ItemType WRITTEN_BOOK = register("minecraft:written_book"); + public static final ItemType YELLOW_BANNER = register("minecraft:yellow_banner"); + public static final ItemType YELLOW_BED = register("minecraft:yellow_bed"); + public static final ItemType YELLOW_CARPET = register("minecraft:yellow_carpet"); + public static final ItemType YELLOW_CONCRETE = register("minecraft:yellow_concrete"); + public static final ItemType YELLOW_CONCRETE_POWDER = register("minecraft:yellow_concrete_powder"); + public static final ItemType YELLOW_GLAZED_TERRACOTTA = register("minecraft:yellow_glazed_terracotta"); + public static final ItemType YELLOW_SHULKER_BOX = register("minecraft:yellow_shulker_box"); + public static final ItemType YELLOW_STAINED_GLASS = register("minecraft:yellow_stained_glass"); + public static final ItemType YELLOW_STAINED_GLASS_PANE = register("minecraft:yellow_stained_glass_pane"); + public static final ItemType YELLOW_TERRACOTTA = register("minecraft:yellow_terracotta"); + public static final ItemType YELLOW_WOOL = register("minecraft:yellow_wool"); + public static final ItemType ZOMBIE_HEAD = register("minecraft:zombie_head"); + public static final ItemType ZOMBIE_HORSE_SPAWN_EGG = register("minecraft:zombie_horse_spawn_egg"); + public static final ItemType ZOMBIE_PIGMAN_SPAWN_EGG = register("minecraft:zombie_pigman_spawn_egg"); + public static final ItemType ZOMBIE_SPAWN_EGG = register("minecraft:zombie_spawn_egg"); + public static final ItemType ZOMBIE_VILLAGER_SPAWN_EGG = register("minecraft:zombie_villager_spawn_egg"); - __RESERVED__, - ACACIA_BOAT, - ACACIA_BUTTON, - ACACIA_DOOR, - ACACIA_FENCE, - ACACIA_FENCE_GATE, - ACACIA_LEAVES, - ACACIA_LOG, - ACACIA_PLANKS, - ACACIA_PRESSURE_PLATE, - ACACIA_SAPLING, - ACACIA_SLAB, - ACACIA_STAIRS, - ACACIA_TRAPDOOR, - ACACIA_WOOD, - ACTIVATOR_RAIL, - AIR, - ALLIUM, - ANDESITE, - ANVIL, - APPLE, - ARMOR_STAND, - ARROW, - AZURE_BLUET, - BAKED_POTATO, - BARRIER, - BAT_SPAWN_EGG, - BEACON, - BEDROCK, - BEEF, - BEETROOT, - BEETROOT_SEEDS, - BEETROOT_SOUP, - BIRCH_BOAT, - BIRCH_BUTTON, - BIRCH_DOOR, - BIRCH_FENCE, - BIRCH_FENCE_GATE, - BIRCH_LEAVES, - BIRCH_LOG, - BIRCH_PLANKS, - BIRCH_PRESSURE_PLATE, - BIRCH_SAPLING, - BIRCH_SLAB, - BIRCH_STAIRS, - BIRCH_TRAPDOOR, - BIRCH_WOOD, - BLACK_BANNER, - BLACK_BED, - BLACK_CARPET, - BLACK_CONCRETE, - BLACK_CONCRETE_POWDER, - BLACK_GLAZED_TERRACOTTA, - BLACK_SHULKER_BOX, - BLACK_STAINED_GLASS, - BLACK_STAINED_GLASS_PANE, - BLACK_TERRACOTTA, - BLACK_WOOL, - BLAZE_POWDER, - BLAZE_ROD, - BLAZE_SPAWN_EGG, - BLUE_BANNER, - BLUE_BED, - BLUE_CARPET, - BLUE_CONCRETE, - BLUE_CONCRETE_POWDER, - BLUE_GLAZED_TERRACOTTA, - BLUE_ICE, - BLUE_ORCHID, - BLUE_SHULKER_BOX, - BLUE_STAINED_GLASS, - BLUE_STAINED_GLASS_PANE, - BLUE_TERRACOTTA, - BLUE_WOOL, - BONE, - BONE_BLOCK, - BONE_MEAL, - BOOK, - BOOKSHELF, - BOW, - BOWL, - BRAIN_CORAL, - BRAIN_CORAL_BLOCK, - BRAIN_CORAL_FAN, - BREAD, - BREWING_STAND, - BRICK, - BRICKS, - BRICK_SLAB, - BRICK_STAIRS, - BROWN_BANNER, - BROWN_BED, - BROWN_CARPET, - BROWN_CONCRETE, - BROWN_CONCRETE_POWDER, - BROWN_GLAZED_TERRACOTTA, - BROWN_MUSHROOM, - BROWN_MUSHROOM_BLOCK, - BROWN_SHULKER_BOX, - BROWN_STAINED_GLASS, - BROWN_STAINED_GLASS_PANE, - BROWN_TERRACOTTA, - BROWN_WOOL, - BUBBLE_CORAL, - BUBBLE_CORAL_BLOCK, - BUBBLE_CORAL_FAN, - BUCKET, - CACTUS, - CACTUS_GREEN, - CAKE, - CARROT, - CARROT_ON_A_STICK, - CARVED_PUMPKIN, - CAULDRON, - CAVE_SPIDER_SPAWN_EGG, - CHAINMAIL_BOOTS, - CHAINMAIL_CHESTPLATE, - CHAINMAIL_HELMET, - CHAINMAIL_LEGGINGS, - CHAIN_COMMAND_BLOCK, - CHARCOAL, - CHEST, - CHEST_MINECART, - CHICKEN, - CHICKEN_SPAWN_EGG, - CHIPPED_ANVIL, - CHISELED_QUARTZ_BLOCK, - CHISELED_RED_SANDSTONE, - CHISELED_SANDSTONE, - CHISELED_STONE_BRICKS, - CHORUS_FLOWER, - CHORUS_FRUIT, - CHORUS_PLANT, - CLAY, - CLAY_BALL, - CLOCK, - COAL, - COAL_BLOCK, - COAL_ORE, - COARSE_DIRT, - COBBLESTONE, - COBBLESTONE_SLAB, - COBBLESTONE_STAIRS, - COBBLESTONE_WALL, - COBWEB, - COCOA_BEANS, - COD, - COD_BUCKET, - COD_SPAWN_EGG, - COMMAND_BLOCK, - COMMAND_BLOCK_MINECART, - COMPARATOR, - COMPASS, - CONDUIT, - COOKED_BEEF, - COOKED_CHICKEN, - COOKED_COD, - COOKED_MUTTON, - COOKED_PORKCHOP, - COOKED_RABBIT, - COOKED_SALMON, - COOKIE, - COW_SPAWN_EGG, - CRACKED_STONE_BRICKS, - CRAFTING_TABLE, - CREEPER_HEAD, - CREEPER_SPAWN_EGG, - CUT_RED_SANDSTONE, - CUT_SANDSTONE, - CYAN_BANNER, - CYAN_BED, - CYAN_CARPET, - CYAN_CONCRETE, - CYAN_CONCRETE_POWDER, - CYAN_DYE, - CYAN_GLAZED_TERRACOTTA, - CYAN_SHULKER_BOX, - CYAN_STAINED_GLASS, - CYAN_STAINED_GLASS_PANE, - CYAN_TERRACOTTA, - CYAN_WOOL, - DAMAGED_ANVIL, - DANDELION, - DANDELION_YELLOW, - DARK_OAK_BOAT, - DARK_OAK_BUTTON, - DARK_OAK_DOOR, - DARK_OAK_FENCE, - DARK_OAK_FENCE_GATE, - DARK_OAK_LEAVES, - DARK_OAK_LOG, - DARK_OAK_PLANKS, - DARK_OAK_PRESSURE_PLATE, - DARK_OAK_SAPLING, - DARK_OAK_SLAB, - DARK_OAK_STAIRS, - DARK_OAK_TRAPDOOR, - DARK_OAK_WOOD, - DARK_PRISMARINE, - DARK_PRISMARINE_SLAB, - DARK_PRISMARINE_STAIRS, - DAYLIGHT_DETECTOR, - DEAD_BRAIN_CORAL, - DEAD_BRAIN_CORAL_BLOCK, - DEAD_BRAIN_CORAL_FAN, - DEAD_BUBBLE_CORAL, - DEAD_BUBBLE_CORAL_BLOCK, - DEAD_BUBBLE_CORAL_FAN, - DEAD_BUSH, - DEAD_FIRE_CORAL, - DEAD_FIRE_CORAL_BLOCK, - DEAD_FIRE_CORAL_FAN, - DEAD_HORN_CORAL, - DEAD_HORN_CORAL_BLOCK, - DEAD_HORN_CORAL_FAN, - DEAD_TUBE_CORAL, - DEAD_TUBE_CORAL_BLOCK, - DEAD_TUBE_CORAL_FAN, - DEBUG_STICK, - DETECTOR_RAIL, - DIAMOND, - DIAMOND_AXE, - DIAMOND_BLOCK, - DIAMOND_BOOTS, - DIAMOND_CHESTPLATE, - DIAMOND_HELMET, - DIAMOND_HOE, - DIAMOND_HORSE_ARMOR, - DIAMOND_LEGGINGS, - DIAMOND_ORE, - DIAMOND_PICKAXE, - DIAMOND_SHOVEL, - DIAMOND_SWORD, - DIORITE, - DIRT, - DISPENSER, - DOLPHIN_SPAWN_EGG, - DONKEY_SPAWN_EGG, - DRAGON_BREATH, - DRAGON_EGG, - DRAGON_HEAD, - DRIED_KELP, - DRIED_KELP_BLOCK, - DROPPER, - DROWNED_SPAWN_EGG, - EGG, - ELDER_GUARDIAN_SPAWN_EGG, - ELYTRA, - EMERALD, - EMERALD_BLOCK, - EMERALD_ORE, - ENCHANTED_BOOK, - ENCHANTED_GOLDEN_APPLE, - ENCHANTING_TABLE, - ENDERMAN_SPAWN_EGG, - ENDERMITE_SPAWN_EGG, - ENDER_CHEST, - ENDER_EYE, - ENDER_PEARL, - END_CRYSTAL, - END_PORTAL_FRAME, - END_ROD, - END_STONE, - END_STONE_BRICKS, - EVOKER_SPAWN_EGG, - EXPERIENCE_BOTTLE, - FARMLAND, - FEATHER, - FERMENTED_SPIDER_EYE, - FERN, - FILLED_MAP, - FIREWORK_ROCKET, - FIREWORK_STAR, - FIRE_CHARGE, - FIRE_CORAL, - FIRE_CORAL_BLOCK, - FIRE_CORAL_FAN, - FISHING_ROD, - FLINT, - FLINT_AND_STEEL, - FLOWER_POT, - FURNACE, - FURNACE_MINECART, - GHAST_SPAWN_EGG, - GHAST_TEAR, - GLASS, - GLASS_BOTTLE, - GLASS_PANE, - GLISTERING_MELON_SLICE, - GLOWSTONE, - GLOWSTONE_DUST, - GOLDEN_APPLE, - GOLDEN_AXE, - GOLDEN_BOOTS, - GOLDEN_CARROT, - GOLDEN_CHESTPLATE, - GOLDEN_HELMET, - GOLDEN_HOE, - GOLDEN_HORSE_ARMOR, - GOLDEN_LEGGINGS, - GOLDEN_PICKAXE, - GOLDEN_SHOVEL, - GOLDEN_SWORD, - GOLD_BLOCK, - GOLD_INGOT, - GOLD_NUGGET, - GOLD_ORE, - GRANITE, - GRASS, - GRASS_BLOCK, - GRASS_PATH, - GRAVEL, - GRAY_BANNER, - GRAY_BED, - GRAY_CARPET, - GRAY_CONCRETE, - GRAY_CONCRETE_POWDER, - GRAY_DYE, - GRAY_GLAZED_TERRACOTTA, - GRAY_SHULKER_BOX, - GRAY_STAINED_GLASS, - GRAY_STAINED_GLASS_PANE, - GRAY_TERRACOTTA, - GRAY_WOOL, - GREEN_BANNER, - GREEN_BED, - GREEN_CARPET, - GREEN_CONCRETE, - GREEN_CONCRETE_POWDER, - GREEN_GLAZED_TERRACOTTA, - GREEN_SHULKER_BOX, - GREEN_STAINED_GLASS, - GREEN_STAINED_GLASS_PANE, - GREEN_TERRACOTTA, - GREEN_WOOL, - GUARDIAN_SPAWN_EGG, - GUNPOWDER, - HAY_BLOCK, - HEART_OF_THE_SEA, - HEAVY_WEIGHTED_PRESSURE_PLATE, - HOPPER, - HOPPER_MINECART, - HORN_CORAL, - HORN_CORAL_BLOCK, - HORN_CORAL_FAN, - HORSE_SPAWN_EGG, - HUSK_SPAWN_EGG, - ICE, - INFESTED_CHISELED_STONE_BRICKS, - INFESTED_COBBLESTONE, - INFESTED_CRACKED_STONE_BRICKS, - INFESTED_MOSSY_STONE_BRICKS, - INFESTED_STONE, - INFESTED_STONE_BRICKS, - INK_SAC, - IRON_AXE, - IRON_BARS, - IRON_BLOCK, - IRON_BOOTS, - IRON_CHESTPLATE, - IRON_DOOR, - IRON_HELMET, - IRON_HOE, - IRON_HORSE_ARMOR, - IRON_INGOT, - IRON_LEGGINGS, - IRON_NUGGET, - IRON_ORE, - IRON_PICKAXE, - IRON_SHOVEL, - IRON_SWORD, - IRON_TRAPDOOR, - ITEM_FRAME, - JACK_O_LANTERN, - JUKEBOX, - JUNGLE_BOAT, - JUNGLE_BUTTON, - JUNGLE_DOOR, - JUNGLE_FENCE, - JUNGLE_FENCE_GATE, - JUNGLE_LEAVES, - JUNGLE_LOG, - JUNGLE_PLANKS, - JUNGLE_PRESSURE_PLATE, - JUNGLE_SAPLING, - JUNGLE_SLAB, - JUNGLE_STAIRS, - JUNGLE_TRAPDOOR, - JUNGLE_WOOD, - KELP, - KNOWLEDGE_BOOK, - LADDER, - LAPIS_BLOCK, - LAPIS_LAZULI, - LAPIS_ORE, - LARGE_FERN, - LAVA_BUCKET, - LEAD, - LEATHER, - LEATHER_BOOTS, - LEATHER_CHESTPLATE, - LEATHER_HELMET, - LEATHER_LEGGINGS, - LEVER, - LIGHT_BLUE_BANNER, - LIGHT_BLUE_BED, - LIGHT_BLUE_CARPET, - LIGHT_BLUE_CONCRETE, - LIGHT_BLUE_CONCRETE_POWDER, - LIGHT_BLUE_DYE, - LIGHT_BLUE_GLAZED_TERRACOTTA, - LIGHT_BLUE_SHULKER_BOX, - LIGHT_BLUE_STAINED_GLASS, - LIGHT_BLUE_STAINED_GLASS_PANE, - LIGHT_BLUE_TERRACOTTA, - LIGHT_BLUE_WOOL, - LIGHT_GRAY_BANNER, - LIGHT_GRAY_BED, - LIGHT_GRAY_CARPET, - LIGHT_GRAY_CONCRETE, - LIGHT_GRAY_CONCRETE_POWDER, - LIGHT_GRAY_DYE, - LIGHT_GRAY_GLAZED_TERRACOTTA, - LIGHT_GRAY_SHULKER_BOX, - LIGHT_GRAY_STAINED_GLASS, - LIGHT_GRAY_STAINED_GLASS_PANE, - LIGHT_GRAY_TERRACOTTA, - LIGHT_GRAY_WOOL, - LIGHT_WEIGHTED_PRESSURE_PLATE, - LILAC, - LILY_PAD, - LIME_BANNER, - LIME_BED, - LIME_CARPET, - LIME_CONCRETE, - LIME_CONCRETE_POWDER, - LIME_DYE, - LIME_GLAZED_TERRACOTTA, - LIME_SHULKER_BOX, - LIME_STAINED_GLASS, - LIME_STAINED_GLASS_PANE, - LIME_TERRACOTTA, - LIME_WOOL, - LINGERING_POTION, - LLAMA_SPAWN_EGG, - MAGENTA_BANNER, - MAGENTA_BED, - MAGENTA_CARPET, - MAGENTA_CONCRETE, - MAGENTA_CONCRETE_POWDER, - MAGENTA_DYE, - MAGENTA_GLAZED_TERRACOTTA, - MAGENTA_SHULKER_BOX, - MAGENTA_STAINED_GLASS, - MAGENTA_STAINED_GLASS_PANE, - MAGENTA_TERRACOTTA, - MAGENTA_WOOL, - MAGMA_BLOCK, - MAGMA_CREAM, - MAGMA_CUBE_SPAWN_EGG, - MAP, - MELON, - MELON_SEEDS, - MELON_SLICE, - MILK_BUCKET, - MINECART, - MOOSHROOM_SPAWN_EGG, - MOSSY_COBBLESTONE, - MOSSY_COBBLESTONE_WALL, - MOSSY_STONE_BRICKS, - MULE_SPAWN_EGG, - MUSHROOM_STEM, - MUSHROOM_STEW, - MUSIC_DISC_11, - MUSIC_DISC_13, - MUSIC_DISC_BLOCKS, - MUSIC_DISC_CAT, - MUSIC_DISC_CHIRP, - MUSIC_DISC_FAR, - MUSIC_DISC_MALL, - MUSIC_DISC_MELLOHI, - MUSIC_DISC_STAL, - MUSIC_DISC_STRAD, - MUSIC_DISC_WAIT, - MUSIC_DISC_WARD, - MUTTON, - MYCELIUM, - NAME_TAG, - NAUTILUS_SHELL, - NETHERRACK, - NETHER_BRICK, - NETHER_BRICKS, - NETHER_BRICK_FENCE, - NETHER_BRICK_SLAB, - NETHER_BRICK_STAIRS, - NETHER_QUARTZ_ORE, - NETHER_STAR, - NETHER_WART, - NETHER_WART_BLOCK, - NOTE_BLOCK, - OAK_BOAT, - OAK_BUTTON, - OAK_DOOR, - OAK_FENCE, - OAK_FENCE_GATE, - OAK_LEAVES, - OAK_LOG, - OAK_PLANKS, - OAK_PRESSURE_PLATE, - OAK_SAPLING, - OAK_SLAB, - OAK_STAIRS, - OAK_TRAPDOOR, - OAK_WOOD, - OBSERVER, - OBSIDIAN, - OCELOT_SPAWN_EGG, - ORANGE_BANNER, - ORANGE_BED, - ORANGE_CARPET, - ORANGE_CONCRETE, - ORANGE_CONCRETE_POWDER, - ORANGE_DYE, - ORANGE_GLAZED_TERRACOTTA, - ORANGE_SHULKER_BOX, - ORANGE_STAINED_GLASS, - ORANGE_STAINED_GLASS_PANE, - ORANGE_TERRACOTTA, - ORANGE_TULIP, - ORANGE_WOOL, - OXEYE_DAISY, - PACKED_ICE, - PAINTING, - PAPER, - PARROT_SPAWN_EGG, - PEONY, - PETRIFIED_OAK_SLAB, - PHANTOM_MEMBRANE, - PHANTOM_SPAWN_EGG, - PIG_SPAWN_EGG, - PINK_BANNER, - PINK_BED, - PINK_CARPET, - PINK_CONCRETE, - PINK_CONCRETE_POWDER, - PINK_DYE, - PINK_GLAZED_TERRACOTTA, - PINK_SHULKER_BOX, - PINK_STAINED_GLASS, - PINK_STAINED_GLASS_PANE, - PINK_TERRACOTTA, - PINK_TULIP, - PINK_WOOL, - PISTON, - PLAYER_HEAD, - PODZOL, - POISONOUS_POTATO, - POLAR_BEAR_SPAWN_EGG, - POLISHED_ANDESITE, - POLISHED_DIORITE, - POLISHED_GRANITE, - POPPED_CHORUS_FRUIT, - POPPY, - PORKCHOP, - POTATO, - POTION, - POWERED_RAIL, - PRISMARINE, - PRISMARINE_BRICKS, - PRISMARINE_BRICK_SLAB, - PRISMARINE_BRICK_STAIRS, - PRISMARINE_CRYSTALS, - PRISMARINE_SHARD, - PRISMARINE_SLAB, - PRISMARINE_STAIRS, - PUFFERFISH, - PUFFERFISH_BUCKET, - PUFFERFISH_SPAWN_EGG, - PUMPKIN, - PUMPKIN_PIE, - PUMPKIN_SEEDS, - PURPLE_BANNER, - PURPLE_BED, - PURPLE_CARPET, - PURPLE_CONCRETE, - PURPLE_CONCRETE_POWDER, - PURPLE_DYE, - PURPLE_GLAZED_TERRACOTTA, - PURPLE_SHULKER_BOX, - PURPLE_STAINED_GLASS, - PURPLE_STAINED_GLASS_PANE, - PURPLE_TERRACOTTA, - PURPLE_WOOL, - PURPUR_BLOCK, - PURPUR_PILLAR, - PURPUR_SLAB, - PURPUR_STAIRS, - QUARTZ, - QUARTZ_BLOCK, - QUARTZ_PILLAR, - QUARTZ_SLAB, - QUARTZ_STAIRS, - RABBIT, - RABBIT_FOOT, - RABBIT_HIDE, - RABBIT_SPAWN_EGG, - RABBIT_STEW, - RAIL, - REDSTONE, - REDSTONE_BLOCK, - REDSTONE_LAMP, - REDSTONE_ORE, - REDSTONE_TORCH, - RED_BANNER, - RED_BED, - RED_CARPET, - RED_CONCRETE, - RED_CONCRETE_POWDER, - RED_GLAZED_TERRACOTTA, - RED_MUSHROOM, - RED_MUSHROOM_BLOCK, - RED_NETHER_BRICKS, - RED_SAND, - RED_SANDSTONE, - RED_SANDSTONE_SLAB, - RED_SANDSTONE_STAIRS, - RED_SHULKER_BOX, - RED_STAINED_GLASS, - RED_STAINED_GLASS_PANE, - RED_TERRACOTTA, - RED_TULIP, - RED_WOOL, - REPEATER, - REPEATING_COMMAND_BLOCK, - ROSE_BUSH, - ROSE_RED, - ROTTEN_FLESH, - SADDLE, - SALMON, - SALMON_BUCKET, - SALMON_SPAWN_EGG, - SAND, - SANDSTONE, - SANDSTONE_SLAB, - SANDSTONE_STAIRS, - SCUTE, - SEAGRASS, - SEA_LANTERN, - SEA_PICKLE, - SHEARS, - SHEEP_SPAWN_EGG, - SHIELD, - SHULKER_BOX, - SHULKER_SHELL, - SHULKER_SPAWN_EGG, - SIGN, - SILVERFISH_SPAWN_EGG, - SKELETON_HORSE_SPAWN_EGG, - SKELETON_SKULL, - SKELETON_SPAWN_EGG, - SLIME_BALL, - SLIME_BLOCK, - SLIME_SPAWN_EGG, - SMOOTH_QUARTZ, - SMOOTH_RED_SANDSTONE, - SMOOTH_SANDSTONE, - SMOOTH_STONE, - SNOW, - SNOWBALL, - SNOW_BLOCK, - SOUL_SAND, - SPAWNER, - SPECTRAL_ARROW, - SPIDER_EYE, - SPIDER_SPAWN_EGG, - SPLASH_POTION, - SPONGE, - SPRUCE_BOAT, - SPRUCE_BUTTON, - SPRUCE_DOOR, - SPRUCE_FENCE, - SPRUCE_FENCE_GATE, - SPRUCE_LEAVES, - SPRUCE_LOG, - SPRUCE_PLANKS, - SPRUCE_PRESSURE_PLATE, - SPRUCE_SAPLING, - SPRUCE_SLAB, - SPRUCE_STAIRS, - SPRUCE_TRAPDOOR, - SPRUCE_WOOD, - SQUID_SPAWN_EGG, - STICK, - STICKY_PISTON, - STONE, - STONE_AXE, - STONE_BRICKS, - STONE_BRICK_SLAB, - STONE_BRICK_STAIRS, - STONE_BUTTON, - STONE_HOE, - STONE_PICKAXE, - STONE_PRESSURE_PLATE, - STONE_SHOVEL, - STONE_SLAB, - STONE_SWORD, - STRAY_SPAWN_EGG, - STRING, - STRIPPED_ACACIA_LOG, - STRIPPED_ACACIA_WOOD, - STRIPPED_BIRCH_LOG, - STRIPPED_BIRCH_WOOD, - STRIPPED_DARK_OAK_LOG, - STRIPPED_DARK_OAK_WOOD, - STRIPPED_JUNGLE_LOG, - STRIPPED_JUNGLE_WOOD, - STRIPPED_OAK_LOG, - STRIPPED_OAK_WOOD, - STRIPPED_SPRUCE_LOG, - STRIPPED_SPRUCE_WOOD, - STRUCTURE_BLOCK, - STRUCTURE_VOID, - SUGAR, - SUGAR_CANE, - SUNFLOWER, - TALL_GRASS, - TERRACOTTA, - TIPPED_ARROW, - TNT, - TNT_MINECART, - TORCH, - TOTEM_OF_UNDYING, - TRAPPED_CHEST, - TRIDENT, - TRIPWIRE_HOOK, - TROPICAL_FISH, - TROPICAL_FISH_BUCKET, - TROPICAL_FISH_SPAWN_EGG, - TUBE_CORAL, - TUBE_CORAL_BLOCK, - TUBE_CORAL_FAN, - TURTLE_EGG, - TURTLE_HELMET, - TURTLE_SPAWN_EGG, - VEX_SPAWN_EGG, - VILLAGER_SPAWN_EGG, - VINDICATOR_SPAWN_EGG, - VINE, - WATER_BUCKET, - WET_SPONGE, - WHEAT, - WHEAT_SEEDS, - WHITE_BANNER, - WHITE_BED, - WHITE_CARPET, - WHITE_CONCRETE, - WHITE_CONCRETE_POWDER, - WHITE_GLAZED_TERRACOTTA, - WHITE_SHULKER_BOX, - WHITE_STAINED_GLASS, - WHITE_STAINED_GLASS_PANE, - WHITE_TERRACOTTA, - WHITE_TULIP, - WHITE_WOOL, - WITCH_SPAWN_EGG, - WITHER_SKELETON_SKULL, - WITHER_SKELETON_SPAWN_EGG, - WOLF_SPAWN_EGG, - WOODEN_AXE, - WOODEN_HOE, - WOODEN_PICKAXE, - WOODEN_SHOVEL, - WOODEN_SWORD, - WRITABLE_BOOK, - WRITTEN_BOOK, - YELLOW_BANNER, - YELLOW_BED, - YELLOW_CARPET, - YELLOW_CONCRETE, - YELLOW_CONCRETE_POWDER, - YELLOW_GLAZED_TERRACOTTA, - YELLOW_SHULKER_BOX, - YELLOW_STAINED_GLASS, - YELLOW_STAINED_GLASS_PANE, - YELLOW_TERRACOTTA, - YELLOW_WOOL, - ZOMBIE_HEAD, - ZOMBIE_HORSE_SPAWN_EGG, - ZOMBIE_PIGMAN_SPAWN_EGG, - ZOMBIE_SPAWN_EGG, - ZOMBIE_VILLAGER_SPAWN_EGG, - - ; - - /* - ----------------------------------------------------- - Instance - ----------------------------------------------------- - */ - - private BlockTypes blockType; - private String id; - private BaseItem defaultState; - private int internalId; - - ItemTypes() { - this(null); + private ItemTypes() { } - ItemTypes(String id) { - init(id); + private static ItemType register(final String id) { + return register(new ItemType(id)); } - private void init(String id) { - if (id == null) id = "minecraft:" + name().toLowerCase(); - // If it has no namespace, assume minecraft. - else if (!id.contains(":")) { - id = "minecraft:" + id; - } - this.id = id; - this.defaultState = new BaseItemStack(this, 1); - this.internalId = ordinal(); + public static ItemType register(final ItemType item) { + if(sortedRegistry == null) + sortedRegistry = new ArrayList(); + if(!sortedRegistry.contains(item))sortedRegistry.add(item); +// return ItemType.REGISTRY.register(item.getId(), item); + return internalRegister(item); } - private void setBlockType(BlockTypes type) { - this.blockType = type; + public static @Nullable ItemType get(final String id) { + return ItemType.REGISTRY.get(id); } - - @Override - public BaseItem getDefaultState() { - return defaultState; - } - - public String getId() { - return this.id; - } - - @Deprecated - public int getInternalId() { - return this.internalId; - } - - /** - * Gets the name of this item, or the ID if the name cannot be found. - * - * @return The name, or ID - */ - public String getName() { - BundledItemData.ItemEntry entry = BundledItemData.getInstance().findById(this.id); - if (entry == null) { - return getId(); - } else { - return entry.localizedName; - } - } - - - /** - * Gets whether this item type has a block representation. - * - * @return If it has a block - */ - public boolean hasBlockType() { - return getBlockType() != null; - } - - /** - * Gets the block representation of this item type, if it exists. - * - * @return The block representation - */ - @Nullable - public BlockTypes getBlockType() { - return blockType; - } - - @Override - public String toString() { - return getId(); + + private static ArrayList sortedRegistry; + + public static ItemType[] values() { + return sortedRegistry.toArray(new ItemType[sortedRegistry.size()]); } /* @@ -929,35 +859,36 @@ public enum ItemTypes implements ItemType { Static Initializer ----------------------------------------------------- */ - private static final Map $REGISTRY = new HashMap<>(); - private static int $LENGTH; - public static final ItemTypes[] values; +// private static final Map $REGISTRY = new HashMap<>(); +// private static int $LENGTH; +// public static final ItemTypes[] values; - static { - try { - Collection items = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getItemRegistry().registerItems(); - ItemTypes[] oldValues = values(); - $LENGTH = oldValues.length; - LinkedHashSet newValues = new LinkedHashSet<>(Arrays.asList(oldValues)); - if (!items.isEmpty()) { // No types found - use defaults - for (String item : items) { - ItemTypes registered = register(item); - if (!newValues.contains(registered)) newValues.add(registered); - } - } +// static { +// try { +// Collection items = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getItemRegistry().registerItems(); +// ItemType[] oldValues = values(); +// $LENGTH = oldValues.length; +// LinkedHashSet newValues = new LinkedHashSet<>(Arrays.asList(oldValues)); +// if (!items.isEmpty()) { // No types found - use defaults +// for (String item : items) { +// ItemType registered = register(item); +// if (!newValues.contains(registered)) newValues.add(registered); +// } +// } // Cache the values - values = newValues.toArray(new ItemTypes[newValues.size()]); - } catch (Throwable e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } +// values = newValues.toArray(new ItemTypes[newValues.size()]); +// } catch (Throwable e) { +// e.printStackTrace(); +// throw new RuntimeException(e); +// } +// } - public static ItemTypes parse(String input) { + @Nullable + public static ItemType parse(String input) { input = input.toLowerCase(); if (!Character.isAlphabetic(input.charAt(0))) { try { - ItemTypes legacy = LegacyMapper.getInstance().getItemFromLegacy(input); + ItemType legacy = LegacyMapper.getInstance().getItemFromLegacy(input); if (legacy != null) return legacy; } catch (NumberFormatException e) { e.printStackTrace(); @@ -965,40 +896,18 @@ public enum ItemTypes implements ItemType { } if (!input.split("\\[", 2)[0].contains(":")) input = "minecraft:" + input; - ItemTypes result = $REGISTRY.get(input); - if (result != null) return result; - return null; + ItemType result = get(input); + return result; } - private static ItemTypes register(final String id) { - // Get the enum name (remove namespace if minecraft:) - int propStart = id.indexOf('['); - String typeName = id.substring(0, propStart == -1 ? id.length() : propStart); - String enumName = (typeName.startsWith("minecraft:") ? typeName.substring(10) : typeName).toUpperCase(); - // Check existing - ItemTypes existing = null; - try { existing = valueOf(enumName.toUpperCase()); } catch (IllegalArgumentException ignore) {} - if (existing == null) { - existing = ReflectionUtils.addEnum(ItemTypes.class, enumName); - } - int internalId = existing.ordinal(); - if (existing.id == null) { - existing.init(null); - } - if (internalId == 0 && existing != __RESERVED__) { - existing.internalId = $LENGTH++; - } - if (typeName.startsWith("minecraft:")) $REGISTRY.put(typeName.substring(10), existing); - $REGISTRY.put(typeName, existing); - return existing; + private static ItemType internalRegister(final ItemType type) { + type.setInternalId(sortedRegistry.indexOf(type)); + type.setDefaultState(new BaseItemStack(type, 1)); + return ItemType.REGISTRY.register(type.getId(), type); } - public static final @Nullable ItemTypes get(final String id) { - return $REGISTRY.get(id); - } - - public static final @Nullable ItemTypes get(BlockTypes type) { - ItemTypes item = $REGISTRY.get(type.getId()); + public static final @Nullable ItemType get(BlockType type) { + ItemType item = get(type.getId()); if (item != null && item.getBlockType() == null) { item.setBlockType(type); } @@ -1006,11 +915,11 @@ public enum ItemTypes implements ItemType { } @Deprecated - public static final ItemTypes get(final int ordinal) { - return values[ordinal]; + public static final ItemType get(final int ordinal) { + return values()[ordinal]; } public static int size() { - return values.length; + return values().length; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java index 9c9845153..ce0726d78 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java @@ -55,7 +55,7 @@ public interface BlockRegistry { * @param blockType the block * @return a map of states where the key is the state's ID */ - Map getProperties(BlockType blockType); + Map> getProperties(BlockType blockType); /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockRegistry.java index 40e123959..9f0636daa 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockRegistry.java @@ -41,7 +41,7 @@ public class BundledBlockRegistry implements BlockRegistry { @Nullable @Override - public Map getProperties(BlockType blockType) { + public Map> getProperties(BlockType blockType) { return Collections.emptyMap(); // Oof } 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 6827a0e9c..4af6acaaf 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 @@ -44,4 +44,11 @@ public class BundledItemRegistry implements ItemRegistry { public Collection registerItems() { return Collections.emptyList(); } + + @Nullable + @Override + public String getName(ItemType itemType) { + BundledItemData.ItemEntry itemEntry = BundledItemData.getInstance().findById(itemType.getId()); + return itemEntry != null ? itemEntry.localizedName : null; + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/EntityRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/EntityRegistry.java index bbfec725f..ff879c6b8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/EntityRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/EntityRegistry.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.world.registry; import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; +import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityTypes; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; @@ -43,7 +44,7 @@ public interface EntityRegistry { */ @Nullable default BaseEntity createFromId(String id) { - EntityTypes entType = EntityTypes.get(id); + EntityType entType = EntityTypes.get(id); return entType == null ? null : new BaseEntity(entType); } 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 d9d30a7fe..5e46af3fe 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 @@ -20,6 +20,7 @@ package com.sk89q.worldedit.world.registry; import com.sk89q.worldedit.blocks.BaseItem; +import com.sk89q.worldedit.world.item.ItemType; import javax.annotation.Nullable; import java.util.Collection; @@ -42,5 +43,14 @@ public interface ItemRegistry { default Collection registerItems() { return Collections.emptyList(); } + + /** + * Gets the name for the given item. + * + * @param itemType the item + * @return The name, or null if it's unknown + */ + @Nullable + String getName(ItemType itemType); } 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 640271d0f..ed249e877 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 @@ -57,7 +57,7 @@ public class LegacyMapper { private final Int2ObjectArrayMap blockStateToLegacyId4Data = new Int2ObjectArrayMap<>(); private final Int2ObjectArrayMap extraId4DataToStateId = new Int2ObjectArrayMap<>(); private final int[] blockArr = new int[4096]; - private final BiMap itemMap = HashBiMap.create(); + private final BiMap itemMap = HashBiMap.create(); /** * Create a new instance. @@ -96,7 +96,7 @@ public class LegacyMapper { try { BlockStateHolder blockState = BlockState.get(null, blockEntry.getValue()); // BlockState blockState = WorldEdit.getInstance().getBlockFactory().parseFromInput(blockEntry.getValue(), parserContext).toImmutableState(); - BlockTypes type = blockState.getBlockType(); + BlockType type = blockState.getBlockType(); if (type.hasProperty(PropertyKey.WATERLOGGED)) { blockState = blockState.with(PropertyKey.WATERLOGGED, false); } @@ -134,11 +134,11 @@ public class LegacyMapper { } @Nullable - public ItemTypes getItemFromLegacy(int legacyId) { + public ItemType getItemFromLegacy(int legacyId) { return itemMap.get(legacyId << 4); } - public ItemTypes getItemFromLegacy(String input) { + public ItemType getItemFromLegacy(String input) { if (input.startsWith("minecraft:")) input = input.substring(10); return itemMap.get(getCombinedId(input)); } @@ -149,7 +149,7 @@ public class LegacyMapper { } @Nullable - public ItemTypes getItemFromLegacy(int legacyId, int data) { + public ItemType getItemFromLegacy(int legacyId, int data) { return itemMap.get((legacyId << 4) + data); }