From 30a78ad279ff56271e01fbf46b9c0b84a5c8403c Mon Sep 17 00:00:00 2001 From: Sen Date: Fri, 27 Jun 2025 16:27:16 +0200 Subject: [PATCH 1/7] remove block metadata TEMP --- client/src/main/java/client/Client.java | 4 +- .../java/client/network/ClientPlayer.java | 7 +- .../java/client/renderer/BlockRenderer.java | 2 +- .../java/client/renderer/ItemModelMesher.java | 6 +- .../renderer/blockmodel/ModelBakery.java | 10 +- .../renderer/blockmodel/ModelManager.java | 4 +- .../renderer/blockmodel/MultiStateMap.java | 2 +- .../renderer/blockmodel/SingleStateMap.java | 2 +- .../renderer/entity/RenderDynamite.java | 2 +- .../renderer/entity/RenderTntPrimed.java | 2 +- .../renderer/particle/EntityBlockDustFX.java | 4 +- .../renderer/particle/EntityBreakingFX.java | 2 +- .../renderer/particle/EntityDiggingFX.java | 3 +- .../client/renderer/texture/TextureMap.java | 2 +- .../tileentity/TileEntityBannerRenderer.java | 9 +- .../tileentity/TileEntityChestRenderer.java | 26 +- .../tileentity/TileEntitySignRenderer.java | 8 +- .../java/client/util/PlayerController.java | 2 +- .../main/java/client/world/ChunkEmpty.java | 2 +- .../main/java/client/world/WorldClient.java | 13 +- .../main/java/common/ai/EntityAIEatGrass.java | 2 +- common/src/main/java/common/biome/IBiome.java | 4 +- common/src/main/java/common/block/Block.java | 2 +- .../common/block/artificial/BlockBed.java | 4 +- .../common/block/artificial/BlockDoor.java | 47 +- .../block/artificial/BlockFlowerPot.java | 4 +- .../common/block/artificial/BlockStairs.java | 2 +- .../common/block/foliage/BlockLeaves.java | 4 +- .../block/liquid/BlockDynamicLiquid.java | 4 +- .../block/liquid/BlockStaticLiquid.java | 4 +- .../common/block/tech/BlockPistonBase.java | 2 +- .../common/block/tech/BlockWorkbench.java | 2 +- .../java/common/block/tile/BlockBanner.java | 3 - .../block/tile/BlockBannerStanding.java | 3 + .../main/java/common/dimension/Dimension.java | 10 +- .../src/main/java/common/entity/Entity.java | 4 +- .../common/entity/animal/EntityRabbit.java | 2 +- .../common/entity/animal/EntitySheep.java | 4 +- .../common/entity/item/EntityFalling.java | 12 +- .../java/common/entity/item/EntityItem.java | 4 +- .../common/entity/npc/EntityMetalhead.java | 2 +- .../java/common/entity/npc/EntityNPC.java | 2 +- .../common/entity/projectile/EntityArrow.java | 5 +- .../entity/projectile/EntityDynamite.java | 2 +- .../common/entity/projectile/EntityEgg.java | 2 +- .../common/entity/projectile/EntityHook.java | 4 +- .../entity/projectile/EntityProjectile.java | 4 +- .../common/entity/types/EntityLiving.java | 4 +- .../common/entity/types/EntityThrowable.java | 4 +- .../main/java/common/init/BlockRegistry.java | 682 ++++++++++-------- common/src/main/java/common/init/Blocks.java | 11 +- .../java/common/init/CraftingRegistry.java | 86 +-- .../main/java/common/init/ItemRegistry.java | 389 +++++----- common/src/main/java/common/init/Items.java | 11 +- .../java/common/init/SmeltingRegistry.java | 12 +- .../src/main/java/common/item/CheatTab.java | 2 +- common/src/main/java/common/item/Item.java | 440 ++++++----- .../src/main/java/common/item/ItemStack.java | 8 +- .../java/common/item/block/ItemBlock.java | 4 +- .../java/common/item/material/ItemDye.java | 2 +- .../java/common/network/PacketBuffer.java | 4 +- .../common/packet/SPacketBlockAction.java | 12 +- .../common/packet/SPacketBlockChange.java | 5 +- .../packet/SPacketMultiBlockChange.java | 5 +- .../common/packet/SPacketSpawnPlayer.java | 2 +- .../java/common/tileentity/TileEntity.java | 19 +- .../common/tileentity/TileEntityHopper.java | 12 +- .../common/tileentity/TileEntityPiston.java | 9 +- common/src/main/java/common/util/IdMap.java | 34 - common/src/main/java/common/util/Mapping.java | 90 --- .../main/java/common/world/BlockArray.java | 7 +- common/src/main/java/common/world/State.java | 32 +- common/src/main/java/common/world/World.java | 2 +- .../server/clipboard/ReorderRegistry.java | 6 +- .../server/clipboard/RotationRegistry.java | 2 +- .../server/command/commands/CommandBlock.java | 8 +- .../server/command/commands/CommandItem.java | 2 +- .../src/main/java/server/network/Player.java | 2 +- .../main/java/server/world/ChunkServer.java | 5 +- .../src/main/java/server/world/Converter.java | 3 +- server/src/main/java/server/world/Region.java | 58 +- .../java/server/worldgen/ChunkPrimer.java | 11 +- .../worldgen/structure/StructureVillage.java | 24 +- 83 files changed, 1088 insertions(+), 1177 deletions(-) delete mode 100755 common/src/main/java/common/util/IdMap.java delete mode 100755 common/src/main/java/common/util/Mapping.java diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 047171e7..ebc4af3d 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -1926,7 +1926,7 @@ public class Client implements IThreadListener { } StringBuilder str = new StringBuilder( - "Schaue auf: " + BlockRegistry.getNameFromBlock(block.getBlock()) + "\n" + + "Schaue auf: " + BlockRegistry.getName(block.getBlock()) + "\n" + String.format("Position: %d %d %d", pos.getX(), pos.getY(), pos.getZ()) ); for(Entry entry : block.getProperties().entrySet()) { @@ -1954,7 +1954,7 @@ public class Client implements IThreadListener { (((EntityLiving)entity).deathTime != 0 ? "Tod: " + ((EntityLiving)entity).deathTime + "t, " : "") + "Rüstung: " + ((EntityLiving)entity).getTotalArmorValue() + ", Pfeile: " + ((EntityLiving)entity).getArrowCountInEntity() : "Rüstung: n/a, Pfeile: n/a") + "\n" + (held != null ? - "Gegens.: " + ItemRegistry.getNameFromItem(held.getItem()) + " x" + held.size : "Gegens.: n/a") + "\n" + + "Gegens.: " + ItemRegistry.getName(held.getItem()) + " x" + held.size : "Gegens.: n/a") + "\n" + "Eigens.: " + (entity.dead ? "D" : "") + (entity.noClip ? "N" : "") + (entity.onGround ? "G" : "") + (entity.canBeCollidedWith() ? "C" : "") + (entity.canBePushed() ? "P" : "") + (entity.isBurning() ? "B" : "") + (entity.isPlayer() ? "S" : "") diff --git a/client/src/main/java/client/network/ClientPlayer.java b/client/src/main/java/client/network/ClientPlayer.java index e7914270..5fb944c1 100755 --- a/client/src/main/java/client/network/ClientPlayer.java +++ b/client/src/main/java/client/network/ClientPlayer.java @@ -517,7 +517,7 @@ public class ClientPlayer implements IClientPlayer } else { - player.inventory.mainInventory[player.inventory.currentItem] = new ItemStack(ItemRegistry.getItemById(i)); + player.inventory.mainInventory[player.inventory.currentItem] = new ItemStack(ItemRegistry.byId(i)); } player.setPositionAndRotation(x, y, z, yaw, pitch); @@ -1165,7 +1165,7 @@ public class ClientPlayer implements IClientPlayer } else { - Block block = BlockRegistry.getRegisteredBlock(id); + Block block = BlockRegistry.byName(id); if(block instanceof BlockWorkbench bench) { this.gm.displayGuiScreen(new GuiCrafting(player.inventory, player.worldObj, bench)); } @@ -1377,7 +1377,8 @@ public class ClientPlayer implements IClientPlayer public void handleBlockAction(SPacketBlockAction packetIn) { NetHandler.checkThread(packetIn, this, this.gm, this.world); - this.gm.world.addBlockEvent(packetIn.getBlockPosition(), packetIn.getBlockType(), packetIn.getData1(), packetIn.getData2()); + if(packetIn.getBlockType() != null) + this.gm.world.addBlockEvent(packetIn.getBlockPosition(), packetIn.getBlockType(), packetIn.getData1(), packetIn.getData2()); } /** diff --git a/client/src/main/java/client/renderer/BlockRenderer.java b/client/src/main/java/client/renderer/BlockRenderer.java index aebe53c5..df5c9d6f 100755 --- a/client/src/main/java/client/renderer/BlockRenderer.java +++ b/client/src/main/java/client/renderer/BlockRenderer.java @@ -409,7 +409,7 @@ public class BlockRenderer { TextureMap texturemap = Client.CLIENT.getTextureMapBlocks(); for(Pair liquid : BlockLiquid.LIQUIDS) { - String name = BlockRegistry.getNameFromBlock(liquid.first()); + String name = BlockRegistry.getName(liquid.first()); TextureAtlasSprite[] sprites = new TextureAtlasSprite[] {texturemap.getAtlasSprite("blocks/" + name + "_still"), texturemap.getAtlasSprite("blocks/" + name + "_flow")}; this.fluids.put(liquid.second(), sprites); this.fluids.put(liquid.first(), sprites); diff --git a/client/src/main/java/client/renderer/ItemModelMesher.java b/client/src/main/java/client/renderer/ItemModelMesher.java index 1a4d16d8..ca010af5 100755 --- a/client/src/main/java/client/renderer/ItemModelMesher.java +++ b/client/src/main/java/client/renderer/ItemModelMesher.java @@ -24,7 +24,7 @@ public class ItemModelMesher { public IBakedModel getItemModel(ItemStack stack) { Item item = stack.getItem(); - IBakedModel model = this.models.get(ItemRegistry.getIdFromItem(item)); + IBakedModel model = this.models.get(ItemRegistry.getId(item)); if(model == null) model = this.manager.getMissingModel(); return model; @@ -36,8 +36,8 @@ public class ItemModelMesher { public void rebuildCache() { this.models.clear(); - for(Item item : ItemRegistry.REGISTRY) { - this.models.put(ItemRegistry.getIdFromItem(item), this.manager.getModel("item/" + ItemRegistry.getNameFromItem(item).toString())); + for(Item item : ItemRegistry.items()) { + this.models.put(ItemRegistry.getId(item), this.manager.getModel("item/" + ItemRegistry.getName(item).toString())); } } } diff --git a/client/src/main/java/client/renderer/blockmodel/ModelBakery.java b/client/src/main/java/client/renderer/blockmodel/ModelBakery.java index d86e3c24..0e3062ba 100755 --- a/client/src/main/java/client/renderer/blockmodel/ModelBakery.java +++ b/client/src/main/java/client/renderer/blockmodel/ModelBakery.java @@ -39,7 +39,7 @@ public abstract class ModelBakery static { for(Pair liquid : BlockLiquid.LIQUIDS) { - String name = BlockRegistry.getNameFromBlock(liquid.first()); + String name = BlockRegistry.getName(liquid.first()); BUILTINS.add("blocks/" + name + "_flow"); BUILTINS.add("blocks/" + name + "_still"); } @@ -57,15 +57,15 @@ public abstract class ModelBakery models.put(MISSING, (ModelBlock)new ModelBlock(null).add().all()); variants.add(MISSING); for(Entry entry : map.entrySet()) { - ModelBlock model = (ModelBlock)entry.getKey().getBlock().getModel(ModelBlock.PROVIDER, BlockRegistry.getNameFromBlock(entry.getKey().getBlock()) + ModelBlock model = (ModelBlock)entry.getKey().getBlock().getModel(ModelBlock.PROVIDER, BlockRegistry.getName(entry.getKey().getBlock()) .toString(), entry.getKey()); models.put(entry.getValue(), model); variants.add(entry.getValue()); } - for (Item item : ItemRegistry.REGISTRY) + for (Item item : ItemRegistry.items()) { - String loc = "item/" + ItemRegistry.getNameFromItem(item); - models.put(loc, (ModelBlock)item.getModel(ModelBlock.PROVIDER, ItemRegistry.getNameFromItem(item))); + String loc = "item/" + ItemRegistry.getName(item); + models.put(loc, (ModelBlock)item.getModel(ModelBlock.PROVIDER, ItemRegistry.getName(item))); itemLocations.add(loc); String[] extra = item.getSprites(); if(extra != null) { diff --git a/client/src/main/java/client/renderer/blockmodel/ModelManager.java b/client/src/main/java/client/renderer/blockmodel/ModelManager.java index d372f2b1..96ec8763 100755 --- a/client/src/main/java/client/renderer/blockmodel/ModelManager.java +++ b/client/src/main/java/client/renderer/blockmodel/ModelManager.java @@ -26,7 +26,7 @@ public class ModelManager public ModelManager(TextureMap textures) { this.texMap = textures; - for(Block block : BlockRegistry.REGISTRY) { + for(Block block : BlockRegistry.blocks()) { if(block.getRenderType() != 3) { this.builtin.add(block); // Log.info("Builtin: " + BlockRegistry.getNameFromBlock(block)); @@ -113,7 +113,7 @@ public class ModelManager public Map getMap() { Map map = Maps.newIdentityHashMap(); - for(Block block : BlockRegistry.REGISTRY) { + for(Block block : BlockRegistry.blocks()) { if(!this.builtin.contains(block)) { StateMap mapper = this.mappers.get(block); if(mapper == null) diff --git a/client/src/main/java/client/renderer/blockmodel/MultiStateMap.java b/client/src/main/java/client/renderer/blockmodel/MultiStateMap.java index 75c9acac..bfc7282c 100755 --- a/client/src/main/java/client/renderer/blockmodel/MultiStateMap.java +++ b/client/src/main/java/client/renderer/blockmodel/MultiStateMap.java @@ -30,7 +30,7 @@ public class MultiStateMap extends StateMap if (this.name == null) { - s = BlockRegistry.getNameFromBlock(state.getBlock()); + s = BlockRegistry.getName(state.getBlock()); } else { diff --git a/client/src/main/java/client/renderer/blockmodel/SingleStateMap.java b/client/src/main/java/client/renderer/blockmodel/SingleStateMap.java index 73100e90..8f2cfaaf 100755 --- a/client/src/main/java/client/renderer/blockmodel/SingleStateMap.java +++ b/client/src/main/java/client/renderer/blockmodel/SingleStateMap.java @@ -8,6 +8,6 @@ public class SingleStateMap extends StateMap { protected String getResourceLocation(State state) { - return BlockRegistry.getNameFromBlock(state.getBlock()).toString() + '#' + this.getPropertyString(state.getProperties()); + return BlockRegistry.getName(state.getBlock()).toString() + '#' + this.getPropertyString(state.getProperties()); } } diff --git a/client/src/main/java/client/renderer/entity/RenderDynamite.java b/client/src/main/java/client/renderer/entity/RenderDynamite.java index f23f318f..a4cc0437 100755 --- a/client/src/main/java/client/renderer/entity/RenderDynamite.java +++ b/client/src/main/java/client/renderer/entity/RenderDynamite.java @@ -11,6 +11,6 @@ public class RenderDynamite extends RenderItemEntity { public ItemStack getStack(EntityDynamite entityIn) { - return new ItemStack(ItemRegistry.getRegisteredItem("dynamite" + (entityIn.explosionSize <= 0 || entityIn.explosionSize >= 8 ? "" : "_" + entityIn.explosionSize))); + return new ItemStack(ItemRegistry.byName("dynamite" + (entityIn.explosionSize <= 0 || entityIn.explosionSize >= 8 ? "" : "_" + entityIn.explosionSize))); } } diff --git a/client/src/main/java/client/renderer/entity/RenderTntPrimed.java b/client/src/main/java/client/renderer/entity/RenderTntPrimed.java index 88aa537e..e606e5ea 100755 --- a/client/src/main/java/client/renderer/entity/RenderTntPrimed.java +++ b/client/src/main/java/client/renderer/entity/RenderTntPrimed.java @@ -38,7 +38,7 @@ public class RenderTntPrimed extends Render float f2 = (1.0F - ((float)entity.fuse - partialTicks + 1.0F) / 100.0F) * 0.8F; this.bindEntityTexture(entity); GL11.glTranslatef(-0.5F, -0.5F, 0.5F); - Block tnt = BlockRegistry.getRegisteredBlock("tnt" + (entity.explosionSize <= 0 || entity.explosionSize >= 8 ? "" : "_" + entity.explosionSize)); + Block tnt = BlockRegistry.byName("tnt" + (entity.explosionSize <= 0 || entity.explosionSize >= 8 ? "" : "_" + entity.explosionSize)); blockrendererdispatcher.renderBlockBrightness(tnt.getState(), entity.getBrightness(partialTicks)); GL11.glTranslatef(0.0F, 0.0F, 1.0F); diff --git a/client/src/main/java/client/renderer/particle/EntityBlockDustFX.java b/client/src/main/java/client/renderer/particle/EntityBlockDustFX.java index cc6f8055..27f871d0 100755 --- a/client/src/main/java/client/renderer/particle/EntityBlockDustFX.java +++ b/client/src/main/java/client/renderer/particle/EntityBlockDustFX.java @@ -18,8 +18,8 @@ public class EntityBlockDustFX extends EntityDiggingFX { public EntityFX getEntityFX(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_) { - State iblockstate = BlockRegistry.getStateById(p_178902_15_[0]); - return iblockstate.getBlock().getRenderType() == -1 ? null : (new EntityBlockDustFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, iblockstate)).calculateColor(); + State iblockstate = BlockRegistry.byId(p_178902_15_[0]); + return iblockstate == null || iblockstate.getBlock().getRenderType() == -1 ? null : (new EntityBlockDustFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, iblockstate)).calculateColor(); } } } diff --git a/client/src/main/java/client/renderer/particle/EntityBreakingFX.java b/client/src/main/java/client/renderer/particle/EntityBreakingFX.java index 7e408b49..6692c560 100755 --- a/client/src/main/java/client/renderer/particle/EntityBreakingFX.java +++ b/client/src/main/java/client/renderer/particle/EntityBreakingFX.java @@ -70,7 +70,7 @@ public class EntityBreakingFX extends EntityFX { public EntityFX getEntityFX(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_) { - return new EntityBreakingFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, ItemRegistry.getItemById(p_178902_15_[0])); + return new EntityBreakingFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, ItemRegistry.byId(p_178902_15_[0])); } } diff --git a/client/src/main/java/client/renderer/particle/EntityDiggingFX.java b/client/src/main/java/client/renderer/particle/EntityDiggingFX.java index 9a6e7537..2279c382 100755 --- a/client/src/main/java/client/renderer/particle/EntityDiggingFX.java +++ b/client/src/main/java/client/renderer/particle/EntityDiggingFX.java @@ -118,7 +118,8 @@ public class EntityDiggingFX extends EntityFX { public EntityFX getEntityFX(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_) { - return (new EntityDiggingFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, BlockRegistry.getStateById(p_178902_15_[0]))).calculateColor(); + State state = BlockRegistry.byId(p_178902_15_[0]); + return state == null ? null : (new EntityDiggingFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, state)).calculateColor(); } } } diff --git a/client/src/main/java/client/renderer/texture/TextureMap.java b/client/src/main/java/client/renderer/texture/TextureMap.java index fd2d49a1..4d0c1595 100755 --- a/client/src/main/java/client/renderer/texture/TextureMap.java +++ b/client/src/main/java/client/renderer/texture/TextureMap.java @@ -41,7 +41,7 @@ public class TextureMap extends Texture Map map = Maps.newHashMap(); Map> anim = Maps.newHashMap(); RenderRegistry.registerAnimations(anim); - for(Block block : BlockRegistry.REGISTRY) { + for(Block block : BlockRegistry.blocks()) { block.getAnimatedTextures(map); } for(Entry entry : map.entrySet()) { diff --git a/client/src/main/java/client/renderer/tileentity/TileEntityBannerRenderer.java b/client/src/main/java/client/renderer/tileentity/TileEntityBannerRenderer.java index c5188929..0b65a2db 100755 --- a/client/src/main/java/client/renderer/tileentity/TileEntityBannerRenderer.java +++ b/client/src/main/java/client/renderer/tileentity/TileEntityBannerRenderer.java @@ -10,6 +10,7 @@ import client.Client; import client.renderer.GlState; import client.renderer.model.ModelBanner; import client.renderer.texture.LayeredColorMaskTexture; +import common.block.tile.BlockBannerStanding; import common.collect.Lists; import common.collect.Maps; import common.color.DyeColor; @@ -17,6 +18,7 @@ import common.init.Blocks; import common.tileentity.TileEntityBanner; import common.util.BlockPos; import common.util.ExtMath; +import common.world.State; public class TileEntityBannerRenderer extends TileEntitySpecialRenderer { @@ -28,7 +30,12 @@ public class TileEntityBannerRenderer extends TileEntitySpecialRenderer @@ -44,21 +44,19 @@ public class TileEntityChestRenderer extends TileEntitySpecialRenderer @@ -23,16 +26,17 @@ public class TileEntitySignRenderer extends TileEntitySpecialRenderer> 12 & 255)); + if(state != null) + this.gm.effectRenderer.addBlockDestroyEffects(blockPosIn, state); break; case 2002: @@ -654,7 +653,7 @@ public class WorldClient extends AWorldClient for (int i1 = 0; i1 < 8; ++i1) { - this.spawnEntityFX(ParticleType.ITEM_CRACK, ParticleType.ITEM_CRACK.getShouldIgnoreRange(), d13, d14, d16, this.rand.gaussian() * 0.15D, this.rand.doublev() * 0.2D, this.rand.gaussian() * 0.15D, new int[] {ItemRegistry.getIdFromItem(Items.potion)}); + this.spawnEntityFX(ParticleType.ITEM_CRACK, ParticleType.ITEM_CRACK.getShouldIgnoreRange(), d13, d14, d16, this.rand.gaussian() * 0.15D, this.rand.doublev() * 0.2D, this.rand.gaussian() * 0.15D, new int[] {ItemRegistry.getId(Items.potion)}); } ParticleType enumparticletypes = ParticleType.WATER_SPLASH; diff --git a/common/src/main/java/common/ai/EntityAIEatGrass.java b/common/src/main/java/common/ai/EntityAIEatGrass.java index f1dfb8c2..bc252230 100755 --- a/common/src/main/java/common/ai/EntityAIEatGrass.java +++ b/common/src/main/java/common/ai/EntityAIEatGrass.java @@ -102,7 +102,7 @@ public class EntityAIEatGrass extends EntityAIBase { if (Vars.mobGrief) { - this.entityWorld.playAuxSFX(2001, blockpos1, BlockRegistry.getIdFromBlock(Blocks.grass)); + this.entityWorld.playAuxSFX(2001, blockpos1, BlockRegistry.getId(Blocks.grass.getState())); this.entityWorld.setState(blockpos1, Blocks.dirt.getState(), 2); } diff --git a/common/src/main/java/common/biome/IBiome.java b/common/src/main/java/common/biome/IBiome.java index 27027f1d..31fd8184 100644 --- a/common/src/main/java/common/biome/IBiome.java +++ b/common/src/main/java/common/biome/IBiome.java @@ -12,10 +12,10 @@ public interface IBiome { public IBiome getBiome(Biome base) { return new IBiome() { public State getFiller() { - return BlockRegistry.getRegisteredBlock("air").getState(); + return BlockRegistry.byName("air").getState(); } public State getTop() { - return BlockRegistry.getRegisteredBlock("air").getState(); + return BlockRegistry.byName("air").getState(); } public void growGrass(AWorldServer worldIn, BlockPos pos, State state, Random rand) { } diff --git a/common/src/main/java/common/block/Block.java b/common/src/main/java/common/block/Block.java index 0f03097b..99a70251 100755 --- a/common/src/main/java/common/block/Block.java +++ b/common/src/main/java/common/block/Block.java @@ -1030,7 +1030,7 @@ public class Block { if(item == null) return null; if(item.getBlock() != this) - throw new IllegalArgumentException("Gegenstand für Block " + BlockRegistry.getNameFromBlock(this) + " stimmt nicht überein"); + throw new IllegalArgumentException("Gegenstand für Block " + BlockRegistry.getName(this) + " stimmt nicht überein"); this.item = item; return item; } diff --git a/common/src/main/java/common/block/artificial/BlockBed.java b/common/src/main/java/common/block/artificial/BlockBed.java index 1b322a9c..1d7f8668 100755 --- a/common/src/main/java/common/block/artificial/BlockBed.java +++ b/common/src/main/java/common/block/artificial/BlockBed.java @@ -113,7 +113,7 @@ public class BlockBed extends Block implements Rotatable { } public Item getItemDropped(State state, Random rand, int fortune) { - return state.getValue(PART) == BlockBed.EnumPartType.HEAD ? null : ItemRegistry.getRegisteredItem(this.color.getName() + "_bed"); + return state.getValue(PART) == BlockBed.EnumPartType.HEAD ? null : ItemRegistry.byName(this.color.getName() + "_bed"); } private void setBedBounds() { @@ -169,7 +169,7 @@ public class BlockBed extends Block implements Rotatable { } public Item getItem(World worldIn, BlockPos pos) { - return ItemRegistry.getRegisteredItem(this.color.getName() + "_bed"); + return ItemRegistry.byName(this.color.getName() + "_bed"); } // public void onBlockHarvested(World worldIn, BlockPos pos, State state, EntityNPC player) { diff --git a/common/src/main/java/common/block/artificial/BlockDoor.java b/common/src/main/java/common/block/artificial/BlockDoor.java index 383f01bc..f82e39b4 100755 --- a/common/src/main/java/common/block/artificial/BlockDoor.java +++ b/common/src/main/java/common/block/artificial/BlockDoor.java @@ -7,8 +7,6 @@ import common.block.Rotatable; import common.block.Material; import common.collect.Lists; import common.entity.npc.EntityNPC; -import common.init.Blocks; -import common.init.Items; import common.item.Item; import common.item.block.ItemDoor; import common.model.BlockLayer; @@ -278,7 +276,7 @@ public class BlockDoor extends Block implements Rotatable */ public Item getItemDropped(State state, Random rand, int fortune) { - return state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER ? null : this.getDoorItem(); + return state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER ? null : this.getItem(); } /** @@ -300,30 +298,33 @@ public class BlockDoor extends Block implements Rotatable return 1; } - public static int combineMetadata(IBlockAccess worldIn, BlockPos pos) - { - State iblockstate = worldIn.getState(pos); - int i = iblockstate.getBlock().getMetaFromState(iblockstate); - boolean flag = isTop(i); - State iblockstate1 = worldIn.getState(pos.down()); - int j = iblockstate1.getBlock().getMetaFromState(iblockstate1); - int k = flag ? j : i; - State iblockstate2 = worldIn.getState(pos.up()); - int l = iblockstate2.getBlock().getMetaFromState(iblockstate2); - int i1 = flag ? i : l; - boolean flag1 = (i1 & 1) != 0; - boolean flag2 = (i1 & 2) != 0; - return removeHalfBit(k) | (flag ? 8 : 0) | (flag1 ? 16 : 0) | (flag2 ? 32 : 0); + private static int combineMetadata(IBlockAccess worldIn, BlockPos pos) { + State state = worldIn.getState(pos); + int meta = getMetadata(state); + boolean top = isTop(meta); + State down = worldIn.getState(pos.down()); + int dmeta = getMetadata(down); + int m1 = top ? dmeta : meta; + State up = worldIn.getState(pos.up()); + int umeta = getMetadata(up); + int m2 = top ? meta : umeta; + boolean right = (m2 & 1) != 0; + boolean power = (m2 & 2) != 0; + return removeHalfBit(m1) | (top ? 8 : 0) | (right ? 16 : 0) | (power ? 32 : 0); + } + + private static int getMetadata(State state) { + if(!(state.getBlock() instanceof BlockDoor)) + return 0; + else if(state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER) + return 8 | (state.getValue(HINGE) == BlockDoor.EnumHingePosition.RIGHT ? 1 : 0) | (state.getValue(POWERED) ? 2 : 0); + else + return state.getValue(FACING).rotateY().getHorizontalIndex() | (state.getValue(OPEN) ? 4 : 0); } public Item getItem(World worldIn, BlockPos pos) { - return this.getDoorItem(); - } - - private Item getDoorItem() - { - return this == Blocks.iron_door ? Items.iron_door : (this == Blocks.spruce_door ? Items.spruce_door : (this == Blocks.birch_door ? Items.birch_door : (this == Blocks.jungle_door ? Items.jungle_door : (this == Blocks.acacia_door ? Items.acacia_door : (this == Blocks.dark_oak_door ? Items.dark_oak_door : (this == Blocks.cherry_door ? Items.cherry_door : (this == Blocks.maple_door ? Items.maple_door : Items.oak_door))))))); + return this.getItem(); } // public void onBlockHarvested(World worldIn, BlockPos pos, State state, EntityNPC player) diff --git a/common/src/main/java/common/block/artificial/BlockFlowerPot.java b/common/src/main/java/common/block/artificial/BlockFlowerPot.java index 889326a3..3142e6f9 100755 --- a/common/src/main/java/common/block/artificial/BlockFlowerPot.java +++ b/common/src/main/java/common/block/artificial/BlockFlowerPot.java @@ -157,7 +157,7 @@ public class BlockFlowerPot extends Block } else { - worldIn.setState(pos, BlockRegistry.getRegisteredBlock("flowerpot_" + BlockRegistry.getNameFromBlock(block)).getState(), 2); + worldIn.setState(pos, BlockRegistry.byName("flowerpot_" + BlockRegistry.getName(block)).getState(), 2); // tileentityflowerpot.setFlowerPotData(itemstack.getItem(), itemstack.getMetadata()); // tileentityflowerpot.markDirty(); // worldIn.markBlockForUpdate(pos); @@ -231,7 +231,7 @@ public class BlockFlowerPot extends Block else if(this.content == Blocks.cactus) return flower_pot_cactus; else { - String plant = BlockRegistry.getNameFromBlock(this.content); + String plant = BlockRegistry.getName(this.content); return provider.getModel("flower_pot") .add(5, 0, 5, 6, 6, 11) .d().uv(5, 5, 6, 11) diff --git a/common/src/main/java/common/block/artificial/BlockStairs.java b/common/src/main/java/common/block/artificial/BlockStairs.java index a65a983f..bbbaef2f 100755 --- a/common/src/main/java/common/block/artificial/BlockStairs.java +++ b/common/src/main/java/common/block/artificial/BlockStairs.java @@ -814,7 +814,7 @@ public class BlockStairs extends Block implements Rotatable } public Model getModel(ModelProvider provider, String name, State state) { - String primary = this.modelBlock.getModel(provider, BlockRegistry.getNameFromBlock(this.modelBlock).toString(), this.modelState) + String primary = this.modelBlock.getModel(provider, BlockRegistry.getName(this.modelBlock).toString(), this.modelState) .getPrimary(); return provider.getModel(primary) .stairs(state.getValue(HALF) == EnumHalf.TOP, state.getValue(SHAPE) == EnumShape.INNER_RIGHT || diff --git a/common/src/main/java/common/block/foliage/BlockLeaves.java b/common/src/main/java/common/block/foliage/BlockLeaves.java index 0c6bcdcd..d95cb516 100755 --- a/common/src/main/java/common/block/foliage/BlockLeaves.java +++ b/common/src/main/java/common/block/foliage/BlockLeaves.java @@ -246,7 +246,7 @@ public class BlockLeaves extends BlockLeavesBase */ public Item getItemDropped(State state, Random rand, int fortune) { - return ItemRegistry.getRegisteredItem(this.type.getName() + "_sapling"); + return ItemRegistry.byName(this.type.getName() + "_sapling"); } /** @@ -287,7 +287,7 @@ public class BlockLeaves extends BlockLeavesBase } if(this.type.getItem() != null && worldIn.rand.chance(i)) // np - spawnAsEntity(worldIn, pos, new ItemStack(ItemRegistry.getRegisteredItem(this.type.getItem()))); + spawnAsEntity(worldIn, pos, new ItemStack(ItemRegistry.byName(this.type.getItem()))); } } diff --git a/common/src/main/java/common/block/liquid/BlockDynamicLiquid.java b/common/src/main/java/common/block/liquid/BlockDynamicLiquid.java index c4dca049..bec5174e 100755 --- a/common/src/main/java/common/block/liquid/BlockDynamicLiquid.java +++ b/common/src/main/java/common/block/liquid/BlockDynamicLiquid.java @@ -315,12 +315,12 @@ public class BlockDynamicLiquid extends BlockLiquid } public void getAnimatedTextures(Map map) { - map.put(BlockRegistry.getNameFromBlock(this.staticBlock) + "_flow", this.animation); + map.put(BlockRegistry.getName(this.staticBlock) + "_flow", this.animation); } public String getFallbackTexture() { if(this.cachedTexture == null) - this.cachedTexture = BlockRegistry.getNameFromBlock(this.staticBlock) + "_still"; + this.cachedTexture = BlockRegistry.getName(this.staticBlock) + "_still"; return this.cachedTexture; } } diff --git a/common/src/main/java/common/block/liquid/BlockStaticLiquid.java b/common/src/main/java/common/block/liquid/BlockStaticLiquid.java index 6e25ad74..f8a74ea4 100755 --- a/common/src/main/java/common/block/liquid/BlockStaticLiquid.java +++ b/common/src/main/java/common/block/liquid/BlockStaticLiquid.java @@ -114,12 +114,12 @@ public class BlockStaticLiquid extends BlockLiquid } public void getAnimatedTextures(Map map) { - map.put(BlockRegistry.getNameFromBlock(this) + "_still", this.animation); + map.put(BlockRegistry.getName(this) + "_still", this.animation); } public String getFallbackTexture() { if(this.cachedTexture == null) - this.cachedTexture = BlockRegistry.getNameFromBlock(this) + "_still"; + this.cachedTexture = BlockRegistry.getName(this) + "_still"; return this.cachedTexture; } } diff --git a/common/src/main/java/common/block/tech/BlockPistonBase.java b/common/src/main/java/common/block/tech/BlockPistonBase.java index 0249caf7..629fc665 100755 --- a/common/src/main/java/common/block/tech/BlockPistonBase.java +++ b/common/src/main/java/common/block/tech/BlockPistonBase.java @@ -404,7 +404,7 @@ public class BlockPistonBase extends Block implements Directional } worldIn.setState(pos, Blocks.piston_extension.getState().withProperty(BlockPistonMoving.FACING, enumfacing).withProperty(BlockPistonMoving.TYPE, this.isSticky ? BlockPistonHead.EnumPistonType.STICKY : BlockPistonHead.EnumPistonType.DEFAULT), 3); - worldIn.setTileEntity(pos, BlockPistonMoving.newTileEntity(this.getStateFromMeta(eventParam), enumfacing, false, true)); + worldIn.setTileEntity(pos, BlockPistonMoving.newTileEntity(this.getState().withProperty(FACING, getFacing(eventParam)).withProperty(EXTENDED, (eventParam & 8) > 0), enumfacing, false, true)); if (this.isSticky) { diff --git a/common/src/main/java/common/block/tech/BlockWorkbench.java b/common/src/main/java/common/block/tech/BlockWorkbench.java index 5e803da7..051e0ef6 100755 --- a/common/src/main/java/common/block/tech/BlockWorkbench.java +++ b/common/src/main/java/common/block/tech/BlockWorkbench.java @@ -75,7 +75,7 @@ public class BlockWorkbench extends Block public String getGuiID() { - return BlockRegistry.getNameFromBlock(this.block); + return BlockRegistry.getName(this.block); } } } diff --git a/common/src/main/java/common/block/tile/BlockBanner.java b/common/src/main/java/common/block/tile/BlockBanner.java index 6c0dd05d..1b85f3b3 100755 --- a/common/src/main/java/common/block/tile/BlockBanner.java +++ b/common/src/main/java/common/block/tile/BlockBanner.java @@ -8,7 +8,6 @@ import common.init.Items; import common.item.Item; import common.item.ItemStack; import common.model.Transforms; -import common.properties.PropertyInteger; import common.rng.Random; import common.tags.TagObject; import common.tileentity.TileEntity; @@ -21,8 +20,6 @@ import common.world.World; public class BlockBanner extends BlockContainer implements Rotatable { - public static final PropertyInteger ROTATION = PropertyInteger.create("rotation", 0, 15); - public BlockBanner() { super(Material.WOOD); diff --git a/common/src/main/java/common/block/tile/BlockBannerStanding.java b/common/src/main/java/common/block/tile/BlockBannerStanding.java index b821fac5..f3560af2 100644 --- a/common/src/main/java/common/block/tile/BlockBannerStanding.java +++ b/common/src/main/java/common/block/tile/BlockBannerStanding.java @@ -4,12 +4,15 @@ import common.block.Block; import common.item.Item; import common.item.block.ItemBanner; import common.properties.Property; +import common.properties.PropertyInteger; import common.util.BlockPos; import common.world.State; import common.world.World; public class BlockBannerStanding extends BlockBanner { + public static final PropertyInteger ROTATION = PropertyInteger.create("rotation", 0, 15); + public BlockBannerStanding() { this.setDefaultState(this.getBaseState().withProperty(ROTATION, Integer.valueOf(0))); diff --git a/common/src/main/java/common/dimension/Dimension.java b/common/src/main/java/common/dimension/Dimension.java index 4d6fb4a1..eb4fee9b 100755 --- a/common/src/main/java/common/dimension/Dimension.java +++ b/common/src/main/java/common/dimension/Dimension.java @@ -223,7 +223,7 @@ public abstract class Dimension extends Nameable implements Comparable= 8 ? "" : "_" + this.explosionSize)))); + this.worldObj.spawnParticle(ParticleType.ITEM_CRACK, this.posX, this.posY, this.posZ, ((double)this.rand.floatv() - 0.5D) * 0.08D, ((double)this.rand.floatv() - 0.5D) * 0.08D, ((double)this.rand.floatv() - 0.5D) * 0.08D, ItemRegistry.getId(ItemRegistry.byName("dynamite" + (this.explosionSize <= 0 || this.explosionSize >= 8 ? "" : "_" + this.explosionSize)))); } if (!this.worldObj.client) diff --git a/common/src/main/java/common/entity/projectile/EntityEgg.java b/common/src/main/java/common/entity/projectile/EntityEgg.java index f010a1b3..d816fea6 100755 --- a/common/src/main/java/common/entity/projectile/EntityEgg.java +++ b/common/src/main/java/common/entity/projectile/EntityEgg.java @@ -60,7 +60,7 @@ public class EntityEgg extends EntityThrowable for (int k = 0; k < 8; ++k) { - this.worldObj.spawnParticle(ParticleType.ITEM_CRACK, this.posX, this.posY, this.posZ, ((double)this.rand.floatv() - 0.5D) * 0.08D, ((double)this.rand.floatv() - 0.5D) * 0.08D, ((double)this.rand.floatv() - 0.5D) * 0.08D, ItemRegistry.getIdFromItem(Items.egg)); + this.worldObj.spawnParticle(ParticleType.ITEM_CRACK, this.posX, this.posY, this.posZ, ((double)this.rand.floatv() - 0.5D) * 0.08D, ((double)this.rand.floatv() - 0.5D) * 0.08D, ((double)this.rand.floatv() - 0.5D) * 0.08D, ItemRegistry.getId(Items.egg)); } if (!this.worldObj.client) diff --git a/common/src/main/java/common/entity/projectile/EntityHook.java b/common/src/main/java/common/entity/projectile/EntityHook.java index f01f65e9..44469994 100755 --- a/common/src/main/java/common/entity/projectile/EntityHook.java +++ b/common/src/main/java/common/entity/projectile/EntityHook.java @@ -523,7 +523,7 @@ public class EntityHook extends Entity implements IObjectData tagCompound.setShort("yTile", (short)this.yTile); tagCompound.setShort("zTile", (short)this.zTile); if(this.inTile != null) { - String id = BlockRegistry.getNameFromBlock(this.inTile); + String id = BlockRegistry.getName(this.inTile); tagCompound.setString("inTile", id == null ? "" : id.toString()); } tagCompound.setByte("shake", (byte)this.shake); @@ -541,7 +541,7 @@ public class EntityHook extends Entity implements IObjectData if (tagCompund.hasString("inTile")) { - this.inTile = BlockRegistry.getRegisteredBlock(tagCompund.getString("inTile")); + this.inTile = BlockRegistry.byName(tagCompund.getString("inTile")); } else { diff --git a/common/src/main/java/common/entity/projectile/EntityProjectile.java b/common/src/main/java/common/entity/projectile/EntityProjectile.java index 394801ed..b78d031b 100755 --- a/common/src/main/java/common/entity/projectile/EntityProjectile.java +++ b/common/src/main/java/common/entity/projectile/EntityProjectile.java @@ -259,7 +259,7 @@ public abstract class EntityProjectile extends Entity tagCompound.setShort("yTile", (short)this.yTile); tagCompound.setShort("zTile", (short)this.zTile); if(this.inTile != null) { - String id = BlockRegistry.getNameFromBlock(this.inTile); + String id = BlockRegistry.getName(this.inTile); tagCompound.setString("inTile", id == null ? "" : id.toString()); } tagCompound.setBool("inGround", this.inGround); @@ -280,7 +280,7 @@ public abstract class EntityProjectile extends Entity if (tagCompund.hasString("inTile")) { - this.inTile = BlockRegistry.getRegisteredBlock(tagCompund.getString("inTile")); + this.inTile = BlockRegistry.byName(tagCompund.getString("inTile")); } else { diff --git a/common/src/main/java/common/entity/types/EntityLiving.java b/common/src/main/java/common/entity/types/EntityLiving.java index 587f197a..b3ff23eb 100755 --- a/common/src/main/java/common/entity/types/EntityLiving.java +++ b/common/src/main/java/common/entity/types/EntityLiving.java @@ -224,7 +224,7 @@ public abstract class EntityLiving extends Entity } int i = (int)(150.0D * d0); - ((AWorldServer)this.worldObj).spawnParticle(ParticleType.BLOCK_DUST, this.posX, this.posY, this.posZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, BlockRegistry.getStateId(iblockstate)); + ((AWorldServer)this.worldObj).spawnParticle(ParticleType.BLOCK_DUST, this.posX, this.posY, this.posZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, BlockRegistry.getId(iblockstate)); } } @@ -1043,7 +1043,7 @@ public abstract class EntityLiving extends Entity vec31 = vec31.rotatePitch(-this.rotPitch * (float)Math.PI / 180.0F); vec31 = vec31.rotateYaw(-this.rotYaw * (float)Math.PI / 180.0F); vec31 = vec31.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ); - this.worldObj.spawnParticle(ParticleType.ITEM_CRACK, vec31.xCoord, vec31.yCoord, vec31.zCoord, vec3.xCoord, vec3.yCoord + 0.05D, vec3.zCoord, ItemRegistry.getIdFromItem(stack.getItem())); + this.worldObj.spawnParticle(ParticleType.ITEM_CRACK, vec31.xCoord, vec31.yCoord, vec31.zCoord, vec3.xCoord, vec3.yCoord + 0.05D, vec3.zCoord, ItemRegistry.getId(stack.getItem())); } } diff --git a/common/src/main/java/common/entity/types/EntityThrowable.java b/common/src/main/java/common/entity/types/EntityThrowable.java index a67633e7..3b628ade 100755 --- a/common/src/main/java/common/entity/types/EntityThrowable.java +++ b/common/src/main/java/common/entity/types/EntityThrowable.java @@ -309,7 +309,7 @@ public abstract class EntityThrowable extends Entity implements IProjectile tagCompound.setShort("yTile", (short)this.yTile); tagCompound.setShort("zTile", (short)this.zTile); if(this.inTile != null) { - String id = BlockRegistry.getNameFromBlock(this.inTile); + String id = BlockRegistry.getName(this.inTile); tagCompound.setString("inTile", id == null ? "" : id.toString()); } tagCompound.setByte("shake", (byte)this.throwableShake); @@ -334,7 +334,7 @@ public abstract class EntityThrowable extends Entity implements IProjectile if (tagCompund.hasString("inTile")) { - this.inTile = BlockRegistry.getRegisteredBlock(tagCompund.getString("inTile")); + this.inTile = BlockRegistry.byName(tagCompund.getString("inTile")); } else { diff --git a/common/src/main/java/common/init/BlockRegistry.java b/common/src/main/java/common/init/BlockRegistry.java index 7982371d..8fdd3236 100755 --- a/common/src/main/java/common/init/BlockRegistry.java +++ b/common/src/main/java/common/init/BlockRegistry.java @@ -1,5 +1,12 @@ package common.init; +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + import common.block.*; import common.block.artificial.BlockBed; import common.block.artificial.BlockBookshelf; @@ -128,48 +135,83 @@ import common.block.tile.BlockBannerHanging; import common.block.tile.BlockBannerStanding; import common.block.tile.BlockStandingSign; import common.block.tile.BlockWallSign; +import common.collect.BiMap; +import common.collect.HashBiMap; +import common.collect.Lists; +import common.collect.Maps; import common.color.DyeColor; import common.item.CheatTab; import common.log.Log; import common.model.TextureAnimation; -import common.util.Mapping; +import common.properties.Property; import common.util.Util; import common.world.State; public abstract class BlockRegistry { - public static final Mapping REGISTRY = new Mapping("air"); + private static final Map BLOCK_MAP = HashBiMap.create(); + private static final List BLOCKS = Lists.newArrayList(); + private static final Map BLOCK_NAMES = ((BiMap)BLOCK_MAP).inverse(); + private static final Map STATE_MAP = Maps.newHashMap(); + private static final List STATES = Lists.newArrayList(); + private static final Map STATE_NAMES = Maps.newHashMap(); + private static final IdentityHashMap STATE_IDS = new IdentityHashMap(512); + + private static Block air; + + private static void register(String name, Block block) { + if(BLOCK_MAP.containsKey(name)) + throw new IllegalArgumentException("Block " + name + " ist bereits registriert"); + BLOCKS.add(block); + BLOCK_MAP.put(name, block); + } + + public static Set getKeys() { + return Collections.unmodifiableSet(BLOCK_MAP.keySet()); + } + + public static Block byName(String name) { + Block block = BLOCK_MAP.get(name); + return block == null ? air : block; + } + + public static Block byNameExact(String name) { + return BLOCK_MAP.get(name); + } + + public static String getName(Block block) { + return BLOCK_NAMES.get(block); + } + + public static Iterable blocks() { + return BLOCKS; + } + + public static State byName(String name, State def) { + if(name == null) + return def; + State state = STATE_MAP.get(name); + if(state != null) + return state; + int idx = name.indexOf(","); + Block block = BlockRegistry.byNameExact(idx >= 0 ? name.substring(0, idx) : name); + return block != null ? block.getState() : def; + } - private static int nextBlockId = 0; - - public static int getIdFromBlock(Block block) { - return REGISTRY.getId(block); + public static String getName(State state) { + return STATE_NAMES.get(state); } - public static Block getBlockById(int id) { - return REGISTRY.byId(id); + public static int getId(State state) { + Integer id = STATE_IDS.get(state); + return id == null ? -1 : id.intValue(); } - public static String getNameFromBlock(Block block) { - return REGISTRY.getName(block); + public static State byId(int id) { + return id >= 0 && id < STATES.size() ? STATES.get(id) : null; } - public static Block getRegisteredBlock(String name) { - return REGISTRY.byName(name); - } - - public static int getStateId(State state) { - Block block = state.getBlock(); - return getIdFromBlock(block) + (block.getMetaFromState(state) << 12); - } - - public static State getStateById(int id) { - int i = id & 4095; - int j = id >> 12 & 15; - return getBlockById(i).getStateFromMeta(j); - } - - private static void registerBlock(String name, Block block) { - REGISTRY.register(nextBlockId++, name, block); + public static Iterable states() { + return STATES; } private static void registerFluid(String name, String display, boolean infinite, LiquidType type, boolean opaque, int light, int rate, @@ -180,59 +222,59 @@ public abstract class BlockRegistry { BlockStaticLiquid st = (BlockStaticLiquid)(new BlockStaticLiquid(type.material, opaque, rate, still, dy)).setHardness(100.0F) .setLightOpacity(opaque ? 0 : 3).setLightLevel((float)light / 15.0f).setDisplay(display) .setRadiation(radiation); - registerBlock("flowing_" + name, dy); - registerBlock(name, st); + register("flowing_" + name, dy); + register(name, st); } static void register() { - registerBlock("air", (new BlockAir()).setDisplay("Luft")); + register("air", air = (new BlockAir()).setDisplay("Luft")); Block stone = (new BlockStone()).setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Stein"); - registerBlock("stone", stone); - registerBlock("bedrock", (new BlockBedrock()).setHardness(1000.0F).setResistance(100000.0F).setStepSound(SoundType.STONE) - .setDisplay("Grundgestein").setTab(CheatTab.NATURE).setMiningLevel(6)); - registerBlock("rock", (new Block(Material.SOLID)).setHardness(2.0F).setResistance(15.0F).setStepSound(SoundType.STONE).setDisplay("Felsen").setTab(CheatTab.NATURE)); - registerBlock("smooth_rock", (new Block(Material.SOLID)).setHardness(2.0F).setResistance(15.0F).setStepSound(SoundType.STONE).setDisplay("Glatter Felsen").setTab(CheatTab.NATURE)); - registerBlock("hellrock", (new BlockHellRock()).setHardness(0.4F).setStepSound(SoundType.STONE).setDisplay("Höllenstein")); - registerBlock("cell_rock", (new Block(Material.LOOSE)).setHardness(1.0F).setResistance(3.0F) - .setStepSound(SoundType.SLIME).setDisplay("Zellstein").setTab(CheatTab.NATURE)); - registerBlock("moon_rock", (new Block(Material.SOLID)).setHardness(2.5F).setResistance(10.0F) - .setStepSound(SoundType.STONE).setDisplay("Mondgestein").setTab(CheatTab.NATURE)); + register("stone", stone); + register("bedrock", (new BlockBedrock()).setHardness(1000.0F).setResistance(100000.0F).setStepSound(SoundType.STONE) + .setDisplay("Grundgestein").setTab(CheatTab.NATURE).setMiningLevel(6)); + register("rock", (new Block(Material.SOLID)).setHardness(2.0F).setResistance(15.0F).setStepSound(SoundType.STONE).setDisplay("Felsen").setTab(CheatTab.NATURE)); + register("smooth_rock", (new Block(Material.SOLID)).setHardness(2.0F).setResistance(15.0F).setStepSound(SoundType.STONE).setDisplay("Glatter Felsen").setTab(CheatTab.NATURE)); + register("hellrock", (new BlockHellRock()).setHardness(0.4F).setStepSound(SoundType.STONE).setDisplay("Höllenstein")); + register("cell_rock", (new Block(Material.LOOSE)).setHardness(1.0F).setResistance(3.0F) + .setStepSound(SoundType.SLIME).setDisplay("Zellstein").setTab(CheatTab.NATURE)); + register("moon_rock", (new Block(Material.SOLID)).setHardness(2.5F).setResistance(10.0F) + .setStepSound(SoundType.STONE).setDisplay("Mondgestein").setTab(CheatTab.NATURE)); Block cobblestone = (new Block(Material.SOLID)).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE) .setDisplay("Bruchstein").setTab(CheatTab.NATURE); - registerBlock("cobblestone", cobblestone); + register("cobblestone", cobblestone); Block mossyCobblestone = (new Block(Material.SOLID)).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE) .setDisplay("Bemooster Bruchstein").setTab(CheatTab.NATURE); - registerBlock("mossy_cobblestone", mossyCobblestone); + register("mossy_cobblestone", mossyCobblestone); Block sandstone = (new BlockSandStone("normal")).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Sandstein"); - registerBlock("sandstone", sandstone); - registerBlock("smooth_sandstone", (new BlockSandStone("smooth")).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Glatter Sandstein")); - registerBlock("carved_sandstone", (new BlockSandStone("carved")).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Gemeißelter Sandstein")); - registerBlock("obsidian", (new BlockObsidian()).setHardness(50.0F).setResistance(2000.0F).setStepSound(SoundType.STONE) - .setDisplay("Obsidian").setMiningLevel(3)); - registerBlock("clay", (new BlockClay()).setHardness(0.6F).setStepSound(SoundType.GRAVEL).setDisplay("Ton").setShovelHarvestable()); - registerBlock("hardened_clay", (new BlockHardenedClay()).setHardness(1.25F).setResistance(7.0F).setStepSound(SoundType.STONE).setDisplay("Gebrannter Ton")); + register("sandstone", sandstone); + register("smooth_sandstone", (new BlockSandStone("smooth")).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Glatter Sandstein")); + register("carved_sandstone", (new BlockSandStone("carved")).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Gemeißelter Sandstein")); + register("obsidian", (new BlockObsidian()).setHardness(50.0F).setResistance(2000.0F).setStepSound(SoundType.STONE) + .setDisplay("Obsidian").setMiningLevel(3)); + register("clay", (new BlockClay()).setHardness(0.6F).setStepSound(SoundType.GRAVEL).setDisplay("Ton").setShovelHarvestable()); + register("hardened_clay", (new BlockHardenedClay()).setHardness(1.25F).setResistance(7.0F).setStepSound(SoundType.STONE).setDisplay("Gebrannter Ton")); for(DyeColor color : DyeColor.values()) { - registerBlock(color.getName() + "_clay", (new BlockColoredClay(color)).setHardness(1.25F).setResistance(7.0F) - .setStepSound(SoundType.STONE).setDisplay(color.getSubject(null) + " gefärbter Ton")); + register(color.getName() + "_clay", (new BlockColoredClay(color)).setHardness(1.25F).setResistance(7.0F) + .setStepSound(SoundType.STONE).setDisplay(color.getSubject(null) + " gefärbter Ton")); } - registerBlock("coal_block", (new Block(Material.SOLID)).setHardness(5.0F).setResistance(10.0F) - .setStepSound(SoundType.STONE).setDisplay("Kohleblock").setTab(CheatTab.NATURE).setFlammable(5, 5)); - registerBlock("sand", (new BlockFalling(Material.LOOSE)).setHardness(0.5F).setStepSound(SoundType.SAND).setDisplay("Sand").setShovelHarvestable().setTab(CheatTab.NATURE)); - registerBlock("red_sand", (new BlockFalling(Material.LOOSE)).setHardness(0.5F).setStepSound(SoundType.SAND).setDisplay("Roter Sand").setShovelHarvestable().setTab(CheatTab.NATURE)); - registerBlock("gravel", (new BlockGravel()).setHardness(0.6F).setStepSound(SoundType.GRAVEL).setDisplay("Kies").setShovelHarvestable()); - registerBlock("ash", (new Block(Material.LOOSE)).setHardness(0.2F).setStepSound(SoundType.SAND).setDisplay("Asche") + register("coal_block", (new Block(Material.SOLID)).setHardness(5.0F).setResistance(10.0F) + .setStepSound(SoundType.STONE).setDisplay("Kohleblock").setTab(CheatTab.NATURE).setFlammable(5, 5)); + register("sand", (new BlockFalling(Material.LOOSE)).setHardness(0.5F).setStepSound(SoundType.SAND).setDisplay("Sand").setShovelHarvestable().setTab(CheatTab.NATURE)); + register("red_sand", (new BlockFalling(Material.LOOSE)).setHardness(0.5F).setStepSound(SoundType.SAND).setDisplay("Roter Sand").setShovelHarvestable().setTab(CheatTab.NATURE)); + register("gravel", (new BlockGravel()).setHardness(0.6F).setStepSound(SoundType.GRAVEL).setDisplay("Kies").setShovelHarvestable()); + register("ash", (new Block(Material.LOOSE)).setHardness(0.2F).setStepSound(SoundType.SAND).setDisplay("Asche") .setTab(CheatTab.NATURE).setShovelHarvestable()); - registerBlock("snow_layer", (new BlockSnow()).setHardness(0.1F).setStepSound(SoundType.SNOW).setDisplay("Schnee").setLightOpacity(0) - .setShovelHarvestable()); - registerBlock("snow", (new BlockSnowBlock()).setHardness(0.2F).setStepSound(SoundType.SNOW).setDisplay("Schnee").setShovelHarvestable()); - registerBlock("ice", (new BlockIce()).setHardness(0.5F).setLightOpacity(3).setStepSound(SoundType.GLASS).setDisplay("Eis").setMiningLevel(0)); - registerBlock("packed_ice", (new BlockPackedIce()).setHardness(0.5F).setStepSound(SoundType.GLASS).setDisplay("Packeis").setMiningLevel(0)); - registerBlock("soul_sand", (new BlockSoulSand()).setHardness(0.5F).setStepSound(SoundType.SAND).setDisplay("Seelensand").setShovelHarvestable()); - registerBlock("glowstone", (new BlockGlowstone(Material.TRANSLUCENT)).setHardness(0.3F).setStepSound(SoundType.GLASS).setLightLevel(1.0F) - .setDisplay("Glowstone")); - registerBlock("blackened_stone", (new BlockBlackenedStone()).setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Schwarzstein")); - registerBlock("blackened_cobble", (new Block(Material.SOLID)).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE) - .setDisplay("Schwarzbruchstein").setTab(CheatTab.NATURE)); + register("snow_layer", (new BlockSnow()).setHardness(0.1F).setStepSound(SoundType.SNOW).setDisplay("Schnee").setLightOpacity(0) + .setShovelHarvestable()); + register("snow", (new BlockSnowBlock()).setHardness(0.2F).setStepSound(SoundType.SNOW).setDisplay("Schnee").setShovelHarvestable()); + register("ice", (new BlockIce()).setHardness(0.5F).setLightOpacity(3).setStepSound(SoundType.GLASS).setDisplay("Eis").setMiningLevel(0)); + register("packed_ice", (new BlockPackedIce()).setHardness(0.5F).setStepSound(SoundType.GLASS).setDisplay("Packeis").setMiningLevel(0)); + register("soul_sand", (new BlockSoulSand()).setHardness(0.5F).setStepSound(SoundType.SAND).setDisplay("Seelensand").setShovelHarvestable()); + register("glowstone", (new BlockGlowstone(Material.TRANSLUCENT)).setHardness(0.3F).setStepSound(SoundType.GLASS).setLightLevel(1.0F) + .setDisplay("Glowstone")); + register("blackened_stone", (new BlockBlackenedStone()).setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Schwarzstein")); + register("blackened_cobble", (new Block(Material.SOLID)).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE) + .setDisplay("Schwarzbruchstein").setTab(CheatTab.NATURE)); registerFluid("water", "Wasser", true, LiquidType.WATER, false, 0, 5, 0.0f, TextureAnimation.WATER, TextureAnimation.WATERFLOW); @@ -248,183 +290,183 @@ public abstract class BlockRegistry { registerFluid("springwater", "Klares Wasser", true, LiquidType.COLD, false, 0, 5, 0.0f, 1, 1); - registerBlock("coal_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE).setDisplay("Steinkohle")); - registerBlock("lapis_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE) - .setDisplay("Lapislazulierz").setMiningLevel(1)); - registerBlock("emerald_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE) - .setDisplay("Smaragderz").setMiningLevel(2)); - registerBlock("quartz_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE) - .setDisplay("Quarzerz")); - registerBlock("black_quartz_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE) - .setDisplay("Schwarzes Quarzerz")); + register("coal_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE).setDisplay("Steinkohle")); + register("lapis_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE) + .setDisplay("Lapislazulierz").setMiningLevel(1)); + register("emerald_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE) + .setDisplay("Smaragderz").setMiningLevel(2)); + register("quartz_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE) + .setDisplay("Quarzerz")); + register("black_quartz_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE) + .setDisplay("Schwarzes Quarzerz")); - registerBlock("redstone_ore", (new BlockRedstoneOre(false)).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE) - .setDisplay("Redstone-Erz").setTab(CheatTab.GEMS).setMiningLevel(2)); - registerBlock("lit_redstone_ore", (new BlockRedstoneOre(true)).setLightLevel(0.625F).setHardness(3.0F).setResistance(5.0F) - .setStepSound(SoundType.STONE).setDisplay("Redstone-Erz").setMiningLevel(2)); + register("redstone_ore", (new BlockRedstoneOre(false)).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE) + .setDisplay("Redstone-Erz").setTab(CheatTab.GEMS).setMiningLevel(2)); + register("lit_redstone_ore", (new BlockRedstoneOre(true)).setLightLevel(0.625F).setHardness(3.0F).setResistance(5.0F) + .setStepSound(SoundType.STONE).setDisplay("Redstone-Erz").setMiningLevel(2)); for(MetalType metal : MetalType.values()) { // String loc = metal.name.substring(0, 1).toUpperCase() + metal.name.substring(1); - registerBlock(metal.name + "_ore", (new BlockMetalOre(metal)).setHardness(3.0F).setResistance(5.0F) - .setDisplay(metal.display + "erz").setMiningLevel(1)); + register(metal.name + "_ore", (new BlockMetalOre(metal)).setHardness(3.0F).setResistance(5.0F) + .setDisplay(metal.display + "erz").setMiningLevel(1)); } for(OreType ore : OreType.values()) { // String loc = ore.name.substring(0, 1).toUpperCase() + ore.name.substring(1); - registerBlock(ore.name + "_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE) - .setDisplay(ore.display + "erz").setMiningLevel(ore.material.getHarvestLevel() - 1)); + register(ore.name + "_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(SoundType.STONE) + .setDisplay(ore.display + "erz").setMiningLevel(ore.material.getHarvestLevel() - 1)); } - registerBlock("dirt", (new Block(Material.LOOSE)).setHardness(0.5F).setStepSound(SoundType.GRAVEL).setDisplay("Erde").setShovelHarvestable().setTab(CheatTab.NATURE)); - registerBlock("grass", (new BlockGrass()).setHardness(0.6F).setStepSound(SoundType.GRASS).setDisplay("Gras").setShovelHarvestable()); - registerBlock("coarse_dirt", (new Block(Material.LOOSE)).setHardness(0.5F).setStepSound(SoundType.GRAVEL).setDisplay("Grobe Erde").setShovelHarvestable().setTab(CheatTab.NATURE)); - registerBlock("podzol", (new BlockPodzol()).setHardness(0.5F).setStepSound(SoundType.GRAVEL).setDisplay("Podsol").setShovelHarvestable()); - registerBlock("mycelium", (new BlockMycelium()).setHardness(0.6F).setStepSound(SoundType.GRASS).setDisplay("Myzel").setShovelHarvestable()); - registerBlock("tian", (new Block(Material.SOLID)).setHardness(2.0F).setResistance(15.0F).setStepSound(SoundType.STONE) - .setDisplay("Tian").setTab(CheatTab.NATURE)); - registerBlock("tian_soil", (new BlockTianSoil()).setHardness(2.0F).setResistance(15.0F).setStepSound(SoundType.STONE) - .setDisplay("Tianerde").setTab(CheatTab.NATURE)); - registerBlock("moon_cheese", (new BlockTreasure(Material.SOFT)).setHardness(1.5F).setResistance(5.0F) - .setStepSound(SoundType.CLOTH).setDisplay("Mondkäse").setTab(CheatTab.NATURE)); - registerBlock("slime_block", (new BlockSlime()).setDisplay("Schleimblock").setStepSound(SoundType.SLIME)); - registerBlock("blackened_dirt", (new BlockBlackenedDirt()).setHardness(0.5F).setStepSound(SoundType.GRAVEL).setDisplay("Schwarzerde").setShovelHarvestable()); - registerBlock("blackened_soil", (new BlockBlackenedSoil()).setHardness(0.6F).setStepSound(SoundType.GRASS).setDisplay("Schwarzgrund").setShovelHarvestable()); + register("dirt", (new Block(Material.LOOSE)).setHardness(0.5F).setStepSound(SoundType.GRAVEL).setDisplay("Erde").setShovelHarvestable().setTab(CheatTab.NATURE)); + register("grass", (new BlockGrass()).setHardness(0.6F).setStepSound(SoundType.GRASS).setDisplay("Gras").setShovelHarvestable()); + register("coarse_dirt", (new Block(Material.LOOSE)).setHardness(0.5F).setStepSound(SoundType.GRAVEL).setDisplay("Grobe Erde").setShovelHarvestable().setTab(CheatTab.NATURE)); + register("podzol", (new BlockPodzol()).setHardness(0.5F).setStepSound(SoundType.GRAVEL).setDisplay("Podsol").setShovelHarvestable()); + register("mycelium", (new BlockMycelium()).setHardness(0.6F).setStepSound(SoundType.GRASS).setDisplay("Myzel").setShovelHarvestable()); + register("tian", (new Block(Material.SOLID)).setHardness(2.0F).setResistance(15.0F).setStepSound(SoundType.STONE) + .setDisplay("Tian").setTab(CheatTab.NATURE)); + register("tian_soil", (new BlockTianSoil()).setHardness(2.0F).setResistance(15.0F).setStepSound(SoundType.STONE) + .setDisplay("Tianerde").setTab(CheatTab.NATURE)); + register("moon_cheese", (new BlockTreasure(Material.SOFT)).setHardness(1.5F).setResistance(5.0F) + .setStepSound(SoundType.CLOTH).setDisplay("Mondkäse").setTab(CheatTab.NATURE)); + register("slime_block", (new BlockSlime()).setDisplay("Schleimblock").setStepSound(SoundType.SLIME)); + register("blackened_dirt", (new BlockBlackenedDirt()).setHardness(0.5F).setStepSound(SoundType.GRAVEL).setDisplay("Schwarzerde").setShovelHarvestable()); + register("blackened_soil", (new BlockBlackenedSoil()).setHardness(0.6F).setStepSound(SoundType.GRASS).setDisplay("Schwarzgrund").setShovelHarvestable()); for(BlockTallGrass.EnumType type : BlockTallGrass.EnumType.values()) { - registerBlock(type.getName(), (new BlockTallGrass(type)).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay(type.getDisplay()).setShearsEfficiency(0)); + register(type.getName(), (new BlockTallGrass(type)).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay(type.getDisplay()).setShearsEfficiency(0)); } - registerBlock("deadbush", (new BlockDeadBush()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Toter Busch")); + register("deadbush", (new BlockDeadBush()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Toter Busch")); for(BlockFlower.EnumFlowerType type : BlockFlower.EnumFlowerType.values()) { - registerBlock(type.getName(), (new BlockFlower(type)).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay(type.getDisplay())); + register(type.getName(), (new BlockFlower(type)).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay(type.getDisplay())); } for(BlockDoublePlant.EnumPlantType type : BlockDoublePlant.EnumPlantType.values()) { - registerBlock(type.getName(), new BlockDoublePlant(type).setDisplay(type.getDisplay())); + register(type.getName(), new BlockDoublePlant(type).setDisplay(type.getDisplay())); } Block cactus = (new BlockCactus()).setHardness(0.4F).setStepSound(SoundType.CLOTH).setDisplay("Kaktus"); - registerBlock("cactus", cactus); - registerBlock("reeds", (new BlockReed()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Zuckerrohr")); - registerBlock("vine", (new BlockVine()).setHardness(0.2F).setStepSound(SoundType.GRASS).setDisplay("Ranken").setShearsEfficiency(0)); - registerBlock("waterlily", (new BlockLilyPad()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Seerosenblatt")); - registerBlock("cocoa", (new BlockCocoa()).setHardness(0.2F).setResistance(5.0F).setStepSound(SoundType.WOOD).setDisplay("Kakao")); + register("cactus", cactus); + register("reeds", (new BlockReed()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Zuckerrohr")); + register("vine", (new BlockVine()).setHardness(0.2F).setStepSound(SoundType.GRASS).setDisplay("Ranken").setShearsEfficiency(0)); + register("waterlily", (new BlockLilyPad()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Seerosenblatt")); + register("cocoa", (new BlockCocoa()).setHardness(0.2F).setResistance(5.0F).setStepSound(SoundType.WOOD).setDisplay("Kakao")); Block brownMushroom = (new BlockMushroom()).setHardness(0.0F).setStepSound(SoundType.GRASS).setLightLevel(0.125F) .setDisplay("Pilz"); - registerBlock("brown_mushroom", brownMushroom); - registerBlock("brown_mushroom_block", (new BlockHugeMushroom(Material.WOOD, brownMushroom)).setHardness(0.2F) - .setStepSound(SoundType.WOOD).setDisplay("Pilzblock").setTab(CheatTab.PLANTS)); + register("brown_mushroom", brownMushroom); + register("brown_mushroom_block", (new BlockHugeMushroom(Material.WOOD, brownMushroom)).setHardness(0.2F) + .setStepSound(SoundType.WOOD).setDisplay("Pilzblock").setTab(CheatTab.PLANTS)); Block redMushrooom = (new BlockMushroom()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("Pilz"); - registerBlock("red_mushroom", redMushrooom); - registerBlock("red_mushroom_block", (new BlockHugeMushroom(Material.WOOD, redMushrooom)).setHardness(0.2F) - .setStepSound(SoundType.WOOD).setDisplay("Pilzblock").setTab(CheatTab.PLANTS)); - registerBlock("blue_mushroom", (new BlockBlueShroom()).setHardness(0.0F).setStepSound(SoundType.GRASS).setLightLevel(0.5F) - .setDisplay("Tianpilz")); + register("red_mushroom", redMushrooom); + register("red_mushroom_block", (new BlockHugeMushroom(Material.WOOD, redMushrooom)).setHardness(0.2F) + .setStepSound(SoundType.WOOD).setDisplay("Pilzblock").setTab(CheatTab.PLANTS)); + register("blue_mushroom", (new BlockBlueShroom()).setHardness(0.0F).setStepSound(SoundType.GRASS).setLightLevel(0.5F) + .setDisplay("Tianpilz")); Block pumpkin = (new BlockPumpkin()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Kürbis"); - registerBlock("pumpkin", pumpkin); - registerBlock("pumpkin_stem", (new BlockStem(pumpkin, "Kürbiskerne")).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Kürbisstamm")); + register("pumpkin", pumpkin); + register("pumpkin_stem", (new BlockStem(pumpkin, "Kürbiskerne")).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Kürbisstamm")); Block melon = (new BlockMelon()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Melone"); - registerBlock("melon_block", melon); - registerBlock("melon_stem", (new BlockStem(melon, "Melonenkerne")).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Melonenstamm")); + register("melon_block", melon); + register("melon_stem", (new BlockStem(melon, "Melonenkerne")).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Melonenstamm")); - registerBlock("dry_leaves", (new BlockDryLeaves()).setDisplay("Vertrocknetes Laub")); + register("dry_leaves", (new BlockDryLeaves()).setDisplay("Vertrocknetes Laub")); for(WoodType wood : WoodType.values()) { - registerBlock(wood.getName() + "_log", (new BlockLog()).setDisplay(wood.getDisplay() + "holz")); + register(wood.getName() + "_log", (new BlockLog()).setDisplay(wood.getDisplay() + "holz")); for(LeavesType type : LeavesType.values()) { - registerBlock(wood.getName() + "_leaves_" + type.getName(), (new BlockLeaves(wood, type)).setDisplay(wood.getDisplay() + "laub (" + type.getDisplayName() + ")")); + register(wood.getName() + "_leaves_" + type.getName(), (new BlockLeaves(wood, type)).setDisplay(wood.getDisplay() + "laub (" + type.getDisplayName() + ")")); } - registerBlock(wood.getName() + "_sapling", (new BlockSapling(wood)).setHardness(0.0F).setStepSound(SoundType.GRASS) - .setDisplay(wood.getDisplay() + "setzling")); + register(wood.getName() + "_sapling", (new BlockSapling(wood)).setHardness(0.0F).setStepSound(SoundType.GRASS) + .setDisplay(wood.getDisplay() + "setzling")); } - registerBlock("soul_fire", (new BlockSoulFire()).setHardness(0.0F).setLightLevel(1.0F).setStepSound(SoundType.CLOTH).setDisplay("Feuer der Seelen")); - registerBlock("black_fire", (new BlockTintedFire(0x202020)).setHardness(0.0F).setLightLevel(1.0F).setStepSound(SoundType.CLOTH).setDisplay("Dunkles Feuer")); - registerBlock("web", (new BlockWeb()).setLightOpacity(1).setHardness(4.0F).setDisplay("Spinnennetz")); - registerBlock("fire", (new BlockFire()).setHardness(0.0F).setLightLevel(1.0F).setStepSound(SoundType.CLOTH).setDisplay("Feuer")); + register("soul_fire", (new BlockSoulFire()).setHardness(0.0F).setLightLevel(1.0F).setStepSound(SoundType.CLOTH).setDisplay("Feuer der Seelen")); + register("black_fire", (new BlockTintedFire(0x202020)).setHardness(0.0F).setLightLevel(1.0F).setStepSound(SoundType.CLOTH).setDisplay("Dunkles Feuer")); + register("web", (new BlockWeb()).setLightOpacity(1).setHardness(4.0F).setDisplay("Spinnennetz")); + register("fire", (new BlockFire()).setHardness(0.0F).setLightLevel(1.0F).setStepSound(SoundType.CLOTH).setDisplay("Feuer")); - registerBlock("lapis_block", (new Block(Material.SOLID)).setHardness(3.0F).setResistance(5.0F) - .setStepSound(SoundType.STONE).setDisplay("Lapislazuliblock").setTab(CheatTab.GEMS).setMiningLevel(1)); - registerBlock("emerald_block", (new Block(Material.SOLID)).setHardness(5.0F).setResistance(10.0F) - .setStepSound(SoundType.STONE).setDisplay("Smaragdblock").setTab(CheatTab.GEMS).setMiningLevel(2)); - registerBlock("redstone_block", (new BlockCompressedPowered(Material.SOLID)).setHardness(5.0F).setResistance(10.0F) - .setStepSound(SoundType.STONE).setDisplay("Redstone-Block").setTab(CheatTab.TECHNOLOGY)); + register("lapis_block", (new Block(Material.SOLID)).setHardness(3.0F).setResistance(5.0F) + .setStepSound(SoundType.STONE).setDisplay("Lapislazuliblock").setTab(CheatTab.GEMS).setMiningLevel(1)); + register("emerald_block", (new Block(Material.SOLID)).setHardness(5.0F).setResistance(10.0F) + .setStepSound(SoundType.STONE).setDisplay("Smaragdblock").setTab(CheatTab.GEMS).setMiningLevel(2)); + register("redstone_block", (new BlockCompressedPowered(Material.SOLID)).setHardness(5.0F).setResistance(10.0F) + .setStepSound(SoundType.STONE).setDisplay("Redstone-Block").setTab(CheatTab.TECHNOLOGY)); - registerBlock("glass", (new BlockGlass()).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("Glas")); + register("glass", (new BlockGlass()).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("Glas")); for(DyeColor color : DyeColor.values()) { - registerBlock(color.getName() + "_glass", (new BlockStainedGlass(color)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay(color.getSubject(null) + " gefärbtes Glas")); + register(color.getName() + "_glass", (new BlockStainedGlass(color)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay(color.getSubject(null) + " gefärbtes Glas")); } - registerBlock("glass_pane", (new BlockPane(Material.TRANSLUCENT, false)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("Glasscheibe")); + register("glass_pane", (new BlockPane(Material.TRANSLUCENT, false)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("Glasscheibe")); for(DyeColor color : DyeColor.values()) { - registerBlock(color.getName() + "_glass_pane", (new BlockStainedGlassPane(color)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay(color.getSubject(null) + " gefärbte Glasscheibe")); + register(color.getName() + "_glass_pane", (new BlockStainedGlassPane(color)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay(color.getSubject(null) + " gefärbte Glasscheibe")); } for(DyeColor color : DyeColor.values()) { - registerBlock(color.getName() + "_wool", (new BlockWool(color)).setHardness(0.8F).setStepSound(SoundType.CLOTH).setDisplay(color.getSubject(-1) + " Wolle") - .setShearsEfficiency(1)); + register(color.getName() + "_wool", (new BlockWool(color)).setHardness(0.8F).setStepSound(SoundType.CLOTH).setDisplay(color.getSubject(-1) + " Wolle") + .setShearsEfficiency(1)); } for(DyeColor color : DyeColor.values()) { - registerBlock(color.getName() + "_carpet", (new BlockCarpet(color)).setHardness(0.1F).setStepSound(SoundType.CLOTH).setDisplay(color.getSubject(1) + " Teppich").setLightOpacity(0)); + register(color.getName() + "_carpet", (new BlockCarpet(color)).setHardness(0.1F).setStepSound(SoundType.CLOTH).setDisplay(color.getSubject(1) + " Teppich").setLightOpacity(0)); } for(DyeColor color : BlockBed.COLORS) { - registerBlock(color.getName() + "_bed", (new BlockBed(color)).setStepSound(SoundType.WOOD).setHardness(0.2F).setDisplay(color.getSubject(0) + " Bett")); + register(color.getName() + "_bed", (new BlockBed(color)).setStepSound(SoundType.WOOD).setHardness(0.2F).setDisplay(color.getSubject(0) + " Bett")); } - registerBlock("ladder", (new BlockLadder()).setHardness(0.4F).setStepSound(SoundType.LADDER).setDisplay("Leiter").setAxeHarvestable()); - registerBlock("torch", (new BlockTorch()).setHardness(0.0F).setLightLevel(0.9375F).setStepSound(SoundType.WOOD).setDisplay("Fackel")); - registerBlock("lamp", (new Block(Material.TRANSLUCENT)).setHardness(0.3F).setStepSound(SoundType.GLASS).setLightLevel(1.0F) - .setDisplay("Lampe").setTab(CheatTab.TECHNOLOGY)); - registerBlock("bookshelf", (new BlockBookshelf()).setHardness(1.5F).setStepSound(SoundType.WOOD).setDisplay("Bücherregal")); - registerBlock("cake", (new BlockCake()).setHardness(0.5F).setStepSound(SoundType.CLOTH).setDisplay("Kuchen")); - registerBlock("dragon_egg", (new BlockDragonEgg()).setHardness(3.0F).setResistance(15.0F).setStepSound(SoundType.STONE) - .setLightLevel(0.125F).setDisplay("Drachenei").setTab(CheatTab.DECORATION)); - registerBlock("flowerpot", (new BlockFlowerPot(null)).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Blumentopf")); - registerBlock("flowerpot_cactus", (new BlockFlowerPot(cactus)).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Blumentopf mit " + cactus.getDisplay())); + register("ladder", (new BlockLadder()).setHardness(0.4F).setStepSound(SoundType.LADDER).setDisplay("Leiter").setAxeHarvestable()); + register("torch", (new BlockTorch()).setHardness(0.0F).setLightLevel(0.9375F).setStepSound(SoundType.WOOD).setDisplay("Fackel")); + register("lamp", (new Block(Material.TRANSLUCENT)).setHardness(0.3F).setStepSound(SoundType.GLASS).setLightLevel(1.0F) + .setDisplay("Lampe").setTab(CheatTab.TECHNOLOGY)); + register("bookshelf", (new BlockBookshelf()).setHardness(1.5F).setStepSound(SoundType.WOOD).setDisplay("Bücherregal")); + register("cake", (new BlockCake()).setHardness(0.5F).setStepSound(SoundType.CLOTH).setDisplay("Kuchen")); + register("dragon_egg", (new BlockDragonEgg()).setHardness(3.0F).setResistance(15.0F).setStepSound(SoundType.STONE) + .setLightLevel(0.125F).setDisplay("Drachenei").setTab(CheatTab.DECORATION)); + register("flowerpot", (new BlockFlowerPot(null)).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Blumentopf")); + register("flowerpot_cactus", (new BlockFlowerPot(cactus)).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Blumentopf mit " + cactus.getDisplay())); for(BlockFlower.EnumFlowerType type : BlockFlower.EnumFlowerType.values()) { - registerBlock("flowerpot_" + type.getName(), (new BlockFlowerPot(BlockFlower.getByType(type))).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Blumentopf mit " + type.getDisplay())); + register("flowerpot_" + type.getName(), (new BlockFlowerPot(BlockFlower.getByType(type))).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Blumentopf mit " + type.getDisplay())); } - registerBlock("sponge", (new Block(Material.LOOSE)).setHardness(0.6F).setStepSound(SoundType.GRASS).setDisplay("Schwamm") - .setTab(CheatTab.DECORATION)); - registerBlock("skull", (new BlockSkull()).setHardness(1.0F).setStepSound(SoundType.STONE).setDisplay("Schädel").setTab(CheatTab.DECORATION)); - registerBlock("lit_pumpkin", (new BlockPumpkin()).setHardness(1.0F).setStepSound(SoundType.WOOD).setLightLevel(1.0F).setDisplay("Kürbislaterne")); - registerBlock("hay_block", (new BlockHay()).setHardness(0.5F).setStepSound(SoundType.GRASS).setDisplay("Strohballen") - .setTab(CheatTab.DECORATION)); - registerBlock("sign", (new BlockStandingSign()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Schild")); - registerBlock("wall_sign", (new BlockWallSign()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Schild")); - registerBlock("banner", (new BlockBannerStanding()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Banner")); - registerBlock("wall_banner", (new BlockBannerHanging()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Banner")); + register("sponge", (new Block(Material.LOOSE)).setHardness(0.6F).setStepSound(SoundType.GRASS).setDisplay("Schwamm") + .setTab(CheatTab.DECORATION)); + register("skull", (new BlockSkull()).setHardness(1.0F).setStepSound(SoundType.STONE).setDisplay("Schädel").setTab(CheatTab.DECORATION)); + register("lit_pumpkin", (new BlockPumpkin()).setHardness(1.0F).setStepSound(SoundType.WOOD).setLightLevel(1.0F).setDisplay("Kürbislaterne")); + register("hay_block", (new BlockHay()).setHardness(0.5F).setStepSound(SoundType.GRASS).setDisplay("Strohballen") + .setTab(CheatTab.DECORATION)); + register("sign", (new BlockStandingSign()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Schild")); + register("wall_sign", (new BlockWallSign()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Schild")); + register("banner", (new BlockBannerStanding()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Banner")); + register("wall_banner", (new BlockBannerHanging()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Banner")); - registerBlock("portal", (new BlockPortal()).setHardness(0.0F).setStepSound(SoundType.GLASS).setLightLevel(0.75F).setDisplay("Portal")); - registerBlock("floor_portal", (new BlockFloorPortal(Material.PORTAL)).setHardness(0.0F).setDisplay("Portal")); - registerBlock("portal_frame", (new BlockPortalFrame()).setStepSound(SoundType.GLASS).setLightLevel(0.125F).setHardness(5.0F) - .setDisplay("Portalrahmen").setResistance(2000.0F).setTab(CheatTab.TECHNOLOGY)); + register("portal", (new BlockPortal()).setHardness(0.0F).setStepSound(SoundType.GLASS).setLightLevel(0.75F).setDisplay("Portal")); + register("floor_portal", (new BlockFloorPortal(Material.PORTAL)).setHardness(0.0F).setDisplay("Portal")); + register("portal_frame", (new BlockPortalFrame()).setStepSound(SoundType.GLASS).setLightLevel(0.125F).setHardness(5.0F) + .setDisplay("Portalrahmen").setResistance(2000.0F).setTab(CheatTab.TECHNOLOGY)); - registerBlock("farmland", (new BlockFarmland()).setHardness(0.6F).setStepSound(SoundType.GRAVEL).setDisplay("Ackerboden") - .setShovelHarvestable().setTab(CheatTab.PLANTS)); - registerBlock("wheat", (new BlockCrops()).setDisplay("Getreide")); - registerBlock("carrot", (new BlockCarrot()).setDisplay("Karotten")); - registerBlock("potato", (new BlockPotato()).setDisplay("Kartoffeln")); - registerBlock("soul_wart", (new BlockWart()).setDisplay("Seelenwarze")); + register("farmland", (new BlockFarmland()).setHardness(0.6F).setStepSound(SoundType.GRAVEL).setDisplay("Ackerboden") + .setShovelHarvestable().setTab(CheatTab.PLANTS)); + register("wheat", (new BlockCrops()).setDisplay("Getreide")); + register("carrot", (new BlockCarrot()).setDisplay("Karotten")); + register("potato", (new BlockPotato()).setDisplay("Kartoffeln")); + register("soul_wart", (new BlockWart()).setDisplay("Seelenwarze")); for(MetalType metal : MetalType.values()) { // String loc = metal.name.substring(0, 1).toUpperCase() + metal.name.substring(1); - registerBlock(metal.name + "_block", (new BlockMetalBlock(metal)).setHardness(5.0F).setResistance(10.0F) + register(metal.name + "_block", (new BlockMetalBlock(metal)).setHardness(5.0F).setResistance(10.0F) .setDisplay(metal.display + "block").setMiningLevel(1)); } for(OreType ore : OreType.values()) { // String loc = ore.name.substring(0, 1).toUpperCase() + ore.name.substring(1); - registerBlock(ore.name + "_block", (new Block(Material.SOLID)).setHardness(5.0F).setResistance(10.0F).setStepSound(SoundType.STONE) + register(ore.name + "_block", (new Block(Material.SOLID)).setHardness(5.0F).setResistance(10.0F).setStepSound(SoundType.STONE) .setDisplay(ore.display + "block").setTab(CheatTab.GEMS) .setMiningLevel(ore.material.getHarvestLevel() - 1)); } @@ -434,198 +476,220 @@ public abstract class BlockRegistry { - registerBlock("stone_slab", (new BlockSlab(Material.SOLID, "stone_slab_side", "double_stone_top", "double_stone_top")) + register("stone_slab", (new BlockSlab(Material.SOLID, "stone_slab_side", "double_stone_top", "double_stone_top")) .setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Steinstufe")); - registerBlock("stone_stairs", (new BlockStairs(stone.getState())).setDisplay("Steintreppe")); + register("stone_stairs", (new BlockStairs(stone.getState())).setDisplay("Steintreppe")); - registerBlock("cobblestone_slab", (new BlockSlab(Material.SOLID, "cobblestone")) + register("cobblestone_slab", (new BlockSlab(Material.SOLID, "cobblestone")) .setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Bruchsteinstufe")); - registerBlock("cobblestone_stairs", (new BlockStairs(cobblestone.getState())).setDisplay("Bruchsteintreppe")); - registerBlock("cobblestone_wall", (new BlockWall(cobblestone, "cobblestone")).setDisplay("Bruchsteinmauer")); - registerBlock("mossy_cobblestone_wall", (new BlockWall(mossyCobblestone, "mossy_cobblestone")).setDisplay("Bemooste Bruchsteinmauer")); + register("cobblestone_stairs", (new BlockStairs(cobblestone.getState())).setDisplay("Bruchsteintreppe")); + register("cobblestone_wall", (new BlockWall(cobblestone, "cobblestone")).setDisplay("Bruchsteinmauer")); + register("mossy_cobblestone_wall", (new BlockWall(mossyCobblestone, "mossy_cobblestone")).setDisplay("Bemooste Bruchsteinmauer")); - registerBlock("sandstone_slab", (new BlockSlab(Material.SOLID, "sandstone_normal", "sandstone_bottom", "sandstone_all")) + register("sandstone_slab", (new BlockSlab(Material.SOLID, "sandstone_normal", "sandstone_bottom", "sandstone_all")) .setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Sandsteinstufe")); - registerBlock("sandstone_stairs", (new BlockStairs(sandstone.getState(), - "sandstone_bottom", "sandstone_all")) // fix type - .setDisplay("Sandsteintreppe")); + register("sandstone_stairs", (new BlockStairs(sandstone.getState(), + "sandstone_bottom", "sandstone_all")) // fix type + .setDisplay("Sandsteintreppe")); Block quartz = (new BlockQuartz(false, false)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Quarzblock"); - registerBlock("quartz_block", quartz); - registerBlock("quartz_ornaments", (new BlockQuartz(false, true)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Gemeißelter Quarzblock")); - registerBlock("quartz_pillar", (new BlockQuartzPillar(false)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Quarzsäule")); - registerBlock("quartz_slab", (new BlockSlab(Material.SOLID, "quartz_block_side", "quartz_block_bottom", "quartz_top")) + register("quartz_block", quartz); + register("quartz_ornaments", (new BlockQuartz(false, true)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Gemeißelter Quarzblock")); + register("quartz_pillar", (new BlockQuartzPillar(false)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Quarzsäule")); + register("quartz_slab", (new BlockSlab(Material.SOLID, "quartz_block_side", "quartz_block_bottom", "quartz_top")) .setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Quarzstufe")); - registerBlock("quartz_stairs", (new BlockStairs(quartz.getState(), - "quartz_block_bottom", "quartz_top")) - .setDisplay("Quarztreppe")); + register("quartz_stairs", (new BlockStairs(quartz.getState(), + "quartz_block_bottom", "quartz_top")) + .setDisplay("Quarztreppe")); - registerBlock("iron_bars", (new BlockPane(Material.SOLID, true)).setHardness(5.0F).setResistance(10.0F).setStepSound(SoundType.STONE) - .setDisplay("Eisengitter")); - registerBlock("iron_door", (new BlockDoor(Material.SOLID)).setHardness(5.0F).setStepSound(SoundType.STONE).setDisplay("Eisentür")); - registerBlock("iron_trapdoor", (new BlockTrapDoor(Material.SOLID)).setHardness(5.0F).setStepSound(SoundType.STONE).setDisplay("Eisenfalltür")); + register("iron_bars", (new BlockPane(Material.SOLID, true)).setHardness(5.0F).setResistance(10.0F).setStepSound(SoundType.STONE) + .setDisplay("Eisengitter")); + register("iron_door", (new BlockDoor(Material.SOLID)).setHardness(5.0F).setStepSound(SoundType.STONE).setDisplay("Eisentür")); + register("iron_trapdoor", (new BlockTrapDoor(Material.SOLID)).setHardness(5.0F).setStepSound(SoundType.STONE).setDisplay("Eisenfalltür")); Block brick = (new Block(Material.SOLID)).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE) .setDisplay("Ziegelsteine").setTab(CheatTab.BLOCKS); - registerBlock("brick_block", brick); - registerBlock("brick_slab", (new BlockSlab(Material.SOLID, "brick_block")) + register("brick_block", brick); + register("brick_slab", (new BlockSlab(Material.SOLID, "brick_block")) .setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Ziegelstufe")); - registerBlock("brick_stairs", (new BlockStairs(brick.getState())).setDisplay("Ziegeltreppe")); + register("brick_stairs", (new BlockStairs(brick.getState())).setDisplay("Ziegeltreppe")); Block stonebrick = (new Block(Material.SOLID)).setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE) .setDisplay("Steinziegel").setTab(CheatTab.BLOCKS); - registerBlock("stonebrick", stonebrick); - registerBlock("mossy_stonebrick", (new Block(Material.SOLID)).setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE) - .setDisplay("Bemooste Steinziegel").setTab(CheatTab.BLOCKS)); - registerBlock("cracked_stonebrick", (new Block(Material.SOLID)).setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE) - .setDisplay("Rissige Steinziegel").setTab(CheatTab.BLOCKS)); - registerBlock("carved_stonebrick", (new Block(Material.SOLID)).setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE) - .setDisplay("Gemeißelte Steinziegel").setTab(CheatTab.BLOCKS)); - registerBlock("stonebrick_slab", (new BlockSlab(Material.SOLID, "stonebrick")) + register("stonebrick", stonebrick); + register("mossy_stonebrick", (new Block(Material.SOLID)).setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE) + .setDisplay("Bemooste Steinziegel").setTab(CheatTab.BLOCKS)); + register("cracked_stonebrick", (new Block(Material.SOLID)).setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE) + .setDisplay("Rissige Steinziegel").setTab(CheatTab.BLOCKS)); + register("carved_stonebrick", (new Block(Material.SOLID)).setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE) + .setDisplay("Gemeißelte Steinziegel").setTab(CheatTab.BLOCKS)); + register("stonebrick_slab", (new BlockSlab(Material.SOLID, "stonebrick")) .setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Steinziegelstufe")); - registerBlock("stonebrick_stairs", (new BlockStairs(stonebrick.getState())) - .setDisplay("Steinziegeltreppe")); + register("stonebrick_stairs", (new BlockStairs(stonebrick.getState())) + .setDisplay("Steinziegeltreppe")); Block bloodBrick = (new Block(Material.SOLID)).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE) .setDisplay("Blutrote Ziegel").setTab(CheatTab.BLOCKS); - registerBlock("blood_brick", bloodBrick); - registerBlock("blood_brick_slab", (new BlockSlab(Material.SOLID, "blood_brick")) + register("blood_brick", bloodBrick); + register("blood_brick_slab", (new BlockSlab(Material.SOLID, "blood_brick")) .setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Blutrote Ziegelstufe")); - registerBlock("blood_brick_fence", (new BlockFence(Material.SOLID, "blood_brick")).setHardness(2.0F).setResistance(10.0F) - .setStepSound(SoundType.STONE).setDisplay("Blutroter Ziegelzaun")); - registerBlock("blood_brick_stairs", (new BlockStairs(bloodBrick.getState())).setDisplay("Blutrote Ziegeltreppe")); + register("blood_brick_fence", (new BlockFence(Material.SOLID, "blood_brick")).setHardness(2.0F).setResistance(10.0F) + .setStepSound(SoundType.STONE).setDisplay("Blutroter Ziegelzaun")); + register("blood_brick_stairs", (new BlockStairs(bloodBrick.getState())).setDisplay("Blutrote Ziegeltreppe")); Block blackBrick = (new Block(Material.SOLID)).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE) .setDisplay("Schwarze Ziegel").setTab(CheatTab.BLOCKS); - registerBlock("black_brick", blackBrick); - registerBlock("black_brick_slab", (new BlockSlab(Material.SOLID, "black_brick")) + register("black_brick", blackBrick); + register("black_brick_slab", (new BlockSlab(Material.SOLID, "black_brick")) .setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Schwarze Ziegelstufe")); - registerBlock("black_brick_stairs", (new BlockStairs(blackBrick.getState())).setDisplay("Schwarze Ziegeltreppe")); - registerBlock("black_brick_fence", (new BlockFence(Material.SOLID, "black_brick")).setHardness(2.0F).setResistance(10.0F) - .setStepSound(SoundType.STONE).setDisplay("Schwarzer Ziegelzaun")); + register("black_brick_stairs", (new BlockStairs(blackBrick.getState())).setDisplay("Schwarze Ziegeltreppe")); + register("black_brick_fence", (new BlockFence(Material.SOLID, "black_brick")).setHardness(2.0F).setResistance(10.0F) + .setStepSound(SoundType.STONE).setDisplay("Schwarzer Ziegelzaun")); Block bquartz = (new BlockQuartz(true, false)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Schwarzer Quarzblock"); - registerBlock("black_quartz_block", bquartz); - registerBlock("black_quartz_ornaments", (new BlockQuartz(true, true)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Schwarzer gemeißelter Quarzblock")); - registerBlock("black_quartz_pillar", (new BlockQuartzPillar(true)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Schwarze Quarzsäule")); - registerBlock("black_quartz_slab", (new BlockSlab(Material.SOLID, "black_quartz_block_side", "black_quartz_block_bottom", "black_quartz_top")) + register("black_quartz_block", bquartz); + register("black_quartz_ornaments", (new BlockQuartz(true, true)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Schwarzer gemeißelter Quarzblock")); + register("black_quartz_pillar", (new BlockQuartzPillar(true)).setStepSound(SoundType.STONE).setHardness(0.8F).setDisplay("Schwarze Quarzsäule")); + register("black_quartz_slab", (new BlockSlab(Material.SOLID, "black_quartz_block_side", "black_quartz_block_bottom", "black_quartz_top")) .setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Schwarze Quarzstufe")); - registerBlock("black_quartz_stairs", (new BlockStairs(bquartz.getState(), - "black_quartz_block_bottom", "black_quartz_top")) - .setDisplay("Schwarze Quarztreppe")); + register("black_quartz_stairs", (new BlockStairs(bquartz.getState(), + "black_quartz_block_bottom", "black_quartz_top")) + .setDisplay("Schwarze Quarztreppe")); for(DecoType deco : DecoType.values()) { - registerBlock(deco.name, (new Block(Material.SOLID)).setHardness(2.0F).setResistance(10.0F) - .setStepSound(SoundType.STONE).setDisplay(deco.display).setTab(CheatTab.BLOCKS)); + register(deco.name, (new Block(Material.SOLID)).setHardness(2.0F).setResistance(10.0F) + .setStepSound(SoundType.STONE).setDisplay(deco.display).setTab(CheatTab.BLOCKS)); } - registerBlock("trapdoor", (new BlockTrapDoor(Material.WOOD)).setHardness(3.0F).setStepSound(SoundType.WOOD).setDisplay("Holzfalltür").setFlammable(5, 20)); + register("trapdoor", (new BlockTrapDoor(Material.WOOD)).setHardness(3.0F).setStepSound(SoundType.WOOD).setDisplay("Holzfalltür").setFlammable(5, 20)); for(WoodType wood : WoodType.values()) { Block planks = (new Block(Material.WOOD)).setHardness(2.0F).setResistance(5.0F).setStepSound(SoundType.WOOD) .setDisplay(wood.getDisplay() + "holzbretter").setTab(CheatTab.WOOD).setFlammable(5, 20); - registerBlock(wood.getName() + "_planks", planks); - registerBlock(wood.getName() + "_stairs", (new BlockStairs(planks.getState())) - .setDisplay(wood.getDisplay() + "holztreppe").setFlammable(5, 20)); - registerBlock(wood.getName() + "_slab", (new BlockSlab(Material.WOOD, wood.getName() + "_planks")) - .setHardness(2.0F).setResistance(5.0F).setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzstufe").setFlammable(5, 20)); - registerBlock(wood.getName() + "_fence", (new BlockFence(Material.WOOD, wood.getName() + "_planks")) - .setHardness(2.0F).setResistance(5.0F).setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzzaun").setFlammable(5, 20)); - registerBlock(wood.getName() + "_fence_gate", (new BlockFenceGate(wood)).setHardness(2.0F).setResistance(5.0F) - .setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzzauntor").setFlammable(5, 20)); - registerBlock(wood.getName() + "_door", (new BlockDoor(Material.WOOD)).setHardness(3.0F).setStepSound(SoundType.WOOD) - .setDisplay(wood.getDisplay() + "holztür").setFlammable(5, 20)); + register(wood.getName() + "_planks", planks); + register(wood.getName() + "_stairs", (new BlockStairs(planks.getState())) + .setDisplay(wood.getDisplay() + "holztreppe").setFlammable(5, 20)); + register(wood.getName() + "_slab", (new BlockSlab(Material.WOOD, wood.getName() + "_planks")) + .setHardness(2.0F).setResistance(5.0F).setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzstufe").setFlammable(5, 20)); + register(wood.getName() + "_fence", (new BlockFence(Material.WOOD, wood.getName() + "_planks")) + .setHardness(2.0F).setResistance(5.0F).setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzzaun").setFlammable(5, 20)); + register(wood.getName() + "_fence_gate", (new BlockFenceGate(wood)).setHardness(2.0F).setResistance(5.0F) + .setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzzauntor").setFlammable(5, 20)); + register(wood.getName() + "_door", (new BlockDoor(Material.WOOD)).setHardness(3.0F).setStepSound(SoundType.WOOD) + .setDisplay(wood.getDisplay() + "holztür").setFlammable(5, 20)); } - registerBlock("core", new BlockCore().setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE) - .setDisplay("Chunk-Lade-Kern")); - registerBlock("mob_spawner", (new BlockMobSpawner()).setHardness(3.0F).setResistance(8.0F).setStepSound(SoundType.STONE).setDisplay("Mob-Spawner")); - registerBlock("workbench", (new BlockWorkbench(3)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Werkbank")); - registerBlock("furnace", (new BlockFurnace(false)).setHardness(3.5F).setStepSound(SoundType.STONE).setDisplay("Ofen") - .setTab(CheatTab.TECHNOLOGY)); - registerBlock("lit_furnace", (new BlockFurnace(true)).setHardness(3.5F).setStepSound(SoundType.STONE).setLightLevel(0.875F) - .setDisplay("Ofen (Gefeuert)").setTab(CheatTab.TECHNOLOGY)); + register("core", new BlockCore().setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE) + .setDisplay("Chunk-Lade-Kern")); + register("mob_spawner", (new BlockMobSpawner()).setHardness(3.0F).setResistance(8.0F).setStepSound(SoundType.STONE).setDisplay("Mob-Spawner")); + register("workbench", (new BlockWorkbench(3)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Werkbank")); + register("furnace", (new BlockFurnace(false)).setHardness(3.5F).setStepSound(SoundType.STONE).setDisplay("Ofen") + .setTab(CheatTab.TECHNOLOGY)); + register("lit_furnace", (new BlockFurnace(true)).setHardness(3.5F).setStepSound(SoundType.STONE).setLightLevel(0.875F) + .setDisplay("Ofen (Gefeuert)").setTab(CheatTab.TECHNOLOGY)); for(int z = 0; z < BlockAnvil.ANVILS.length; z++) { - registerBlock("anvil" + (z == 0 ? "" : "_damaged_" + z), (new BlockAnvil(z)).setHardness(5.0F).setStepSound(SoundType.ANVIL).setResistance(2000.0F).setDisplay((z == 0 ? "" : (z == 1 ? "Leicht beschädigter " : "Stark beschädigter ")) + "Amboss")); + register("anvil" + (z == 0 ? "" : "_damaged_" + z), (new BlockAnvil(z)).setHardness(5.0F).setStepSound(SoundType.ANVIL).setResistance(2000.0F).setDisplay((z == 0 ? "" : (z == 1 ? "Leicht beschädigter " : "Stark beschädigter ")) + "Amboss")); } - registerBlock("enchanting_table", (new BlockEnchantmentTable()).setHardness(5.0F).setResistance(2000.0F).setDisplay("Zaubertisch")); - registerBlock("brewing_stand", (new BlockBrewingStand()).setHardness(0.5F).setLightLevel(0.125F).setDisplay("Braustand")); - registerBlock("cauldron", (new BlockCauldron()).setHardness(2.0F).setDisplay("Kessel")); - registerBlock("beacon", (new BlockBeacon()).setDisplay("Leuchtfeuer").setLightLevel(1.0F)); - registerBlock("noteblock", (new BlockNote()).setHardness(0.8F).setDisplay("Notenblock")); - registerBlock("jukebox", (new BlockJukebox()).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Plattenspieler")); - registerBlock("construction_table", (new BlockWorkbench(4)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Konstruktionstisch")); - registerBlock("assembly_unit", (new BlockWorkbench(5)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Fertigungseinheit")); + register("enchanting_table", (new BlockEnchantmentTable()).setHardness(5.0F).setResistance(2000.0F).setDisplay("Zaubertisch")); + register("brewing_stand", (new BlockBrewingStand()).setHardness(0.5F).setLightLevel(0.125F).setDisplay("Braustand")); + register("cauldron", (new BlockCauldron()).setHardness(2.0F).setDisplay("Kessel")); + register("beacon", (new BlockBeacon()).setDisplay("Leuchtfeuer").setLightLevel(1.0F)); + register("noteblock", (new BlockNote()).setHardness(0.8F).setDisplay("Notenblock")); + register("jukebox", (new BlockJukebox()).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Plattenspieler")); + register("construction_table", (new BlockWorkbench(4)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Konstruktionstisch")); + register("assembly_unit", (new BlockWorkbench(5)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Fertigungseinheit")); - registerBlock("chest", (new BlockChest(0)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Truhe")); - registerBlock("trapped_chest", (new BlockChest(1)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Redstonetruhe")); - registerBlock("warp_chest", (new BlockWarpChest()).setHardness(22.5F).setResistance(1000.0F).setStepSound(SoundType.STONE) - .setDisplay("Warptruhe").setLightLevel(0.5F)); + register("chest", (new BlockChest(0)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Truhe")); + register("trapped_chest", (new BlockChest(1)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Redstonetruhe")); + register("warp_chest", (new BlockWarpChest()).setHardness(22.5F).setResistance(1000.0F).setStepSound(SoundType.STONE) + .setDisplay("Warptruhe").setLightLevel(0.5F)); for(int z = 0; z < BlockTNT.TNTS.length; z++) { - registerBlock("tnt" + (z == 0 ? "" : "_" + z), (new BlockTNT(z)).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("TNT" + Util.getTierSuffix(z))); + register("tnt" + (z == 0 ? "" : "_" + z), (new BlockTNT(z)).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("TNT" + Util.getTierSuffix(z))); } - registerBlock("nuke", (new BlockNuke()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("T-17")); + register("nuke", (new BlockNuke()).setHardness(0.0F).setStepSound(SoundType.GRASS).setDisplay("T-17")); - registerBlock("piston", (new BlockPistonBase(false)).setDisplay("Kolben")); - registerBlock("sticky_piston", (new BlockPistonBase(true)).setDisplay("Klebriger Kolben")); - registerBlock("piston_head", (new BlockPistonHead()).setDisplay("Kolben")); - registerBlock("piston_extension", new BlockPistonMoving().setDisplay("Kolben")); - registerBlock("dispenser", (new BlockDispenser()).setHardness(3.5F).setStepSound(SoundType.STONE).setDisplay("Werfer")); - registerBlock("dropper", (new BlockDropper()).setHardness(3.5F).setStepSound(SoundType.STONE).setDisplay("Spender")); - registerBlock("hopper", (new BlockHopper()).setHardness(3.0F).setResistance(8.0F).setStepSound(SoundType.STONE).setDisplay("Trichter")); - registerBlock("tian_reactor", (new BlockTianReactor()).setHardness(3.0F).setResistance(8.0F).setStepSound(SoundType.STONE).setDisplay("Tianreaktor")); + register("piston", (new BlockPistonBase(false)).setDisplay("Kolben")); + register("sticky_piston", (new BlockPistonBase(true)).setDisplay("Klebriger Kolben")); + register("piston_head", (new BlockPistonHead()).setDisplay("Kolben")); + register("piston_extension", new BlockPistonMoving().setDisplay("Kolben")); + register("dispenser", (new BlockDispenser()).setHardness(3.5F).setStepSound(SoundType.STONE).setDisplay("Werfer")); + register("dropper", (new BlockDropper()).setHardness(3.5F).setStepSound(SoundType.STONE).setDisplay("Spender")); + register("hopper", (new BlockHopper()).setHardness(3.0F).setResistance(8.0F).setStepSound(SoundType.STONE).setDisplay("Trichter")); + register("tian_reactor", (new BlockTianReactor()).setHardness(3.0F).setResistance(8.0F).setStepSound(SoundType.STONE).setDisplay("Tianreaktor")); - registerBlock("rail", (new BlockRail()).setHardness(0.7F).setStepSound(SoundType.STONE).setDisplay("Schiene").setMiningLevel(0)); - registerBlock("golden_rail", (new BlockRailPowered()).setHardness(0.7F).setStepSound(SoundType.STONE).setDisplay("Antriebsschiene").setMiningLevel(0)); - registerBlock("detector_rail", (new BlockRailDetector()).setHardness(0.7F).setStepSound(SoundType.STONE).setDisplay("Sensorschiene").setMiningLevel(0)); - registerBlock("activator_rail", (new BlockRailPowered()).setHardness(0.7F).setStepSound(SoundType.STONE).setDisplay("Aktivierungsschiene").setMiningLevel(0)); + register("rail", (new BlockRail()).setHardness(0.7F).setStepSound(SoundType.STONE).setDisplay("Schiene").setMiningLevel(0)); + register("golden_rail", (new BlockRailPowered()).setHardness(0.7F).setStepSound(SoundType.STONE).setDisplay("Antriebsschiene").setMiningLevel(0)); + register("detector_rail", (new BlockRailDetector()).setHardness(0.7F).setStepSound(SoundType.STONE).setDisplay("Sensorschiene").setMiningLevel(0)); + register("activator_rail", (new BlockRailPowered()).setHardness(0.7F).setStepSound(SoundType.STONE).setDisplay("Aktivierungsschiene").setMiningLevel(0)); - registerBlock("lever", (new BlockLever()).setHardness(0.5F).setStepSound(SoundType.WOOD).setDisplay("Hebel")); + register("lever", (new BlockLever()).setHardness(0.5F).setStepSound(SoundType.WOOD).setDisplay("Hebel")); - registerBlock("stone_pressure_plate", (new BlockPressurePlate(Material.SOLID, BlockPressurePlate.Sensitivity.MOBS)).setHardness(0.5F) - .setStepSound(SoundType.STONE).setDisplay("Steindruckplatte")); - registerBlock("wooden_pressure_plate", (new BlockPressurePlate(Material.WOOD, BlockPressurePlate.Sensitivity.EVERYTHING)) - .setHardness(0.5F).setStepSound(SoundType.WOOD).setDisplay("Holzdruckplatte")); - registerBlock("light_weighted_pressure_plate", (new BlockPressurePlateWeighted(Material.SOLID, 15)).setHardness(0.5F) - .setStepSound(SoundType.WOOD).setDisplay("Wägeplatte (niedrige Gewichte)")); - registerBlock("heavy_weighted_pressure_plate", (new BlockPressurePlateWeighted(Material.SOLID, 150)).setHardness(0.5F) - .setStepSound(SoundType.WOOD).setDisplay("Wägeplatte (hohe Gewichte)")); + register("stone_pressure_plate", (new BlockPressurePlate(Material.SOLID, BlockPressurePlate.Sensitivity.MOBS)).setHardness(0.5F) + .setStepSound(SoundType.STONE).setDisplay("Steindruckplatte")); + register("wooden_pressure_plate", (new BlockPressurePlate(Material.WOOD, BlockPressurePlate.Sensitivity.EVERYTHING)) + .setHardness(0.5F).setStepSound(SoundType.WOOD).setDisplay("Holzdruckplatte")); + register("light_weighted_pressure_plate", (new BlockPressurePlateWeighted(Material.SOLID, 15)).setHardness(0.5F) + .setStepSound(SoundType.WOOD).setDisplay("Wägeplatte (niedrige Gewichte)")); + register("heavy_weighted_pressure_plate", (new BlockPressurePlateWeighted(Material.SOLID, 150)).setHardness(0.5F) + .setStepSound(SoundType.WOOD).setDisplay("Wägeplatte (hohe Gewichte)")); - registerBlock("stone_button", (new BlockButton(false, 20, "stone")).setHardness(0.5F).setStepSound(SoundType.STONE).setDisplay("Knopf")); - registerBlock("wooden_button", (new BlockButton(true, 30, "oak_planks")).setHardness(0.5F).setStepSound(SoundType.WOOD).setDisplay("Knopf")); - registerBlock("red_button", (new BlockButton(true, 10, "red_button")).setHardness(0.5F).setStepSound(SoundType.STONE).setDisplay("Knopf")); + register("stone_button", (new BlockButton(false, 20, "stone")).setHardness(0.5F).setStepSound(SoundType.STONE).setDisplay("Knopf")); + register("wooden_button", (new BlockButton(true, 30, "oak_planks")).setHardness(0.5F).setStepSound(SoundType.WOOD).setDisplay("Knopf")); + register("red_button", (new BlockButton(true, 10, "red_button")).setHardness(0.5F).setStepSound(SoundType.STONE).setDisplay("Knopf")); - registerBlock("redstone", (new BlockRedstoneWire()).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Redstone-Staub")); - registerBlock("unlit_redstone_torch", (new BlockRedstoneTorch(false)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Redstone-Fackel")); - registerBlock("redstone_torch", (new BlockRedstoneTorch(true)).setHardness(0.0F).setLightLevel(0.5F).setStepSound(SoundType.WOOD) - .setDisplay("Redstone-Fackel").setTab(CheatTab.TECHNOLOGY)); - registerBlock("repeater", (new BlockRedstoneRepeater(false)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Redstone-Verstärker")); - registerBlock("powered_repeater", (new BlockRedstoneRepeater(true)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Redstone-Verstärker")); - registerBlock("comparator", (new BlockRedstoneComparator(false)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Redstone-Komparator")); - registerBlock("powered_comparator", (new BlockRedstoneComparator(true)).setHardness(0.0F).setLightLevel(0.625F) - .setStepSound(SoundType.WOOD).setDisplay("Redstone-Komparator")); - registerBlock("redstone_lamp", (new BlockRedstoneLight(false)).setHardness(0.3F).setStepSound(SoundType.GLASS) - .setDisplay("Redstone-Lampe").setTab(CheatTab.TECHNOLOGY)); - registerBlock("lit_redstone_lamp", (new BlockRedstoneLight(true)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("Redstone-Lampe")); - registerBlock("daylight_detector", new BlockDaylightDetector(false).setDisplay("Tageslichtsensor")); - registerBlock("daylight_detector_inverted", new BlockDaylightDetector(true).setDisplay("Tageslichtsensor")); - registerBlock("tripwire_hook", (new BlockTripWireHook()).setDisplay("Haken")); - registerBlock("string", (new BlockTripWire()).setDisplay("Stolperdraht").setShearsEfficiency(0)); + register("redstone", (new BlockRedstoneWire()).setHardness(0.0F).setStepSound(SoundType.STONE).setDisplay("Redstone-Staub")); + register("unlit_redstone_torch", (new BlockRedstoneTorch(false)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Redstone-Fackel")); + register("redstone_torch", (new BlockRedstoneTorch(true)).setHardness(0.0F).setLightLevel(0.5F).setStepSound(SoundType.WOOD) + .setDisplay("Redstone-Fackel").setTab(CheatTab.TECHNOLOGY)); + register("repeater", (new BlockRedstoneRepeater(false)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Redstone-Verstärker")); + register("powered_repeater", (new BlockRedstoneRepeater(true)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Redstone-Verstärker")); + register("comparator", (new BlockRedstoneComparator(false)).setHardness(0.0F).setStepSound(SoundType.WOOD).setDisplay("Redstone-Komparator")); + register("powered_comparator", (new BlockRedstoneComparator(true)).setHardness(0.0F).setLightLevel(0.625F) + .setStepSound(SoundType.WOOD).setDisplay("Redstone-Komparator")); + register("redstone_lamp", (new BlockRedstoneLight(false)).setHardness(0.3F).setStepSound(SoundType.GLASS) + .setDisplay("Redstone-Lampe").setTab(CheatTab.TECHNOLOGY)); + register("lit_redstone_lamp", (new BlockRedstoneLight(true)).setHardness(0.3F).setStepSound(SoundType.GLASS).setDisplay("Redstone-Lampe")); + register("daylight_detector", new BlockDaylightDetector(false).setDisplay("Tageslichtsensor")); + register("daylight_detector_inverted", new BlockDaylightDetector(true).setDisplay("Tageslichtsensor")); + register("tripwire_hook", (new BlockTripWireHook()).setDisplay("Haken")); + register("string", (new BlockTripWire()).setDisplay("Stolperdraht").setShearsEfficiency(0)); - REGISTRY.finish(); - - for(Block block : REGISTRY) { + Map map = Maps.newLinkedHashMap(); + for(Block block : BLOCKS) { for(State state : block.getValidStates()) { - state.buildSaved(); + STATE_NAMES.put(state, state.buildSaved()); } + for(int n = 0; n < 16; n++) { + State state = block.getStateFromMeta(n); + String id = STATE_NAMES.get(state); + if(!STATE_MAP.containsKey(id)) { + STATE_MAP.put(id, state); + STATE_IDS.put(state, STATES.size()); + STATES.add(state); + } + } + StringBuilder sb = new StringBuilder("\n\n\tpublic Property[] getSavedProperties() {\n\t\treturn new Property[] {"); + boolean put = false; + for(Property prop : block.getState().getSavedProperties()) { + if(put) + sb.append(", "); + sb.append(prop.getName().toUpperCase()); + put = true; + } + if(put) + map.put(block.getClass(), sb.append("};\n\t}").toString()); + } + for(Entry entry : map.entrySet()) { + System.out.printf("%s.java\n%s\n", entry.getKey().getSimpleName(), entry.getValue()); } - Log.SYSTEM.debug("%d Blöcke registriert", nextBlockId); + Log.SYSTEM.debug("%d Blöcke registriert", BLOCK_MAP.size()); + Log.SYSTEM.debug("%d Blockzustände registriert", STATE_MAP.size()); } } diff --git a/common/src/main/java/common/init/Blocks.java b/common/src/main/java/common/init/Blocks.java index 51b33907..3dee3b61 100755 --- a/common/src/main/java/common/init/Blocks.java +++ b/common/src/main/java/common/init/Blocks.java @@ -580,14 +580,15 @@ public abstract class Blocks { public static final BlockOre zinc_ore = get("zinc_ore"); private static T get(String id) { - if(!BlockRegistry.REGISTRY.has(id)) + T block = (T)BlockRegistry.byNameExact(id); + if(block == null) throw new RuntimeException("Block " + id + " existiert nicht"); - return (T)BlockRegistry.REGISTRY.byName(id); + return block; } static { if(Util.DEVMODE) { - Set blocks = Sets.newHashSet(BlockRegistry.REGISTRY); + Set blocks = Sets.newHashSet(BlockRegistry.blocks()); for(Field field : Blocks.class.getDeclaredFields()) { if(Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && Block.class.isAssignableFrom(field.getType())) try { @@ -599,10 +600,10 @@ public abstract class Blocks { } if(!blocks.isEmpty()) { List list = Lists.newArrayList(blocks); - Collections.sort(list, Comparator.comparing(block -> BlockRegistry.getNameFromBlock(block))); + Collections.sort(list, Comparator.comparing(block -> BlockRegistry.getName(block))); System.err.printf("\n*** -------------------------------------------------------------- ***\n\n"); for(Block block : list) { - String name = BlockRegistry.getNameFromBlock(block); + String name = BlockRegistry.getName(block); System.err.printf("\tpublic static final %s %s = get(\"%s\");\n", block.getClass().getSimpleName(), name, name); } System.err.printf("\n^^^ " + Blocks.class.getCanonicalName() + ": Blockliste ist unvollständig, Bitte neuen Quellcode einfügen ^^^\n"); diff --git a/common/src/main/java/common/init/CraftingRegistry.java b/common/src/main/java/common/init/CraftingRegistry.java index 7afc4c59..e5c7a83f 100755 --- a/common/src/main/java/common/init/CraftingRegistry.java +++ b/common/src/main/java/common/init/CraftingRegistry.java @@ -50,77 +50,77 @@ public abstract class CraftingRegistry static void register() { for(OreType ore : OreType.values()) { - Item item = ItemRegistry.getRegisteredItem(ore.item); + Item item = ItemRegistry.byName(ore.item); ore.material.addRepairItem(item); if(ore.material.hasTools()) { - add(new ItemStack(ItemRegistry.getRegisteredItem(ore.name + "_pickaxe")), TOOLS[0], '#', Items.stick, 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(ore.name + "_shovel")), TOOLS[1], '#', Items.stick, 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(ore.name + "_axe")), TOOLS[2], '#', Items.stick, 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(ore.name + "_hoe")), TOOLS[3], '#', Items.stick, 'X', item); + add(new ItemStack(ItemRegistry.byName(ore.name + "_pickaxe")), TOOLS[0], '#', Items.stick, 'X', item); + add(new ItemStack(ItemRegistry.byName(ore.name + "_shovel")), TOOLS[1], '#', Items.stick, 'X', item); + add(new ItemStack(ItemRegistry.byName(ore.name + "_axe")), TOOLS[2], '#', Items.stick, 'X', item); + add(new ItemStack(ItemRegistry.byName(ore.name + "_hoe")), TOOLS[3], '#', Items.stick, 'X', item); } if(ore.material.hasExtras()) { - add(new ItemStack(ItemRegistry.getRegisteredItem(ore.name + "_shears")), " #", "# ", '#', item); + add(new ItemStack(ItemRegistry.byName(ore.name + "_shears")), " #", "# ", '#', item); } if(ore.material.hasWeapons()) { - add(new ItemStack(ItemRegistry.getRegisteredItem(ore.name + "_sword")), WEAPONS[0], '#', Items.stick, 'X', item); + add(new ItemStack(ItemRegistry.byName(ore.name + "_sword")), WEAPONS[0], '#', Items.stick, 'X', item); } if(ore.material.hasArmor()) { - add(new ItemStack(ItemRegistry.getRegisteredItem(ore.name + "_helmet")), ARMOR[0], 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(ore.name + "_chestplate")), ARMOR[1], 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(ore.name + "_leggings")), ARMOR[2], 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(ore.name + "_boots")), ARMOR[3], 'X', item); + add(new ItemStack(ItemRegistry.byName(ore.name + "_helmet")), ARMOR[0], 'X', item); + add(new ItemStack(ItemRegistry.byName(ore.name + "_chestplate")), ARMOR[1], 'X', item); + add(new ItemStack(ItemRegistry.byName(ore.name + "_leggings")), ARMOR[2], 'X', item); + add(new ItemStack(ItemRegistry.byName(ore.name + "_boots")), ARMOR[3], 'X', item); } - Item block = ItemRegistry.getRegisteredItem(ore.name + "_block"); + Item block = ItemRegistry.byName(ore.name + "_block"); add(new ItemStack(block), "###", "###", "###", '#', item); add(new ItemStack(item, 9), "#", '#', block); } for(MetalType metal : MetalType.values()) { - Item item = ItemRegistry.getRegisteredItem(metal.isPowder ? (metal.name + "_powder") : (metal.name + "_ingot")); + Item item = ItemRegistry.byName(metal.isPowder ? (metal.name + "_powder") : (metal.name + "_ingot")); if(metal.material != null) metal.material.addRepairItem(item); if(metal.material != null && metal.material.hasTools()) { - add(new ItemStack(ItemRegistry.getRegisteredItem(metal.name + "_pickaxe")), TOOLS[0], '#', Items.stick, 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(metal.name + "_shovel")), TOOLS[1], '#', Items.stick, 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(metal.name + "_axe")), TOOLS[2], '#', Items.stick, 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(metal.name + "_hoe")), TOOLS[3], '#', Items.stick, 'X', item); + add(new ItemStack(ItemRegistry.byName(metal.name + "_pickaxe")), TOOLS[0], '#', Items.stick, 'X', item); + add(new ItemStack(ItemRegistry.byName(metal.name + "_shovel")), TOOLS[1], '#', Items.stick, 'X', item); + add(new ItemStack(ItemRegistry.byName(metal.name + "_axe")), TOOLS[2], '#', Items.stick, 'X', item); + add(new ItemStack(ItemRegistry.byName(metal.name + "_hoe")), TOOLS[3], '#', Items.stick, 'X', item); } if(metal.material != null && metal.material.hasExtras()) { - add(new ItemStack(ItemRegistry.getRegisteredItem(metal.name + "_shears")), " #", "# ", '#', item); + add(new ItemStack(ItemRegistry.byName(metal.name + "_shears")), " #", "# ", '#', item); } if(metal.material != null && metal.material.hasWeapons()) { - add(new ItemStack(ItemRegistry.getRegisteredItem(metal.name + "_sword")), WEAPONS[0], '#', Items.stick, 'X', item); + add(new ItemStack(ItemRegistry.byName(metal.name + "_sword")), WEAPONS[0], '#', Items.stick, 'X', item); } if(metal.material != null && metal.material.hasArmor()) { - add(new ItemStack(ItemRegistry.getRegisteredItem(metal.name + "_helmet")), ARMOR[0], 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(metal.name + "_chestplate")), ARMOR[1], 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(metal.name + "_leggings")), ARMOR[2], 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(metal.name + "_boots")), ARMOR[3], 'X', item); + add(new ItemStack(ItemRegistry.byName(metal.name + "_helmet")), ARMOR[0], 'X', item); + add(new ItemStack(ItemRegistry.byName(metal.name + "_chestplate")), ARMOR[1], 'X', item); + add(new ItemStack(ItemRegistry.byName(metal.name + "_leggings")), ARMOR[2], 'X', item); + add(new ItemStack(ItemRegistry.byName(metal.name + "_boots")), ARMOR[3], 'X', item); } - Item block = ItemRegistry.getRegisteredItem(metal.name + "_block"); + Item block = ItemRegistry.byName(metal.name + "_block"); add(new ItemStack(block), "###", "###", "###", '#', item); add(new ItemStack(item, 9), "#", '#', block); } for(ToolType tool : ToolType.values()) { for(String itm : tool.items) { - Item item = ItemRegistry.getRegisteredItem(itm); + Item item = ItemRegistry.byName(itm); tool.material.addRepairItem(item); if(tool.material.hasTools()) { - add(new ItemStack(ItemRegistry.getRegisteredItem(tool.name + "_pickaxe")), TOOLS[0], '#', Items.stick, 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(tool.name + "_shovel")), TOOLS[1], '#', Items.stick, 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(tool.name + "_axe")), TOOLS[2], '#', Items.stick, 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(tool.name + "_hoe")), TOOLS[3], '#', Items.stick, 'X', item); + add(new ItemStack(ItemRegistry.byName(tool.name + "_pickaxe")), TOOLS[0], '#', Items.stick, 'X', item); + add(new ItemStack(ItemRegistry.byName(tool.name + "_shovel")), TOOLS[1], '#', Items.stick, 'X', item); + add(new ItemStack(ItemRegistry.byName(tool.name + "_axe")), TOOLS[2], '#', Items.stick, 'X', item); + add(new ItemStack(ItemRegistry.byName(tool.name + "_hoe")), TOOLS[3], '#', Items.stick, 'X', item); } if(tool.material.hasExtras()) { - add(new ItemStack(ItemRegistry.getRegisteredItem(tool.name + "_shears")), " #", "# ", '#', item); + add(new ItemStack(ItemRegistry.byName(tool.name + "_shears")), " #", "# ", '#', item); } if(tool.material.hasWeapons()) { - add(new ItemStack(ItemRegistry.getRegisteredItem(tool.name + "_sword")), WEAPONS[0], '#', Items.stick, 'X', item); + add(new ItemStack(ItemRegistry.byName(tool.name + "_sword")), WEAPONS[0], '#', Items.stick, 'X', item); } if(tool.material.hasArmor()) { - add(new ItemStack(ItemRegistry.getRegisteredItem(tool.name + "_helmet")), ARMOR[0], 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(tool.name + "_chestplate")), ARMOR[1], 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(tool.name + "_leggings")), ARMOR[2], 'X', item); - add(new ItemStack(ItemRegistry.getRegisteredItem(tool.name + "_boots")), ARMOR[3], 'X', item); + add(new ItemStack(ItemRegistry.byName(tool.name + "_helmet")), ARMOR[0], 'X', item); + add(new ItemStack(ItemRegistry.byName(tool.name + "_chestplate")), ARMOR[1], 'X', item); + add(new ItemStack(ItemRegistry.byName(tool.name + "_leggings")), ARMOR[2], 'X', item); + add(new ItemStack(ItemRegistry.byName(tool.name + "_boots")), ARMOR[3], 'X', item); } } } @@ -227,14 +227,14 @@ public abstract class CraftingRegistry addShapeless(new ItemStack(Items.book, 1), Items.paper, Items.paper, Items.paper, Items.leather); addShapeless(new ItemStack(Items.writable_book, 1), Items.book, Items.ink_sack, Items.feather); for(WoodType wood : WoodType.values()) { - Item planks = ItemRegistry.getRegisteredItem(wood.getName() + "_planks"); - add(new ItemStack(ItemRegistry.getRegisteredItem(wood.getName() + "_fence"), 3), "W#W", "W#W", '#', Items.stick, 'W', planks); - add(new ItemStack(ItemRegistry.getRegisteredItem(wood.getName() + "_fence_gate"), 1), "#W#", "#W#", '#', Items.stick, 'W', planks); - add(new ItemStack(ItemRegistry.getRegisteredItem(wood.getName() + "_door"), 3), "##", "##", "##", '#', planks); - addBasic(new ItemStack(planks, 4), "#", '#', ItemRegistry.getRegisteredItem(wood.getName() + "_log")); - Item slab = ItemRegistry.getRegisteredItem(wood.getName() + "_slab"); + Item planks = ItemRegistry.byName(wood.getName() + "_planks"); + add(new ItemStack(ItemRegistry.byName(wood.getName() + "_fence"), 3), "W#W", "W#W", '#', Items.stick, 'W', planks); + add(new ItemStack(ItemRegistry.byName(wood.getName() + "_fence_gate"), 1), "#W#", "#W#", '#', Items.stick, 'W', planks); + add(new ItemStack(ItemRegistry.byName(wood.getName() + "_door"), 3), "##", "##", "##", '#', planks); + addBasic(new ItemStack(planks, 4), "#", '#', ItemRegistry.byName(wood.getName() + "_log")); + Item slab = ItemRegistry.byName(wood.getName() + "_slab"); add(new ItemStack(slab, 6), "###", '#', planks); - add(new ItemStack(ItemRegistry.getRegisteredItem(wood.getName() + "_stairs"), 4), "# ", "## ", "###", '#', planks); + add(new ItemStack(ItemRegistry.byName(wood.getName() + "_stairs"), 4), "# ", "## ", "###", '#', planks); add(new ItemStack(Items.daylight_detector), "GGG", "QQQ", "WWW", 'G', Items.glass, 'Q', Items.quartz, 'W', slab); add(new ItemStack(Items.chest), "###", "# #", "###", '#', planks); @@ -255,7 +255,7 @@ public abstract class CraftingRegistry add(new ItemStack(Items.wooden_pressure_plate, 1), "##", '#', planks); add(new ItemStack(Items.piston, 1), "TTT", "#X#", "#R#", '#', Items.cobblestone, 'X', Items.iron_ingot, 'R', Items.redstone, 'T', planks); for(DyeColor color : BlockBed.COLORS) { - add(new ItemStack(ItemRegistry.getRegisteredItem(color.getName() + "_bed"), 1), "###", "XXX", '#', BlockWool.getByColor(color).getItem(), 'X', planks); + add(new ItemStack(ItemRegistry.byName(color.getName() + "_bed"), 1), "###", "XXX", '#', BlockWool.getByColor(color).getItem(), 'X', planks); } } diff --git a/common/src/main/java/common/init/ItemRegistry.java b/common/src/main/java/common/init/ItemRegistry.java index 88cf33ab..307437be 100755 --- a/common/src/main/java/common/init/ItemRegistry.java +++ b/common/src/main/java/common/init/ItemRegistry.java @@ -1,11 +1,20 @@ package common.init; +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + import common.attributes.UsageSlot; import common.block.Block; import common.block.liquid.BlockDynamicLiquid; import common.block.liquid.BlockLiquid; import common.block.liquid.BlockStaticLiquid; import common.block.natural.BlockOre; +import common.collect.BiMap; +import common.collect.HashBiMap; +import common.collect.Lists; import common.color.DyeColor; import common.color.TextColor; import common.entity.item.EntityCart; @@ -80,239 +89,257 @@ import common.log.Log; import common.potion.Potion; import common.potion.PotionHelper; import common.util.Pair; -import common.util.Mapping; import common.util.Util; import common.world.Weather; public abstract class ItemRegistry { - public static final Mapping REGISTRY = new Mapping(); - - private static int nextItemId = 4096; + private static final Map ITEM_MAP = HashBiMap.create(); + private static final List ITEMS = Lists.newArrayList(); + private static final Map ITEM_NAMES = ((BiMap)ITEM_MAP).inverse(); + private static final IdentityHashMap ITEM_IDS = new IdentityHashMap(512); - public static int getIdFromItem(Item item) { - return item == null ? 0 : REGISTRY.getId(item); - } - - public static Item getItemById(int id) { - return REGISTRY.byId(id); - } - - public static String getNameFromItem(Item item) { - return REGISTRY.getName(item); - } - - public static Item getRegisteredItem(String name) { - return REGISTRY.byName(name); - } - - private static void registerItem(String name, Item item) { + private static void register(String name, Item item) { if(item.getBlock() != null) - throw new IllegalArgumentException("Item " + name + " darf keinen Block besitzen"); - REGISTRY.register(nextItemId++, name, item); + throw new IllegalArgumentException("Gegenstand " + name + " darf keinen Block besitzen"); + if(ITEM_MAP.containsKey(name)) + throw new IllegalArgumentException("Gegenstand " + name + " ist bereits mit ID " + ITEM_IDS.get(ITEM_MAP.get(name)) + " registriert"); + ITEMS.add(item); + ITEM_MAP.put(name, item); + ITEM_IDS.put(item, ITEMS.size()); + } + + public static Set getKeys() { + return Collections.unmodifiableSet(ITEM_MAP.keySet()); + } + + public static Item byName(String name) { + return ITEM_MAP.get(name); + } + + public static String getName(Item item) { + return ITEM_NAMES.get(item); + } + + public static Item byId(int id) { + return id > 0 && id <= ITEMS.size() ? ITEMS.get(id - 1) : null; + } + + public static int getId(Item item) { + if(item == null) + return 0; + Integer id = ITEM_IDS.get(item); + return id == null ? -1 : id.intValue(); + } + + public static Iterable items() { + return ITEMS; } private static void registerTools(ToolMaterial material, String name, String prefix) { if(material.hasTools()) { - registerItem(name + "_shovel", (new ItemShovel(material)).setDisplay(prefix + "schaufel")); - registerItem(name + "_pickaxe", (new ItemPickaxe(material)).setDisplay(prefix + "spitzhacke")); - registerItem(name + "_axe", (new ItemAxe(material)).setDisplay(prefix + "axt")); - registerItem(name + "_hoe", (new ItemHoe(material)).setDisplay(prefix + "hacke")); + register(name + "_shovel", (new ItemShovel(material)).setDisplay(prefix + "schaufel")); + register(name + "_pickaxe", (new ItemPickaxe(material)).setDisplay(prefix + "spitzhacke")); + register(name + "_axe", (new ItemAxe(material)).setDisplay(prefix + "axt")); + register(name + "_hoe", (new ItemHoe(material)).setDisplay(prefix + "hacke")); } if(material.hasExtras()) { - registerItem(name + "_shears", (new ItemShears(material)).setDisplay(prefix + "schere")); - registerItem(name + "_horse_armor", (new ItemHorseArmor(material, name)).setDisplay(prefix + "pferderüstung")); + register(name + "_shears", (new ItemShears(material)).setDisplay(prefix + "schere")); + register(name + "_horse_armor", (new ItemHorseArmor(material, name)).setDisplay(prefix + "pferderüstung")); } if(material.hasWeapons()) { - registerItem(name + "_sword", (new ItemSword(material)).setDisplay(prefix + "schwert")); + register(name + "_sword", (new ItemSword(material)).setDisplay(prefix + "schwert")); } if(material.hasArmor()) { - registerItem(name + "_helmet", (new ItemArmor(material, name, UsageSlot.HEAD)).setDisplay(prefix == null ? "Kappe" : prefix + "helm")); - registerItem(name + "_chestplate", (new ItemArmor(material, name, UsageSlot.BODY)).setDisplay(prefix == null ? "Jacke" : prefix + "brustpanzer")); - registerItem(name + "_leggings", (new ItemArmor(material, name, UsageSlot.LEGS)).setDisplay(prefix == null ? "Hose" : prefix + "beinschutz")); - registerItem(name + "_boots", (new ItemArmor(material, name, UsageSlot.FEET)).setDisplay(prefix == null ? "Stiefel" : prefix + "stiefel")); + register(name + "_helmet", (new ItemArmor(material, name, UsageSlot.HEAD)).setDisplay(prefix == null ? "Kappe" : prefix + "helm")); + register(name + "_chestplate", (new ItemArmor(material, name, UsageSlot.BODY)).setDisplay(prefix == null ? "Jacke" : prefix + "brustpanzer")); + register(name + "_leggings", (new ItemArmor(material, name, UsageSlot.LEGS)).setDisplay(prefix == null ? "Hose" : prefix + "beinschutz")); + register(name + "_boots", (new ItemArmor(material, name, UsageSlot.FEET)).setDisplay(prefix == null ? "Stiefel" : prefix + "stiefel")); } } static void register() { - for(Block block : BlockRegistry.REGISTRY) { + for(Block block : BlockRegistry.blocks()) { Item item = block.registerItem(); - if(item != null) - REGISTRY.register(BlockRegistry.getIdFromBlock(block), BlockRegistry.getNameFromBlock(block), item); + if(item != null) { + ITEMS.add(item); + ITEM_MAP.put(BlockRegistry.getName(block), item); + ITEM_IDS.put(item, ITEMS.size()); + } } Item bucket = (new ItemBucket(null, false)).setDisplay("Eimer"); - registerItem("bucket", bucket); + register("bucket", bucket); for(Pair liquid : BlockLiquid.LIQUIDS) { - registerItem(BlockRegistry.getNameFromBlock(liquid.first()) + - "_bucket", new ItemBucket(liquid.second(), false).setDisplay("Eimer") - .setContainerItem(bucket)); + register(BlockRegistry.getName(liquid.first()) + + "_bucket", new ItemBucket(liquid.second(), false).setDisplay("Eimer") + .setContainerItem(bucket)); } - registerItem("recursive_bucket", (new ItemBucket(null, true)).setDisplay("Unendlicher Eimer")); + register("recursive_bucket", (new ItemBucket(null, true)).setDisplay("Unendlicher Eimer")); for(Pair liquid : BlockLiquid.LIQUIDS) { - registerItem("recursive_" + BlockRegistry.getNameFromBlock(liquid.first()) + - "_bucket", new ItemBucket(liquid.second(), true).setDisplay("Flutender Eimer")); + register("recursive_" + BlockRegistry.getName(liquid.first()) + + "_bucket", new ItemBucket(liquid.second(), true).setDisplay("Flutender Eimer")); } - registerItem("milk_bucket", (new ItemBucketMilk()).setDisplay("Milch").setContainerItem(bucket)); + register("milk_bucket", (new ItemBucketMilk()).setDisplay("Milch").setContainerItem(bucket)); - registerItem("boat", (new ItemBoat()).setDisplay("Boot")); - registerItem("minecart", (new ItemMinecart(EntityCart.EnumMinecartType.RIDEABLE)).setDisplay("Lore")); - registerItem("chest_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.CHEST)).setDisplay("Güterlore")); - registerItem("hopper_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.HOPPER)).setDisplay("Trichterlore")); - registerItem("tnt_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.TNT)).setDisplay("TNT-Lore") - .setColor(TextColor.RED)); + register("boat", (new ItemBoat()).setDisplay("Boot")); + register("minecart", (new ItemMinecart(EntityCart.EnumMinecartType.RIDEABLE)).setDisplay("Lore")); + register("chest_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.CHEST)).setDisplay("Güterlore")); + register("hopper_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.HOPPER)).setDisplay("Trichterlore")); + register("tnt_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.TNT)).setDisplay("TNT-Lore") + .setColor(TextColor.RED)); for(EntityInfo egg : EntityRegistry.SPAWN_EGGS.values()) { - registerItem(egg.id().toLowerCase() + "_spawner", (new ItemMonsterPlacer(egg.id())) - .setDisplay("Spawner").setMaxAmount(128)); + register(egg.id().toLowerCase() + "_spawner", (new ItemMonsterPlacer(egg.id())) + .setDisplay("Spawner").setMaxAmount(128)); } for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) { for(CharacterInfo charinfo : species.chars) { if(charinfo.spawner) - registerItem(charinfo.skin + "_spawner", (new ItemNpcSpawner(charinfo)).setDisplay("NSC-Spawner") - .setMaxAmount(128)); + register(charinfo.skin + "_spawner", (new ItemNpcSpawner(charinfo)).setDisplay("NSC-Spawner") + .setMaxAmount(128)); } } - registerItem("wand", (new ItemEditWand()).setDisplay("Bearbeitungswerkzeug")); - registerItem("info_wand", (new ItemInfoWand()).setDisplay("Infowerkzeug")); - registerItem("lightning_wand", (new ItemLightning()).setDisplay("Geladenes Zepter")); - registerItem("banhammer", (new ItemBanHammer()).setDisplay("Hammer der Verbannung").setTab(CheatTab.TOOLS)); - registerItem("key", (new ItemKey()).setDisplay("Schlüssel").setTab(CheatTab.TOOLS).setMaxAmount(128)); + register("wand", (new ItemEditWand()).setDisplay("Bearbeitungswerkzeug")); + register("info_wand", (new ItemInfoWand()).setDisplay("Infowerkzeug")); + register("lightning_wand", (new ItemLightning()).setDisplay("Geladenes Zepter")); + register("banhammer", (new ItemBanHammer()).setDisplay("Hammer der Verbannung").setTab(CheatTab.TOOLS)); + register("key", (new ItemKey()).setDisplay("Schlüssel").setTab(CheatTab.TOOLS).setMaxAmount(128)); for(Pair sides : ItemDie.DIE_SIDES) { - registerItem("die_" + sides.first(), (new ItemDie(sides.first(), sides.second())).setDisplay("Würfel").setMaxAmount(128)); + register("die_" + sides.first(), (new ItemDie(sides.first(), sides.second())).setDisplay("Würfel").setMaxAmount(128)); } - registerItem("chick_magnet", (new ItemMagnet(true)).setDisplay("Kükenmagnet")); - registerItem("magnet", (new ItemMagnet(false)).setDisplay("Magnet")); - registerItem("camera", (new ItemCamera()).setDisplay("Kamera").setTab(CheatTab.TOOLS)); + register("chick_magnet", (new ItemMagnet(true)).setDisplay("Kükenmagnet")); + register("magnet", (new ItemMagnet(false)).setDisplay("Magnet")); + register("camera", (new ItemCamera()).setDisplay("Kamera").setTab(CheatTab.TOOLS)); for(Weather weather : Weather.values()) { - registerItem("weather_token_" + weather.getName(), new ItemWeatherToken(weather).setDisplay("Wetterkristall").setTab(CheatTab.TOOLS)); + register("weather_token_" + weather.getName(), new ItemWeatherToken(weather).setDisplay("Wetterkristall").setTab(CheatTab.TOOLS)); } - registerItem("flint_and_steel", (new ItemFlintAndSteel(Blocks.fire)).setDisplay("Feuerzeug")); - registerItem("burning_soul", (new ItemFlintAndSteel(Blocks.soul_fire)).setDisplay("Brennende Seele")); - registerItem("dark_lighter", (new ItemFlintAndSteel(Blocks.black_fire)).setDisplay("Verdunkelndes Feuerzeug")); - registerItem("apple", (new ItemFood(4, false)).setDisplay("Apfel").setMaxAmount(128)); - registerItem("bow", (new ItemBow()).setDisplay("Bogen")); - registerItem("boltgun", (new ItemBoltgun()).setDisplay("Bolter")); - registerItem("bolt", (new ItemAmmo(5, 1.0f, 128)).setDisplay("Bolter-Munition")); - registerItem("arrow", (new ItemArrow()).setDisplay("Pfeil").setTab(CheatTab.COMBAT).setMaxAmount(128)); + register("flint_and_steel", (new ItemFlintAndSteel(Blocks.fire)).setDisplay("Feuerzeug")); + register("burning_soul", (new ItemFlintAndSteel(Blocks.soul_fire)).setDisplay("Brennende Seele")); + register("dark_lighter", (new ItemFlintAndSteel(Blocks.black_fire)).setDisplay("Verdunkelndes Feuerzeug")); + register("apple", (new ItemFood(4, false)).setDisplay("Apfel").setMaxAmount(128)); + register("bow", (new ItemBow()).setDisplay("Bogen")); + register("boltgun", (new ItemBoltgun()).setDisplay("Bolter")); + register("bolt", (new ItemAmmo(5, 1.0f, 128)).setDisplay("Bolter-Munition")); + register("arrow", (new ItemArrow()).setDisplay("Pfeil").setTab(CheatTab.COMBAT).setMaxAmount(128)); Item coal = (new Item()).setDisplay("Kohle").setTab(CheatTab.METALS); - registerItem("coal", coal); - registerItem("charcoal", (new Item()).setDisplay("Holzkohle").setTab(CheatTab.METALS)); - registerItem("stick", (new ItemStick()).setDisplay("Stock").setTab(CheatTab.MATERIALS).setMaxAmount(256)); - registerItem("bowl", (new ItemSmall()).setDisplay("Schüssel").setTab(CheatTab.MISC)); - registerItem("mushroom_stew", (new ItemSoup(6)).setDisplay("Pilzsuppe")); - registerItem("feather", (new Item()).setDisplay("Feder").setTab(CheatTab.MATERIALS).setMaxAmount(512)); - registerItem("gunpowder", (new Item()).setDisplay("Schwarzpulver").setPotionEffect(PotionHelper.gunpowderEffect).setTab(CheatTab.MATERIALS).setMaxAmount(256)); - registerItem("wheats", (new Item()).setDisplay("Weizen").setTab(CheatTab.MATERIALS).setMaxAmount(128)); - registerItem("bread", (new ItemFood(5, false)).setDisplay("Brot")); - registerItem("flint", (new Item()).setDisplay("Feuerstein").setTab(CheatTab.MATERIALS).setMaxAmount(128)); - registerItem("porkchop", (new ItemFood(3, true)).setDisplay("Rohes Schweinefleisch")); - registerItem("cooked_porkchop", (new ItemFood(8, true)).setDisplay("Gebratenes Schweinefleisch")); - registerItem("golden_apple", (new ItemAppleGold(4, false)).setPotionEffect(Potion.REGENERATION, 5, 1, 1.0F) - .setDisplay("Goldener Apfel")); - registerItem("charged_apple", (new ItemAppleGold(4, true)).setPotionEffect(Potion.REGENERATION, 5, 1, 1.0F) - .setDisplay("Geladener Apfel")); - registerItem("saddle", (new ItemSaddle()).setDisplay("Sattel")); - registerItem("snowball", (new ItemSnowball()).setDisplay("Schneeball").setMaxAmount(128)); - registerItem("leather", (new Item()).setDisplay("Leder").setTab(CheatTab.MATERIALS)); - registerItem("brick", (new Item()).setDisplay("Ziegel").setTab(CheatTab.MATERIALS)); - registerItem("clay_ball", (new Item()).setDisplay("Ton").setTab(CheatTab.MATERIALS).setMaxAmount(128)); - registerItem("paper", (new Item()).setDisplay("Papier").setTab(CheatTab.MATERIALS).setMaxAmount(256)); - registerItem("book", (new ItemBook()).setDisplay("Buch").setTab(CheatTab.MISC)); - registerItem("slime_ball", (new Item()).setDisplay("Schleimball").setTab(CheatTab.MATERIALS).setMaxAmount(128)); - registerItem("egg", (new ItemEgg()).setDisplay("Ei").setMaxAmount(128)); - registerItem("navigator", (new ItemSpaceNavigator()).setDisplay("Elektronischer Navigator").setTab(CheatTab.TOOLS)); - registerItem("exterminator", (new ItemExterminator()).setDisplay("Weltenzerstörer").setTab(CheatTab.TOOLS)); - registerItem("fishing_rod", (new ItemFishingRod()).setDisplay("Angel")); - registerItem("glowstone_dust", (new Item()).setDisplay("Glowstonestaub").setPotionEffect(PotionHelper.glowstoneEffect) - .setTab(CheatTab.MATERIALS).setMaxAmount(256)); + register("coal", coal); + register("charcoal", (new Item()).setDisplay("Holzkohle").setTab(CheatTab.METALS)); + register("stick", (new ItemStick()).setDisplay("Stock").setTab(CheatTab.MATERIALS).setMaxAmount(256)); + register("bowl", (new ItemSmall()).setDisplay("Schüssel").setTab(CheatTab.MISC)); + register("mushroom_stew", (new ItemSoup(6)).setDisplay("Pilzsuppe")); + register("feather", (new Item()).setDisplay("Feder").setTab(CheatTab.MATERIALS).setMaxAmount(512)); + register("gunpowder", (new Item()).setDisplay("Schwarzpulver").setPotionEffect(PotionHelper.gunpowderEffect).setTab(CheatTab.MATERIALS).setMaxAmount(256)); + register("wheats", (new Item()).setDisplay("Weizen").setTab(CheatTab.MATERIALS).setMaxAmount(128)); + register("bread", (new ItemFood(5, false)).setDisplay("Brot")); + register("flint", (new Item()).setDisplay("Feuerstein").setTab(CheatTab.MATERIALS).setMaxAmount(128)); + register("porkchop", (new ItemFood(3, true)).setDisplay("Rohes Schweinefleisch")); + register("cooked_porkchop", (new ItemFood(8, true)).setDisplay("Gebratenes Schweinefleisch")); + register("golden_apple", (new ItemAppleGold(4, false)).setPotionEffect(Potion.REGENERATION, 5, 1, 1.0F) + .setDisplay("Goldener Apfel")); + register("charged_apple", (new ItemAppleGold(4, true)).setPotionEffect(Potion.REGENERATION, 5, 1, 1.0F) + .setDisplay("Geladener Apfel")); + register("saddle", (new ItemSaddle()).setDisplay("Sattel")); + register("snowball", (new ItemSnowball()).setDisplay("Schneeball").setMaxAmount(128)); + register("leather", (new Item()).setDisplay("Leder").setTab(CheatTab.MATERIALS)); + register("brick", (new Item()).setDisplay("Ziegel").setTab(CheatTab.MATERIALS)); + register("clay_ball", (new Item()).setDisplay("Ton").setTab(CheatTab.MATERIALS).setMaxAmount(128)); + register("paper", (new Item()).setDisplay("Papier").setTab(CheatTab.MATERIALS).setMaxAmount(256)); + register("book", (new ItemBook()).setDisplay("Buch").setTab(CheatTab.MISC)); + register("slime_ball", (new Item()).setDisplay("Schleimball").setTab(CheatTab.MATERIALS).setMaxAmount(128)); + register("egg", (new ItemEgg()).setDisplay("Ei").setMaxAmount(128)); + register("navigator", (new ItemSpaceNavigator()).setDisplay("Elektronischer Navigator").setTab(CheatTab.TOOLS)); + register("exterminator", (new ItemExterminator()).setDisplay("Weltenzerstörer").setTab(CheatTab.TOOLS)); + register("fishing_rod", (new ItemFishingRod()).setDisplay("Angel")); + register("glowstone_dust", (new Item()).setDisplay("Glowstonestaub").setPotionEffect(PotionHelper.glowstoneEffect) + .setTab(CheatTab.MATERIALS).setMaxAmount(256)); for(ItemFishFood.FishType type : ItemFishFood.FishType.values()) { - registerItem(type.getName(), (new ItemFishFood(false, type)).setDisplay(type.getDisplay())); + register(type.getName(), (new ItemFishFood(false, type)).setDisplay(type.getDisplay())); if(type.canCook()) - registerItem("cooked_" + type.getName(), (new ItemFishFood(true, type)).setDisplay(type.getDisplay())); + register("cooked_" + type.getName(), (new ItemFishFood(true, type)).setDisplay(type.getDisplay())); } Item lapis = null; for(DyeColor color : DyeColor.values()) { Item dye = (new ItemDye(color)).setDisplay(color.getDyeName()).setMaxAmount(512); if(color == DyeColor.BLUE) lapis = dye; - registerItem(color.getDye(), dye); + register(color.getDye(), dye); } - registerItem("bone", (new ItemStick()).setDisplay("Knochen").setTab(CheatTab.MATERIALS).setMaxAmount(128)); - registerItem("sugar", (new Item()).setDisplay("Zucker").setPotionEffect(PotionHelper.sugarEffect).setTab(CheatTab.MATERIALS).setMaxAmount(512)); - registerItem("cookie", (new ItemFood(2, false)).setDisplay("Keks").setMaxAmount(128)); - registerItem("melon", (new ItemFood(2, false)).setDisplay("Melone")); - registerItem("beef", (new ItemFood(3, true)).setDisplay("Rohes Rindfleisch")); - registerItem("cooked_beef", (new ItemFood(8, true)).setDisplay("Steak")); - registerItem("chicken", (new ItemFood(2, true)).setDisplay("Rohes Hühnchen")); - registerItem("cooked_chicken", (new ItemFood(6, true)).setDisplay("Gebratenes Hühnchen")); - registerItem("rotten_flesh", (new ItemFood(4, true)).setDisplay("Verrottetes Fleisch")); - registerItem("orb", (new ItemFragile()).setDisplay("Kugel").setTab(CheatTab.TOOLS)); - registerItem("blaze_rod", (new ItemRod()).setDisplay("Lohenrute").setTab(CheatTab.MATERIALS).setMaxAmount(256)); - registerItem("tear", (new ItemTiny()).setDisplay("Träne").setPotionEffect(PotionHelper.tearEffect).setTab(CheatTab.MATERIALS).setMaxAmount(256)); - registerItem("gold_nugget", (new ItemNugget()).setDisplay("Goldnugget").setTab(CheatTab.METALS).setMaxAmount(256)); + register("bone", (new ItemStick()).setDisplay("Knochen").setTab(CheatTab.MATERIALS).setMaxAmount(128)); + register("sugar", (new Item()).setDisplay("Zucker").setPotionEffect(PotionHelper.sugarEffect).setTab(CheatTab.MATERIALS).setMaxAmount(512)); + register("cookie", (new ItemFood(2, false)).setDisplay("Keks").setMaxAmount(128)); + register("melon", (new ItemFood(2, false)).setDisplay("Melone")); + register("beef", (new ItemFood(3, true)).setDisplay("Rohes Rindfleisch")); + register("cooked_beef", (new ItemFood(8, true)).setDisplay("Steak")); + register("chicken", (new ItemFood(2, true)).setDisplay("Rohes Hühnchen")); + register("cooked_chicken", (new ItemFood(6, true)).setDisplay("Gebratenes Hühnchen")); + register("rotten_flesh", (new ItemFood(4, true)).setDisplay("Verrottetes Fleisch")); + register("orb", (new ItemFragile()).setDisplay("Kugel").setTab(CheatTab.TOOLS)); + register("blaze_rod", (new ItemRod()).setDisplay("Lohenrute").setTab(CheatTab.MATERIALS).setMaxAmount(256)); + register("tear", (new ItemTiny()).setDisplay("Träne").setPotionEffect(PotionHelper.tearEffect).setTab(CheatTab.MATERIALS).setMaxAmount(256)); + register("gold_nugget", (new ItemNugget()).setDisplay("Goldnugget").setTab(CheatTab.METALS).setMaxAmount(256)); for(int data : ItemPotion.getValidDataValues()) { ItemPotion potion = new ItemPotion(data); - registerItem(ItemPotion.getPotionName(potion), potion.setDisplay("Trank")); + register(ItemPotion.getPotionName(potion), potion.setDisplay("Trank")); } - registerItem("glass_bottle", (new ItemGlassBottle()).setDisplay("Glasflasche")); - registerItem("spider_eye", (new ItemFood(2, false)).setPotionEffect(Potion.POISON, 5, 0, 1.0F).setDisplay("Spinnenauge") - .setPotionEffect(PotionHelper.spiderEyeEffect).setMaxAmount(128)); - registerItem("fermented_spider_eye", (new Item()).setDisplay("Fermentiertes Spinnenauge") - .setPotionEffect(PotionHelper.fermentedSpiderEyeEffect).setTab(CheatTab.MISC).setMaxAmount(128)); - registerItem("blazing_powder", (new Item()).setDisplay("Glühender Staub").setPotionEffect(PotionHelper.blazingPowderEffect) - .setTab(CheatTab.MATERIALS).setMaxAmount(256)); - registerItem("magma_cream", (new Item()).setDisplay("Magmacreme").setPotionEffect(PotionHelper.magmaCreamEffect).setTab(CheatTab.MATERIALS).setMaxAmount(128)); - registerItem("charged_orb", (new ItemChargedOrb()).setDisplay("Geladene Kugel")); - registerItem("speckled_melon", (new Item()).setDisplay("Glitzernde Melone").setPotionEffect(PotionHelper.speckledMelonEffect) - .setTab(CheatTab.MISC)); - registerItem("experience_bottle", (new ItemExpBottle()).setDisplay("Erfahrungsfläschchen")); - registerItem("fire_charge", (new ItemFireball()).setDisplay("Feuerkugel")); - registerItem("writable_book", (new Item()).setDisplay("Buch und Feder").setTab(CheatTab.TOOLS)); - registerItem("written_book", (new Item()).setDisplay("Beschriebenes Buch").setTab(CheatTab.MISC)); + register("glass_bottle", (new ItemGlassBottle()).setDisplay("Glasflasche")); + register("spider_eye", (new ItemFood(2, false)).setPotionEffect(Potion.POISON, 5, 0, 1.0F).setDisplay("Spinnenauge") + .setPotionEffect(PotionHelper.spiderEyeEffect).setMaxAmount(128)); + register("fermented_spider_eye", (new Item()).setDisplay("Fermentiertes Spinnenauge") + .setPotionEffect(PotionHelper.fermentedSpiderEyeEffect).setTab(CheatTab.MISC).setMaxAmount(128)); + register("blazing_powder", (new Item()).setDisplay("Glühender Staub").setPotionEffect(PotionHelper.blazingPowderEffect) + .setTab(CheatTab.MATERIALS).setMaxAmount(256)); + register("magma_cream", (new Item()).setDisplay("Magmacreme").setPotionEffect(PotionHelper.magmaCreamEffect).setTab(CheatTab.MATERIALS).setMaxAmount(128)); + register("charged_orb", (new ItemChargedOrb()).setDisplay("Geladene Kugel")); + register("speckled_melon", (new Item()).setDisplay("Glitzernde Melone").setPotionEffect(PotionHelper.speckledMelonEffect) + .setTab(CheatTab.MISC)); + register("experience_bottle", (new ItemExpBottle()).setDisplay("Erfahrungsfläschchen")); + register("fire_charge", (new ItemFireball()).setDisplay("Feuerkugel")); + register("writable_book", (new Item()).setDisplay("Buch und Feder").setTab(CheatTab.TOOLS)); + register("written_book", (new Item()).setDisplay("Beschriebenes Buch").setTab(CheatTab.MISC)); Item emerald = (new Item()).setDisplay("Smaragd").setTab(CheatTab.METALS); - registerItem("emerald", emerald); - registerItem("baked_potato", (new ItemFood(5, false)).setDisplay("Ofenkartoffel").setMaxAmount(128)); - registerItem("poisonous_potato", (new ItemFood(2, false)).setPotionEffect(Potion.POISON, 5, 0, 0.6F).setDisplay("Giftige Kartoffel").setMaxAmount(128)); - registerItem("golden_carrot", (new ItemFood(6, false)).setDisplay("Goldene Karotte") - .setPotionEffect(PotionHelper.goldenCarrotEffect).setTab(CheatTab.MISC)); - registerItem("carrot_on_a_stick", (new ItemCarrotOnAStick()).setDisplay("Karottenrute")); - registerItem("charge_crystal", (new ItemEffect()).setDisplay("Energiekristall").setTab(CheatTab.MISC).setColor(TextColor.DMAGENTA)); - registerItem("pumpkin_pie", (new ItemFood(8, false)).setDisplay("Kürbiskuchen").setTab(CheatTab.MISC)); - registerItem("fireworks", (new ItemFirework()).setDisplay("Feuerwerksrakete")); - registerItem("firework_charge", (new ItemFireworkCharge()).setDisplay("Feuerwerksstern").setTab(CheatTab.MATERIALS)); - registerItem("enchanted_book", (new ItemEnchantedBook()).setMaxAmount(1).setDisplay("Verzaubertes Buch").setTab(CheatTab.MAGIC)); - registerItem("bloodbrick", (new Item()).setDisplay("Blutroter Ziegel").setTab(CheatTab.MATERIALS)); - registerItem("blackbrick", (new Item()).setDisplay("Schwarzer Ziegel").setTab(CheatTab.MATERIALS)); + register("emerald", emerald); + register("baked_potato", (new ItemFood(5, false)).setDisplay("Ofenkartoffel").setMaxAmount(128)); + register("poisonous_potato", (new ItemFood(2, false)).setPotionEffect(Potion.POISON, 5, 0, 0.6F).setDisplay("Giftige Kartoffel").setMaxAmount(128)); + register("golden_carrot", (new ItemFood(6, false)).setDisplay("Goldene Karotte") + .setPotionEffect(PotionHelper.goldenCarrotEffect).setTab(CheatTab.MISC)); + register("carrot_on_a_stick", (new ItemCarrotOnAStick()).setDisplay("Karottenrute")); + register("charge_crystal", (new ItemEffect()).setDisplay("Energiekristall").setTab(CheatTab.MISC).setColor(TextColor.DMAGENTA)); + register("pumpkin_pie", (new ItemFood(8, false)).setDisplay("Kürbiskuchen").setTab(CheatTab.MISC)); + register("fireworks", (new ItemFirework()).setDisplay("Feuerwerksrakete")); + register("firework_charge", (new ItemFireworkCharge()).setDisplay("Feuerwerksstern").setTab(CheatTab.MATERIALS)); + register("enchanted_book", (new ItemEnchantedBook()).setMaxAmount(1).setDisplay("Verzaubertes Buch").setTab(CheatTab.MAGIC)); + register("bloodbrick", (new Item()).setDisplay("Blutroter Ziegel").setTab(CheatTab.MATERIALS)); + register("blackbrick", (new Item()).setDisplay("Schwarzer Ziegel").setTab(CheatTab.MATERIALS)); Item quartz = (new Item()).setDisplay("Quarz").setTab(CheatTab.METALS); - registerItem("quartz", quartz); + register("quartz", quartz); Item bquartz = (new Item()).setDisplay("Schwarzes Quarz").setTab(CheatTab.METALS); - registerItem("black_quartz", bquartz); - registerItem("lead", (new ItemLead()).setDisplay("Leine").setMaxAmount(128)); - registerItem("name_tag", (new ItemNameTag()).setDisplay("Namensschild")); + register("black_quartz", bquartz); + register("lead", (new ItemLead()).setDisplay("Leine").setMaxAmount(128)); + register("name_tag", (new ItemNameTag()).setDisplay("Namensschild")); for(int z = 0; z < ItemDynamite.DYNAMITE.length; z++) { - registerItem("dynamite" + (z == 0 ? "" : ("_" + z)), (new ItemDynamite(z)).setDisplay("Dynamit" + Util.getTierSuffix(z)).setColor(TextColor.RED)); + register("dynamite" + (z == 0 ? "" : ("_" + z)), (new ItemDynamite(z)).setDisplay("Dynamit" + Util.getTierSuffix(z)).setColor(TextColor.RED)); } - registerItem("chain", (new ItemMagnetic()).setDisplay("Kette").setTab(CheatTab.MATERIALS)); + register("chain", (new ItemMagnetic()).setDisplay("Kette").setTab(CheatTab.MATERIALS)); for(OreType ore : OreType.values()) { Item itm = (new Item()).setDisplay(ore.itemDisplay).setTab(CheatTab.METALS); - registerItem(ore.item, itm); - ((BlockOre)BlockRegistry.getRegisteredBlock(ore.name + "_ore")).setDropItem(new ItemStack(itm, ore.dropQuantity), + register(ore.item, itm); + ((BlockOre)BlockRegistry.byName(ore.name + "_ore")).setDropItem(new ItemStack(itm, ore.dropQuantity), ore.bonusChance, ore.experience); registerTools(ore.material, ore.name, ore.display); } for(MetalType metal : MetalType.values()) { if(metal.isPowder) { Item itm = (new ItemMetal(metal)).setDisplay(metal.display + "pulver").setTab(CheatTab.METALS); - registerItem(metal.name + "_powder", itm); - ((BlockOre)BlockRegistry.getRegisteredBlock(metal.name + "_ore")).setDropItem(new ItemStack(itm), 0, 2); + register(metal.name + "_powder", itm); + ((BlockOre)BlockRegistry.byName(metal.name + "_ore")).setDropItem(new ItemStack(itm), 0, 2); } else { Item itm = (new ItemMetal(metal)).setDisplay(metal.display + "barren").setTab(CheatTab.METALS); - registerItem(metal.name + "_ingot", itm); - ((BlockOre)BlockRegistry.getRegisteredBlock(metal.name + "_ore")).setSmeltItem(new ItemStack(itm)); + register(metal.name + "_ingot", itm); + ((BlockOre)BlockRegistry.byName(metal.name + "_ore")).setSmeltItem(new ItemStack(itm)); } if(metal.material != null) registerTools(metal.material, metal.name, metal.display); @@ -321,29 +348,27 @@ public abstract class ItemRegistry { registerTools(tool.material, tool.name, tool.display); } - registerItem("record_13", (new ItemRecord()).setDisplay("Protokoll #1 - 13 Tage ohne Kaffee")); - registerItem("record_cat", (new ItemRecord()).setDisplay("Protokoll #2 - Versuchskatzen")); - registerItem("record_blocks", (new ItemRecord()).setDisplay("Protokoll #3 - Blöcke und mehr Experimente")); - registerItem("record_chirp", (new ItemRecord()).setDisplay("Protokoll #4 - Experimente mit Vögeln: Eine gute Idee?")); - registerItem("record_far", (new ItemRecord()).setDisplay("Protokoll #5 - Haben wir es mit dem Design übertrieben?")); - registerItem("record_mall", (new ItemRecord()).setDisplay("Protokoll #6 - Wocheneinkauf und mehr Kaffee")); - registerItem("record_mellohi", (new ItemRecord()).setDisplay("Protokoll #7 - Explosion: Hoffe auf Versicherungsersatz")); - registerItem("record_stal", (new ItemRecord()).setDisplay("Protokoll #8 - Fortschritt stagniert")); - registerItem("record_strad", (new ItemRecord()).setDisplay("Protokoll #9 - Neue Strategie")); - registerItem("record_ward", (new ItemRecord()).setDisplay("Protokoll #10 - Neue Lösung: Seelenwarzen??")); - registerItem("record_11", (new ItemRecord()).setDisplay("Protokoll #11 - Wir waren erfolgreich")); - registerItem("record_wait", (new ItemRecord()).setDisplay("Protokoll #12 - Warte auf Bezahlung")); - registerItem("record_delay", (new ItemRecord()).setDisplay("Protokoll #13 - Verzögerung der Umsetzung")); - registerItem("record_extend", (new ItemRecord()).setDisplay("Protokoll #14 - Explosive Erweiterung unseres Labors")); + register("record_13", (new ItemRecord()).setDisplay("Protokoll #1 - 13 Tage ohne Kaffee")); + register("record_cat", (new ItemRecord()).setDisplay("Protokoll #2 - Versuchskatzen")); + register("record_blocks", (new ItemRecord()).setDisplay("Protokoll #3 - Blöcke und mehr Experimente")); + register("record_chirp", (new ItemRecord()).setDisplay("Protokoll #4 - Experimente mit Vögeln: Eine gute Idee?")); + register("record_far", (new ItemRecord()).setDisplay("Protokoll #5 - Haben wir es mit dem Design übertrieben?")); + register("record_mall", (new ItemRecord()).setDisplay("Protokoll #6 - Wocheneinkauf und mehr Kaffee")); + register("record_mellohi", (new ItemRecord()).setDisplay("Protokoll #7 - Explosion: Hoffe auf Versicherungsersatz")); + register("record_stal", (new ItemRecord()).setDisplay("Protokoll #8 - Fortschritt stagniert")); + register("record_strad", (new ItemRecord()).setDisplay("Protokoll #9 - Neue Strategie")); + register("record_ward", (new ItemRecord()).setDisplay("Protokoll #10 - Neue Lösung: Seelenwarzen??")); + register("record_11", (new ItemRecord()).setDisplay("Protokoll #11 - Wir waren erfolgreich")); + register("record_wait", (new ItemRecord()).setDisplay("Protokoll #12 - Warte auf Bezahlung")); + register("record_delay", (new ItemRecord()).setDisplay("Protokoll #13 - Verzögerung der Umsetzung")); + register("record_extend", (new ItemRecord()).setDisplay("Protokoll #14 - Explosive Erweiterung unseres Labors")); - ((BlockOre)BlockRegistry.getRegisteredBlock("coal_ore")).setDropItem(new ItemStack(coal), 0); - ((BlockOre)BlockRegistry.getRegisteredBlock("emerald_ore")).setDropItem(new ItemStack(emerald), 3); - ((BlockOre)BlockRegistry.getRegisteredBlock("lapis_ore")).setDropItem(new ItemStack(lapis, 4), 4, 2); - ((BlockOre)BlockRegistry.getRegisteredBlock("quartz_ore")).setDropItem(new ItemStack(quartz), 2); - ((BlockOre)BlockRegistry.getRegisteredBlock("black_quartz_ore")).setDropItem(new ItemStack(bquartz), 3); + ((BlockOre)BlockRegistry.byName("coal_ore")).setDropItem(new ItemStack(coal), 0); + ((BlockOre)BlockRegistry.byName("emerald_ore")).setDropItem(new ItemStack(emerald), 3); + ((BlockOre)BlockRegistry.byName("lapis_ore")).setDropItem(new ItemStack(lapis, 4), 4, 2); + ((BlockOre)BlockRegistry.byName("quartz_ore")).setDropItem(new ItemStack(quartz), 2); + ((BlockOre)BlockRegistry.byName("black_quartz_ore")).setDropItem(new ItemStack(bquartz), 3); - REGISTRY.finish(); - - Log.SYSTEM.debug("%d Gegenstände registriert", nextItemId - 4096); + Log.SYSTEM.debug("%d Gegenstände registriert", ITEM_MAP.size()); } } diff --git a/common/src/main/java/common/init/Items.java b/common/src/main/java/common/init/Items.java index 8dc94a20..94b5f9fa 100755 --- a/common/src/main/java/common/init/Items.java +++ b/common/src/main/java/common/init/Items.java @@ -959,14 +959,15 @@ public abstract class Items { public static final ItemFishFood pufferfish = get("pufferfish"); private static T get(String id) { - if(!ItemRegistry.REGISTRY.has(id)) + T item = (T)ItemRegistry.byName(id); + if(item == null) throw new RuntimeException("Gegenstand " + id + " existiert nicht"); - return (T)ItemRegistry.REGISTRY.byName(id); + return item; } static { if(Util.DEVMODE) { - Set items = Sets.newHashSet(ItemRegistry.REGISTRY); + Set items = Sets.newHashSet(ItemRegistry.items()); for(Field field : Items.class.getDeclaredFields()) { if(Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && Item.class.isAssignableFrom(field.getType())) try { @@ -983,10 +984,10 @@ public abstract class Items { } if(!items.isEmpty()) { List list = Lists.newArrayList(items); - Collections.sort(list, Comparator.comparing(item -> ItemRegistry.getNameFromItem(item))); + Collections.sort(list, Comparator.comparing(item -> ItemRegistry.getName(item))); System.err.printf("\n*** -------------------------------------------------------------- ***\n\n"); for(Item item : list) { - String name = ItemRegistry.getNameFromItem(item); + String name = ItemRegistry.getName(item); System.err.printf("\tpublic static final %s %s = get(\"%s\");\n", item.getClass().getSimpleName(), name, name); } System.err.printf("\n^^^ " + Items.class.getCanonicalName() + ": Gegenstandsliste ist unvollständig, Bitte neuen Quellcode einfügen ^^^\n"); diff --git a/common/src/main/java/common/init/SmeltingRegistry.java b/common/src/main/java/common/init/SmeltingRegistry.java index 7342d931..60764346 100755 --- a/common/src/main/java/common/init/SmeltingRegistry.java +++ b/common/src/main/java/common/init/SmeltingRegistry.java @@ -39,7 +39,7 @@ public abstract class SmeltingRegistry { if (fish.canCook()) { - add(ItemRegistry.getRegisteredItem(fish.getName()), new ItemStack(ItemRegistry.getRegisteredItem("cooked_" + fish.getName())), 0.35F); + add(ItemRegistry.byName(fish.getName()), new ItemStack(ItemRegistry.byName("cooked_" + fish.getName())), 0.35F); } } @@ -50,15 +50,15 @@ public abstract class SmeltingRegistry add(Items.redstone_ore, new ItemStack(Items.redstone), 0.7F); for(OreType ore : OreType.values()) { - Item item = ItemRegistry.getRegisteredItem(ore.item); - add(ItemRegistry.getRegisteredItem(ore.name + "_ore"), new ItemStack(item), ((float)ore.experience) / 3.0F); + Item item = ItemRegistry.byName(ore.item); + add(ItemRegistry.byName(ore.name + "_ore"), new ItemStack(item), ((float)ore.experience) / 3.0F); } for(MetalType metal : MetalType.values()) { - Item item = ItemRegistry.getRegisteredItem(metal.isPowder ? (metal.name + "_powder") : (metal.name + "_ingot")); - add(ItemRegistry.getRegisteredItem(metal.name + "_ore"), new ItemStack(item), 0.7F); + Item item = ItemRegistry.byName(metal.isPowder ? (metal.name + "_powder") : (metal.name + "_ingot")); + add(ItemRegistry.byName(metal.name + "_ore"), new ItemStack(item), 0.7F); } for(WoodType wood : WoodType.values()) { - add(ItemRegistry.getRegisteredItem(wood.getName() + "_log"), new ItemStack(Items.charcoal), 0.15F); + add(ItemRegistry.byName(wood.getName() + "_log"), new ItemStack(Items.charcoal), 0.15F); } } diff --git a/common/src/main/java/common/item/CheatTab.java b/common/src/main/java/common/item/CheatTab.java index d53a0d4b..3f4c21c0 100755 --- a/common/src/main/java/common/item/CheatTab.java +++ b/common/src/main/java/common/item/CheatTab.java @@ -121,7 +121,7 @@ public enum CheatTab { protected abstract Item getIconItem(); public void filter(List list) { - for(Item item : ItemRegistry.REGISTRY) { + for(Item item : ItemRegistry.items()) { if(item != null && item.getTab() == this) { item.getSubItems(item, this, list); } diff --git a/common/src/main/java/common/item/Item.java b/common/src/main/java/common/item/Item.java index ad66a2a9..7b5a363f 100755 --- a/common/src/main/java/common/item/Item.java +++ b/common/src/main/java/common/item/Item.java @@ -25,284 +25,248 @@ import common.util.HitPosition; import common.util.Vec3; import common.world.World; -public class Item -{ - private int maxAmount = 64; - private int maxDamage = 0; - private Item containerItem; - private String potionEffect; - private String display; - private CheatTab tab; - private TextColor color = null; +public class Item { + private int maxAmount = 64; + private int maxDamage = 0; + private Item containerItem; + private String potionEffect; + private String display; + private CheatTab tab; + private TextColor color = null; - public final Item setMaxAmount(int max) - { - this.maxAmount = max; - this.maxDamage = 0; - return this; - } + public final Item setUnstackable() { + this.maxAmount = 1; + this.maxDamage = 0; + return this; + } - public final Item setMaxDamage(int max) - { - this.maxAmount = 1; - this.maxDamage = max; - return this; - } - - public Item setDisplay(String name) - { - this.display = name; - return this; - } + public final Item setMaxAmount(int max) { + this.maxAmount = max; + this.maxDamage = 0; + return this; + } - public final Item setContainerItem(Item containerItem) - { - this.containerItem = containerItem; - return this; - } + public final Item setMaxDamage(int max) { + this.maxAmount = 1; + this.maxDamage = max; + return this; + } - public final Item setPotionEffect(String potionEffect) - { - this.potionEffect = potionEffect; - return this; - } + public Item setDisplay(String name) { + this.display = name; + return this; + } - public final Item setTab(CheatTab tab) - { - this.tab = tab; - return this; - } + public final Item setContainerItem(Item containerItem) { + this.containerItem = containerItem; + return this; + } - public Item setColor(TextColor color) - { - this.color = color; - return this; - } + public final Item setPotionEffect(String potionEffect) { + this.potionEffect = potionEffect; + return this; + } + public final Item setTab(CheatTab tab) { + this.tab = tab; + return this; + } - public final int getItemStackLimit() - { - return this.maxAmount; - } + public Item setColor(TextColor color) { + this.color = color; + return this; + } - public final int getMaxDamage() - { - return this.maxDamage; - } + public final int getItemStackLimit() { + return this.maxAmount; + } - public final boolean isDamageable() - { - return this.maxDamage > 0; - } + public final int getMaxDamage() { + return this.maxDamage; + } + public final boolean isDamageable() { + return this.maxDamage > 0; + } - public Block getBlock() - { - return null; - } + public Block getBlock() { + return null; + } - public boolean onItemUse(ItemStack stack, EntityNPC playerIn, World worldIn, BlockPos pos, Facing side, float hitX, float hitY, float hitZ) - { - return false; - } - - public boolean onAction(ItemStack stack, EntityNPC player, World world, ItemControl control, BlockPos block) { - return false; - } + public boolean onItemUse(ItemStack stack, EntityNPC playerIn, World worldIn, BlockPos pos, Facing side, float hitX, float hitY, float hitZ) { + return false; + } - public float getStrVsBlock(ItemStack stack, Block state) - { - return 1.0F; - } + public boolean onAction(ItemStack stack, EntityNPC player, World world, ItemControl control, BlockPos block) { + return false; + } - public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) - { - return itemStackIn; - } + public float getStrVsBlock(ItemStack stack, Block state) { + return 1.0F; + } - public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityNPC playerIn) - { - return stack; - } + public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) { + return itemStackIn; + } - public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker) - { - return false; - } + public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityNPC playerIn) { + return stack; + } - public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLiving playerIn) - { - return false; - } + public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker) { + return false; + } - public boolean canHarvestBlock(Block blockIn) - { - return false; - } + public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLiving playerIn) { + return false; + } - public boolean itemInteractionForEntity(ItemStack stack, EntityNPC playerIn, EntityLiving target) - { - return false; - } - - public String getDisplay(ItemStack stack) - { - return this.display; - } + public boolean canHarvestBlock(Block blockIn) { + return false; + } - public Item getContainerItem() - { - return this.containerItem; - } + public boolean itemInteractionForEntity(ItemStack stack, EntityNPC playerIn, EntityLiving target) { + return false; + } - public boolean hasContainerItem() - { - return this.containerItem != null; - } + public String getDisplay(ItemStack stack) { + return this.display; + } - public int getColorFromItemStack(ItemStack stack, int renderPass) - { - return 16777215; - } + public Item getContainerItem() { + return this.containerItem; + } - public ItemAction getItemUseAction(ItemStack stack) - { - return ItemAction.NONE; - } + public boolean hasContainerItem() { + return this.containerItem != null; + } - public ItemAction getItemPosition(ItemStack stack) - { - return ItemAction.NONE; - } + public int getColorFromItemStack(ItemStack stack, int renderPass) { + return 16777215; + } - public int getMaxItemUseDuration(ItemStack stack) - { - return 0; - } + public ItemAction getItemUseAction(ItemStack stack) { + return ItemAction.NONE; + } - public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityNPC playerIn, int timeLeft) - { - } + public ItemAction getItemPosition(ItemStack stack) { + return ItemAction.NONE; + } - public String getPotionEffect(ItemStack stack) - { - return this.potionEffect; - } + public int getMaxItemUseDuration(ItemStack stack) { + return 0; + } - public boolean isPotionIngredient(ItemStack stack) - { - return this.getPotionEffect(stack) != null; - } + public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityNPC playerIn, int timeLeft) { + } - public void addInformation(ItemStack stack, EntityNPC playerIn, List tooltip) - { - } + public String getPotionEffect(ItemStack stack) { + return this.potionEffect; + } - public boolean hasEffect(ItemStack stack) - { - return stack.isItemEnchanted(); - } - - public TextColor getColor(ItemStack stack) - { - return this.color != null ? this.color : (stack.isItemEnchanted() ? TextColor.NEON : TextColor.WHITE); - } + public boolean isPotionIngredient(ItemStack stack) { + return this.getPotionEffect(stack) != null; + } - public boolean isItemTool(ItemStack stack) - { - return this.getItemStackLimit() == 1 && this.isDamageable(); - } + public void addInformation(ItemStack stack, EntityNPC playerIn, List tooltip) { + } - protected HitPosition getMovingObjectPositionFromPlayer(World worldIn, EntityNPC playerIn, boolean useLiquids) - { - float f = playerIn.rotPitch; - float f1 = playerIn.rotYaw; - double d0 = playerIn.posX; - double d1 = playerIn.posY + (double)playerIn.getEyeHeight(); - double d2 = playerIn.posZ; - Vec3 vec3 = new Vec3(d0, d1, d2); - float f2 = ExtMath.cos(-f1 * 0.017453292F - (float)Math.PI); - float f3 = ExtMath.sin(-f1 * 0.017453292F - (float)Math.PI); - float f4 = -ExtMath.cos(-f * 0.017453292F); - float f5 = ExtMath.sin(-f * 0.017453292F); - float f6 = f3 * f4; - float f7 = f2 * f4; - double d3 = 5.0D; - Vec3 vec31 = vec3.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3); - return worldIn.rayTraceBlocks(vec3, vec31, useLiquids, !useLiquids, false); - } + public boolean hasEffect(ItemStack stack) { + return stack.isItemEnchanted(); + } - public int getItemEnchantability() - { - return 0; - } + public TextColor getColor(ItemStack stack) { + return this.color != null ? this.color : (stack.isItemEnchanted() ? TextColor.NEON : TextColor.WHITE); + } - public void getSubItems(Item itemIn, CheatTab tab, List subItems) - { - subItems.add(new ItemStack(itemIn)); - } + public boolean isItemTool(ItemStack stack) { + return this.getItemStackLimit() == 1 && this.isDamageable(); + } - public CheatTab getTab() - { - return this.tab; - } + protected HitPosition getMovingObjectPositionFromPlayer(World worldIn, EntityNPC playerIn, boolean useLiquids) { + float f = playerIn.rotPitch; + float f1 = playerIn.rotYaw; + double d0 = playerIn.posX; + double d1 = playerIn.posY + (double)playerIn.getEyeHeight(); + double d2 = playerIn.posZ; + Vec3 vec3 = new Vec3(d0, d1, d2); + float f2 = ExtMath.cos(-f1 * 0.017453292F - (float)Math.PI); + float f3 = ExtMath.sin(-f1 * 0.017453292F - (float)Math.PI); + float f4 = -ExtMath.cos(-f * 0.017453292F); + float f5 = ExtMath.sin(-f * 0.017453292F); + float f6 = f3 * f4; + float f7 = f2 * f4; + double d3 = 5.0D; + Vec3 vec31 = vec3.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3); + return worldIn.rayTraceBlocks(vec3, vec31, useLiquids, !useLiquids, false); + } - public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) - { - return false; - } - - public int getAttackDamageBonus() { - return 0; - } + public int getItemEnchantability() { + return 0; + } - public void getModifiers(Map map, UsageSlot slot) - { - } - - public boolean isFragile() { - return false; - } - - public final Set getValidTags() { - return Sets.newHashSet(); - } - - public float getRadiation(ItemStack stack) { - return 0.0f; - } - - public boolean isMagnetic() { - return false; - } - - public boolean isFirstPerson() { - return true; - } - - public boolean canBeWielded() { - return false; - } - - public String getHotbarText(EntityNPC player, ItemStack stack) { - return stack.getColoredName(); - } + public void getSubItems(Item itemIn, CheatTab tab, List subItems) { + subItems.add(new ItemStack(itemIn)); + } - public Transforms getTransform() { - return Transforms.ITEM; - } + public CheatTab getTab() { + return this.tab; + } - public Model getModel(ModelProvider provider, String name) { - return provider.getModel(this.getTransform(), name); - } - - public String[] getSprites() { - return null; - } - - public String getSprite(EntityNPC player, ItemStack stack) { - return null; - } + public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { + return false; + } + + public int getAttackDamageBonus() { + return 0; + } + + public void getModifiers(Map map, UsageSlot slot) { + } + + public boolean isFragile() { + return false; + } + + public final Set getValidTags() { + return Sets.newHashSet(); + } + + public float getRadiation(ItemStack stack) { + return 0.0f; + } + + public boolean isMagnetic() { + return false; + } + + public boolean isFirstPerson() { + return true; + } + + public boolean canBeWielded() { + return false; + } + + public String getHotbarText(EntityNPC player, ItemStack stack) { + return stack.getColoredName(); + } + + public Transforms getTransform() { + return Transforms.ITEM; + } + + public Model getModel(ModelProvider provider, String name) { + return provider.getModel(this.getTransform(), name); + } + + public String[] getSprites() { + return null; + } + + public String getSprite(EntityNPC player, ItemStack stack) { + return null; + } public ItemStack dispenseStack(World world, TileEntity source, Vec3 position, BlockPos blockpos, Facing facing, ItemStack stack) { BlockDispenser.dispense(world, 6.0, facing, position, stack.splitStack(1)); diff --git a/common/src/main/java/common/item/ItemStack.java b/common/src/main/java/common/item/ItemStack.java index 8a400a9e..8e5a5eb3 100755 --- a/common/src/main/java/common/item/ItemStack.java +++ b/common/src/main/java/common/item/ItemStack.java @@ -70,7 +70,7 @@ public final class ItemStack public static ItemStack getStack(String name, ItemStack def) { if(name == null) return def; - Item item = ItemRegistry.REGISTRY.byNameExact(name); + Item item = ItemRegistry.byName(name); return item == null ? def : new ItemStack(item); } @@ -143,7 +143,7 @@ public final class ItemStack public TagObject writeTags(TagObject tag) { if(this.item != null) - tag.setString("id", ItemRegistry.getNameFromItem(this.item)); + tag.setString("id", ItemRegistry.getName(this.item)); if(this.size != 1) tag.setInt("size", this.size); if(this.tag != null) @@ -153,7 +153,7 @@ public final class ItemStack private void readTags(TagObject tag) { - this.item = tag.hasString("id") ? ItemRegistry.getRegisteredItem(tag.getString("id")) : null; + this.item = tag.hasString("id") ? ItemRegistry.byName(tag.getString("id")) : null; this.size = tag.hasInt("size") ? tag.getInt("size") : 1; this.tag = tag.hasObject("tag") ? tag.getObject("tag") : null; } @@ -601,7 +601,7 @@ public final class ItemStack if(this.getRepairCost() > 0) list.add("Reparaturkosten: " + this.getRepairCost() + " Mana"); - list.add(TextColor.GRAY + ItemRegistry.getNameFromItem(this.item)); + list.add(TextColor.GRAY + ItemRegistry.getName(this.item)); if (this.hasTagCompound()) { diff --git a/common/src/main/java/common/item/block/ItemBlock.java b/common/src/main/java/common/item/block/ItemBlock.java index 6b3a044b..f0afbd5c 100755 --- a/common/src/main/java/common/item/block/ItemBlock.java +++ b/common/src/main/java/common/item/block/ItemBlock.java @@ -212,8 +212,8 @@ public class ItemBlock extends Item public Model getModel(ModelProvider provider, String name) { return this.flatTexture != null ? provider.getModel(this.getTransform(), !this.flatTexture.isEmpty() ? this.flatTexture : this.block.getModel(provider, - BlockRegistry.getNameFromBlock(this.block).toString(), this.block.getState()).getPrimary() /* "blocks/" + name */) : + BlockRegistry.getName(this.block).toString(), this.block.getState()).getPrimary() /* "blocks/" + name */) : provider.getModel(this.block.getModel(provider, - BlockRegistry.getNameFromBlock(this.block).toString(), this.block.getState()), this.getTransform()); + BlockRegistry.getName(this.block).toString(), this.block.getState()), this.getTransform()); } } diff --git a/common/src/main/java/common/item/material/ItemDye.java b/common/src/main/java/common/item/material/ItemDye.java index 185e1703..50d8ce7b 100755 --- a/common/src/main/java/common/item/material/ItemDye.java +++ b/common/src/main/java/common/item/material/ItemDye.java @@ -104,7 +104,7 @@ public class ItemDye extends Item } State iblockstate = worldIn.getState(pos); if(iblockstate.getBlock() instanceof BlockBed) { - Block bedBlock = BlockRegistry.getRegisteredBlock(this.color.getName() + "_bed"); + Block bedBlock = BlockRegistry.byName(this.color.getName() + "_bed"); if(bedBlock != Blocks.air) { if (iblockstate.getValue(BlockBed.PART) == BlockBed.EnumPartType.FOOT) { diff --git a/common/src/main/java/common/network/PacketBuffer.java b/common/src/main/java/common/network/PacketBuffer.java index 9adf71bd..9b65e219 100755 --- a/common/src/main/java/common/network/PacketBuffer.java +++ b/common/src/main/java/common/network/PacketBuffer.java @@ -117,7 +117,7 @@ public class PacketBuffer { this.writeShort(-1); return; } - this.writeShort(ItemRegistry.getIdFromItem(stack.getItem())); + this.writeShort(ItemRegistry.getId(stack.getItem())); this.writeVarInt(stack.size); this.writeTag(stack.getTagCompound()); } @@ -127,7 +127,7 @@ public class PacketBuffer { if(id < 0) return null; int amt = this.readVarInt(); - ItemStack stack = new ItemStack(ItemRegistry.getItemById(id), amt); + ItemStack stack = new ItemStack(ItemRegistry.byId(id), amt); stack.setTagCompound(this.readTag()); return stack; } diff --git a/common/src/main/java/common/packet/SPacketBlockAction.java b/common/src/main/java/common/packet/SPacketBlockAction.java index 083cf7fe..0b682079 100755 --- a/common/src/main/java/common/packet/SPacketBlockAction.java +++ b/common/src/main/java/common/packet/SPacketBlockAction.java @@ -8,6 +8,7 @@ import common.network.IClientPlayer; import common.network.Packet; import common.network.PacketBuffer; import common.util.BlockPos; +import common.world.State; public class SPacketBlockAction implements Packet { @@ -36,7 +37,8 @@ public class SPacketBlockAction implements Packet this.blockPosition = buf.readBlockPos(); this.instrument = buf.readUnsignedByte(); this.pitch = buf.readUnsignedByte(); - this.block = BlockRegistry.getBlockById(buf.readVarInt() & 4095); + State state = BlockRegistry.byId(buf.readVarInt()); + this.block = state == null ? null : state.getBlock(); } /** @@ -47,7 +49,7 @@ public class SPacketBlockAction implements Packet buf.writeBlockPos(this.blockPosition); buf.writeByte(this.instrument); buf.writeByte(this.pitch); - buf.writeVarInt(BlockRegistry.getIdFromBlock(this.block) & 4095); + buf.writeVarInt(BlockRegistry.getId(this.block.getState())); } /** @@ -63,17 +65,11 @@ public class SPacketBlockAction implements Packet return this.blockPosition; } - /** - * instrument data for noteblocks - */ public int getData1() { return this.instrument; } - /** - * pitch data for noteblocks - */ public int getData2() { return this.pitch; diff --git a/common/src/main/java/common/packet/SPacketBlockChange.java b/common/src/main/java/common/packet/SPacketBlockChange.java index 95a37d08..a4697f58 100755 --- a/common/src/main/java/common/packet/SPacketBlockChange.java +++ b/common/src/main/java/common/packet/SPacketBlockChange.java @@ -2,6 +2,7 @@ package common.packet; import java.io.IOException; +import common.init.BlockRegistry; import common.network.IClientPlayer; import common.network.Packet; import common.network.PacketBuffer; @@ -30,7 +31,7 @@ public class SPacketBlockChange implements Packet public void readPacketData(PacketBuffer buf) throws IOException { this.blockPosition = buf.readBlockPos(); - this.blockState = (State)State.ID_MAP.getByValue(buf.readVarInt()); + this.blockState = BlockRegistry.byId(buf.readVarInt()); } /** @@ -39,7 +40,7 @@ public class SPacketBlockChange implements Packet public void writePacketData(PacketBuffer buf) throws IOException { buf.writeBlockPos(this.blockPosition); - buf.writeVarInt(State.ID_MAP.get(this.blockState)); + buf.writeVarInt(BlockRegistry.getId(this.blockState)); } /** diff --git a/common/src/main/java/common/packet/SPacketMultiBlockChange.java b/common/src/main/java/common/packet/SPacketMultiBlockChange.java index 7e0aa3c6..5e907340 100755 --- a/common/src/main/java/common/packet/SPacketMultiBlockChange.java +++ b/common/src/main/java/common/packet/SPacketMultiBlockChange.java @@ -2,6 +2,7 @@ package common.packet; import java.io.IOException; +import common.init.BlockRegistry; import common.network.IClientPlayer; import common.network.Packet; import common.network.PacketBuffer; @@ -38,7 +39,7 @@ public class SPacketMultiBlockChange implements Packet for (int i = 0; i < this.changedBlocks.length; ++i) { - this.changedBlocks[i] = new SPacketMultiBlockChange.BlockUpdateData(buf.readLong(), (State)State.ID_MAP.getByValue(buf.readVarInt())); + this.changedBlocks[i] = new SPacketMultiBlockChange.BlockUpdateData(buf.readLong(), BlockRegistry.byId(buf.readVarInt())); } } @@ -54,7 +55,7 @@ public class SPacketMultiBlockChange implements Packet for (SPacketMultiBlockChange.BlockUpdateData s22packetmultiblockchange$blockupdatedata : this.changedBlocks) { buf.writeLong(s22packetmultiblockchange$blockupdatedata.getRawPos()); - buf.writeVarInt(State.ID_MAP.get(s22packetmultiblockchange$blockupdatedata.getBlockState())); + buf.writeVarInt(BlockRegistry.getId(s22packetmultiblockchange$blockupdatedata.getBlockState())); } } diff --git a/common/src/main/java/common/packet/SPacketSpawnPlayer.java b/common/src/main/java/common/packet/SPacketSpawnPlayer.java index a12ede65..4f5e95e8 100755 --- a/common/src/main/java/common/packet/SPacketSpawnPlayer.java +++ b/common/src/main/java/common/packet/SPacketSpawnPlayer.java @@ -42,7 +42,7 @@ public class SPacketSpawnPlayer implements Packet this.yaw = (byte)((int)(player.rotYaw * 256.0F / 360.0F)); this.pitch = (byte)((int)(player.rotPitch * 256.0F / 360.0F)); ItemStack itemstack = player.inventory.getCurrentItem(); - this.currentItem = itemstack == null ? 0 : ItemRegistry.getIdFromItem(itemstack.getItem()); + this.currentItem = itemstack == null ? 0 : ItemRegistry.getId(itemstack.getItem()); this.watcher = player.getDataWatcher(); this.texture = player.getSkin(); } diff --git a/common/src/main/java/common/tileentity/TileEntity.java b/common/src/main/java/common/tileentity/TileEntity.java index 4892eaaa..d644d23d 100755 --- a/common/src/main/java/common/tileentity/TileEntity.java +++ b/common/src/main/java/common/tileentity/TileEntity.java @@ -24,7 +24,7 @@ public abstract class TileEntity protected World worldObj; protected BlockPos pos = BlockPos.ORIGIN; protected boolean tileEntityInvalid; - private int blockMetadata = -1; + private State blockState = null; /** the Block type that this TileEntity is contained within */ protected Block blockType; @@ -108,15 +108,11 @@ public abstract class TileEntity return tileentity; } - public int getBlockMetadata() + public State getBlockState() { - if (this.blockMetadata == -1) - { - State iblockstate = this.worldObj.getState(this.pos); - this.blockMetadata = iblockstate.getBlock().getMetaFromState(iblockstate); - } - - return this.blockMetadata; + if(this.blockState == null) + this.blockState = this.worldObj.getState(this.pos); + return this.blockState; } /** @@ -127,8 +123,7 @@ public abstract class TileEntity { if (this.worldObj != null) { - State iblockstate = this.worldObj.getState(this.pos); - this.blockMetadata = iblockstate.getBlock().getMetaFromState(iblockstate); + this.blockState = this.worldObj.getState(this.pos); if(!this.worldObj.client) ((AWorldServer)this.worldObj).markChunkDirty(this.pos); @@ -212,7 +207,7 @@ public abstract class TileEntity public void updateContainingBlockInfo() { this.blockType = null; - this.blockMetadata = -1; + this.blockState = null; } public void setPos(BlockPos posIn) diff --git a/common/src/main/java/common/tileentity/TileEntityHopper.java b/common/src/main/java/common/tileentity/TileEntityHopper.java index b866b247..23da1a3a 100755 --- a/common/src/main/java/common/tileentity/TileEntityHopper.java +++ b/common/src/main/java/common/tileentity/TileEntityHopper.java @@ -22,6 +22,7 @@ import common.util.BoundingBox; import common.util.ExtMath; import common.util.Facing; import common.vars.Vars; +import common.world.State; import common.world.World; public class TileEntityHopper extends TileEntityLockable implements IHopper, ITickable @@ -240,8 +241,11 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi { if (this.worldObj != null && !this.worldObj.client) { - if (!this.isOnTransferCooldown() && BlockHopper.isEnabled(this.getBlockMetadata())) + if (!this.isOnTransferCooldown()) { + State state = this.getBlockState(); + if(!(state.getBlock() instanceof BlockHopper) || !state.getValue(BlockHopper.ENABLED)) + return false; boolean flag = false; if (!this.isEmpty()) @@ -306,7 +310,8 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi } else { - Facing enumfacing = BlockHopper.getFacing(this.getBlockMetadata()).getOpposite(); + State state = this.getBlockState(); + Facing enumfacing = state.getBlock() instanceof BlockHopper ? state.getValue(BlockHopper.FACING).getOpposite() : Facing.DOWN; if (isInventoryFull(iinventory, enumfacing)) { @@ -618,7 +623,8 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi */ private IInventory getInventoryForHopperTransfer() { - Facing enumfacing = BlockHopper.getFacing(this.getBlockMetadata()); + State state = this.getBlockState(); + Facing enumfacing = state.getBlock() instanceof BlockHopper ? state.getValue(BlockHopper.FACING) : Facing.DOWN; return getInventoryAtPosition(this.getWorld(), (double)(this.pos.getX() + enumfacing.getFrontOffsetX()), (double)(this.pos.getY() + enumfacing.getFrontOffsetY()), (double)(this.pos.getZ() + enumfacing.getFrontOffsetZ())); } diff --git a/common/src/main/java/common/tileentity/TileEntityPiston.java b/common/src/main/java/common/tileentity/TileEntityPiston.java index 596c1e77..88097b97 100755 --- a/common/src/main/java/common/tileentity/TileEntityPiston.java +++ b/common/src/main/java/common/tileentity/TileEntityPiston.java @@ -4,6 +4,7 @@ import java.util.List; import common.collect.Lists; import common.entity.Entity; +import common.init.BlockRegistry; import common.init.Blocks; import common.tags.TagObject; import common.util.BoundingBox; @@ -41,9 +42,9 @@ public class TileEntityPiston extends TileEntity implements ITickable return this.pistonState; } - public int getBlockMetadata() + public State getBlockState() { - return 0; + return Blocks.piston_extension.getState(); } /** @@ -200,7 +201,7 @@ public class TileEntityPiston extends TileEntity implements ITickable public void readTags(TagObject compound) { super.readTags(compound); - this.pistonState = State.getState(compound.getString("block"), Blocks.air.getState()); + this.pistonState = BlockRegistry.byName(compound.getString("block"), Blocks.air.getState()); this.pistonFacing = Facing.getFront(compound.getInt("facing")); this.lastProgress = this.progress = compound.getFloat("progress"); this.extending = compound.getBool("extending"); @@ -209,7 +210,7 @@ public class TileEntityPiston extends TileEntity implements ITickable public void writeTags(TagObject compound) { super.writeTags(compound); - compound.setString("block", this.pistonState.getId()); + compound.setString("block", BlockRegistry.getName(this.pistonState)); compound.setInt("facing", this.pistonFacing.getIndex()); compound.setFloat("progress", this.lastProgress); compound.setBool("extending", this.extending); diff --git a/common/src/main/java/common/util/IdMap.java b/common/src/main/java/common/util/IdMap.java deleted file mode 100755 index d99576dd..00000000 --- a/common/src/main/java/common/util/IdMap.java +++ /dev/null @@ -1,34 +0,0 @@ -package common.util; - -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.List; - -import common.collect.Iterators; -import common.collect.Lists; - -public class IdMap implements Iterable { - private final IdentityHashMap mapping = new IdentityHashMap(512); - private final List list = Lists.newArrayList(); - - public void put(T key, int value) { - this.mapping.put(key, value); - while(this.list.size() <= value) { - this.list.add(null); - } - this.list.set(value, key); - } - - public int get(T key) { - Integer i = this.mapping.get(key); - return i == null ? -1 : i.intValue(); - } - - public final T getByValue(int value) { - return value >= 0 && value < this.list.size() ? this.list.get(value) : null; - } - - public Iterator iterator() { - return Iterators.filter(this.list.iterator(), Predicates.notNull()); - } -} diff --git a/common/src/main/java/common/util/Mapping.java b/common/src/main/java/common/util/Mapping.java deleted file mode 100755 index 1f8f269d..00000000 --- a/common/src/main/java/common/util/Mapping.java +++ /dev/null @@ -1,90 +0,0 @@ -package common.util; - -import java.util.Collections; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import common.collect.BiMap; -import common.collect.HashBiMap; - -public class Mapping implements Iterable { - private final Map mapping = HashBiMap.create(); - private final IdMap idMap = new IdMap(); - private final Map nameMap; - private final String defaultKey; - - private V defaultValue; - private boolean registered; - - public Mapping(String def) { - this.nameMap = ((BiMap)this.mapping).inverse(); - this.defaultKey = def; - } - - public Mapping() { - this(null); - } - - public void register(int id, String key, V value) { - if(this.registered) - throw new IllegalStateException("Es können keine neuen Werte registriert werden"); - if(key == null) - throw new NullPointerException("Schlüssel ist null"); - if(value == null) - throw new NullPointerException("Wert ist null"); - if(this.mapping.containsKey(key)) - throw new IllegalArgumentException( - "Schlüssel " + key + " ist bereits mit ID " + this.idMap.get(this.mapping.get(key)) + " registriert"); - if(this.idMap.getByValue(id) != null) - throw new IllegalArgumentException("ID " + id + " ist bereits mit Name " + this.nameMap.get(this.idMap.getByValue(id)) + " registriert"); - this.idMap.put(value, id); - this.mapping.put(key, value); - if(key.equals(this.defaultKey)) - this.defaultValue = value; - } - - public void finish() { - if(this.defaultKey != null && this.defaultValue == null) - throw new NullPointerException("Wert zu Standard-Schlüssel " + this.defaultKey + " ist nicht vorhanden"); - this.registered = true; - } - - public Set getKeys() { - return Collections.unmodifiableSet(this.mapping.keySet()); - } - - public V byName(String name) { - V v = this.mapping.get(name); - return v == null ? this.defaultValue : v; - } - - public V byNameExact(String name) { - return this.mapping.get(name); - } - - public String getName(V value) { - return this.nameMap.get(value); - } - - public V byId(int id) { - V v = this.idMap.getByValue(id); - return v == null ? this.defaultValue : v; - } - - public V byIdExact(int id) { - return this.idMap.getByValue(id); - } - - public int getId(V value) { - return this.idMap.get(value); - } - - public boolean has(String key) { - return this.mapping.containsKey(key); - } - - public Iterator iterator() { - return this.idMap.iterator(); - } -} diff --git a/common/src/main/java/common/world/BlockArray.java b/common/src/main/java/common/world/BlockArray.java index e9ca8fa2..2308fa1a 100755 --- a/common/src/main/java/common/world/BlockArray.java +++ b/common/src/main/java/common/world/BlockArray.java @@ -3,6 +3,7 @@ package common.world; import java.util.Arrays; import common.block.Block; +import common.init.BlockRegistry; import common.init.Blocks; import common.util.NibbleArray; @@ -21,14 +22,14 @@ public class BlockArray { if(sky) this.skylight = new NibbleArray(); if(filler != null && filler.getBlock() != Blocks.air) { - Arrays.fill(this.data, (char)State.ID_MAP.get(filler)); + Arrays.fill(this.data, (char)BlockRegistry.getId(filler)); this.blocks = this.data.length; this.ticked = filler.getBlock().getTickRandomly() ? this.data.length : 0; } } public State get(int x, int y, int z) { - State iblockstate = State.ID_MAP.getByValue(this.data[y << 8 | z << 4 | x]); + State iblockstate = BlockRegistry.byId(this.data[y << 8 | z << 4 | x]); return iblockstate != null ? iblockstate : Blocks.air.getState(); } @@ -46,7 +47,7 @@ public class BlockArray { if(block.getTickRandomly()) ++this.ticked; } - this.data[y << 8 | z << 4 | x] = (char)State.ID_MAP.get(state); + this.data[y << 8 | z << 4 | x] = (char)BlockRegistry.getId(state); } public Block getBlock(int x, int y, int z) { diff --git a/common/src/main/java/common/world/State.java b/common/src/main/java/common/world/State.java index 953b86d6..28d0bc15 100755 --- a/common/src/main/java/common/world/State.java +++ b/common/src/main/java/common/world/State.java @@ -19,7 +19,6 @@ import common.collect.StandardTable; import common.collect.Table; import common.init.BlockRegistry; import common.properties.Property; -import common.util.IdMap; public class State { private static final Function, String> MAP_ENTRY_TO_STRING = @@ -34,15 +33,12 @@ public class State { } } }; - private static final Map NAME_MAP = Maps.newLinkedHashMap(); - public static final IdMap ID_MAP = new IdMap(); private final Block block; private final ImmutableMap properties; private ImmutableTable map; private ImmutableSet saved; - private String id; - + private static Set getSavedProperties(Block block) { Set stored = Sets.newHashSet(); Map map = Maps.newHashMap(); @@ -70,7 +66,7 @@ public class State { } private static String filterProperties(State state, Set stored) { - StringBuilder sb = new StringBuilder(BlockRegistry.getNameFromBlock(state.getBlock())); + StringBuilder sb = new StringBuilder(BlockRegistry.getName(state.getBlock())); for(Entry entry : state.getProperties().entrySet()) { if(stored.contains(entry.getKey())) sb.append(',').append(entry.getKey().getName()).append('=').append(entry.getKey().getName(entry.getValue())); @@ -78,17 +74,6 @@ public class State { return sb.toString(); } - public static State getState(String name, State def) { - if(name == null) - return def; - State state = NAME_MAP.get(name); - if(state != null) - return state; - int idx = name.indexOf(","); - Block block = BlockRegistry.REGISTRY.byNameExact(idx >= 0 ? name.substring(0, idx) : name); - return block != null ? block.getState() : def; - } - public State(Block block, ImmutableMap properties) { this.block = block; this.properties = properties; @@ -116,10 +101,6 @@ public class State { return this.saved; } - public String getId() { - return this.id; - } - public > T getValue(Property property) { if(!this.properties.containsKey(property)) { throw new IllegalArgumentException("Cannot get property " + property + " as it does not exist in " + this.block); @@ -135,7 +116,7 @@ public class State { } else if(!property.getStates().contains(value)) { throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on block " - + BlockRegistry.getNameFromBlock(this.block) + ", it is not an allowed value"); + + BlockRegistry.getName(this.block) + ", it is not an allowed value"); } else { return (State)(this.properties.get(property) == value ? this : (State)this.map.get(property, value)); @@ -160,7 +141,7 @@ public class State { public String toString() { StringBuilder sb = new StringBuilder(); - sb.append(BlockRegistry.getNameFromBlock(this.getBlock())); + sb.append(BlockRegistry.getName(this.getBlock())); if(!this.getProperties().isEmpty()) { sb.append("["); Iterable iter = Iterables.transform(this.getProperties().entrySet(), MAP_ENTRY_TO_STRING); @@ -194,11 +175,10 @@ public class State { this.map = ImmutableTable.copyOf(table); } - public void buildSaved() { + public String buildSaved() { if(this.saved != null) throw new IllegalStateException(); - ID_MAP.put(this, BlockRegistry.getIdFromBlock(this.block) << 4 | this.block.getMetaFromState(this)); this.saved = ImmutableSet.copyOf(getSavedProperties(this.block)); - NAME_MAP.put(this.id = filterProperties(this, this.saved), this); + return filterProperties(this, this.saved); } } diff --git a/common/src/main/java/common/world/World.java b/common/src/main/java/common/world/World.java index c2c668b5..01042490 100755 --- a/common/src/main/java/common/world/World.java +++ b/common/src/main/java/common/world/World.java @@ -248,7 +248,7 @@ public abstract class World implements IWorldAccess { return false; } else { - this.playAuxSFX(2001, pos, BlockRegistry.getStateId(iblockstate)); + this.playAuxSFX(2001, pos, BlockRegistry.getId(iblockstate)); if(dropBlock) { block.dropBlockAsItem(this, pos, iblockstate, 0); diff --git a/server/src/main/java/server/clipboard/ReorderRegistry.java b/server/src/main/java/server/clipboard/ReorderRegistry.java index f2d2e356..c806aca0 100755 --- a/server/src/main/java/server/clipboard/ReorderRegistry.java +++ b/server/src/main/java/server/clipboard/ReorderRegistry.java @@ -42,11 +42,11 @@ public abstract class ReorderRegistry { public static void register() { for(WoodType wood : WoodType.values()) { - PLACE_LAST.add(BlockRegistry.getRegisteredBlock(wood.getName() + "_sapling")); + PLACE_LAST.add(BlockRegistry.byName(wood.getName() + "_sapling")); } // PLACE_LAST.add(Blocks.bed); for(DyeColor color : BlockBed.COLORS) { - PLACE_LAST.add(BlockRegistry.getRegisteredBlock(color.getName() + "_bed")); + PLACE_LAST.add(BlockRegistry.byName(color.getName() + "_bed")); } PLACE_LAST.add(Blocks.golden_rail); PLACE_LAST.add(Blocks.detector_rail); @@ -141,7 +141,7 @@ public abstract class ReorderRegistry { static { for(WoodType wood : WoodType.values()) { - addAttach(BlockRegistry.getRegisteredBlock(wood.getName() + "_sapling"), Facing.DOWN); + addAttach(BlockRegistry.byName(wood.getName() + "_sapling"), Facing.DOWN); } addAttach(Blocks.tallgrass, Facing.DOWN); addAttach(Blocks.deadbush, Facing.DOWN); diff --git a/server/src/main/java/server/clipboard/RotationRegistry.java b/server/src/main/java/server/clipboard/RotationRegistry.java index 3971c278..f4b48421 100755 --- a/server/src/main/java/server/clipboard/RotationRegistry.java +++ b/server/src/main/java/server/clipboard/RotationRegistry.java @@ -15,7 +15,7 @@ public abstract class RotationRegistry { public static void register() { List values = Lists.newArrayList(); - for(Block block : common.init.BlockRegistry.REGISTRY) { + for(Block block : common.init.BlockRegistry.blocks()) { for(Property prop : block.getPropertyMap()) { for(Comparable v : prop.getStates()) { if(!(v instanceof DirectionVec vec)) diff --git a/server/src/main/java/server/command/commands/CommandBlock.java b/server/src/main/java/server/command/commands/CommandBlock.java index ea2553c5..fe281ac8 100644 --- a/server/src/main/java/server/command/commands/CommandBlock.java +++ b/server/src/main/java/server/command/commands/CommandBlock.java @@ -25,11 +25,11 @@ public class CommandBlock extends Command { public Collection complete(CommandEnvironment env, String last) { int idx = last.indexOf(','); if(idx >= 0) { - Block block = BlockRegistry.REGISTRY.byNameExact(last.substring(0, idx)); + Block block = BlockRegistry.byNameExact(last.substring(0, idx)); if(block != null) - return Lists.newArrayList(Iterables.transform(block.getValidStates(), state -> state.getId())); + return Lists.newArrayList(Iterables.transform(block.getValidStates(), state -> BlockRegistry.getName(state))); } - return BlockRegistry.REGISTRY.getKeys(); + return BlockRegistry.getKeys(); } }); this.addBlockPos("position", true); @@ -40,7 +40,7 @@ public class CommandBlock extends Command { } public Object exec(CommandEnvironment env, Executor exec, String block, BlockPos position, WorldServer world, TagObject tag) { - State state = State.getState(block, null); + State state = BlockRegistry.byName(block, null); if(state == null) throw new RunException("Block '%s' existiert nicht", block); boolean success = world.setState(position, state); diff --git a/server/src/main/java/server/command/commands/CommandItem.java b/server/src/main/java/server/command/commands/CommandItem.java index 0ec54ea2..085d82db 100644 --- a/server/src/main/java/server/command/commands/CommandItem.java +++ b/server/src/main/java/server/command/commands/CommandItem.java @@ -20,7 +20,7 @@ public class CommandItem extends Command { this.addString("item", false, new StringCompleter() { public Collection complete(CommandEnvironment env, String last) { - return ItemRegistry.REGISTRY.getKeys(); + return ItemRegistry.getKeys(); } }); this.setParamsOptional(); diff --git a/server/src/main/java/server/network/Player.java b/server/src/main/java/server/network/Player.java index 231e585a..79db8561 100755 --- a/server/src/main/java/server/network/Player.java +++ b/server/src/main/java/server/network/Player.java @@ -1207,7 +1207,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer State iblockstate = this.entity.worldObj.getState(pos); TileEntity tileentity = this.entity.worldObj.getTileEntity(pos); - this.entity.worldObj.playAuxSFX(this.entity, 2001, pos, BlockRegistry.getStateId(iblockstate)); + this.entity.worldObj.playAuxSFX(this.entity, 2001, pos, BlockRegistry.getId(iblockstate)); boolean flag1 = this.removeBlock(pos); // if (this.creative) diff --git a/server/src/main/java/server/world/ChunkServer.java b/server/src/main/java/server/world/ChunkServer.java index a747135a..e4334793 100644 --- a/server/src/main/java/server/world/ChunkServer.java +++ b/server/src/main/java/server/world/ChunkServer.java @@ -5,6 +5,7 @@ import java.util.Set; import common.biome.Biome; import common.block.Block; import common.entity.Entity; +import common.init.BlockRegistry; import common.init.Blocks; import common.log.Log; import common.rng.Random; @@ -24,13 +25,13 @@ public class ChunkServer extends Chunk { super(world, x, z); } - public ChunkServer(World world, short[] data, int height, boolean base, boolean ceil, Random rand, Biome[] biomes, int x, int z) { + public ChunkServer(World world, char[] data, int height, boolean base, boolean ceil, Random rand, Biome[] biomes, int x, int z) { this(world, x, z); boolean sky = !world.dimension.hasNoLight(); for(int bx = 0; bx < 16; ++bx) { for(int bz = 0; bz < 16; ++bz) { for(int by = 0; by < height; ++by) { - State state = State.ID_MAP.getByValue(data[bx << 4 | bz | by << 8]); + State state = BlockRegistry.byId(data[bx << 4 | bz | by << 8]); if(state != null && state.getBlock() != Blocks.air) { int y = by >> 4; BlockArray arr = this.getArray(y); diff --git a/server/src/main/java/server/world/Converter.java b/server/src/main/java/server/world/Converter.java index fd75daf3..4ac16d9d 100644 --- a/server/src/main/java/server/world/Converter.java +++ b/server/src/main/java/server/world/Converter.java @@ -109,6 +109,7 @@ import common.entity.animal.EntitySquid; import common.entity.animal.EntityWolf; import common.entity.item.EntityBoat; import common.entity.item.EntityMinecart; +import common.init.BlockRegistry; import common.init.Blocks; import common.init.EntityRegistry; import common.init.TileRegistry; @@ -327,7 +328,7 @@ public abstract class Converter { } private static void mapBlock(State state, int id, int data) { - BLOCK_MAP[(id << 4) | data] = (char)State.ID_MAP.get(state); + BLOCK_MAP[(id << 4) | data] = (char)BlockRegistry.getId(state); } private static void mapBlock(State state, int id, int ... values) { diff --git a/server/src/main/java/server/world/Region.java b/server/src/main/java/server/world/Region.java index 3df78278..52f84ff6 100755 --- a/server/src/main/java/server/world/Region.java +++ b/server/src/main/java/server/world/Region.java @@ -44,39 +44,25 @@ public class Region { removed.add(id); } Map mapping = Maps.newHashMap(); - Map> current = Maps.newHashMap(); Set taken = Sets.newHashSet(); List missing = Lists.newArrayList(); - for(int z = 0; z < 4096; z++) { - Block block = BlockRegistry.getBlockById(z); - if(block != Blocks.air) { - for(int n = 0; n < 16; n++) { - State state = block.getStateFromMeta(n); - String id = state.getId(); - List ids = current.get(id); - char mid = (char)State.ID_MAP.get(state); - if(ids == null) { - current.put(id, Lists.newArrayList(mid)); - } - else { - ids.add(mid); - continue; - } - if(tag.hasChar(id)) { - char bid = tag.getChar(id); - if(bid == 0) { - missing.add(id); - continue; - } - mapping.put(id, bid); - taken.add(bid); - removed.remove(id); - Log.IO.debug("Bestehende Block-ID %d = %s", (int)bid, id); - } - else { - missing.add(id); - } + for(State state : BlockRegistry.states()) { + if(state.getBlock() == Blocks.air) + continue; + String id = BlockRegistry.getName(state); + if(tag.hasChar(id)) { + char bid = tag.getChar(id); + if(bid == 0) { + missing.add(id); + continue; } + mapping.put(id, bid); + taken.add(bid); + removed.remove(id); + Log.IO.debug("Bestehende Block-ID %d = %s", (int)bid, id); + } + else { + missing.add(id); } } char bid = 1; @@ -91,11 +77,9 @@ public class Region { } for(Entry entry : mapping.entrySet()) { bid = entry.getValue(); - List ids = current.get(entry.getKey()); - DECODE_MAP[bid] = ids.get(0); - for(char id : ids) { - ENCODE_MAP[id] = bid; - } + char ids = (char)BlockRegistry.getId(BlockRegistry.byName(entry.getKey(), null)); + DECODE_MAP[bid] = ids; + ENCODE_MAP[ids] = bid; } for(String id : removed) { tag.remove(id); @@ -559,7 +543,7 @@ public class Region { int invalid = 0; for(int n = 0; n < ticks.size(); ++n) { TagObject tick = ticks.get(n); - Block block = BlockRegistry.getRegisteredBlock(tick.getString("i")); + Block block = BlockRegistry.byName(tick.getString("i")); if(block != Blocks.air) { // FIX world.scheduleBlockUpdate(new BlockPos(tick.getInt("x"), tick.getInt("y"), tick.getInt("z")), block, @@ -671,7 +655,7 @@ public class Region { if(tic.getBlock() == Blocks.air) continue; TagObject tick = new TagObject(); - String res = BlockRegistry.getNameFromBlock(tic.getBlock()); + String res = BlockRegistry.getName(tic.getBlock()); tick.setString("i", res == null ? "" : res); tick.setInt("x", tic.position.getX()); tick.setInt("y", tic.position.getY()); diff --git a/server/src/main/java/server/worldgen/ChunkPrimer.java b/server/src/main/java/server/worldgen/ChunkPrimer.java index 6e9517c4..5179c612 100755 --- a/server/src/main/java/server/worldgen/ChunkPrimer.java +++ b/server/src/main/java/server/worldgen/ChunkPrimer.java @@ -1,27 +1,28 @@ package server.worldgen; +import common.init.BlockRegistry; import common.init.Blocks; import common.world.State; public class ChunkPrimer { public final int height; - private final short[] data; + private final char[] data; public ChunkPrimer(int height) { - this.data = new short[Math.max(height, 256) * 256]; + this.data = new char[Math.max(height, 256) * 256]; this.height = height; } - public short[] getData() { + public char[] getData() { return this.data; } public State get(int x, int y, int z) { - State state = State.ID_MAP.getByValue(this.data[x << 4 | z | y << 8]); + State state = BlockRegistry.byId(this.data[x << 4 | z | y << 8]); return state != null ? state : Blocks.air.getState(); } public void set(int x, int y, int z, State state) { - this.data[x << 4 | z | y << 8] = (short)State.ID_MAP.get(state); + this.data[x << 4 | z | y << 8] = (char)BlockRegistry.getId(state); } } diff --git a/server/src/main/java/server/worldgen/structure/StructureVillage.java b/server/src/main/java/server/worldgen/structure/StructureVillage.java index f82db30b..40113de6 100755 --- a/server/src/main/java/server/worldgen/structure/StructureVillage.java +++ b/server/src/main/java/server/worldgen/structure/StructureVillage.java @@ -404,19 +404,19 @@ public class StructureVillage protected void writeTags(TagObject tagCompound) { super.writeTags(tagCompound); - tagCompound.setString("CA", BlockRegistry.getNameFromBlock(this.cropTypeA)); - tagCompound.setString("CB", BlockRegistry.getNameFromBlock(this.cropTypeB)); - tagCompound.setString("CC", BlockRegistry.getNameFromBlock(this.cropTypeC)); - tagCompound.setString("CD", BlockRegistry.getNameFromBlock(this.cropTypeD)); + tagCompound.setString("CA", BlockRegistry.getName(this.cropTypeA)); + tagCompound.setString("CB", BlockRegistry.getName(this.cropTypeB)); + tagCompound.setString("CC", BlockRegistry.getName(this.cropTypeC)); + tagCompound.setString("CD", BlockRegistry.getName(this.cropTypeD)); } protected void readTags(TagObject tagCompound) { super.readTags(tagCompound); - this.cropTypeA = BlockRegistry.getRegisteredBlock(tagCompound.getString("CA")) instanceof BlockCrops crops ? crops : Blocks.wheat; - this.cropTypeB = BlockRegistry.getRegisteredBlock(tagCompound.getString("CB")) instanceof BlockCrops crops ? crops : Blocks.wheat; - this.cropTypeC = BlockRegistry.getRegisteredBlock(tagCompound.getString("CC")) instanceof BlockCrops crops ? crops : Blocks.wheat; - this.cropTypeD = BlockRegistry.getRegisteredBlock(tagCompound.getString("CD")) instanceof BlockCrops crops ? crops : Blocks.wheat; + this.cropTypeA = BlockRegistry.byName(tagCompound.getString("CA")) instanceof BlockCrops crops ? crops : Blocks.wheat; + this.cropTypeB = BlockRegistry.byName(tagCompound.getString("CB")) instanceof BlockCrops crops ? crops : Blocks.wheat; + this.cropTypeC = BlockRegistry.byName(tagCompound.getString("CC")) instanceof BlockCrops crops ? crops : Blocks.wheat; + this.cropTypeD = BlockRegistry.byName(tagCompound.getString("CD")) instanceof BlockCrops crops ? crops : Blocks.wheat; } private BlockCrops func_151559_a(Random rand) @@ -513,15 +513,15 @@ public class StructureVillage protected void writeTags(TagObject tagCompound) { super.writeTags(tagCompound); - tagCompound.setString("CA", BlockRegistry.getNameFromBlock(this.cropTypeA)); - tagCompound.setString("CB", BlockRegistry.getNameFromBlock(this.cropTypeB)); + tagCompound.setString("CA", BlockRegistry.getName(this.cropTypeA)); + tagCompound.setString("CB", BlockRegistry.getName(this.cropTypeB)); } protected void readTags(TagObject tagCompound) { super.readTags(tagCompound); - this.cropTypeA = BlockRegistry.getRegisteredBlock(tagCompound.getString("CA")) instanceof BlockCrops crops ? crops : Blocks.wheat; - this.cropTypeB = BlockRegistry.getRegisteredBlock(tagCompound.getString("CB")) instanceof BlockCrops crops ? crops : Blocks.wheat; + this.cropTypeA = BlockRegistry.byName(tagCompound.getString("CA")) instanceof BlockCrops crops ? crops : Blocks.wheat; + this.cropTypeB = BlockRegistry.byName(tagCompound.getString("CB")) instanceof BlockCrops crops ? crops : Blocks.wheat; } private BlockCrops func_151560_a(Random rand) From 2919d991263086a50275630ee1adc7360e81fe42 Mon Sep 17 00:00:00 2001 From: Sen Date: Fri, 27 Jun 2025 16:56:08 +0200 Subject: [PATCH 2/7] remove block metadata TEMP --- common/src/main/java/common/block/Block.java | 34 ++++++++++++++++++- .../common/block/artificial/BlockFence.java | 4 +++ .../block/artificial/BlockFenceGate.java | 4 +++ .../common/block/artificial/BlockPane.java | 4 +++ .../common/block/artificial/BlockStairs.java | 4 +++ .../common/block/artificial/BlockWall.java | 4 +++ .../block/foliage/BlockDoublePlant.java | 12 +++---- .../java/common/block/foliage/BlockGrass.java | 4 +++ .../common/block/foliage/BlockMycelium.java | 4 +++ .../java/common/block/foliage/BlockStem.java | 4 +++ .../common/block/foliage/BlockTianSoil.java | 4 +++ .../java/common/block/foliage/BlockVine.java | 4 +++ .../java/common/block/natural/BlockFire.java | 4 +++ .../common/block/natural/BlockPodzol.java | 4 +++ .../common/block/tech/BlockPistonHead.java | 4 +++ .../block/tech/BlockRedstoneRepeater.java | 4 +++ .../common/block/tech/BlockRedstoneWire.java | 4 +++ .../java/common/block/tech/BlockTripWire.java | 4 +++ .../common/block/tech/BlockTripWireHook.java | 4 +++ .../main/java/common/init/BlockRegistry.java | 7 +++- 20 files changed, 111 insertions(+), 10 deletions(-) diff --git a/common/src/main/java/common/block/Block.java b/common/src/main/java/common/block/Block.java index 99a70251..6ea1c5a3 100755 --- a/common/src/main/java/common/block/Block.java +++ b/common/src/main/java/common/block/Block.java @@ -158,7 +158,9 @@ public class Block { } private final ImmutableList properties; + private final ImmutableList savedProps; private final ImmutableList states; + private final ImmutableList saved; protected final Material material; protected final boolean translucent; @@ -253,6 +255,26 @@ public class Block { return ImmutableList.copyOf(properties); } + private static ImmutableList getPropertyList(Property[] properties, Property[] unsaved) { + List list = unsaved.length == 0 ? Lists.newArrayList(properties) : Lists.newArrayList(); + if(unsaved.length > 0) { + for(Property prop : properties) { + for(int z = 0; z < unsaved.length; z++) { + if(unsaved[z] == prop) + break; + else if(z == unsaved.length - 1) + list.add(prop); + } + } + } + Collections.sort(list, new Comparator() { + public int compare(Property p1, Property p2) { + return p1.getName().compareTo(p2.getName()); + } + }); + return ImmutableList.copyOf(list); + } + private static ImmutableList getStateList(List properties, Block block) { Map, State> map = Maps., State>newLinkedHashMap(); List list = Lists.newArrayList(); @@ -283,6 +305,8 @@ public class Block { this.properties = getPropertyList(this.getProperties()); this.states = getStateList(this.properties, this); this.setDefaultState(this.getBaseState()); + this.savedProps = getPropertyList(this.getProperties(), this.getUnsavedProperties()); + this.saved = getStateList(this.savedProps, this); } public Block setStepSound(SoundType sound) { @@ -397,12 +421,16 @@ public class Block { return this.states; } + public ImmutableList getSavedStates() { + return this.saved; + } + public final State getBaseState() { return this.states.get(0); } public Collection getPropertyMap() { - return this.properties; + return this.savedProps; } public State getStateFromMeta(int meta) { @@ -951,6 +979,10 @@ public class Block { return new Property[0]; } + public Property[] getUnsavedProperties() { + return new Property[0]; + } + protected final void setDefaultState(State state) { this.defaultState = state; } diff --git a/common/src/main/java/common/block/artificial/BlockFence.java b/common/src/main/java/common/block/artificial/BlockFence.java index a00a463f..5e072bcb 100755 --- a/common/src/main/java/common/block/artificial/BlockFence.java +++ b/common/src/main/java/common/block/artificial/BlockFence.java @@ -385,4 +385,8 @@ public class BlockFence extends Block protected Item getItemToRegister() { return new ItemFence(this); } + + public Property[] getUnsavedProperties() { + return new Property[] {NORTH, SOUTH, WEST, EAST}; + } } diff --git a/common/src/main/java/common/block/artificial/BlockFenceGate.java b/common/src/main/java/common/block/artificial/BlockFenceGate.java index 0d936155..53384e89 100755 --- a/common/src/main/java/common/block/artificial/BlockFenceGate.java +++ b/common/src/main/java/common/block/artificial/BlockFenceGate.java @@ -409,4 +409,8 @@ public class BlockFenceGate extends Block implements Rotatable public Property[] getIgnoredProperties() { return new Property[] {POWERED}; } + + public Property[] getUnsavedProperties() { + return new Property[] {IN_WALL}; + } } diff --git a/common/src/main/java/common/block/artificial/BlockPane.java b/common/src/main/java/common/block/artificial/BlockPane.java index 0c1ee080..c8d474bb 100755 --- a/common/src/main/java/common/block/artificial/BlockPane.java +++ b/common/src/main/java/common/block/artificial/BlockPane.java @@ -504,4 +504,8 @@ public class BlockPane extends Block protected Item getItemToRegister() { return this.canDrop ? super.getItemToRegister() : new ItemBlock(this, "glass", false); } + + public Property[] getUnsavedProperties() { + return new Property[] {NORTH, SOUTH, WEST, EAST}; + } } diff --git a/common/src/main/java/common/block/artificial/BlockStairs.java b/common/src/main/java/common/block/artificial/BlockStairs.java index bbbaef2f..17492719 100755 --- a/common/src/main/java/common/block/artificial/BlockStairs.java +++ b/common/src/main/java/common/block/artificial/BlockStairs.java @@ -833,6 +833,10 @@ public class BlockStairs extends Block implements Rotatable return true; } + public Property[] getUnsavedProperties() { + return new Property[] {SHAPE}; + } + public static enum EnumHalf implements Identifyable { TOP("top"), diff --git a/common/src/main/java/common/block/artificial/BlockWall.java b/common/src/main/java/common/block/artificial/BlockWall.java index e393ea43..1ca2a161 100755 --- a/common/src/main/java/common/block/artificial/BlockWall.java +++ b/common/src/main/java/common/block/artificial/BlockWall.java @@ -299,4 +299,8 @@ public class BlockWall extends Block protected Item getItemToRegister() { return new ItemWall(this); } + + public Property[] getUnsavedProperties() { + return new Property[] {NORTH, SOUTH, UP, WEST, EAST}; + } } diff --git a/common/src/main/java/common/block/foliage/BlockDoublePlant.java b/common/src/main/java/common/block/foliage/BlockDoublePlant.java index 1a06a153..e194886d 100755 --- a/common/src/main/java/common/block/foliage/BlockDoublePlant.java +++ b/common/src/main/java/common/block/foliage/BlockDoublePlant.java @@ -29,7 +29,7 @@ import common.world.State; import common.world.World; import common.world.AWorldServer; -public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable +public class BlockDoublePlant extends BlockBush implements IGrowable { public static final PropertyEnum HALF = PropertyEnum.create("half", BlockDoublePlant.EnumBlockHalf.class); public static final BlockDoublePlant[] PLANTS = new BlockDoublePlant[EnumPlantType.values().length]; @@ -44,7 +44,7 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable { super(Material.BUSH); this.type = type; - this.setDefaultState(this.getBaseState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER).withProperty(FACING, Facing.NORTH)); + this.setDefaultState(this.getBaseState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER)); this.setHardness(0.0F); this.setStepSound(SoundType.GRASS); this.setFlammable(60, 100); @@ -271,12 +271,12 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable */ public int getMetaFromState(State state) { - return state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER ? 8 | ((Facing)state.getValue(FACING)).getHorizontalIndex() : 0; + return state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER ? 8 : 0; } protected Property[] getProperties() { - return new Property[] {HALF, FACING}; + return new Property[] {HALF}; } public Model getModel(ModelProvider provider, String name, State state) { @@ -295,10 +295,6 @@ public class BlockDoublePlant extends BlockBush implements Rotatable, IGrowable return provider.getModel(this.type.getName() + "_" + (state.getValue(HALF) == EnumBlockHalf.UPPER ? "top" : "bottom")).cross(); } - - public Property[] getIgnoredProperties() { - return new Property[] {FACING}; - } protected Item getItemToRegister() { return new ItemDoublePlant(this); diff --git a/common/src/main/java/common/block/foliage/BlockGrass.java b/common/src/main/java/common/block/foliage/BlockGrass.java index c4248043..66b7d827 100755 --- a/common/src/main/java/common/block/foliage/BlockGrass.java +++ b/common/src/main/java/common/block/foliage/BlockGrass.java @@ -148,4 +148,8 @@ public class BlockGrass extends Block implements IGrowable protected Item getItemToRegister() { return new ItemColored(this); } + + public Property[] getUnsavedProperties() { + return new Property[] {SNOWY}; + } } diff --git a/common/src/main/java/common/block/foliage/BlockMycelium.java b/common/src/main/java/common/block/foliage/BlockMycelium.java index 49b79fdb..d13bda0e 100755 --- a/common/src/main/java/common/block/foliage/BlockMycelium.java +++ b/common/src/main/java/common/block/foliage/BlockMycelium.java @@ -106,4 +106,8 @@ public class BlockMycelium extends Block else return provider.getModel("mycelium_side").add().nswe().d("dirt").u("mycelium_top"); } + + public Property[] getUnsavedProperties() { + return new Property[] {SNOWY}; + } } diff --git a/common/src/main/java/common/block/foliage/BlockStem.java b/common/src/main/java/common/block/foliage/BlockStem.java index f4b252d0..c0d3382b 100755 --- a/common/src/main/java/common/block/foliage/BlockStem.java +++ b/common/src/main/java/common/block/foliage/BlockStem.java @@ -324,4 +324,8 @@ public class BlockStem extends BlockBush implements DirectionalUp, IGrowable protected Item getItemToRegister() { return new ItemSeeds(this, Blocks.farmland).setDisplay(this.itemName).setMaxAmount(256); } + + public Property[] getUnsavedProperties() { + return new Property[] {FACING}; + } } diff --git a/common/src/main/java/common/block/foliage/BlockTianSoil.java b/common/src/main/java/common/block/foliage/BlockTianSoil.java index dce3ab62..28967997 100755 --- a/common/src/main/java/common/block/foliage/BlockTianSoil.java +++ b/common/src/main/java/common/block/foliage/BlockTianSoil.java @@ -52,4 +52,8 @@ public class BlockTianSoil extends Block else return provider.getModel("tian_soil_side").add().nswe().d("tian").u("tian_soil_top"); } + + public Property[] getUnsavedProperties() { + return new Property[] {SNOWY}; + } } diff --git a/common/src/main/java/common/block/foliage/BlockVine.java b/common/src/main/java/common/block/foliage/BlockVine.java index c3347ba0..a7440890 100755 --- a/common/src/main/java/common/block/foliage/BlockVine.java +++ b/common/src/main/java/common/block/foliage/BlockVine.java @@ -597,4 +597,8 @@ public class BlockVine extends Block protected Item getItemToRegister() { return new ItemColored(this, ""); } + + public Property[] getUnsavedProperties() { + return new Property[] {UP}; + } } diff --git a/common/src/main/java/common/block/natural/BlockFire.java b/common/src/main/java/common/block/natural/BlockFire.java index ef5d1bdf..687087d0 100755 --- a/common/src/main/java/common/block/natural/BlockFire.java +++ b/common/src/main/java/common/block/natural/BlockFire.java @@ -1156,4 +1156,8 @@ public class BlockFire extends Block protected Item getItemToRegister() { return null; } + + public Property[] getUnsavedProperties() { + return new Property[] {NORTH, SOUTH, UPPER, FLIP, WEST, EAST, ALT}; + } } diff --git a/common/src/main/java/common/block/natural/BlockPodzol.java b/common/src/main/java/common/block/natural/BlockPodzol.java index f812ce73..8552fc4c 100644 --- a/common/src/main/java/common/block/natural/BlockPodzol.java +++ b/common/src/main/java/common/block/natural/BlockPodzol.java @@ -45,4 +45,8 @@ public class BlockPodzol extends Block { return state.getValue(SNOWY) ? provider.getModel("grass_side_snowed").add().nswe().d("dirt").u("grass_top") : provider.getModel("dirt_podzol_side").add().nswe().d("dirt").u("dirt_podzol_top"); } + + public Property[] getUnsavedProperties() { + return new Property[] {SNOWY}; + } } diff --git a/common/src/main/java/common/block/tech/BlockPistonHead.java b/common/src/main/java/common/block/tech/BlockPistonHead.java index 6e907e59..d8e39df6 100755 --- a/common/src/main/java/common/block/tech/BlockPistonHead.java +++ b/common/src/main/java/common/block/tech/BlockPistonHead.java @@ -300,6 +300,10 @@ public class BlockPistonHead extends Block implements Directional return null; } + public Property[] getUnsavedProperties() { + return new Property[] {SHORT}; + } + public static enum EnumPistonType implements Identifyable { DEFAULT("normal"), diff --git a/common/src/main/java/common/block/tech/BlockRedstoneRepeater.java b/common/src/main/java/common/block/tech/BlockRedstoneRepeater.java index 573d19a8..17dd4e8d 100755 --- a/common/src/main/java/common/block/tech/BlockRedstoneRepeater.java +++ b/common/src/main/java/common/block/tech/BlockRedstoneRepeater.java @@ -574,4 +574,8 @@ public class BlockRedstoneRepeater extends BlockRedstoneDiode protected Item getItemToRegister() { return this.isRepeaterPowered ? null : new ItemSmallBlock(this).setDisplay("Redstone-Verstärker").setTab(CheatTab.TECHNOLOGY); } + + public Property[] getUnsavedProperties() { + return new Property[] {LOCKED}; + } } diff --git a/common/src/main/java/common/block/tech/BlockRedstoneWire.java b/common/src/main/java/common/block/tech/BlockRedstoneWire.java index 3c272622..102808c6 100755 --- a/common/src/main/java/common/block/tech/BlockRedstoneWire.java +++ b/common/src/main/java/common/block/tech/BlockRedstoneWire.java @@ -1033,6 +1033,10 @@ public class BlockRedstoneWire extends Block return new ItemRedstone(Blocks.redstone).setDisplay("Redstone").setPotionEffect(PotionHelper.redstoneEffect).setMaxAmount(256); } + public Property[] getUnsavedProperties() { + return new Property[] {EAST, NORTH, SOUTH, WEST}; + } + public static enum EnumAttachPosition implements Identifyable { UP("up"), diff --git a/common/src/main/java/common/block/tech/BlockTripWire.java b/common/src/main/java/common/block/tech/BlockTripWire.java index 05c7a2a9..cc1363c8 100755 --- a/common/src/main/java/common/block/tech/BlockTripWire.java +++ b/common/src/main/java/common/block/tech/BlockTripWire.java @@ -702,4 +702,8 @@ public class BlockTripWire extends Block protected Item getItemToRegister() { return new ItemSmallBlock(this).setDisplay("Faden").setTab(CheatTab.TECHNOLOGY).setMaxAmount(1024); } + + public Property[] getUnsavedProperties() { + return new Property[] {NORTH, SOUTH, WEST, EAST}; + } } diff --git a/common/src/main/java/common/block/tech/BlockTripWireHook.java b/common/src/main/java/common/block/tech/BlockTripWireHook.java index c4d8166e..8aca2476 100755 --- a/common/src/main/java/common/block/tech/BlockTripWireHook.java +++ b/common/src/main/java/common/block/tech/BlockTripWireHook.java @@ -594,4 +594,8 @@ public class BlockTripWireHook extends Block implements Rotatable protected Item getItemToRegister() { return new ItemBlock(this, "tripwire_hook", false); } + + public Property[] getUnsavedProperties() { + return new Property[] {SUSPENDED}; + } } diff --git a/common/src/main/java/common/init/BlockRegistry.java b/common/src/main/java/common/init/BlockRegistry.java index 8fdd3236..4ae3a708 100755 --- a/common/src/main/java/common/init/BlockRegistry.java +++ b/common/src/main/java/common/init/BlockRegistry.java @@ -139,6 +139,7 @@ import common.collect.BiMap; import common.collect.HashBiMap; import common.collect.Lists; import common.collect.Maps; +import common.collect.Sets; import common.color.DyeColor; import common.item.CheatTab; import common.log.Log; @@ -674,9 +675,13 @@ public abstract class BlockRegistry { STATES.add(state); } } - StringBuilder sb = new StringBuilder("\n\n\tpublic Property[] getSavedProperties() {\n\t\treturn new Property[] {"); + StringBuilder sb = new StringBuilder("\n\n\tpublic Property[] getUnsavedProperties() {\n\t\treturn new Property[] {"); boolean put = false; + Set props = Sets.newHashSet(block.getPropertyMap()); for(Property prop : block.getState().getSavedProperties()) { + props.remove(prop); + } + for(Property prop : props) { if(put) sb.append(", "); sb.append(prop.getName().toUpperCase()); From 3db0dca0733fea4baaa7a51f8ba4a93c2c545edd Mon Sep 17 00:00:00 2001 From: Sen Date: Fri, 27 Jun 2025 18:04:17 +0200 Subject: [PATCH 3/7] remove block metadata T2 --- client/src/main/java/client/Client.java | 2 +- common/src/main/java/common/block/Block.java | 35 ++++++++---- .../common/block/artificial/BlockBed.java | 4 -- .../common/block/artificial/BlockCake.java | 8 --- .../common/block/artificial/BlockDoor.java | 34 ------------ .../common/block/artificial/BlockFence.java | 8 --- .../block/artificial/BlockFenceGate.java | 21 ------- .../common/block/artificial/BlockHay.java | 20 ------- .../common/block/artificial/BlockLadder.java | 8 --- .../common/block/artificial/BlockPane.java | 8 --- .../common/block/artificial/BlockPortal.java | 9 --- .../block/artificial/BlockPortalFrame.java | 16 ------ .../block/artificial/BlockQuartzPillar.java | 15 ----- .../common/block/artificial/BlockSkull.java | 4 -- .../common/block/artificial/BlockSlab.java | 8 --- .../common/block/artificial/BlockStairs.java | 16 ------ .../block/artificial/BlockTrapDoor.java | 21 ------- .../common/block/artificial/BlockWall.java | 4 -- .../common/block/foliage/BlockCactus.java | 8 --- .../java/common/block/foliage/BlockCocoa.java | 11 ---- .../java/common/block/foliage/BlockCrops.java | 8 --- .../block/foliage/BlockDoublePlant.java | 10 ---- .../common/block/foliage/BlockFarmland.java | 8 --- .../java/common/block/foliage/BlockGrass.java | 8 --- .../block/foliage/BlockHugeMushroom.java | 8 --- .../common/block/foliage/BlockLeaves.java | 10 ---- .../common/block/foliage/BlockLilyPad.java | 5 -- .../java/common/block/foliage/BlockLog.java | 18 ------ .../common/block/foliage/BlockMycelium.java | 8 --- .../common/block/foliage/BlockPumpkin.java | 4 -- .../java/common/block/foliage/BlockReed.java | 8 --- .../common/block/foliage/BlockSapling.java | 11 ---- .../java/common/block/foliage/BlockStem.java | 8 --- .../common/block/foliage/BlockTianSoil.java | 5 -- .../java/common/block/foliage/BlockVine.java | 30 ---------- .../java/common/block/foliage/BlockWart.java | 8 --- .../java/common/block/liquid/BlockLiquid.java | 8 --- .../java/common/block/natural/BlockFire.java | 8 --- .../java/common/block/natural/BlockOre.java | 2 +- .../common/block/natural/BlockPodzol.java | 4 -- .../java/common/block/natural/BlockSnow.java | 8 --- .../java/common/block/tech/BlockAnvil.java | 10 ---- .../common/block/tech/BlockBrewingStand.java | 18 ------ .../java/common/block/tech/BlockButton.java | 42 -------------- .../java/common/block/tech/BlockCauldron.java | 8 --- .../java/common/block/tech/BlockChest.java | 8 --- .../block/tech/BlockDaylightDetector.java | 8 --- .../common/block/tech/BlockDispenser.java | 16 ------ .../java/common/block/tech/BlockFurnace.java | 8 --- .../java/common/block/tech/BlockHopper.java | 16 ------ .../java/common/block/tech/BlockLever.java | 16 ------ .../java/common/block/tech/BlockMachine.java | 4 -- .../common/block/tech/BlockPistonBase.java | 16 ------ .../common/block/tech/BlockPistonHead.java | 16 ------ .../common/block/tech/BlockPistonMoving.java | 16 ------ .../common/block/tech/BlockPressurePlate.java | 8 --- .../tech/BlockPressurePlateWeighted.java | 8 --- .../java/common/block/tech/BlockRail.java | 8 --- .../common/block/tech/BlockRailDetector.java | 16 ------ .../common/block/tech/BlockRailPowered.java | 16 ------ .../block/tech/BlockRedstoneComparator.java | 21 ------- .../block/tech/BlockRedstoneRepeater.java | 11 ---- .../common/block/tech/BlockRedstoneWire.java | 8 --- .../main/java/common/block/tech/BlockTNT.java | 8 --- .../java/common/block/tech/BlockTorch.java | 34 ------------ .../java/common/block/tech/BlockTripWire.java | 30 ---------- .../common/block/tech/BlockTripWireHook.java | 21 ------- .../common/block/tech/BlockWarpChest.java | 8 --- .../common/block/tile/BlockBannerHanging.java | 5 -- .../block/tile/BlockBannerStanding.java | 5 -- .../common/block/tile/BlockStandingSign.java | 8 --- .../java/common/block/tile/BlockWallSign.java | 8 --- .../main/java/common/init/BlockRegistry.java | 35 ++---------- common/src/main/java/common/world/State.java | 55 +++---------------- .../server/clipboard/ReorderRegistry.java | 19 ++++--- .../server/clipboard/RotationRegistry.java | 2 +- .../server/command/commands/CommandBlock.java | 2 +- 77 files changed, 51 insertions(+), 934 deletions(-) diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index ebc4af3d..69d904fb 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -1930,7 +1930,7 @@ public class Client implements IThreadListener { String.format("Position: %d %d %d", pos.getX(), pos.getY(), pos.getZ()) ); for(Entry entry : block.getProperties().entrySet()) { - str.append("\n" + (block.getSavedProperties().contains(entry.getKey()) ? TextColor.NEON : TextColor.LGRAY) + entry.getKey().getName() + TextColor.RESET + ": " + (entry.getValue() instanceof Boolean bool ? (bool ? TextColor.GREEN : TextColor.RED) + "" + entry.getValue() + TextColor.RESET : entry.getValue())); + str.append("\n" + (block.getBlock().getSavedProperties().contains(entry.getKey()) ? TextColor.NEON : TextColor.LGRAY) + entry.getKey().getName() + TextColor.RESET + ": " + (entry.getValue() instanceof Boolean bool ? (bool ? TextColor.GREEN : TextColor.RED) + "" + entry.getValue() + TextColor.RESET : entry.getValue())); } return str.toString(); diff --git a/common/src/main/java/common/block/Block.java b/common/src/main/java/common/block/Block.java index 6ea1c5a3..e7e54576 100755 --- a/common/src/main/java/common/block/Block.java +++ b/common/src/main/java/common/block/Block.java @@ -9,6 +9,8 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; +import java.util.Set; +import java.util.Map.Entry; import java.util.function.Function; import common.block.artificial.BlockSlab; @@ -17,6 +19,7 @@ import common.collect.ImmutableMap; import common.collect.Iterables; import common.collect.Lists; import common.collect.Maps; +import common.collect.Sets; import common.collect.UnmodifiableIterator; import common.enchantment.EnchantmentHelper; import common.entity.Entity; @@ -43,6 +46,7 @@ import common.util.Facing; import common.util.HitPosition; import common.util.Vec3; import common.util.HitPosition.ObjectType; +import common.util.Pair; import common.vars.Vars; import common.world.Explosion; import common.world.IBlockAccess; @@ -289,6 +293,24 @@ public class Block { } return ImmutableList.copyOf(list); } + + private static ImmutableList getStateList(ImmutableList saved, ImmutableList states) { + Set>> uniq = Sets.newHashSet(); + List list = Lists.newArrayList(); + for(State state : states) { + List> props = Lists.newArrayList(); + for(Entry entry : state.getProperties().entrySet()) { + if(saved.contains(entry.getKey())) + props.add(new Pair(entry.getKey(), entry.getValue())); + } + if(!uniq.contains(props)) { + uniq.add(props); + list.add(state); + } + } + uniq.clear(); + return ImmutableList.copyOf(list); + } public Block(Material material) { this.miningLevel = (material == Material.SOLID || material == Material.HEAVY) ? 0 : -1; @@ -306,7 +328,7 @@ public class Block { this.states = getStateList(this.properties, this); this.setDefaultState(this.getBaseState()); this.savedProps = getPropertyList(this.getProperties(), this.getUnsavedProperties()); - this.saved = getStateList(this.savedProps, this); + this.saved = getStateList(this.savedProps, this.states); } public Block setStepSound(SoundType sound) { @@ -429,7 +451,7 @@ public class Block { return this.states.get(0); } - public Collection getPropertyMap() { + public Collection getSavedProperties() { return this.savedProps; } @@ -437,15 +459,6 @@ public class Block { return this.getState(); } - public int getMetaFromState(State state) { - if(state != null && !state.getPropertyNames().isEmpty()) { - throw new IllegalArgumentException("Don\'t know how to convert " + state + " back into data..."); - } - else { - return 0; - } - } - public State getActualState(State state, IWorldAccess worldIn, BlockPos pos) { return state; } diff --git a/common/src/main/java/common/block/artificial/BlockBed.java b/common/src/main/java/common/block/artificial/BlockBed.java index 1d7f8668..d2697694 100755 --- a/common/src/main/java/common/block/artificial/BlockBed.java +++ b/common/src/main/java/common/block/artificial/BlockBed.java @@ -185,10 +185,6 @@ public class BlockBed extends Block implements Rotatable { .withProperty(FACING, Facing.getHorizontal(meta)); } - public int getMetaFromState(State state) { - return ((Facing)state.getValue(FACING)).getHorizontalIndex() | (state.getValue(PART) == BlockBed.EnumPartType.HEAD ? 8 : 0); - } - protected Property[] getProperties() { return new Property[] {FACING, PART}; } diff --git a/common/src/main/java/common/block/artificial/BlockCake.java b/common/src/main/java/common/block/artificial/BlockCake.java index 5ed23440..2befa3dc 100755 --- a/common/src/main/java/common/block/artificial/BlockCake.java +++ b/common/src/main/java/common/block/artificial/BlockCake.java @@ -222,14 +222,6 @@ public class BlockCake extends Block return this.getState().withProperty(BITES, Integer.valueOf(meta > 6 ? 0 : meta)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Integer)state.getValue(BITES)).intValue(); - } - protected Property[] getProperties() { return new Property[] {BITES}; diff --git a/common/src/main/java/common/block/artificial/BlockDoor.java b/common/src/main/java/common/block/artificial/BlockDoor.java index f82e39b4..03a24f82 100755 --- a/common/src/main/java/common/block/artificial/BlockDoor.java +++ b/common/src/main/java/common/block/artificial/BlockDoor.java @@ -378,40 +378,6 @@ public class BlockDoor extends Block implements Rotatable return (meta & 8) > 0 ? this.getState().withProperty(HALF, BlockDoor.EnumDoorHalf.UPPER).withProperty(HINGE, (meta & 1) > 0 ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT).withProperty(POWERED, Boolean.valueOf((meta & 2) > 0)) : this.getState().withProperty(HALF, BlockDoor.EnumDoorHalf.LOWER).withProperty(FACING, Facing.getHorizontal(meta & 3).rotateYCCW()).withProperty(OPEN, Boolean.valueOf((meta & 4) > 0)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - - if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER) - { - i = i | 8; - - if (state.getValue(HINGE) == BlockDoor.EnumHingePosition.RIGHT) - { - i |= 1; - } - - if (((Boolean)state.getValue(POWERED)).booleanValue()) - { - i |= 2; - } - } - else - { - i = i | ((Facing)state.getValue(FACING)).rotateY().getHorizontalIndex(); - - if (((Boolean)state.getValue(OPEN)).booleanValue()) - { - i |= 4; - } - } - - return i; - } - protected static int removeHalfBit(int meta) { return meta & 7; diff --git a/common/src/main/java/common/block/artificial/BlockFence.java b/common/src/main/java/common/block/artificial/BlockFence.java index 5e072bcb..59358c9e 100755 --- a/common/src/main/java/common/block/artificial/BlockFence.java +++ b/common/src/main/java/common/block/artificial/BlockFence.java @@ -181,14 +181,6 @@ public class BlockFence extends Block return worldIn.client ? true : ItemLead.attachToFence(playerIn, worldIn, pos); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return 0; - } - /** * Get the actual Block state of this Block at the given position. This applies properties not visible in the * metadata, such as fence connections. diff --git a/common/src/main/java/common/block/artificial/BlockFenceGate.java b/common/src/main/java/common/block/artificial/BlockFenceGate.java index 53384e89..eae45f15 100755 --- a/common/src/main/java/common/block/artificial/BlockFenceGate.java +++ b/common/src/main/java/common/block/artificial/BlockFenceGate.java @@ -179,27 +179,6 @@ public class BlockFenceGate extends Block implements Rotatable return this.getState().withProperty(FACING, Facing.getHorizontal(meta)).withProperty(OPEN, Boolean.valueOf((meta & 4) != 0)).withProperty(POWERED, Boolean.valueOf((meta & 8) != 0)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - i = i | ((Facing)state.getValue(FACING)).getHorizontalIndex(); - - if (((Boolean)state.getValue(POWERED)).booleanValue()) - { - i |= 8; - } - - if (((Boolean)state.getValue(OPEN)).booleanValue()) - { - i |= 4; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {FACING, OPEN, POWERED, IN_WALL}; diff --git a/common/src/main/java/common/block/artificial/BlockHay.java b/common/src/main/java/common/block/artificial/BlockHay.java index a93007bd..55946e64 100755 --- a/common/src/main/java/common/block/artificial/BlockHay.java +++ b/common/src/main/java/common/block/artificial/BlockHay.java @@ -41,26 +41,6 @@ public class BlockHay extends BlockRotatedPillar return this.getState().withProperty(AXIS, enumfacing$axis); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - Facing.Axis enumfacing$axis = (Facing.Axis)state.getValue(AXIS); - - if (enumfacing$axis == Facing.Axis.X) - { - i |= 4; - } - else if (enumfacing$axis == Facing.Axis.Z) - { - i |= 8; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {AXIS}; diff --git a/common/src/main/java/common/block/artificial/BlockLadder.java b/common/src/main/java/common/block/artificial/BlockLadder.java index b8d4fc80..65bea537 100755 --- a/common/src/main/java/common/block/artificial/BlockLadder.java +++ b/common/src/main/java/common/block/artificial/BlockLadder.java @@ -151,14 +151,6 @@ public class BlockLadder extends Block implements Rotatable return this.getState().withProperty(FACING, enumfacing); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Facing)state.getValue(FACING)).getIndex(); - } - protected Property[] getProperties() { return new Property[] {FACING}; diff --git a/common/src/main/java/common/block/artificial/BlockPane.java b/common/src/main/java/common/block/artificial/BlockPane.java index c8d474bb..53355517 100755 --- a/common/src/main/java/common/block/artificial/BlockPane.java +++ b/common/src/main/java/common/block/artificial/BlockPane.java @@ -195,14 +195,6 @@ public class BlockPane extends Block return BlockLayer.CUTOUT_MIPPED; } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return 0; - } - protected Property[] getProperties() { return new Property[] {NORTH, EAST, WEST, SOUTH}; diff --git a/common/src/main/java/common/block/artificial/BlockPortal.java b/common/src/main/java/common/block/artificial/BlockPortal.java index 0b82a136..1c6a8848 100755 --- a/common/src/main/java/common/block/artificial/BlockPortal.java +++ b/common/src/main/java/common/block/artificial/BlockPortal.java @@ -19,7 +19,6 @@ import common.rng.Random; import common.util.BlockPos; import common.util.BoundingBox; import common.util.Facing; -import common.util.Facing.Axis; import common.world.IWorldAccess; import common.world.AWorldClient; import common.world.State; @@ -269,14 +268,6 @@ public class BlockPortal extends Block .withProperty(DIM, meta & 7); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return (state.getValue(AXIS) == Axis.Z ? 8 : 0) | state.getValue(DIM); - } - protected Property[] getProperties() { return new Property[] {AXIS, DIM}; diff --git a/common/src/main/java/common/block/artificial/BlockPortalFrame.java b/common/src/main/java/common/block/artificial/BlockPortalFrame.java index 2aeaa4f7..7b4d8705 100755 --- a/common/src/main/java/common/block/artificial/BlockPortalFrame.java +++ b/common/src/main/java/common/block/artificial/BlockPortalFrame.java @@ -115,22 +115,6 @@ public class BlockPortalFrame extends Block implements Rotatable return this.getState().withProperty(ORB, Boolean.valueOf((meta & 4) != 0)).withProperty(FACING, Facing.getHorizontal(meta & 3)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - i = i | ((Facing)state.getValue(FACING)).getHorizontalIndex(); - - if (((Boolean)state.getValue(ORB)).booleanValue()) - { - i |= 4; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {FACING, ORB}; diff --git a/common/src/main/java/common/block/artificial/BlockQuartzPillar.java b/common/src/main/java/common/block/artificial/BlockQuartzPillar.java index ddfbecdd..b8ca8a2f 100644 --- a/common/src/main/java/common/block/artificial/BlockQuartzPillar.java +++ b/common/src/main/java/common/block/artificial/BlockQuartzPillar.java @@ -52,21 +52,6 @@ public class BlockQuartzPillar extends BlockRotatedPillar return state; } - public int getMetaFromState(State state) - { - int meta = 0; - switch (state.getValue(AXIS)) - { - case X: - meta = 1; - break; - case Z: - meta = 2; - break; - } - return meta; - } - protected Property[] getProperties() { return new Property[] {AXIS}; diff --git a/common/src/main/java/common/block/artificial/BlockSkull.java b/common/src/main/java/common/block/artificial/BlockSkull.java index c6788d43..6b307822 100755 --- a/common/src/main/java/common/block/artificial/BlockSkull.java +++ b/common/src/main/java/common/block/artificial/BlockSkull.java @@ -38,10 +38,6 @@ public class BlockSkull extends Block implements Rotatable { return this.getState().withProperty(FACING, Facing.getHorizontal(meta)); } - public int getMetaFromState(State state) { - return state.getValue(FACING).getHorizontalIndex(); - } - protected Property[] getProperties() { return new Property[] {FACING}; } diff --git a/common/src/main/java/common/block/artificial/BlockSlab.java b/common/src/main/java/common/block/artificial/BlockSlab.java index 347125a8..fbb0fd1c 100755 --- a/common/src/main/java/common/block/artificial/BlockSlab.java +++ b/common/src/main/java/common/block/artificial/BlockSlab.java @@ -63,14 +63,6 @@ public class BlockSlab extends Block implements Directional .withProperty(FACING, (meta == 0 || meta >= 6) ? Facing.DOWN : (meta == 1 ? Facing.UP : Facing.getHorizontal(meta - 2))); } - - public int getMetaFromState(State state) - { - if(state.getValue(DOUBLE)) - return state.getValue(SEAMLESS) ? 7 : 6; - Facing dir = state.getValue(FACING); - return dir == Facing.DOWN ? 0 : (dir == Facing.UP ? 1 : (dir.getHorizontalIndex() + 2)); - } protected Property[] getProperties() { diff --git a/common/src/main/java/common/block/artificial/BlockStairs.java b/common/src/main/java/common/block/artificial/BlockStairs.java index 17492719..73888e39 100755 --- a/common/src/main/java/common/block/artificial/BlockStairs.java +++ b/common/src/main/java/common/block/artificial/BlockStairs.java @@ -746,22 +746,6 @@ public class BlockStairs extends Block implements Rotatable return iblockstate; } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - - if (state.getValue(HALF) == BlockStairs.EnumHalf.TOP) - { - i |= 4; - } - - i = i | 5 - ((Facing)state.getValue(FACING)).getIndex(); - return i; - } - /** * Get the actual Block state of this Block at the given position. This applies properties not visible in the * metadata, such as fence connections. diff --git a/common/src/main/java/common/block/artificial/BlockTrapDoor.java b/common/src/main/java/common/block/artificial/BlockTrapDoor.java index b5e2adca..ca8e72d0 100755 --- a/common/src/main/java/common/block/artificial/BlockTrapDoor.java +++ b/common/src/main/java/common/block/artificial/BlockTrapDoor.java @@ -265,27 +265,6 @@ public class BlockTrapDoor extends Block implements Rotatable return this.getState().withProperty(FACING, getFacing(meta)).withProperty(OPEN, Boolean.valueOf((meta & 4) != 0)).withProperty(HALF, (meta & 8) == 0 ? BlockTrapDoor.DoorHalf.BOTTOM : BlockTrapDoor.DoorHalf.TOP); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - i = i | getMetaForFacing((Facing)state.getValue(FACING)); - - if (((Boolean)state.getValue(OPEN)).booleanValue()) - { - i |= 4; - } - - if (state.getValue(HALF) == BlockTrapDoor.DoorHalf.TOP) - { - i |= 8; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {FACING, OPEN, HALF}; diff --git a/common/src/main/java/common/block/artificial/BlockWall.java b/common/src/main/java/common/block/artificial/BlockWall.java index 1ca2a161..692d5cdd 100755 --- a/common/src/main/java/common/block/artificial/BlockWall.java +++ b/common/src/main/java/common/block/artificial/BlockWall.java @@ -142,10 +142,6 @@ public class BlockWall extends Block return state.withProperty(UP, Boolean.valueOf(worldIn.getState(pos.up()).getBlock() != Blocks.air)).withProperty(NORTH, Boolean.valueOf(this.canConnectTo(worldIn, pos.north()))).withProperty(EAST, Boolean.valueOf(this.canConnectTo(worldIn, pos.east()))).withProperty(SOUTH, Boolean.valueOf(this.canConnectTo(worldIn, pos.south()))).withProperty(WEST, Boolean.valueOf(this.canConnectTo(worldIn, pos.west()))); } - public int getMetaFromState(State state) { - return 0; - } - protected Property[] getProperties() { return new Property[] {UP, NORTH, EAST, WEST, SOUTH}; diff --git a/common/src/main/java/common/block/foliage/BlockCactus.java b/common/src/main/java/common/block/foliage/BlockCactus.java index 7a496474..268e767e 100755 --- a/common/src/main/java/common/block/foliage/BlockCactus.java +++ b/common/src/main/java/common/block/foliage/BlockCactus.java @@ -153,14 +153,6 @@ public class BlockCactus extends Block return this.getState().withProperty(AGE, Integer.valueOf(meta)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Integer)state.getValue(AGE)).intValue(); - } - protected Property[] getProperties() { return new Property[] {AGE}; diff --git a/common/src/main/java/common/block/foliage/BlockCocoa.java b/common/src/main/java/common/block/foliage/BlockCocoa.java index 71c03c02..aee6d9d9 100755 --- a/common/src/main/java/common/block/foliage/BlockCocoa.java +++ b/common/src/main/java/common/block/foliage/BlockCocoa.java @@ -208,17 +208,6 @@ public class BlockCocoa extends Block implements Rotatable, IGrowable return this.getState().withProperty(FACING, Facing.getHorizontal(meta)).withProperty(AGE, Integer.valueOf((meta & 12) == 12 ? 0 : ((meta & 12) >> 2))); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - i = i | ((Facing)state.getValue(FACING)).getHorizontalIndex(); - i = i | ((Integer)state.getValue(AGE)).intValue() << 2; - return i; - } - protected Property[] getProperties() { return new Property[] {FACING, AGE}; diff --git a/common/src/main/java/common/block/foliage/BlockCrops.java b/common/src/main/java/common/block/foliage/BlockCrops.java index 6b5e57ee..c0294da8 100755 --- a/common/src/main/java/common/block/foliage/BlockCrops.java +++ b/common/src/main/java/common/block/foliage/BlockCrops.java @@ -210,14 +210,6 @@ public class BlockCrops extends BlockBush implements IGrowable return this.getState().withProperty(AGE, Integer.valueOf(meta > 7 ? 0 : meta)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Integer)state.getValue(AGE)).intValue(); - } - protected Property[] getProperties() { return new Property[] {AGE}; diff --git a/common/src/main/java/common/block/foliage/BlockDoublePlant.java b/common/src/main/java/common/block/foliage/BlockDoublePlant.java index e194886d..d92b04a0 100755 --- a/common/src/main/java/common/block/foliage/BlockDoublePlant.java +++ b/common/src/main/java/common/block/foliage/BlockDoublePlant.java @@ -1,7 +1,6 @@ package common.block.foliage; import common.block.Block; -import common.block.Rotatable; import common.block.Material; import common.block.SoundType; import common.color.Colorizer; @@ -20,7 +19,6 @@ import common.properties.PropertyEnum; import common.rng.Random; import common.tileentity.TileEntity; import common.util.BlockPos; -import common.util.Facing; import common.util.Identifyable; import common.util.Facing.Axis; import common.vars.Vars; @@ -266,14 +264,6 @@ public class BlockDoublePlant extends BlockBush implements IGrowable return (meta & 8) > 0 ? this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER) : this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER ? 8 : 0; - } - protected Property[] getProperties() { return new Property[] {HALF}; diff --git a/common/src/main/java/common/block/foliage/BlockFarmland.java b/common/src/main/java/common/block/foliage/BlockFarmland.java index 1ffb8066..a10af9f7 100755 --- a/common/src/main/java/common/block/foliage/BlockFarmland.java +++ b/common/src/main/java/common/block/foliage/BlockFarmland.java @@ -164,14 +164,6 @@ public class BlockFarmland extends Block return this.getState().withProperty(MOISTURE, Integer.valueOf(meta & 7)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Integer)state.getValue(MOISTURE)).intValue(); - } - protected Property[] getProperties() { return new Property[] {MOISTURE}; diff --git a/common/src/main/java/common/block/foliage/BlockGrass.java b/common/src/main/java/common/block/foliage/BlockGrass.java index 66b7d827..52be0176 100755 --- a/common/src/main/java/common/block/foliage/BlockGrass.java +++ b/common/src/main/java/common/block/foliage/BlockGrass.java @@ -124,14 +124,6 @@ public class BlockGrass extends Block implements IGrowable return BlockLayer.CUTOUT_MIPPED; } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return 0; - } - protected Property[] getProperties() { return new Property[] {SNOWY}; diff --git a/common/src/main/java/common/block/foliage/BlockHugeMushroom.java b/common/src/main/java/common/block/foliage/BlockHugeMushroom.java index 0079f1d6..bb8c78e1 100755 --- a/common/src/main/java/common/block/foliage/BlockHugeMushroom.java +++ b/common/src/main/java/common/block/foliage/BlockHugeMushroom.java @@ -87,14 +87,6 @@ public class BlockHugeMushroom extends Block return this.getState().withProperty(VARIANT, BlockHugeMushroom.EnumType.byMetadata(meta)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((BlockHugeMushroom.EnumType)state.getValue(VARIANT)).getMetadata(); - } - protected Property[] getProperties() { return new Property[] {VARIANT}; diff --git a/common/src/main/java/common/block/foliage/BlockLeaves.java b/common/src/main/java/common/block/foliage/BlockLeaves.java index d95cb516..0c1cc2ff 100755 --- a/common/src/main/java/common/block/foliage/BlockLeaves.java +++ b/common/src/main/java/common/block/foliage/BlockLeaves.java @@ -308,16 +308,6 @@ public class BlockLeaves extends BlockLeavesBase return this.getState().withProperty(DECAY, Boolean.valueOf((meta & 8) == 0)); } - public int getMetaFromState(State state) { - int i = 0; - - if(!((Boolean)state.getValue(DECAY)).booleanValue()) { - i |= 8; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {DECAY}; } diff --git a/common/src/main/java/common/block/foliage/BlockLilyPad.java b/common/src/main/java/common/block/foliage/BlockLilyPad.java index 6d6d24bb..81a64ba6 100755 --- a/common/src/main/java/common/block/foliage/BlockLilyPad.java +++ b/common/src/main/java/common/block/foliage/BlockLilyPad.java @@ -91,11 +91,6 @@ public class BlockLilyPad extends BlockBush implements Rotatable { return this.getState().withProperty(FACING, Facing.getHorizontal(meta)); } - - public int getMetaFromState(State state) - { - return ((Facing)state.getValue(FACING)).getHorizontalIndex(); - } protected Property[] getProperties() { diff --git a/common/src/main/java/common/block/foliage/BlockLog.java b/common/src/main/java/common/block/foliage/BlockLog.java index ae209891..aa16b972 100755 --- a/common/src/main/java/common/block/foliage/BlockLog.java +++ b/common/src/main/java/common/block/foliage/BlockLog.java @@ -89,24 +89,6 @@ public class BlockLog extends BlockRotatedPillar return state; } - public int getMetaFromState(State state) - { - int meta = 0; - - switch ((Facing.Axis)state.getValue(AXIS)) - { - case X: - meta = 1; - break; - - case Z: - meta = 2; - break; - } - - return meta; - } - protected Property[] getProperties() { return new Property[] {AXIS}; diff --git a/common/src/main/java/common/block/foliage/BlockMycelium.java b/common/src/main/java/common/block/foliage/BlockMycelium.java index d13bda0e..72c13857 100755 --- a/common/src/main/java/common/block/foliage/BlockMycelium.java +++ b/common/src/main/java/common/block/foliage/BlockMycelium.java @@ -87,14 +87,6 @@ public class BlockMycelium extends Block return Blocks.dirt.getItemDropped(Blocks.dirt.getState(), rand, fortune); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return 0; - } - protected Property[] getProperties() { return new Property[] {SNOWY}; diff --git a/common/src/main/java/common/block/foliage/BlockPumpkin.java b/common/src/main/java/common/block/foliage/BlockPumpkin.java index 201f602b..d3b4c9be 100755 --- a/common/src/main/java/common/block/foliage/BlockPumpkin.java +++ b/common/src/main/java/common/block/foliage/BlockPumpkin.java @@ -33,10 +33,6 @@ public class BlockPumpkin extends Block implements Rotatable { return this.getState().withProperty(FACING, Facing.getHorizontal(meta)); } - public int getMetaFromState(State state) { - return state.getValue(FACING).getHorizontalIndex(); - } - protected Property[] getProperties() { return new Property[] {FACING}; } diff --git a/common/src/main/java/common/block/foliage/BlockReed.java b/common/src/main/java/common/block/foliage/BlockReed.java index b977c13e..e791165b 100755 --- a/common/src/main/java/common/block/foliage/BlockReed.java +++ b/common/src/main/java/common/block/foliage/BlockReed.java @@ -173,14 +173,6 @@ public class BlockReed extends Block return this.getState().withProperty(AGE, Integer.valueOf(meta)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Integer)state.getValue(AGE)).intValue(); - } - protected Property[] getProperties() { return new Property[] {AGE}; diff --git a/common/src/main/java/common/block/foliage/BlockSapling.java b/common/src/main/java/common/block/foliage/BlockSapling.java index 05bd2412..7b082d6d 100755 --- a/common/src/main/java/common/block/foliage/BlockSapling.java +++ b/common/src/main/java/common/block/foliage/BlockSapling.java @@ -122,17 +122,6 @@ public class BlockSapling extends BlockBush implements IGrowable return this.getState() /* .withProperty(TYPE, BlockPlanks.EnumType.byMetadata(meta & 7)) */ .withProperty(STAGE, meta & 1); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { -// int i = 0; -// i = i | ((BlockPlanks.EnumType)state.getValue(TYPE)).getMetadata(); -// i = i | ((Integer)state.getValue(STAGE)).intValue() << 3; - return state.getValue(STAGE); - } - protected Property[] getProperties() { return new Property[] {STAGE}; diff --git a/common/src/main/java/common/block/foliage/BlockStem.java b/common/src/main/java/common/block/foliage/BlockStem.java index c0d3382b..9e9d448d 100755 --- a/common/src/main/java/common/block/foliage/BlockStem.java +++ b/common/src/main/java/common/block/foliage/BlockStem.java @@ -221,14 +221,6 @@ public class BlockStem extends BlockBush implements DirectionalUp, IGrowable return this.getState().withProperty(AGE, Integer.valueOf(meta > 7 ? 0 : meta)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Integer)state.getValue(AGE)).intValue(); - } - protected Property[] getProperties() { return new Property[] {AGE, FACING}; diff --git a/common/src/main/java/common/block/foliage/BlockTianSoil.java b/common/src/main/java/common/block/foliage/BlockTianSoil.java index 28967997..20bb3d2b 100755 --- a/common/src/main/java/common/block/foliage/BlockTianSoil.java +++ b/common/src/main/java/common/block/foliage/BlockTianSoil.java @@ -36,11 +36,6 @@ public class BlockTianSoil extends Block return Blocks.tian.getItemDropped(Blocks.tian.getState(), rand, fortune); } - public int getMetaFromState(State state) - { - return 0; - } - protected Property[] getProperties() { return new Property[] {SNOWY}; diff --git a/common/src/main/java/common/block/foliage/BlockVine.java b/common/src/main/java/common/block/foliage/BlockVine.java index a7440890..8904bd83 100755 --- a/common/src/main/java/common/block/foliage/BlockVine.java +++ b/common/src/main/java/common/block/foliage/BlockVine.java @@ -449,36 +449,6 @@ public class BlockVine extends Block return this.getState().withProperty(SOUTH, Boolean.valueOf((meta & 1) > 0)).withProperty(WEST, Boolean.valueOf((meta & 2) > 0)).withProperty(NORTH, Boolean.valueOf((meta & 4) > 0)).withProperty(EAST, Boolean.valueOf((meta & 8) > 0)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - - if (((Boolean)state.getValue(SOUTH)).booleanValue()) - { - i |= 1; - } - - if (((Boolean)state.getValue(WEST)).booleanValue()) - { - i |= 2; - } - - if (((Boolean)state.getValue(NORTH)).booleanValue()) - { - i |= 4; - } - - if (((Boolean)state.getValue(EAST)).booleanValue()) - { - i |= 8; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {UP, NORTH, EAST, SOUTH, WEST}; diff --git a/common/src/main/java/common/block/foliage/BlockWart.java b/common/src/main/java/common/block/foliage/BlockWart.java index 2b9f2e1a..144493fe 100755 --- a/common/src/main/java/common/block/foliage/BlockWart.java +++ b/common/src/main/java/common/block/foliage/BlockWart.java @@ -116,14 +116,6 @@ public class BlockWart extends BlockBush return this.getState().withProperty(AGE, Integer.valueOf(meta > 3 ? 0 : meta)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Integer)state.getValue(AGE)).intValue(); - } - protected Property[] getProperties() { return new Property[] {AGE}; diff --git a/common/src/main/java/common/block/liquid/BlockLiquid.java b/common/src/main/java/common/block/liquid/BlockLiquid.java index d99dc97c..5f1008e1 100755 --- a/common/src/main/java/common/block/liquid/BlockLiquid.java +++ b/common/src/main/java/common/block/liquid/BlockLiquid.java @@ -386,14 +386,6 @@ public abstract class BlockLiquid extends Block return this.getState().withProperty(LEVEL, Integer.valueOf(meta)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Integer)state.getValue(LEVEL)).intValue(); - } - protected Property[] getProperties() { return new Property[] {LEVEL}; diff --git a/common/src/main/java/common/block/natural/BlockFire.java b/common/src/main/java/common/block/natural/BlockFire.java index 687087d0..3de59193 100755 --- a/common/src/main/java/common/block/natural/BlockFire.java +++ b/common/src/main/java/common/block/natural/BlockFire.java @@ -445,14 +445,6 @@ public class BlockFire extends Block return this.getState().withProperty(AGE, Integer.valueOf(meta)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Integer)state.getValue(AGE)).intValue(); - } - protected Property[] getProperties() { return new Property[] {AGE, NORTH, EAST, SOUTH, WEST, UPPER, FLIP, ALT}; diff --git a/common/src/main/java/common/block/natural/BlockOre.java b/common/src/main/java/common/block/natural/BlockOre.java index d04455e6..90a278cd 100755 --- a/common/src/main/java/common/block/natural/BlockOre.java +++ b/common/src/main/java/common/block/natural/BlockOre.java @@ -66,7 +66,7 @@ public class BlockOre extends Block public int quantityDroppedWithBonus(int fortune, Random random) { if (fortune > 0 && - this.getItem() != this.getItemDropped((State)this.getValidStates().iterator().next(), random, fortune)) + this.getItem() != this.getItemDropped(this.getState(), random, fortune)) { int i = random.zrange(fortune + 2) - 1; diff --git a/common/src/main/java/common/block/natural/BlockPodzol.java b/common/src/main/java/common/block/natural/BlockPodzol.java index 8552fc4c..38979a15 100644 --- a/common/src/main/java/common/block/natural/BlockPodzol.java +++ b/common/src/main/java/common/block/natural/BlockPodzol.java @@ -29,10 +29,6 @@ public class BlockPodzol extends Block { return state.withProperty(SNOWY, Boolean.valueOf(block == Blocks.snow || block == Blocks.snow_layer)); } - public int getMetaFromState(State state) { - return 0; - } - protected Property[] getProperties() { return new Property[] {SNOWY}; } diff --git a/common/src/main/java/common/block/natural/BlockSnow.java b/common/src/main/java/common/block/natural/BlockSnow.java index c64de387..b9c56207 100755 --- a/common/src/main/java/common/block/natural/BlockSnow.java +++ b/common/src/main/java/common/block/natural/BlockSnow.java @@ -167,14 +167,6 @@ public class BlockSnow extends Block return ((Integer)worldIn.getState(pos).getValue(LAYERS)).intValue() == 1; } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Integer)state.getValue(LAYERS)).intValue() - 1; - } - protected Property[] getProperties() { return new Property[] {LAYERS}; diff --git a/common/src/main/java/common/block/tech/BlockAnvil.java b/common/src/main/java/common/block/tech/BlockAnvil.java index 4c99dd49..e74bf4f3 100755 --- a/common/src/main/java/common/block/tech/BlockAnvil.java +++ b/common/src/main/java/common/block/tech/BlockAnvil.java @@ -129,16 +129,6 @@ public class BlockAnvil extends BlockFalling implements Rotatable return this.getState().withProperty(FACING, Facing.getHorizontal(meta & 3)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - i = i | ((Facing)state.getValue(FACING)).getHorizontalIndex(); - return i; - } - protected Property[] getProperties() { return new Property[] {FACING}; diff --git a/common/src/main/java/common/block/tech/BlockBrewingStand.java b/common/src/main/java/common/block/tech/BlockBrewingStand.java index 978c6257..5f034f20 100755 --- a/common/src/main/java/common/block/tech/BlockBrewingStand.java +++ b/common/src/main/java/common/block/tech/BlockBrewingStand.java @@ -516,24 +516,6 @@ public class BlockBrewingStand extends BlockContainer return iblockstate; } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - - for (int j = 0; j < 3; ++j) - { - if (((Boolean)state.getValue(HAS_BOTTLE[j])).booleanValue()) - { - i |= 1 << j; - } - } - - return i; - } - protected Property[] getProperties() { return new Property[] {HAS_BOTTLE[0], HAS_BOTTLE[1], HAS_BOTTLE[2]}; diff --git a/common/src/main/java/common/block/tech/BlockButton.java b/common/src/main/java/common/block/tech/BlockButton.java index cf712034..c106c88b 100755 --- a/common/src/main/java/common/block/tech/BlockButton.java +++ b/common/src/main/java/common/block/tech/BlockButton.java @@ -353,48 +353,6 @@ public class BlockButton extends Block implements Directional return this.getState().withProperty(FACING, enumfacing).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i; - - switch ((Facing)state.getValue(FACING)) - { - case EAST: - i = 1; - break; - - case WEST: - i = 2; - break; - - case SOUTH: - i = 3; - break; - - case NORTH: - i = 4; - break; - - case UP: - default: - i = 5; - break; - - case DOWN: - i = 0; - } - - if (((Boolean)state.getValue(POWERED)).booleanValue()) - { - i |= 8; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {FACING, POWERED}; diff --git a/common/src/main/java/common/block/tech/BlockCauldron.java b/common/src/main/java/common/block/tech/BlockCauldron.java index e91fcc09..1d274257 100755 --- a/common/src/main/java/common/block/tech/BlockCauldron.java +++ b/common/src/main/java/common/block/tech/BlockCauldron.java @@ -651,14 +651,6 @@ public class BlockCauldron extends Block return this.getState().withProperty(LEVEL, Integer.valueOf(meta > 3 ? 0 : meta)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Integer)state.getValue(LEVEL)).intValue(); - } - protected Property[] getProperties() { return new Property[] {LEVEL}; diff --git a/common/src/main/java/common/block/tech/BlockChest.java b/common/src/main/java/common/block/tech/BlockChest.java index db0345af..43f3d33b 100755 --- a/common/src/main/java/common/block/tech/BlockChest.java +++ b/common/src/main/java/common/block/tech/BlockChest.java @@ -619,14 +619,6 @@ public class BlockChest extends BlockContainer implements Rotatable return this.getState().withProperty(FACING, enumfacing); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Facing)state.getValue(FACING)).getIndex(); - } - protected Property[] getProperties() { return new Property[] {FACING}; diff --git a/common/src/main/java/common/block/tech/BlockDaylightDetector.java b/common/src/main/java/common/block/tech/BlockDaylightDetector.java index e6a2e193..1a6e361f 100755 --- a/common/src/main/java/common/block/tech/BlockDaylightDetector.java +++ b/common/src/main/java/common/block/tech/BlockDaylightDetector.java @@ -164,14 +164,6 @@ public class BlockDaylightDetector extends BlockContainer return this.getState().withProperty(POWER, Integer.valueOf(meta)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Integer)state.getValue(POWER)).intValue(); - } - protected Property[] getProperties() { return new Property[] {POWER}; diff --git a/common/src/main/java/common/block/tech/BlockDispenser.java b/common/src/main/java/common/block/tech/BlockDispenser.java index a7d7bba7..ab5ea623 100755 --- a/common/src/main/java/common/block/tech/BlockDispenser.java +++ b/common/src/main/java/common/block/tech/BlockDispenser.java @@ -282,22 +282,6 @@ public class BlockDispenser extends BlockContainer implements Directional return this.getState().withProperty(FACING, getFacing(meta)).withProperty(TRIGGERED, Boolean.valueOf((meta & 8) > 0)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - i = i | ((Facing)state.getValue(FACING)).getIndex(); - - if (((Boolean)state.getValue(TRIGGERED)).booleanValue()) - { - i |= 8; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {FACING, TRIGGERED}; diff --git a/common/src/main/java/common/block/tech/BlockFurnace.java b/common/src/main/java/common/block/tech/BlockFurnace.java index b92aa33d..e69aef68 100755 --- a/common/src/main/java/common/block/tech/BlockFurnace.java +++ b/common/src/main/java/common/block/tech/BlockFurnace.java @@ -262,14 +262,6 @@ public class BlockFurnace extends BlockContainer implements Rotatable return this.getState().withProperty(FACING, enumfacing); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Facing)state.getValue(FACING)).getIndex(); - } - protected Property[] getProperties() { return new Property[] {FACING}; diff --git a/common/src/main/java/common/block/tech/BlockHopper.java b/common/src/main/java/common/block/tech/BlockHopper.java index b68c4bec..a6eaddf1 100755 --- a/common/src/main/java/common/block/tech/BlockHopper.java +++ b/common/src/main/java/common/block/tech/BlockHopper.java @@ -279,22 +279,6 @@ public class BlockHopper extends BlockContainer implements DirectionalDown return this.getState().withProperty(FACING, getFacing(((meta & 7) == 1 || (meta & 7) > 5) ? 0 : meta)).withProperty(ENABLED, Boolean.valueOf(isEnabled(meta))); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - i = i | ((Facing)state.getValue(FACING)).getIndex(); - - if (!((Boolean)state.getValue(ENABLED)).booleanValue()) - { - i |= 8; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {FACING, ENABLED}; diff --git a/common/src/main/java/common/block/tech/BlockLever.java b/common/src/main/java/common/block/tech/BlockLever.java index 0d4f3e63..4aa93c35 100755 --- a/common/src/main/java/common/block/tech/BlockLever.java +++ b/common/src/main/java/common/block/tech/BlockLever.java @@ -257,22 +257,6 @@ public class BlockLever extends Block return this.getState().withProperty(FACING, BlockLever.EnumOrientation.byMetadata(meta & 7)).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - i = i | ((BlockLever.EnumOrientation)state.getValue(FACING)).getMetadata(); - - if (((Boolean)state.getValue(POWERED)).booleanValue()) - { - i |= 8; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {FACING, POWERED}; diff --git a/common/src/main/java/common/block/tech/BlockMachine.java b/common/src/main/java/common/block/tech/BlockMachine.java index 2c88635a..339459bb 100755 --- a/common/src/main/java/common/block/tech/BlockMachine.java +++ b/common/src/main/java/common/block/tech/BlockMachine.java @@ -89,10 +89,6 @@ public abstract class BlockMachine extends Block implements Rotatable, ITileEnti return this.getState().withProperty(FACING, Facing.getHorizontal(meta)); } - public int getMetaFromState(State state) { - return ((Facing)state.getValue(FACING)).getHorizontalIndex(); - } - protected Property[] getProperties() { return new Property[] {FACING}; } diff --git a/common/src/main/java/common/block/tech/BlockPistonBase.java b/common/src/main/java/common/block/tech/BlockPistonBase.java index 629fc665..7394de33 100755 --- a/common/src/main/java/common/block/tech/BlockPistonBase.java +++ b/common/src/main/java/common/block/tech/BlockPistonBase.java @@ -687,22 +687,6 @@ public class BlockPistonBase extends Block implements Directional return this.getState().withProperty(FACING, getFacing(meta)).withProperty(EXTENDED, Boolean.valueOf((meta & 8) > 0)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - i = i | ((Facing)state.getValue(FACING)).getIndex(); - - if (((Boolean)state.getValue(EXTENDED)).booleanValue()) - { - i |= 8; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {FACING, EXTENDED}; diff --git a/common/src/main/java/common/block/tech/BlockPistonHead.java b/common/src/main/java/common/block/tech/BlockPistonHead.java index d8e39df6..054580e4 100755 --- a/common/src/main/java/common/block/tech/BlockPistonHead.java +++ b/common/src/main/java/common/block/tech/BlockPistonHead.java @@ -238,22 +238,6 @@ public class BlockPistonHead extends Block implements Directional return this.getState().withProperty(FACING, getFacing(meta)).withProperty(TYPE, (meta & 8) > 0 ? BlockPistonHead.EnumPistonType.STICKY : BlockPistonHead.EnumPistonType.DEFAULT); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - i = i | ((Facing)state.getValue(FACING)).getIndex(); - - if (state.getValue(TYPE) == BlockPistonHead.EnumPistonType.STICKY) - { - i |= 8; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {FACING, TYPE, SHORT}; diff --git a/common/src/main/java/common/block/tech/BlockPistonMoving.java b/common/src/main/java/common/block/tech/BlockPistonMoving.java index 27b04938..479e42e6 100755 --- a/common/src/main/java/common/block/tech/BlockPistonMoving.java +++ b/common/src/main/java/common/block/tech/BlockPistonMoving.java @@ -290,22 +290,6 @@ public class BlockPistonMoving extends BlockContainer return this.getState().withProperty(FACING, BlockPistonHead.getFacing(meta)).withProperty(TYPE, (meta & 8) > 0 ? BlockPistonHead.EnumPistonType.STICKY : BlockPistonHead.EnumPistonType.DEFAULT); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - i = i | ((Facing)state.getValue(FACING)).getIndex(); - - if (state.getValue(TYPE) == BlockPistonHead.EnumPistonType.STICKY) - { - i |= 8; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {FACING, TYPE}; diff --git a/common/src/main/java/common/block/tech/BlockPressurePlate.java b/common/src/main/java/common/block/tech/BlockPressurePlate.java index 338cbbab..2eb17df8 100755 --- a/common/src/main/java/common/block/tech/BlockPressurePlate.java +++ b/common/src/main/java/common/block/tech/BlockPressurePlate.java @@ -75,14 +75,6 @@ public class BlockPressurePlate extends BlockBasePressurePlate return this.getState().withProperty(POWERED, Boolean.valueOf(meta == 1)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Boolean)state.getValue(POWERED)).booleanValue() ? 1 : 0; - } - protected Property[] getProperties() { return new Property[] {POWERED}; diff --git a/common/src/main/java/common/block/tech/BlockPressurePlateWeighted.java b/common/src/main/java/common/block/tech/BlockPressurePlateWeighted.java index 375fd766..64d5acf2 100755 --- a/common/src/main/java/common/block/tech/BlockPressurePlateWeighted.java +++ b/common/src/main/java/common/block/tech/BlockPressurePlateWeighted.java @@ -62,14 +62,6 @@ public class BlockPressurePlateWeighted extends BlockBasePressurePlate return this.getState().withProperty(POWER, Integer.valueOf(meta)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Integer)state.getValue(POWER)).intValue(); - } - protected Property[] getProperties() { return new Property[] {POWER}; diff --git a/common/src/main/java/common/block/tech/BlockRail.java b/common/src/main/java/common/block/tech/BlockRail.java index bdfa0aae..c5f77876 100755 --- a/common/src/main/java/common/block/tech/BlockRail.java +++ b/common/src/main/java/common/block/tech/BlockRail.java @@ -38,14 +38,6 @@ public class BlockRail extends BlockRailBase return this.getState().withProperty(SHAPE, BlockRailBase.EnumRailDirection.byMetadata(meta)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)).getMetadata(); - } - protected Property[] getProperties() { return new Property[] {SHAPE}; diff --git a/common/src/main/java/common/block/tech/BlockRailDetector.java b/common/src/main/java/common/block/tech/BlockRailDetector.java index 7a3a59d0..126e33d6 100755 --- a/common/src/main/java/common/block/tech/BlockRailDetector.java +++ b/common/src/main/java/common/block/tech/BlockRailDetector.java @@ -184,22 +184,6 @@ public class BlockRailDetector extends BlockRailBase return this.getState().withProperty(SHAPE, BlockRailBase.EnumRailDirection.byMetadata((meta & 7) > 5 ? 0 : (meta & 7))).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - i = i | ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)).getMetadata(); - - if (((Boolean)state.getValue(POWERED)).booleanValue()) - { - i |= 8; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {SHAPE, POWERED}; diff --git a/common/src/main/java/common/block/tech/BlockRailPowered.java b/common/src/main/java/common/block/tech/BlockRailPowered.java index 72fa440d..cc62294e 100755 --- a/common/src/main/java/common/block/tech/BlockRailPowered.java +++ b/common/src/main/java/common/block/tech/BlockRailPowered.java @@ -171,22 +171,6 @@ public class BlockRailPowered extends BlockRailBase return this.getState().withProperty(SHAPE, BlockRailBase.EnumRailDirection.byMetadata((meta & 7) > 5 ? 0 : (meta & 7))).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - i = i | ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)).getMetadata(); - - if (((Boolean)state.getValue(POWERED)).booleanValue()) - { - i |= 8; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {SHAPE, POWERED}; diff --git a/common/src/main/java/common/block/tech/BlockRedstoneComparator.java b/common/src/main/java/common/block/tech/BlockRedstoneComparator.java index b769faf1..d45048ed 100755 --- a/common/src/main/java/common/block/tech/BlockRedstoneComparator.java +++ b/common/src/main/java/common/block/tech/BlockRedstoneComparator.java @@ -282,27 +282,6 @@ public class BlockRedstoneComparator extends BlockRedstoneDiode implements ITile return this.getState().withProperty(FACING, Facing.getHorizontal(meta)).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0)).withProperty(MODE, (meta & 4) > 0 ? BlockRedstoneComparator.Mode.SUBTRACT : BlockRedstoneComparator.Mode.COMPARE); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - i = i | ((Facing)state.getValue(FACING)).getHorizontalIndex(); - - if (((Boolean)state.getValue(POWERED)).booleanValue()) - { - i |= 8; - } - - if (state.getValue(MODE) == BlockRedstoneComparator.Mode.SUBTRACT) - { - i |= 4; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {FACING, MODE, POWERED}; diff --git a/common/src/main/java/common/block/tech/BlockRedstoneRepeater.java b/common/src/main/java/common/block/tech/BlockRedstoneRepeater.java index 17dd4e8d..0d83b6fe 100755 --- a/common/src/main/java/common/block/tech/BlockRedstoneRepeater.java +++ b/common/src/main/java/common/block/tech/BlockRedstoneRepeater.java @@ -144,17 +144,6 @@ public class BlockRedstoneRepeater extends BlockRedstoneDiode return this.getState().withProperty(FACING, Facing.getHorizontal(meta)).withProperty(LOCKED, Boolean.valueOf(false)).withProperty(DELAY, Integer.valueOf(1 + (meta >> 2))); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - i = i | ((Facing)state.getValue(FACING)).getHorizontalIndex(); - i = i | ((Integer)state.getValue(DELAY)).intValue() - 1 << 2; - return i; - } - protected Property[] getProperties() { return new Property[] {FACING, DELAY, LOCKED}; diff --git a/common/src/main/java/common/block/tech/BlockRedstoneWire.java b/common/src/main/java/common/block/tech/BlockRedstoneWire.java index 102808c6..7d4ec7d1 100755 --- a/common/src/main/java/common/block/tech/BlockRedstoneWire.java +++ b/common/src/main/java/common/block/tech/BlockRedstoneWire.java @@ -811,14 +811,6 @@ public class BlockRedstoneWire extends Block return this.getState().withProperty(POWER, Integer.valueOf(meta)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Integer)state.getValue(POWER)).intValue(); - } - protected Property[] getProperties() { return new Property[] {NORTH, EAST, SOUTH, WEST, POWER}; diff --git a/common/src/main/java/common/block/tech/BlockTNT.java b/common/src/main/java/common/block/tech/BlockTNT.java index a58e086a..be3bff6a 100755 --- a/common/src/main/java/common/block/tech/BlockTNT.java +++ b/common/src/main/java/common/block/tech/BlockTNT.java @@ -166,14 +166,6 @@ public class BlockTNT extends Block return this.getState().withProperty(EXPLODE, Boolean.valueOf((meta & 1) > 0)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Boolean)state.getValue(EXPLODE)).booleanValue() ? 1 : 0; - } - protected Property[] getProperties() { return new Property[] {EXPLODE}; diff --git a/common/src/main/java/common/block/tech/BlockTorch.java b/common/src/main/java/common/block/tech/BlockTorch.java index fd0fe12e..0af989df 100755 --- a/common/src/main/java/common/block/tech/BlockTorch.java +++ b/common/src/main/java/common/block/tech/BlockTorch.java @@ -277,40 +277,6 @@ public class BlockTorch extends Block implements DirectionalUp return iblockstate; } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - - switch ((Facing)state.getValue(FACING)) - { - case EAST: - i = i | 1; - break; - - case WEST: - i = i | 2; - break; - - case SOUTH: - i = i | 3; - break; - - case NORTH: - i = i | 4; - break; - - case DOWN: - case UP: - default: - i = i | 5; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {FACING}; diff --git a/common/src/main/java/common/block/tech/BlockTripWire.java b/common/src/main/java/common/block/tech/BlockTripWire.java index cc1363c8..398a134d 100755 --- a/common/src/main/java/common/block/tech/BlockTripWire.java +++ b/common/src/main/java/common/block/tech/BlockTripWire.java @@ -272,36 +272,6 @@ public class BlockTripWire extends Block return this.getState().withProperty(POWERED, Boolean.valueOf((meta & 1) > 0)).withProperty(SUSPENDED, Boolean.valueOf((meta & 2) > 0)).withProperty(ATTACHED, Boolean.valueOf((meta & 4) > 0)).withProperty(DISARMED, Boolean.valueOf((meta & 8) > 0)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - - if (((Boolean)state.getValue(POWERED)).booleanValue()) - { - i |= 1; - } - - if (((Boolean)state.getValue(SUSPENDED)).booleanValue()) - { - i |= 2; - } - - if (((Boolean)state.getValue(ATTACHED)).booleanValue()) - { - i |= 4; - } - - if (((Boolean)state.getValue(DISARMED)).booleanValue()) - { - i |= 8; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {POWERED, SUSPENDED, ATTACHED, DISARMED, NORTH, EAST, WEST, SOUTH}; diff --git a/common/src/main/java/common/block/tech/BlockTripWireHook.java b/common/src/main/java/common/block/tech/BlockTripWireHook.java index 8aca2476..77024a15 100755 --- a/common/src/main/java/common/block/tech/BlockTripWireHook.java +++ b/common/src/main/java/common/block/tech/BlockTripWireHook.java @@ -350,27 +350,6 @@ public class BlockTripWireHook extends Block implements Rotatable return this.getState().withProperty(FACING, Facing.getHorizontal(meta & 3)).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0)).withProperty(ATTACHED, Boolean.valueOf((meta & 4) > 0)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - int i = 0; - i = i | ((Facing)state.getValue(FACING)).getHorizontalIndex(); - - if (((Boolean)state.getValue(POWERED)).booleanValue()) - { - i |= 8; - } - - if (((Boolean)state.getValue(ATTACHED)).booleanValue()) - { - i |= 4; - } - - return i; - } - protected Property[] getProperties() { return new Property[] {FACING, POWERED, ATTACHED, SUSPENDED}; diff --git a/common/src/main/java/common/block/tech/BlockWarpChest.java b/common/src/main/java/common/block/tech/BlockWarpChest.java index 1d6f8d5a..4d6c5191 100755 --- a/common/src/main/java/common/block/tech/BlockWarpChest.java +++ b/common/src/main/java/common/block/tech/BlockWarpChest.java @@ -146,14 +146,6 @@ public class BlockWarpChest extends Block implements Rotatable return this.getState().withProperty(FACING, enumfacing); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Facing)state.getValue(FACING)).getIndex(); - } - protected Property[] getProperties() { return new Property[] {FACING}; diff --git a/common/src/main/java/common/block/tile/BlockBannerHanging.java b/common/src/main/java/common/block/tile/BlockBannerHanging.java index 2babfe4a..00256303 100644 --- a/common/src/main/java/common/block/tile/BlockBannerHanging.java +++ b/common/src/main/java/common/block/tile/BlockBannerHanging.java @@ -71,11 +71,6 @@ public class BlockBannerHanging extends BlockBanner return this.getState().withProperty(FACING, enumfacing); } - public int getMetaFromState(State state) - { - return ((Facing)state.getValue(FACING)).getIndex(); - } - protected Property[] getProperties() { return new Property[] {FACING}; diff --git a/common/src/main/java/common/block/tile/BlockBannerStanding.java b/common/src/main/java/common/block/tile/BlockBannerStanding.java index f3560af2..7a50c147 100644 --- a/common/src/main/java/common/block/tile/BlockBannerStanding.java +++ b/common/src/main/java/common/block/tile/BlockBannerStanding.java @@ -34,11 +34,6 @@ public class BlockBannerStanding extends BlockBanner return this.getState().withProperty(ROTATION, Integer.valueOf(meta)); } - public int getMetaFromState(State state) - { - return ((Integer)state.getValue(ROTATION)).intValue(); - } - protected Property[] getProperties() { return new Property[] {ROTATION}; diff --git a/common/src/main/java/common/block/tile/BlockStandingSign.java b/common/src/main/java/common/block/tile/BlockStandingSign.java index 89513200..bbc45dfe 100755 --- a/common/src/main/java/common/block/tile/BlockStandingSign.java +++ b/common/src/main/java/common/block/tile/BlockStandingSign.java @@ -40,14 +40,6 @@ public class BlockStandingSign extends BlockSign return this.getState().withProperty(ROTATION, Integer.valueOf(meta)); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Integer)state.getValue(ROTATION)).intValue(); - } - protected Property[] getProperties() { return new Property[] {ROTATION}; diff --git a/common/src/main/java/common/block/tile/BlockWallSign.java b/common/src/main/java/common/block/tile/BlockWallSign.java index 46a844ae..3922feaf 100755 --- a/common/src/main/java/common/block/tile/BlockWallSign.java +++ b/common/src/main/java/common/block/tile/BlockWallSign.java @@ -78,14 +78,6 @@ public class BlockWallSign extends BlockSign implements Rotatable return this.getState().withProperty(FACING, enumfacing); } - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(State state) - { - return ((Facing)state.getValue(FACING)).getIndex(); - } - protected Property[] getProperties() { return new Property[] {FACING}; diff --git a/common/src/main/java/common/init/BlockRegistry.java b/common/src/main/java/common/init/BlockRegistry.java index 4ae3a708..af32bfc7 100755 --- a/common/src/main/java/common/init/BlockRegistry.java +++ b/common/src/main/java/common/init/BlockRegistry.java @@ -4,7 +4,6 @@ import java.util.Collections; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; import common.block.*; @@ -139,12 +138,10 @@ import common.collect.BiMap; import common.collect.HashBiMap; import common.collect.Lists; import common.collect.Maps; -import common.collect.Sets; import common.color.DyeColor; import common.item.CheatTab; import common.log.Log; import common.model.TextureAnimation; -import common.properties.Property; import common.util.Util; import common.world.State; @@ -661,37 +658,15 @@ public abstract class BlockRegistry { register("tripwire_hook", (new BlockTripWireHook()).setDisplay("Haken")); register("string", (new BlockTripWire()).setDisplay("Stolperdraht").setShearsEfficiency(0)); - Map map = Maps.newLinkedHashMap(); for(Block block : BLOCKS) { for(State state : block.getValidStates()) { - STATE_NAMES.put(state, state.buildSaved()); + STATE_NAMES.put(state, state.getId()); } - for(int n = 0; n < 16; n++) { - State state = block.getStateFromMeta(n); - String id = STATE_NAMES.get(state); - if(!STATE_MAP.containsKey(id)) { - STATE_MAP.put(id, state); - STATE_IDS.put(state, STATES.size()); - STATES.add(state); - } + for(State state : block.getSavedStates()) { + STATE_MAP.put(STATE_NAMES.get(state), state); + STATE_IDS.put(state, STATES.size()); + STATES.add(state); } - StringBuilder sb = new StringBuilder("\n\n\tpublic Property[] getUnsavedProperties() {\n\t\treturn new Property[] {"); - boolean put = false; - Set props = Sets.newHashSet(block.getPropertyMap()); - for(Property prop : block.getState().getSavedProperties()) { - props.remove(prop); - } - for(Property prop : props) { - if(put) - sb.append(", "); - sb.append(prop.getName().toUpperCase()); - put = true; - } - if(put) - map.put(block.getClass(), sb.append("};\n\t}").toString()); - } - for(Entry entry : map.entrySet()) { - System.out.printf("%s.java\n%s\n", entry.getKey().getSimpleName(), entry.getValue()); } Log.SYSTEM.debug("%d Blöcke registriert", BLOCK_MAP.size()); diff --git a/common/src/main/java/common/world/State.java b/common/src/main/java/common/world/State.java index 28d0bc15..27e91e12 100755 --- a/common/src/main/java/common/world/State.java +++ b/common/src/main/java/common/world/State.java @@ -4,17 +4,14 @@ import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.Map; -import java.util.Set; import java.util.Map.Entry; import java.util.function.Function; import common.block.Block; import common.collect.ImmutableMap; -import common.collect.ImmutableSet; import common.collect.ImmutableTable; import common.collect.Iterables; import common.collect.Maps; -import common.collect.Sets; import common.collect.StandardTable; import common.collect.Table; import common.init.BlockRegistry; @@ -37,42 +34,6 @@ public class State { private final Block block; private final ImmutableMap properties; private ImmutableTable map; - private ImmutableSet saved; - - private static Set getSavedProperties(Block block) { - Set stored = Sets.newHashSet(); - Map map = Maps.newHashMap(); - for(int z = 0; z < 16; z++) { - State sub = block.getStateFromMeta(z); - for(Entry entry : sub.getProperties().entrySet()) { - if(map.containsKey(entry.getKey())) { - if(!map.get(entry.getKey()).equals(entry.getValue())) - stored.add(entry.getKey()); - } - else { - map.put(entry.getKey(), entry.getValue()); - } - } - } - for(int z = 0; z < 16; z++) { - State sub = block.getStateFromMeta(z); - Map smap = sub.getProperties(); - for(Property prop : map.keySet()) { - if(!smap.containsKey(prop)) - stored.add(prop); - } - } - return stored; - } - - private static String filterProperties(State state, Set stored) { - StringBuilder sb = new StringBuilder(BlockRegistry.getName(state.getBlock())); - for(Entry entry : state.getProperties().entrySet()) { - if(stored.contains(entry.getKey())) - sb.append(',').append(entry.getKey().getName()).append('=').append(entry.getKey().getName(entry.getValue())); - } - return sb.toString(); - } public State(Block block, ImmutableMap properties) { this.block = block; @@ -97,10 +58,6 @@ public class State { return Collections.unmodifiableCollection(this.properties.keySet()); } - public Collection getSavedProperties() { - return this.saved; - } - public > T getValue(Property property) { if(!this.properties.containsKey(property)) { throw new IllegalArgumentException("Cannot get property " + property + " as it does not exist in " + this.block); @@ -175,10 +132,12 @@ public class State { this.map = ImmutableTable.copyOf(table); } - public String buildSaved() { - if(this.saved != null) - throw new IllegalStateException(); - this.saved = ImmutableSet.copyOf(getSavedProperties(this.block)); - return filterProperties(this, this.saved); + public String getId() { + StringBuilder sb = new StringBuilder(BlockRegistry.getName(this.getBlock())); + for(Entry entry : this.getProperties().entrySet()) { + if(this.getBlock().getSavedProperties().contains(entry.getKey())) + sb.append(',').append(entry.getKey().getName()).append('=').append(entry.getKey().getName(entry.getValue())); + } + return sb.toString(); } } diff --git a/server/src/main/java/server/clipboard/ReorderRegistry.java b/server/src/main/java/server/clipboard/ReorderRegistry.java index c806aca0..ba7e3b46 100755 --- a/server/src/main/java/server/clipboard/ReorderRegistry.java +++ b/server/src/main/java/server/clipboard/ReorderRegistry.java @@ -1,8 +1,6 @@ package server.clipboard; -import java.util.HashMap; import java.util.HashSet; -import java.util.Map; import java.util.Set; import common.block.Block; @@ -16,15 +14,14 @@ import common.color.DyeColor; import common.init.BlockRegistry; import common.init.Blocks; import common.init.WoodType; -import common.util.Facing; import common.util.Vec3i; import common.world.State; public abstract class ReorderRegistry { private static final Set PLACE_LAST = new HashSet(); private static final Set PLACE_FINAL = new HashSet(); - private static final Map STATE_ATTACH = new HashMap(); - private static final Map BLOCK_ATTACH = new HashMap(); +// private static final Map STATE_ATTACH = new HashMap(); +// private static final Map BLOCK_ATTACH = new HashMap(); public static boolean shouldPlaceLast(Block id) { return PLACE_LAST.contains(id); @@ -35,11 +32,15 @@ public abstract class ReorderRegistry { } public static Vec3i getAttachment(State state) { - Vec3i direction = BLOCK_ATTACH.get(state.getBlock()); - if (direction != null) return direction; - return STATE_ATTACH.get(state); + return null; //TODO: add attachment clean } +// public static Vec3i getAttachment(State state) { +// Vec3i direction = BLOCK_ATTACH.get(state.getBlock()); +// if (direction != null) return direction; +// return STATE_ATTACH.get(state); +// } + public static void register() { for(WoodType wood : WoodType.values()) { PLACE_LAST.add(BlockRegistry.byName(wood.getName() + "_sapling")); @@ -124,6 +125,7 @@ public abstract class ReorderRegistry { PLACE_FINAL.add(Blocks.wall_banner); } + /* private static void addAttach(State state, Facing dir) { STATE_ATTACH.put(state, dir.getDirectionVec()); } @@ -247,4 +249,5 @@ public abstract class ReorderRegistry { addAttach(Blocks.blue_mushroom, Facing.DOWN); } + */ } diff --git a/server/src/main/java/server/clipboard/RotationRegistry.java b/server/src/main/java/server/clipboard/RotationRegistry.java index f4b48421..15b96599 100755 --- a/server/src/main/java/server/clipboard/RotationRegistry.java +++ b/server/src/main/java/server/clipboard/RotationRegistry.java @@ -16,7 +16,7 @@ public abstract class RotationRegistry { public static void register() { List values = Lists.newArrayList(); for(Block block : common.init.BlockRegistry.blocks()) { - for(Property prop : block.getPropertyMap()) { + for(Property prop : block.getSavedProperties()) { for(Comparable v : prop.getStates()) { if(!(v instanceof DirectionVec vec)) continue; diff --git a/server/src/main/java/server/command/commands/CommandBlock.java b/server/src/main/java/server/command/commands/CommandBlock.java index fe281ac8..ca569efa 100644 --- a/server/src/main/java/server/command/commands/CommandBlock.java +++ b/server/src/main/java/server/command/commands/CommandBlock.java @@ -27,7 +27,7 @@ public class CommandBlock extends Command { if(idx >= 0) { Block block = BlockRegistry.byNameExact(last.substring(0, idx)); if(block != null) - return Lists.newArrayList(Iterables.transform(block.getValidStates(), state -> BlockRegistry.getName(state))); + return Lists.newArrayList(Iterables.transform(block.getSavedStates(), state -> BlockRegistry.getName(state))); } return BlockRegistry.getKeys(); } From a4a488523bc9e318bfb3300fda4e38ea5c15d7e1 Mon Sep 17 00:00:00 2001 From: Sen Date: Fri, 27 Jun 2025 18:19:35 +0200 Subject: [PATCH 4/7] remove block metadata --- common/src/main/java/common/init/BlockRegistry.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/common/init/BlockRegistry.java b/common/src/main/java/common/init/BlockRegistry.java index af32bfc7..e3294f37 100755 --- a/common/src/main/java/common/init/BlockRegistry.java +++ b/common/src/main/java/common/init/BlockRegistry.java @@ -502,7 +502,6 @@ public abstract class BlockRegistry { register("iron_bars", (new BlockPane(Material.SOLID, true)).setHardness(5.0F).setResistance(10.0F).setStepSound(SoundType.STONE) .setDisplay("Eisengitter")); - register("iron_door", (new BlockDoor(Material.SOLID)).setHardness(5.0F).setStepSound(SoundType.STONE).setDisplay("Eisentür")); register("iron_trapdoor", (new BlockTrapDoor(Material.SOLID)).setHardness(5.0F).setStepSound(SoundType.STONE).setDisplay("Eisenfalltür")); Block brick = (new Block(Material.SOLID)).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE) @@ -577,8 +576,6 @@ public abstract class BlockRegistry { .setHardness(2.0F).setResistance(5.0F).setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzzaun").setFlammable(5, 20)); register(wood.getName() + "_fence_gate", (new BlockFenceGate(wood)).setHardness(2.0F).setResistance(5.0F) .setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzzauntor").setFlammable(5, 20)); - register(wood.getName() + "_door", (new BlockDoor(Material.WOOD)).setHardness(3.0F).setStepSound(SoundType.WOOD) - .setDisplay(wood.getDisplay() + "holztür").setFlammable(5, 20)); } @@ -658,6 +655,12 @@ public abstract class BlockRegistry { register("tripwire_hook", (new BlockTripWireHook()).setDisplay("Haken")); register("string", (new BlockTripWire()).setDisplay("Stolperdraht").setShearsEfficiency(0)); + register("iron_door", (new BlockDoor(Material.SOLID)).setHardness(5.0F).setStepSound(SoundType.STONE).setDisplay("Eisentür")); + for(WoodType wood : WoodType.values()) { + register(wood.getName() + "_door", (new BlockDoor(Material.WOOD)).setHardness(3.0F).setStepSound(SoundType.WOOD) + .setDisplay(wood.getDisplay() + "holztür").setFlammable(5, 20)); + } + for(Block block : BLOCKS) { for(State state : block.getValidStates()) { STATE_NAMES.put(state, state.getId()); From a1a15dcdf65506ef57a9a57b687486b9b27e7435 Mon Sep 17 00:00:00 2001 From: Sen Date: Fri, 27 Jun 2025 18:34:29 +0200 Subject: [PATCH 5/7] remove door metadata --- .../common/block/artificial/BlockDoor.java | 98 ++----------------- 1 file changed, 6 insertions(+), 92 deletions(-) diff --git a/common/src/main/java/common/block/artificial/BlockDoor.java b/common/src/main/java/common/block/artificial/BlockDoor.java index 03a24f82..00e5b7af 100755 --- a/common/src/main/java/common/block/artificial/BlockDoor.java +++ b/common/src/main/java/common/block/artificial/BlockDoor.java @@ -61,7 +61,7 @@ public class BlockDoor extends Block implements Rotatable public boolean isPassable(IBlockAccess worldIn, BlockPos pos) { - return isOpen(combineMetadata(worldIn, pos)); + return worldIn.getState(pos).getValue(OPEN); } public boolean isFullCube() @@ -82,17 +82,13 @@ public class BlockDoor extends Block implements Rotatable } public void setBlockBoundsBasedOnState(IWorldAccess worldIn, BlockPos pos) - { - this.setBoundBasedOnMeta(combineMetadata(worldIn, pos)); - } - - private void setBoundBasedOnMeta(int combinedMeta) { float f = 0.1875F; this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F); - Facing enumfacing = getFacing(combinedMeta); - boolean flag = isOpen(combinedMeta); - boolean flag1 = isHingeLeft(combinedMeta); + State state = worldIn.getState(pos); + Facing enumfacing = state.getValue(FACING); + boolean flag = state.getValue(OPEN); + boolean flag1 = state.getValue(HINGE) == BlockDoor.EnumHingePosition.RIGHT; if (flag) { @@ -298,30 +294,6 @@ public class BlockDoor extends Block implements Rotatable return 1; } - private static int combineMetadata(IBlockAccess worldIn, BlockPos pos) { - State state = worldIn.getState(pos); - int meta = getMetadata(state); - boolean top = isTop(meta); - State down = worldIn.getState(pos.down()); - int dmeta = getMetadata(down); - int m1 = top ? dmeta : meta; - State up = worldIn.getState(pos.up()); - int umeta = getMetadata(up); - int m2 = top ? meta : umeta; - boolean right = (m2 & 1) != 0; - boolean power = (m2 & 2) != 0; - return removeHalfBit(m1) | (top ? 8 : 0) | (right ? 16 : 0) | (power ? 32 : 0); - } - - private static int getMetadata(State state) { - if(!(state.getBlock() instanceof BlockDoor)) - return 0; - else if(state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER) - return 8 | (state.getValue(HINGE) == BlockDoor.EnumHingePosition.RIGHT ? 1 : 0) | (state.getValue(POWERED) ? 2 : 0); - else - return state.getValue(FACING).rotateY().getHorizontalIndex() | (state.getValue(OPEN) ? 4 : 0); - } - public Item getItem(World worldIn, BlockPos pos) { return this.getItem(); @@ -342,34 +314,6 @@ public class BlockDoor extends Block implements Rotatable return BlockLayer.CUTOUT; } - /** - * Get the actual Block state of this Block at the given position. This applies properties not visible in the - * metadata, such as fence connections. - */ - public State getActualState(State state, IWorldAccess worldIn, BlockPos pos) - { - if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER) - { - State iblockstate = worldIn.getState(pos.up()); - - if (iblockstate.getBlock() == this) - { - state = state.withProperty(HINGE, iblockstate.getValue(HINGE)).withProperty(POWERED, iblockstate.getValue(POWERED)); - } - } - else - { - State iblockstate1 = worldIn.getState(pos.down()); - - if (iblockstate1.getBlock() == this) - { - state = state.withProperty(FACING, iblockstate1.getValue(FACING)).withProperty(OPEN, iblockstate1.getValue(OPEN)); - } - } - - return state; - } - /** * Convert the given metadata into a BlockState for this Block */ @@ -378,39 +322,9 @@ public class BlockDoor extends Block implements Rotatable return (meta & 8) > 0 ? this.getState().withProperty(HALF, BlockDoor.EnumDoorHalf.UPPER).withProperty(HINGE, (meta & 1) > 0 ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT).withProperty(POWERED, Boolean.valueOf((meta & 2) > 0)) : this.getState().withProperty(HALF, BlockDoor.EnumDoorHalf.LOWER).withProperty(FACING, Facing.getHorizontal(meta & 3).rotateYCCW()).withProperty(OPEN, Boolean.valueOf((meta & 4) > 0)); } - protected static int removeHalfBit(int meta) - { - return meta & 7; - } - - public static boolean isOpen(IBlockAccess worldIn, BlockPos pos) - { - return isOpen(combineMetadata(worldIn, pos)); - } - public static Facing getFacing(IBlockAccess worldIn, BlockPos pos) { - return getFacing(combineMetadata(worldIn, pos)); - } - - public static Facing getFacing(int combinedMeta) - { - return Facing.getHorizontal(combinedMeta & 3).rotateYCCW(); - } - - protected static boolean isOpen(int combinedMeta) - { - return (combinedMeta & 4) != 0; - } - - protected static boolean isTop(int meta) - { - return (meta & 8) != 0; - } - - protected static boolean isHingeLeft(int combinedMeta) - { - return (combinedMeta & 16) != 0; + return worldIn.getState(pos).getValue(FACING); } protected Property[] getProperties() From 6ef8caddbe1917d602e2b77173cd45e89e4c96e3 Mon Sep 17 00:00:00 2001 From: Sen Date: Fri, 27 Jun 2025 20:57:58 +0200 Subject: [PATCH 6/7] remove block metadata --- .../java/common/block/tech/BlockLever.java | 16 +- .../worldgen/structure/StructureBridge.java | 36 +- .../structure/StructureComponent.java | 448 +++++++----------- .../structure/StructureMineshaft.java | 13 +- .../structure/StructureScattered.java | 133 +++--- .../structure/StructureStronghold.java | 59 +-- .../worldgen/structure/StructureVillage.java | 106 +++-- 7 files changed, 373 insertions(+), 438 deletions(-) diff --git a/common/src/main/java/common/block/tech/BlockLever.java b/common/src/main/java/common/block/tech/BlockLever.java index 4aa93c35..00e9edc5 100755 --- a/common/src/main/java/common/block/tech/BlockLever.java +++ b/common/src/main/java/common/block/tech/BlockLever.java @@ -113,30 +113,30 @@ public class BlockLever extends Block } } - public static int getMetadataForFacing(Facing facing) + public static EnumOrientation getMetadataForFacing(Facing facing) { switch (facing) { case DOWN: - return 0; + return EnumOrientation.DOWN_X; case UP: - return 5; + return EnumOrientation.UP_Z; case NORTH: - return 4; + return EnumOrientation.NORTH; case SOUTH: - return 3; + return EnumOrientation.SOUTH; case WEST: - return 2; + return EnumOrientation.WEST; case EAST: - return 1; + return EnumOrientation.EAST; default: - return -1; + return null; } } diff --git a/server/src/main/java/server/worldgen/structure/StructureBridge.java b/server/src/main/java/server/worldgen/structure/StructureBridge.java index 42ccbd32..3e3b78bd 100755 --- a/server/src/main/java/server/worldgen/structure/StructureBridge.java +++ b/server/src/main/java/server/worldgen/structure/StructureBridge.java @@ -2,6 +2,7 @@ package server.worldgen.structure; import java.util.List; +import common.block.artificial.BlockStairs; import common.collect.Lists; import common.entity.npc.EntityDarkMage; import common.init.Blocks; @@ -9,6 +10,7 @@ import common.rng.Random; import common.tags.TagObject; import common.util.BlockPos; import common.util.Facing; +import common.world.State; import server.vars.SVars; import server.world.WorldServer; import server.worldgen.LootConstants; @@ -267,7 +269,7 @@ public class StructureBridge public boolean addComponentParts(WorldServer worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) { - int i = this.getMetadataWithOffset(Blocks.blood_brick_stairs, 2); + State i = this.getMetadataWithOffset(Blocks.blood_brick_stairs.getState().withProperty(BlockStairs.FACING, Facing.SOUTH)); for (int j = 0; j <= 9; ++j) { @@ -279,9 +281,9 @@ public class StructureBridge if (j <= 6) { - this.setBlockState(worldIn, Blocks.blood_brick_stairs.getStateFromMeta(i), 1, k + 1, j, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.blood_brick_stairs.getStateFromMeta(i), 2, k + 1, j, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.blood_brick_stairs.getStateFromMeta(i), 3, k + 1, j, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 1, k + 1, j, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 2, k + 1, j, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 3, k + 1, j, structureBoundingBoxIn); } this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, l, j, 4, l, j, Blocks.blood_brick.getState(), Blocks.blood_brick.getState(), false); @@ -857,7 +859,7 @@ public class StructureBridge this.fillWithBlocks(worldIn, structureBoundingBoxIn, 11, 7, j1, 11, 8, j1, Blocks.blood_brick_fence.getState(), Blocks.blood_brick_fence.getState(), false); } - int k1 = this.getMetadataWithOffset(Blocks.blood_brick_stairs, 3); + State k1 = this.getMetadataWithOffset(Blocks.blood_brick_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)); for (int j = 0; j <= 6; ++j) { @@ -865,7 +867,7 @@ public class StructureBridge for (int l = 5; l <= 7; ++l) { - this.setBlockState(worldIn, Blocks.blood_brick_stairs.getStateFromMeta(k1), l, 5 + j, k, structureBoundingBoxIn); + this.setBlockState(worldIn, k1, l, 5 + j, k, structureBoundingBoxIn); } if (k >= 5 && k <= 8) @@ -885,7 +887,7 @@ public class StructureBridge for (int l1 = 5; l1 <= 7; ++l1) { - this.setBlockState(worldIn, Blocks.blood_brick_stairs.getStateFromMeta(k1), l1, 12, 11, structureBoundingBoxIn); + this.setBlockState(worldIn, k1, l1, 12, 11, structureBoundingBoxIn); } this.fillWithBlocks(worldIn, structureBoundingBoxIn, 5, 6, 7, 5, 7, 7, Blocks.blood_brick_fence.getState(), Blocks.blood_brick_fence.getState(), false); @@ -897,16 +899,16 @@ public class StructureBridge this.fillWithBlocks(worldIn, structureBoundingBoxIn, 9, 5, 2, 10, 5, 3, Blocks.blood_brick.getState(), Blocks.blood_brick.getState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 9, 5, 9, 10, 5, 10, Blocks.blood_brick.getState(), Blocks.blood_brick.getState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 10, 5, 4, 10, 5, 8, Blocks.blood_brick.getState(), Blocks.blood_brick.getState(), false); - int i2 = this.getMetadataWithOffset(Blocks.blood_brick_stairs, 0); - int j2 = this.getMetadataWithOffset(Blocks.blood_brick_stairs, 1); - this.setBlockState(worldIn, Blocks.blood_brick_stairs.getStateFromMeta(j2), 4, 5, 2, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.blood_brick_stairs.getStateFromMeta(j2), 4, 5, 3, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.blood_brick_stairs.getStateFromMeta(j2), 4, 5, 9, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.blood_brick_stairs.getStateFromMeta(j2), 4, 5, 10, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.blood_brick_stairs.getStateFromMeta(i2), 8, 5, 2, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.blood_brick_stairs.getStateFromMeta(i2), 8, 5, 3, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.blood_brick_stairs.getStateFromMeta(i2), 8, 5, 9, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.blood_brick_stairs.getStateFromMeta(i2), 8, 5, 10, structureBoundingBoxIn); + State i2 = this.getMetadataWithOffset(Blocks.blood_brick_stairs.getState().withProperty(BlockStairs.FACING, Facing.EAST)); + State j2 = this.getMetadataWithOffset(Blocks.blood_brick_stairs.getState().withProperty(BlockStairs.FACING, Facing.WEST)); + this.setBlockState(worldIn, j2, 4, 5, 2, structureBoundingBoxIn); + this.setBlockState(worldIn, j2, 4, 5, 3, structureBoundingBoxIn); + this.setBlockState(worldIn, j2, 4, 5, 9, structureBoundingBoxIn); + this.setBlockState(worldIn, j2, 4, 5, 10, structureBoundingBoxIn); + this.setBlockState(worldIn, i2, 8, 5, 2, structureBoundingBoxIn); + this.setBlockState(worldIn, i2, 8, 5, 3, structureBoundingBoxIn); + this.setBlockState(worldIn, i2, 8, 5, 9, structureBoundingBoxIn); + this.setBlockState(worldIn, i2, 8, 5, 10, structureBoundingBoxIn); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 3, 4, 4, 4, 4, 8, Blocks.soul_sand.getState(), Blocks.soul_sand.getState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 8, 4, 4, 9, 4, 8, Blocks.soul_sand.getState(), Blocks.soul_sand.getState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 3, 5, 4, 4, 5, 8, Blocks.soul_wart.getState(), Blocks.soul_wart.getState(), false); diff --git a/server/src/main/java/server/worldgen/structure/StructureComponent.java b/server/src/main/java/server/worldgen/structure/StructureComponent.java index 134f944f..d652bc35 100755 --- a/server/src/main/java/server/worldgen/structure/StructureComponent.java +++ b/server/src/main/java/server/worldgen/structure/StructureComponent.java @@ -3,8 +3,15 @@ package server.worldgen.structure; import java.util.List; import common.block.Block; +import common.block.Directional; import common.block.Rotatable; import common.block.artificial.BlockDoor; +import common.block.tech.BlockButton; +import common.block.tech.BlockDispenser; +import common.block.tech.BlockLever; +import common.block.tech.BlockPistonBase; +import common.block.tech.BlockRail; +import common.block.tech.BlockRailBase; import common.init.Blocks; import common.item.RngLoot; import common.item.block.ItemDoor; @@ -251,342 +258,253 @@ public abstract class StructureComponent } } - /** - * Returns the direction-shifted metadata for blocks that require orientation, e.g. doors, stairs, ladders. - */ - protected int getMetadataWithOffset(Block blockIn, int meta) + protected final State getMetadataWithOffset(State state) { + Block blockIn = state.getBlock(); if (blockIn == Blocks.rail) { if (this.coordBaseMode == Facing.WEST || this.coordBaseMode == Facing.EAST) { - if (meta == 1) + if (state.getValue(BlockRail.SHAPE) == BlockRailBase.EnumRailDirection.EAST_WEST) { - return 0; + return state.withProperty(BlockRail.SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH); } - return 1; + return state.withProperty(BlockRail.SHAPE, BlockRailBase.EnumRailDirection.EAST_WEST); } } - else if (blockIn instanceof BlockDoor) + else if (blockIn instanceof Rotatable) { + Facing meta = state.getValue(Rotatable.FACING); if (this.coordBaseMode == Facing.SOUTH) { - if (meta == 0) + if (meta == Facing.NORTH) { - return 2; + return state.withProperty(Rotatable.FACING, Facing.SOUTH); } - if (meta == 2) + if (meta == Facing.SOUTH) { - return 0; + return state.withProperty(Rotatable.FACING, Facing.NORTH); } } - else + else if (this.coordBaseMode == Facing.WEST) { - if (this.coordBaseMode == Facing.WEST) + if (meta == Facing.NORTH) { - return meta + 1 & 3; + return state.withProperty(Rotatable.FACING, Facing.WEST); } - if (this.coordBaseMode == Facing.EAST) + if (meta == Facing.SOUTH) { - return meta + 3 & 3; + return state.withProperty(Rotatable.FACING, Facing.EAST); + } + + if (meta == Facing.WEST) + { + return state.withProperty(Rotatable.FACING, Facing.NORTH); + } + + if (meta == Facing.EAST) + { + return state.withProperty(Rotatable.FACING, Facing.SOUTH); + } + } + else if (this.coordBaseMode == Facing.EAST) + { + if (meta == Facing.NORTH) + { + return state.withProperty(Rotatable.FACING, Facing.EAST); + } + + if (meta == Facing.SOUTH) + { + return state.withProperty(Rotatable.FACING, Facing.WEST); + } + + if (meta == Facing.WEST) + { + return state.withProperty(Rotatable.FACING, Facing.NORTH); + } + + if (meta == Facing.EAST) + { + return state.withProperty(Rotatable.FACING, Facing.SOUTH); } } } - else if (blockIn != Blocks.cobblestone_stairs && blockIn != Blocks.oak_stairs && blockIn != Blocks.blood_brick_stairs && blockIn != Blocks.stonebrick_stairs && blockIn != Blocks.sandstone_stairs) + if (blockIn instanceof BlockButton) { - if (blockIn == Blocks.ladder) + Facing meta = state.getValue(BlockButton.FACING); + if (this.coordBaseMode == Facing.SOUTH) { - if (this.coordBaseMode == Facing.SOUTH) + if (meta == Facing.SOUTH) { - if (meta == Facing.NORTH.getIndex()) - { - return Facing.SOUTH.getIndex(); - } - - if (meta == Facing.SOUTH.getIndex()) - { - return Facing.NORTH.getIndex(); - } + return state.withProperty(BlockButton.FACING, Facing.NORTH); } - else if (this.coordBaseMode == Facing.WEST) + + if (meta == Facing.NORTH) { - if (meta == Facing.NORTH.getIndex()) - { - return Facing.WEST.getIndex(); - } - - if (meta == Facing.SOUTH.getIndex()) - { - return Facing.EAST.getIndex(); - } - - if (meta == Facing.WEST.getIndex()) - { - return Facing.NORTH.getIndex(); - } - - if (meta == Facing.EAST.getIndex()) - { - return Facing.SOUTH.getIndex(); - } - } - else if (this.coordBaseMode == Facing.EAST) - { - if (meta == Facing.NORTH.getIndex()) - { - return Facing.EAST.getIndex(); - } - - if (meta == Facing.SOUTH.getIndex()) - { - return Facing.WEST.getIndex(); - } - - if (meta == Facing.WEST.getIndex()) - { - return Facing.NORTH.getIndex(); - } - - if (meta == Facing.EAST.getIndex()) - { - return Facing.SOUTH.getIndex(); - } + return state.withProperty(BlockButton.FACING, Facing.SOUTH); } } - else if (blockIn == Blocks.stone_button) + else if (this.coordBaseMode == Facing.WEST) { - if (this.coordBaseMode == Facing.SOUTH) + if (meta == Facing.SOUTH) { - if (meta == 3) - { - return 4; - } - - if (meta == 4) - { - return 3; - } + return state.withProperty(BlockButton.FACING, Facing.EAST); } - else if (this.coordBaseMode == Facing.WEST) + + if (meta == Facing.NORTH) { - if (meta == 3) - { - return 1; - } - - if (meta == 4) - { - return 2; - } - - if (meta == 2) - { - return 3; - } - - if (meta == 1) - { - return 4; - } + return state.withProperty(BlockButton.FACING, Facing.WEST); } - else if (this.coordBaseMode == Facing.EAST) + + if (meta == Facing.WEST) { - if (meta == 3) - { - return 2; - } + return state.withProperty(BlockButton.FACING, Facing.SOUTH); + } - if (meta == 4) - { - return 1; - } - - if (meta == 2) - { - return 3; - } - - if (meta == 1) - { - return 4; - } + if (meta == Facing.EAST) + { + return state.withProperty(BlockButton.FACING, Facing.NORTH); } } - else if (blockIn != Blocks.tripwire_hook && !(blockIn instanceof Rotatable)) + else if (this.coordBaseMode == Facing.EAST) { - if (blockIn == Blocks.piston || blockIn == Blocks.sticky_piston || blockIn == Blocks.lever || blockIn == Blocks.dispenser) + if (meta == Facing.SOUTH) { - if (this.coordBaseMode == Facing.SOUTH) - { - if (meta == Facing.NORTH.getIndex() || meta == Facing.SOUTH.getIndex()) - { - return Facing.getFront(meta).getOpposite().getIndex(); - } - } - else if (this.coordBaseMode == Facing.WEST) - { - if (meta == Facing.NORTH.getIndex()) - { - return Facing.WEST.getIndex(); - } - - if (meta == Facing.SOUTH.getIndex()) - { - return Facing.EAST.getIndex(); - } - - if (meta == Facing.WEST.getIndex()) - { - return Facing.NORTH.getIndex(); - } - - if (meta == Facing.EAST.getIndex()) - { - return Facing.SOUTH.getIndex(); - } - } - else if (this.coordBaseMode == Facing.EAST) - { - if (meta == Facing.NORTH.getIndex()) - { - return Facing.EAST.getIndex(); - } - - if (meta == Facing.SOUTH.getIndex()) - { - return Facing.WEST.getIndex(); - } - - if (meta == Facing.WEST.getIndex()) - { - return Facing.NORTH.getIndex(); - } - - if (meta == Facing.EAST.getIndex()) - { - return Facing.SOUTH.getIndex(); - } - } + return state.withProperty(BlockButton.FACING, Facing.WEST); } - } - else - { - Facing enumfacing = Facing.getHorizontal(meta); - if (this.coordBaseMode == Facing.SOUTH) + if (meta == Facing.NORTH) { - if (enumfacing == Facing.SOUTH || enumfacing == Facing.NORTH) - { - return enumfacing.getOpposite().getHorizontalIndex(); - } + return state.withProperty(BlockButton.FACING, Facing.EAST); } - else if (this.coordBaseMode == Facing.WEST) + + if (meta == Facing.WEST) { - if (enumfacing == Facing.NORTH) - { - return Facing.WEST.getHorizontalIndex(); - } - - if (enumfacing == Facing.SOUTH) - { - return Facing.EAST.getHorizontalIndex(); - } - - if (enumfacing == Facing.WEST) - { - return Facing.NORTH.getHorizontalIndex(); - } - - if (enumfacing == Facing.EAST) - { - return Facing.SOUTH.getHorizontalIndex(); - } + return state.withProperty(BlockButton.FACING, Facing.SOUTH); } - else if (this.coordBaseMode == Facing.EAST) + + if (meta == Facing.EAST) { - if (enumfacing == Facing.NORTH) - { - return Facing.EAST.getHorizontalIndex(); - } - - if (enumfacing == Facing.SOUTH) - { - return Facing.WEST.getHorizontalIndex(); - } - - if (enumfacing == Facing.WEST) - { - return Facing.NORTH.getHorizontalIndex(); - } - - if (enumfacing == Facing.EAST) - { - return Facing.SOUTH.getHorizontalIndex(); - } + return state.withProperty(BlockButton.FACING, Facing.NORTH); } } } - else if (this.coordBaseMode == Facing.SOUTH) + else if (blockIn instanceof BlockPistonBase || blockIn instanceof BlockDispenser) { - if (meta == 2) + Facing meta = state.getValue(Directional.FACING); + if (this.coordBaseMode == Facing.SOUTH) { - return 3; + if (meta == Facing.NORTH || meta == Facing.SOUTH) + { + return state.withProperty(Directional.FACING, meta.getOpposite()); + } } - - if (meta == 3) + else if (this.coordBaseMode == Facing.WEST) { - return 2; + if (meta == Facing.NORTH) + { + return state.withProperty(Directional.FACING, Facing.WEST); + } + + if (meta == Facing.SOUTH) + { + return state.withProperty(Directional.FACING, Facing.EAST); + } + + if (meta == Facing.WEST) + { + return state.withProperty(Directional.FACING, Facing.NORTH); + } + + if (meta == Facing.EAST) + { + return state.withProperty(Directional.FACING, Facing.SOUTH); + } + } + else if (this.coordBaseMode == Facing.EAST) + { + if (meta == Facing.NORTH) + { + return state.withProperty(Directional.FACING, Facing.EAST); + } + + if (meta == Facing.SOUTH) + { + return state.withProperty(Directional.FACING, Facing.WEST); + } + + if (meta == Facing.WEST) + { + return state.withProperty(Directional.FACING, Facing.NORTH); + } + + if (meta == Facing.EAST) + { + return state.withProperty(Directional.FACING, Facing.SOUTH); + } } } - else if (this.coordBaseMode == Facing.WEST) + else if (blockIn instanceof BlockLever) { - if (meta == 0) + BlockLever.EnumOrientation meta = state.getValue(BlockLever.FACING); + if (this.coordBaseMode == Facing.SOUTH) { - return 2; + if (meta == BlockLever.EnumOrientation.NORTH || meta == BlockLever.EnumOrientation.SOUTH) + { + return state.withProperty(BlockLever.FACING, meta == BlockLever.EnumOrientation.NORTH ? BlockLever.EnumOrientation.SOUTH : BlockLever.EnumOrientation.NORTH); + } } + else if (this.coordBaseMode == Facing.WEST) + { + if (meta == BlockLever.EnumOrientation.NORTH) + { + return state.withProperty(BlockLever.FACING, BlockLever.EnumOrientation.WEST); + } - if (meta == 1) - { - return 3; - } + if (meta == BlockLever.EnumOrientation.SOUTH) + { + return state.withProperty(BlockLever.FACING, BlockLever.EnumOrientation.EAST); + } - if (meta == 2) - { - return 0; - } + if (meta == BlockLever.EnumOrientation.WEST) + { + return state.withProperty(BlockLever.FACING, BlockLever.EnumOrientation.NORTH); + } - if (meta == 3) - { - return 1; + if (meta == BlockLever.EnumOrientation.EAST) + { + return state.withProperty(BlockLever.FACING, BlockLever.EnumOrientation.SOUTH); + } } - } - else if (this.coordBaseMode == Facing.EAST) - { - if (meta == 0) + else if (this.coordBaseMode == Facing.EAST) { - return 2; - } + if (meta == BlockLever.EnumOrientation.NORTH) + { + return state.withProperty(BlockLever.FACING, BlockLever.EnumOrientation.EAST); + } - if (meta == 1) - { - return 3; - } + if (meta == BlockLever.EnumOrientation.SOUTH) + { + return state.withProperty(BlockLever.FACING, BlockLever.EnumOrientation.WEST); + } - if (meta == 2) - { - return 1; - } + if (meta == BlockLever.EnumOrientation.WEST) + { + return state.withProperty(BlockLever.FACING, BlockLever.EnumOrientation.NORTH); + } - if (meta == 3) - { - return 0; + if (meta == BlockLever.EnumOrientation.EAST) + { + return state.withProperty(BlockLever.FACING, BlockLever.EnumOrientation.SOUTH); + } } } - return meta; + return state; } protected void setBlockState(WorldServer worldIn, State blockstateIn, int x, int y, int z, StructureBoundingBox boundingboxIn) @@ -800,13 +718,13 @@ public abstract class StructureComponent } } - protected boolean generateDispenserContents(WorldServer worldIn, StructureBoundingBox boundingBoxIn, Random rand, int x, int y, int z, int meta, WeightedList listIn, int max) + protected boolean generateDispenserContents(WorldServer worldIn, StructureBoundingBox boundingBoxIn, Random rand, int x, int y, int z, Facing dir, WeightedList listIn, int max) { BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z)); if (boundingBoxIn.isVecInside(blockpos) && worldIn.getState(blockpos).getBlock() != Blocks.dispenser) { - worldIn.setState(blockpos, Blocks.dispenser.getStateFromMeta(this.getMetadataWithOffset(Blocks.dispenser, meta)), 2); + worldIn.setState(blockpos, this.getMetadataWithOffset(Blocks.dispenser.getState().withProperty(BlockDispenser.FACING, dir)), 2); TileEntity tileentity = worldIn.getTileEntity(blockpos); if (tileentity instanceof TileEntityDispenser) @@ -825,13 +743,13 @@ public abstract class StructureComponent /** * Places door on given position */ - protected void placeDoorCurrentPosition(WorldServer worldIn, StructureBoundingBox boundingBoxIn, Random rand, int x, int y, int z, Facing facing) + protected void placeDoorCurrentPosition(WorldServer worldIn, StructureBoundingBox boundingBoxIn, Random rand, int x, int y, int z, State state) { BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z)); if (boundingBoxIn.isVecInside(blockpos)) { - ItemDoor.placeDoor(worldIn, blockpos, facing.rotateYCCW(), Blocks.oak_door, true); + ItemDoor.placeDoor(worldIn, blockpos, state.getValue(BlockDoor.FACING).rotateYCCW(), Blocks.oak_door, true); } } diff --git a/server/src/main/java/server/worldgen/structure/StructureMineshaft.java b/server/src/main/java/server/worldgen/structure/StructureMineshaft.java index 7ede5655..60be3d5b 100755 --- a/server/src/main/java/server/worldgen/structure/StructureMineshaft.java +++ b/server/src/main/java/server/worldgen/structure/StructureMineshaft.java @@ -3,6 +3,9 @@ package server.worldgen.structure; import java.util.LinkedList; import java.util.List; +import common.block.tech.BlockRail; +import common.block.tech.BlockRailBase; +import common.block.tech.BlockTorch; import common.entity.item.EntityChestCart; import common.entity.npc.EntityArachnoid; import common.init.Blocks; @@ -289,8 +292,8 @@ public class StructureMineshaft if (boundingBoxIn.isVecInside(blockpos) && worldIn.getState(blockpos).getBlock() == Blocks.air) { - int i = rand.chance() ? 1 : 0; - worldIn.setState(blockpos, Blocks.rail.getStateFromMeta(this.getMetadataWithOffset(Blocks.rail, i)), 2); + BlockRailBase.EnumRailDirection i = rand.chance() ? BlockRailBase.EnumRailDirection.EAST_WEST : BlockRailBase.EnumRailDirection.NORTH_SOUTH; + worldIn.setState(blockpos, this.getMetadataWithOffset(Blocks.rail.getState().withProperty(BlockRail.SHAPE, i)), 2); EntityChestCart entityminecartchest = new EntityChestCart(worldIn, (double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.5F), (double)((float)blockpos.getZ() + 0.5F)); RngLoot.generateChestContents(rand, listIn, entityminecartchest, max); worldIn.spawnEntityInWorld(entityminecartchest); @@ -347,8 +350,8 @@ public class StructureMineshaft this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 2, 2, k1 - 2, Blocks.web.getState()); this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 0, 2, k1 + 2, Blocks.web.getState()); this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 2, 2, k1 + 2, Blocks.web.getState()); - this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 1, 2, k1 - 1, Blocks.torch.getStateFromMeta(Facing.UP.getIndex())); - this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 1, 2, k1 + 1, Blocks.torch.getStateFromMeta(Facing.UP.getIndex())); + this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 1, 2, k1 - 1, Blocks.torch.getState().withProperty(BlockTorch.FACING, Facing.UP)); + this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 1, 2, k1 + 1, Blocks.torch.getState().withProperty(BlockTorch.FACING, Facing.UP)); if (randomIn.zrange(100) == 0) { @@ -402,7 +405,7 @@ public class StructureMineshaft if (iblockstate.getBlock() != Blocks.air && iblockstate.getBlock().isFullBlock()) { - this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.7F, 1, 0, l2, Blocks.rail.getStateFromMeta(this.getMetadataWithOffset(Blocks.rail, 0))); + this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.7F, 1, 0, l2, this.getMetadataWithOffset(Blocks.rail.getState().withProperty(BlockRail.SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH))); } } } diff --git a/server/src/main/java/server/worldgen/structure/StructureScattered.java b/server/src/main/java/server/worldgen/structure/StructureScattered.java index 09326a30..9f9d159d 100755 --- a/server/src/main/java/server/worldgen/structure/StructureScattered.java +++ b/server/src/main/java/server/worldgen/structure/StructureScattered.java @@ -1,6 +1,10 @@ package server.worldgen.structure; +import common.block.artificial.BlockStairs; +import common.block.foliage.BlockVine; import common.block.tech.BlockLever; +import common.block.tech.BlockPistonBase; +import common.block.tech.BlockRedstoneRepeater; import common.block.tech.BlockTripWire; import common.block.tech.BlockTripWireHook; import common.entity.npc.EntityMage; @@ -11,6 +15,7 @@ import common.rng.Random; import common.tags.TagObject; import common.util.BlockPos; import common.util.Facing; +import common.world.State; import server.vars.SVars; import server.world.WorldServer; import server.worldgen.LootConstants; @@ -73,22 +78,22 @@ public class StructureScattered } } - int k2 = this.getMetadataWithOffset(Blocks.sandstone_stairs, 3); - int l2 = this.getMetadataWithOffset(Blocks.sandstone_stairs, 2); - int i3 = this.getMetadataWithOffset(Blocks.sandstone_stairs, 0); - int l = this.getMetadataWithOffset(Blocks.sandstone_stairs, 1); + State k2 = this.getMetadataWithOffset(Blocks.sandstone_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)); + State l2 = this.getMetadataWithOffset(Blocks.sandstone_stairs.getState().withProperty(BlockStairs.FACING, Facing.SOUTH)); + State i3 = this.getMetadataWithOffset(Blocks.sandstone_stairs.getState().withProperty(BlockStairs.FACING, Facing.EAST)); + State l = this.getMetadataWithOffset(Blocks.sandstone_stairs.getState().withProperty(BlockStairs.FACING, Facing.WEST)); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 4, 9, 4, Blocks.sandstone.getState(), Blocks.air.getState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 10, 1, 3, 10, 3, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false); - this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(k2), 2, 10, 0, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(l2), 2, 10, 4, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(i3), 0, 10, 2, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(l), 4, 10, 2, structureBoundingBoxIn); + this.setBlockState(worldIn, k2, 2, 10, 0, structureBoundingBoxIn); + this.setBlockState(worldIn, l2, 2, 10, 4, structureBoundingBoxIn); + this.setBlockState(worldIn, i3, 0, 10, 2, structureBoundingBoxIn); + this.setBlockState(worldIn, l, 4, 10, 2, structureBoundingBoxIn); this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.scatteredFeatureSizeX - 5, 0, 0, this.scatteredFeatureSizeX - 1, 9, 4, Blocks.sandstone.getState(), Blocks.air.getState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.scatteredFeatureSizeX - 4, 10, 1, this.scatteredFeatureSizeX - 2, 10, 3, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false); - this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(k2), this.scatteredFeatureSizeX - 3, 10, 0, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(l2), this.scatteredFeatureSizeX - 3, 10, 4, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(i3), this.scatteredFeatureSizeX - 5, 10, 2, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(l), this.scatteredFeatureSizeX - 1, 10, 2, structureBoundingBoxIn); + this.setBlockState(worldIn, k2, this.scatteredFeatureSizeX - 3, 10, 0, structureBoundingBoxIn); + this.setBlockState(worldIn, l2, this.scatteredFeatureSizeX - 3, 10, 4, structureBoundingBoxIn); + this.setBlockState(worldIn, i3, this.scatteredFeatureSizeX - 5, 10, 2, structureBoundingBoxIn); + this.setBlockState(worldIn, l, this.scatteredFeatureSizeX - 1, 10, 2, structureBoundingBoxIn); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 8, 0, 0, 12, 4, 4, Blocks.sandstone.getState(), Blocks.air.getState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 9, 1, 0, 11, 3, 4, Blocks.air.getState(), Blocks.air.getState(), false); this.setBlockState(worldIn, Blocks.smooth_sandstone.getState(), 9, 1, 1, structureBoundingBoxIn); @@ -122,18 +127,18 @@ public class StructureScattered this.setBlockState(worldIn, Blocks.air.getState(), this.scatteredFeatureSizeX - 7, 6, 10, structureBoundingBoxIn); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 2, 4, 4, 2, 6, 4, Blocks.air.getState(), Blocks.air.getState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.scatteredFeatureSizeX - 3, 4, 4, this.scatteredFeatureSizeX - 3, 6, 4, Blocks.air.getState(), Blocks.air.getState(), false); - this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(k2), 2, 4, 5, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(k2), 2, 3, 4, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(k2), this.scatteredFeatureSizeX - 3, 4, 5, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(k2), this.scatteredFeatureSizeX - 3, 3, 4, structureBoundingBoxIn); + this.setBlockState(worldIn, k2, 2, 4, 5, structureBoundingBoxIn); + this.setBlockState(worldIn, k2, 2, 3, 4, structureBoundingBoxIn); + this.setBlockState(worldIn, k2, this.scatteredFeatureSizeX - 3, 4, 5, structureBoundingBoxIn); + this.setBlockState(worldIn, k2, this.scatteredFeatureSizeX - 3, 3, 4, structureBoundingBoxIn); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 3, 2, 2, 3, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.scatteredFeatureSizeX - 3, 1, 3, this.scatteredFeatureSizeX - 2, 2, 3, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false); this.setBlockState(worldIn, Blocks.sandstone_stairs.getState(), 1, 1, 2, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.sandstone_stairs.getState(), this.scatteredFeatureSizeX - 2, 1, 2, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.sandstone_slab.getState(), 1, 2, 2, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.sandstone_slab.getState(), this.scatteredFeatureSizeX - 2, 2, 2, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(l), 2, 1, 2, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(i3), this.scatteredFeatureSizeX - 3, 1, 2, structureBoundingBoxIn); + this.setBlockState(worldIn, l, 2, 1, 2, structureBoundingBoxIn); + this.setBlockState(worldIn, i3, this.scatteredFeatureSizeX - 3, 1, 2, structureBoundingBoxIn); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 4, 3, 5, 4, 3, 18, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.scatteredFeatureSizeX - 5, 3, 5, this.scatteredFeatureSizeX - 5, 3, 17, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 3, 1, 5, 4, 2, 16, Blocks.air.getState(), Blocks.air.getState(), false); @@ -385,10 +390,10 @@ public class StructureScattered } else { - int i = this.getMetadataWithOffset(Blocks.cobblestone_stairs, 3); - int j = this.getMetadataWithOffset(Blocks.cobblestone_stairs, 2); - int k = this.getMetadataWithOffset(Blocks.cobblestone_stairs, 0); - int l = this.getMetadataWithOffset(Blocks.cobblestone_stairs, 1); + State i = this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)); + State j = this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.SOUTH)); + State k = this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.EAST)); + State l = this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.WEST)); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 0, -4, 0, this.scatteredFeatureSizeX - 1, 0, this.scatteredFeatureSizeZ - 1, false, randomIn, junglePyramidsRandomScatteredStones); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 2, 1, 2, 9, 2, 2, false, randomIn, junglePyramidsRandomScatteredStones); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 2, 1, 12, 9, 2, 12, false, randomIn, junglePyramidsRandomScatteredStones); @@ -446,31 +451,31 @@ public class StructureScattered this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 4, 9, 10, 4, 9, 10, false, randomIn, junglePyramidsRandomScatteredStones); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 7, 9, 10, 7, 9, 10, false, randomIn, junglePyramidsRandomScatteredStones); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 5, 9, 7, 6, 9, 7, false, randomIn, junglePyramidsRandomScatteredStones); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 5, 9, 6, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 6, 9, 6, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(j), 5, 9, 8, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(j), 6, 9, 8, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 4, 0, 0, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 5, 0, 0, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 6, 0, 0, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 7, 0, 0, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 4, 1, 8, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 4, 2, 9, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 4, 3, 10, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 7, 1, 8, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 7, 2, 9, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 7, 3, 10, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 5, 9, 6, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 6, 9, 6, structureBoundingBoxIn); + this.setBlockState(worldIn, j, 5, 9, 8, structureBoundingBoxIn); + this.setBlockState(worldIn, j, 6, 9, 8, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 4, 0, 0, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 5, 0, 0, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 6, 0, 0, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 7, 0, 0, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 4, 1, 8, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 4, 2, 9, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 4, 3, 10, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 7, 1, 8, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 7, 2, 9, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 7, 3, 10, structureBoundingBoxIn); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 4, 1, 9, 4, 1, 9, false, randomIn, junglePyramidsRandomScatteredStones); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 7, 1, 9, 7, 1, 9, false, randomIn, junglePyramidsRandomScatteredStones); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 4, 1, 10, 7, 2, 10, false, randomIn, junglePyramidsRandomScatteredStones); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 5, 4, 5, 6, 4, 5, false, randomIn, junglePyramidsRandomScatteredStones); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(k), 4, 4, 5, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(l), 7, 4, 5, structureBoundingBoxIn); + this.setBlockState(worldIn, k, 4, 4, 5, structureBoundingBoxIn); + this.setBlockState(worldIn, l, 7, 4, 5, structureBoundingBoxIn); for (int l1 = 0; l1 < 4; ++l1) { - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(j), 5, 0 - l1, 6 + l1, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(j), 6, 0 - l1, 6 + l1, structureBoundingBoxIn); + this.setBlockState(worldIn, j, 5, 0 - l1, 6 + l1, structureBoundingBoxIn); + this.setBlockState(worldIn, j, 6, 0 - l1, 6 + l1, structureBoundingBoxIn); this.fillWithAir(worldIn, structureBoundingBoxIn, 5, 0 - l1, 7 + l1, 6, 0 - l1, 9 + l1); } @@ -492,8 +497,8 @@ public class StructureScattered this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 7, -2, 1, 9, -2, 1, false, randomIn, junglePyramidsRandomScatteredStones); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 6, -3, 1, 6, -3, 1, false, randomIn, junglePyramidsRandomScatteredStones); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 6, -1, 1, 6, -1, 1, false, randomIn, junglePyramidsRandomScatteredStones); - this.setBlockState(worldIn, Blocks.tripwire_hook.getStateFromMeta(this.getMetadataWithOffset(Blocks.tripwire_hook, Facing.EAST.getHorizontalIndex())).withProperty(BlockTripWireHook.ATTACHED, Boolean.valueOf(true)), 1, -3, 8, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.tripwire_hook.getStateFromMeta(this.getMetadataWithOffset(Blocks.tripwire_hook, Facing.WEST.getHorizontalIndex())).withProperty(BlockTripWireHook.ATTACHED, Boolean.valueOf(true)), 4, -3, 8, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.tripwire_hook.getState().withProperty(BlockTripWireHook.FACING, Facing.EAST).withProperty(BlockTripWireHook.ATTACHED, Boolean.valueOf(true))), 1, -3, 8, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.tripwire_hook.getState().withProperty(BlockTripWireHook.FACING, Facing.WEST).withProperty(BlockTripWireHook.ATTACHED, Boolean.valueOf(true))), 4, -3, 8, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.string.getState().withProperty(BlockTripWire.ATTACHED, Boolean.valueOf(true)), 2, -3, 8, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.string.getState().withProperty(BlockTripWire.ATTACHED, Boolean.valueOf(true)), 3, -3, 8, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.redstone.getState(), 5, -3, 7, structureBoundingBoxIn); @@ -508,12 +513,12 @@ public class StructureScattered if (!this.placedTrap1) { - this.placedTrap1 = this.generateDispenserContents(worldIn, structureBoundingBoxIn, randomIn, 3, -2, 1, Facing.NORTH.getIndex(), LootConstants.JUNGLE_TRAP, 2); + this.placedTrap1 = this.generateDispenserContents(worldIn, structureBoundingBoxIn, randomIn, 3, -2, 1, Facing.NORTH, LootConstants.JUNGLE_TRAP, 2); } - this.setBlockState(worldIn, Blocks.vine.getStateFromMeta(15), 3, -2, 2, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.tripwire_hook.getStateFromMeta(this.getMetadataWithOffset(Blocks.tripwire_hook, Facing.NORTH.getHorizontalIndex())).withProperty(BlockTripWireHook.ATTACHED, Boolean.valueOf(true)), 7, -3, 1, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.tripwire_hook.getStateFromMeta(this.getMetadataWithOffset(Blocks.tripwire_hook, Facing.SOUTH.getHorizontalIndex())).withProperty(BlockTripWireHook.ATTACHED, Boolean.valueOf(true)), 7, -3, 5, structureBoundingBoxIn); + this.setBlockState(worldIn, Blocks.vine.getState().withProperty(BlockVine.EAST, true).withProperty(BlockVine.NORTH, true).withProperty(BlockVine.SOUTH, true).withProperty(BlockVine.WEST, true), 3, -2, 2, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.tripwire_hook.getState().withProperty(BlockTripWireHook.FACING, Facing.NORTH).withProperty(BlockTripWireHook.ATTACHED, Boolean.valueOf(true))), 7, -3, 1, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.tripwire_hook.getState().withProperty(BlockTripWireHook.FACING, Facing.SOUTH).withProperty(BlockTripWireHook.ATTACHED, Boolean.valueOf(true))), 7, -3, 5, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.string.getState().withProperty(BlockTripWire.ATTACHED, Boolean.valueOf(true)), 7, -3, 2, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.string.getState().withProperty(BlockTripWire.ATTACHED, Boolean.valueOf(true)), 7, -3, 3, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.string.getState().withProperty(BlockTripWire.ATTACHED, Boolean.valueOf(true)), 7, -3, 4, structureBoundingBoxIn); @@ -525,11 +530,11 @@ public class StructureScattered if (!this.placedTrap2) { - this.placedTrap2 = this.generateDispenserContents(worldIn, structureBoundingBoxIn, randomIn, 9, -2, 3, Facing.WEST.getIndex(), LootConstants.JUNGLE_TRAP, 2); + this.placedTrap2 = this.generateDispenserContents(worldIn, structureBoundingBoxIn, randomIn, 9, -2, 3, Facing.WEST, LootConstants.JUNGLE_TRAP, 2); } - this.setBlockState(worldIn, Blocks.vine.getStateFromMeta(15), 8, -1, 3, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.vine.getStateFromMeta(15), 8, -2, 3, structureBoundingBoxIn); + this.setBlockState(worldIn, Blocks.vine.getState().withProperty(BlockVine.EAST, true).withProperty(BlockVine.NORTH, true).withProperty(BlockVine.SOUTH, true).withProperty(BlockVine.WEST, true), 8, -1, 3, structureBoundingBoxIn); + this.setBlockState(worldIn, Blocks.vine.getState().withProperty(BlockVine.EAST, true).withProperty(BlockVine.NORTH, true).withProperty(BlockVine.SOUTH, true).withProperty(BlockVine.WEST, true), 8, -2, 3, structureBoundingBoxIn); if (!this.placedMainChest) { @@ -550,19 +555,19 @@ public class StructureScattered this.setBlockState(worldIn, Blocks.carved_stonebrick.getState(), 8, -2, 11, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.carved_stonebrick.getState(), 9, -2, 11, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.carved_stonebrick.getState(), 10, -2, 11, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.lever.getStateFromMeta(BlockLever.getMetadataForFacing(Facing.getFront(this.getMetadataWithOffset(Blocks.lever, Facing.NORTH.getIndex())))), 8, -2, 12, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.lever.getStateFromMeta(BlockLever.getMetadataForFacing(Facing.getFront(this.getMetadataWithOffset(Blocks.lever, Facing.NORTH.getIndex())))), 9, -2, 12, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.lever.getStateFromMeta(BlockLever.getMetadataForFacing(Facing.getFront(this.getMetadataWithOffset(Blocks.lever, Facing.NORTH.getIndex())))), 10, -2, 12, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.lever.getState().withProperty(BlockLever.FACING, BlockLever.EnumOrientation.NORTH)), 8, -2, 12, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.lever.getState().withProperty(BlockLever.FACING, BlockLever.EnumOrientation.NORTH)), 9, -2, 12, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.lever.getState().withProperty(BlockLever.FACING, BlockLever.EnumOrientation.NORTH)), 10, -2, 12, structureBoundingBoxIn); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 8, -3, 8, 8, -3, 10, false, randomIn, junglePyramidsRandomScatteredStones); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 10, -3, 8, 10, -3, 10, false, randomIn, junglePyramidsRandomScatteredStones); this.setBlockState(worldIn, Blocks.mossy_cobblestone.getState(), 10, -2, 9, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.redstone.getState(), 8, -2, 9, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.redstone.getState(), 8, -2, 10, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.redstone.getState(), 10, -1, 9, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.sticky_piston.getStateFromMeta(Facing.UP.getIndex()), 9, -2, 8, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.sticky_piston.getStateFromMeta(this.getMetadataWithOffset(Blocks.sticky_piston, Facing.WEST.getIndex())), 10, -2, 8, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.sticky_piston.getStateFromMeta(this.getMetadataWithOffset(Blocks.sticky_piston, Facing.WEST.getIndex())), 10, -1, 8, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.repeater.getStateFromMeta(this.getMetadataWithOffset(Blocks.repeater, Facing.NORTH.getHorizontalIndex())), 10, -2, 10, structureBoundingBoxIn); + this.setBlockState(worldIn, Blocks.sticky_piston.getState().withProperty(BlockPistonBase.FACING, Facing.UP), 9, -2, 8, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.sticky_piston.getState().withProperty(BlockPistonBase.FACING, Facing.WEST)), 10, -2, 8, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.sticky_piston.getState().withProperty(BlockPistonBase.FACING, Facing.WEST)), 10, -1, 8, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.repeater.getState().withProperty(BlockRedstoneRepeater.FACING, Facing.NORTH)), 10, -2, 10, structureBoundingBoxIn); if (!this.placedHiddenChest) { @@ -647,14 +652,14 @@ public class StructureScattered this.setBlockState(worldIn, Blocks.cauldron.getState(), 4, 2, 6, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.oak_fence.getState(), 1, 2, 1, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.oak_fence.getState(), 5, 2, 1, structureBoundingBoxIn); - int i = this.getMetadataWithOffset(Blocks.oak_stairs, 3); - int j = this.getMetadataWithOffset(Blocks.oak_stairs, 1); - int k = this.getMetadataWithOffset(Blocks.oak_stairs, 0); - int l = this.getMetadataWithOffset(Blocks.oak_stairs, 2); - this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 4, 1, 6, 4, 1, Blocks.spruce_stairs.getStateFromMeta(i), Blocks.spruce_stairs.getStateFromMeta(i), false); - this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 4, 2, 0, 4, 7, Blocks.spruce_stairs.getStateFromMeta(k), Blocks.spruce_stairs.getStateFromMeta(k), false); - this.fillWithBlocks(worldIn, structureBoundingBoxIn, 6, 4, 2, 6, 4, 7, Blocks.spruce_stairs.getStateFromMeta(j), Blocks.spruce_stairs.getStateFromMeta(j), false); - this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 4, 8, 6, 4, 8, Blocks.spruce_stairs.getStateFromMeta(l), Blocks.spruce_stairs.getStateFromMeta(l), false); + State i = this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)); + State j = this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.WEST)); + State k = this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.EAST)); + State l = this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.SOUTH)); + this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 4, 1, 6, 4, 1, i, i, false); + this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 4, 2, 0, 4, 7, k, k, false); + this.fillWithBlocks(worldIn, structureBoundingBoxIn, 6, 4, 2, 6, 4, 7, j, j, false); + this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 4, 8, 6, 4, 8, l, l, false); for (int i1 = 2; i1 <= 7; i1 += 5) { diff --git a/server/src/main/java/server/worldgen/structure/StructureStronghold.java b/server/src/main/java/server/worldgen/structure/StructureStronghold.java index 49d68447..1770de4b 100755 --- a/server/src/main/java/server/worldgen/structure/StructureStronghold.java +++ b/server/src/main/java/server/worldgen/structure/StructureStronghold.java @@ -3,7 +3,11 @@ package server.worldgen.structure; import java.util.List; import java.util.Map; +import common.block.artificial.BlockDoor; +import common.block.artificial.BlockLadder; import common.block.artificial.BlockSlab; +import common.block.artificial.BlockStairs; +import common.block.tech.BlockButton; import common.collect.Lists; import common.collect.Maps; import common.entity.npc.EntityHaunter; @@ -14,6 +18,7 @@ import common.rng.Random; import common.tags.TagObject; import common.util.BlockPos; import common.util.Facing; +import common.world.State; import server.vars.SVars; import server.world.WorldServer; import server.worldgen.LootConstants; @@ -708,14 +713,14 @@ public class StructureStronghold this.setBlockState(worldIn, Blocks.oak_fence.getState(), 9, 6, 11, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.oak_fence.getState(), 8, 6, 11, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.oak_fence.getState(), 9, 6, 10, structureBoundingBoxIn); - int l1 = this.getMetadataWithOffset(Blocks.ladder, 3); - this.setBlockState(worldIn, Blocks.ladder.getStateFromMeta(l1), 10, 1, 13, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.ladder.getStateFromMeta(l1), 10, 2, 13, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.ladder.getStateFromMeta(l1), 10, 3, 13, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.ladder.getStateFromMeta(l1), 10, 4, 13, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.ladder.getStateFromMeta(l1), 10, 5, 13, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.ladder.getStateFromMeta(l1), 10, 6, 13, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.ladder.getStateFromMeta(l1), 10, 7, 13, structureBoundingBoxIn); + State l1 = this.getMetadataWithOffset(Blocks.ladder.getState().withProperty(BlockLadder.FACING, Facing.SOUTH)); + this.setBlockState(worldIn, l1, 10, 1, 13, structureBoundingBoxIn); + this.setBlockState(worldIn, l1, 10, 2, 13, structureBoundingBoxIn); + this.setBlockState(worldIn, l1, 10, 3, 13, structureBoundingBoxIn); + this.setBlockState(worldIn, l1, 10, 4, 13, structureBoundingBoxIn); + this.setBlockState(worldIn, l1, 10, 5, 13, structureBoundingBoxIn); + this.setBlockState(worldIn, l1, 10, 6, 13, structureBoundingBoxIn); + this.setBlockState(worldIn, l1, 10, 7, 13, structureBoundingBoxIn); int i1 = 7; int j1 = 7; this.setBlockState(worldIn, Blocks.oak_fence.getState(), i1 - 1, 9, j1, structureBoundingBoxIn); @@ -844,16 +849,16 @@ public class StructureStronghold this.fillWithBlocks(worldIn, structureBoundingBoxIn, k1, 3, 15, k1, 4, 15, Blocks.iron_bars.getState(), Blocks.iron_bars.getState(), false); } - int l1 = this.getMetadataWithOffset(Blocks.stonebrick_stairs, 3); + State l1 = this.getMetadataWithOffset(Blocks.stonebrick_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 4, 1, 5, 6, 1, 7, false, randomIn, StructureStronghold.strongholdStones); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 4, 2, 6, 6, 2, 7, false, randomIn, StructureStronghold.strongholdStones); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 4, 3, 7, 6, 3, 7, false, randomIn, StructureStronghold.strongholdStones); for (int k = 4; k <= 6; ++k) { - this.setBlockState(worldIn, Blocks.stonebrick_stairs.getStateFromMeta(l1), k, 1, 4, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.stonebrick_stairs.getStateFromMeta(l1), k, 2, 5, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.stonebrick_stairs.getStateFromMeta(l1), k, 3, 6, structureBoundingBoxIn); + this.setBlockState(worldIn, l1, k, 1, 4, structureBoundingBoxIn); + this.setBlockState(worldIn, l1, k, 2, 5, structureBoundingBoxIn); + this.setBlockState(worldIn, l1, k, 3, 6, structureBoundingBoxIn); } int i2 = Facing.NORTH.getHorizontalIndex(); @@ -961,10 +966,10 @@ public class StructureStronghold this.fillWithBlocks(worldIn, structureBoundingBoxIn, 5, 1, 5, 7, 3, 5, Blocks.iron_bars.getState(), Blocks.iron_bars.getState(), false); this.setBlockState(worldIn, Blocks.iron_bars.getState(), 4, 3, 2, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.iron_bars.getState(), 4, 3, 8, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.iron_door.getStateFromMeta(this.getMetadataWithOffset(Blocks.iron_door, 3)), 4, 1, 2, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.iron_door.getStateFromMeta(this.getMetadataWithOffset(Blocks.iron_door, 3) + 8), 4, 2, 2, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.iron_door.getStateFromMeta(this.getMetadataWithOffset(Blocks.iron_door, 3)), 4, 1, 8, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.iron_door.getStateFromMeta(this.getMetadataWithOffset(Blocks.iron_door, 3) + 8), 4, 2, 8, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.iron_door.getState().withProperty(BlockDoor.FACING, Facing.NORTH)), 4, 1, 2, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.iron_door.getState().withProperty(BlockDoor.FACING, Facing.NORTH).withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER)), 4, 2, 2, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.iron_door.getState().withProperty(BlockDoor.FACING, Facing.NORTH)), 4, 1, 8, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.iron_door.getState().withProperty(BlockDoor.FACING, Facing.NORTH).withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER)), 4, 2, 8, structureBoundingBoxIn); return true; } } @@ -1148,9 +1153,9 @@ public class StructureStronghold this.setBlockState(worldIn, Blocks.oak_planks.getState(), 8, 3, l, structureBoundingBoxIn); } - this.setBlockState(worldIn, Blocks.ladder.getStateFromMeta(this.getMetadataWithOffset(Blocks.ladder, Facing.WEST.getIndex())), 9, 1, 3, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.ladder.getStateFromMeta(this.getMetadataWithOffset(Blocks.ladder, Facing.WEST.getIndex())), 9, 2, 3, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.ladder.getStateFromMeta(this.getMetadataWithOffset(Blocks.ladder, Facing.WEST.getIndex())), 9, 3, 3, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.ladder.getState().withProperty(BlockLadder.FACING, Facing.WEST)), 9, 1, 3, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.ladder.getState().withProperty(BlockLadder.FACING, Facing.WEST)), 9, 2, 3, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.ladder.getState().withProperty(BlockLadder.FACING, Facing.WEST)), 9, 3, 3, structureBoundingBoxIn); this.generateChestContents(worldIn, structureBoundingBoxIn, randomIn, 3, 4, 8, RngLoot.addToList(LootConstants.STRONGHOLD_CROSS, Items.enchanted_book.getRandom(randomIn)), 1 + randomIn.zrange(4)); } @@ -1313,13 +1318,13 @@ public class StructureStronghold this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 4, 10, 7, true, randomIn, StructureStronghold.strongholdStones); this.placeDoor(worldIn, randomIn, structureBoundingBoxIn, this.field_143013_d, 1, 7, 0); this.placeDoor(worldIn, randomIn, structureBoundingBoxIn, StructureStronghold.Stronghold.Door.OPENING, 1, 1, 7); - int i = this.getMetadataWithOffset(Blocks.cobblestone_stairs, 2); + State i = this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.SOUTH)); for (int j = 0; j < 6; ++j) { - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 1, 6 - j, 1 + j, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 2, 6 - j, 1 + j, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 3, 6 - j, 1 + j, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 1, 6 - j, 1 + j, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 2, 6 - j, 1 + j, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 3, 6 - j, 1 + j, structureBoundingBoxIn); if (j < 5) { @@ -1496,7 +1501,7 @@ public class StructureStronghold this.setBlockState(worldIn, Blocks.stonebrick.getState(), p_74990_5_ + 2, p_74990_6_ + 1, p_74990_7_, p_74990_3_); this.setBlockState(worldIn, Blocks.stonebrick.getState(), p_74990_5_ + 2, p_74990_6_, p_74990_7_, p_74990_3_); this.setBlockState(worldIn, Blocks.oak_door.getState(), p_74990_5_ + 1, p_74990_6_, p_74990_7_, p_74990_3_); - this.setBlockState(worldIn, Blocks.oak_door.getStateFromMeta(8), p_74990_5_ + 1, p_74990_6_ + 1, p_74990_7_, p_74990_3_); + this.setBlockState(worldIn, Blocks.oak_door.getState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), p_74990_5_ + 1, p_74990_6_ + 1, p_74990_7_, p_74990_3_); break; case GRATES: @@ -1520,9 +1525,9 @@ public class StructureStronghold this.setBlockState(worldIn, Blocks.stonebrick.getState(), p_74990_5_ + 2, p_74990_6_ + 1, p_74990_7_, p_74990_3_); this.setBlockState(worldIn, Blocks.stonebrick.getState(), p_74990_5_ + 2, p_74990_6_, p_74990_7_, p_74990_3_); this.setBlockState(worldIn, Blocks.iron_door.getState(), p_74990_5_ + 1, p_74990_6_, p_74990_7_, p_74990_3_); - this.setBlockState(worldIn, Blocks.iron_door.getStateFromMeta(8), p_74990_5_ + 1, p_74990_6_ + 1, p_74990_7_, p_74990_3_); - this.setBlockState(worldIn, Blocks.stone_button.getStateFromMeta(this.getMetadataWithOffset(Blocks.stone_button, 4)), p_74990_5_ + 2, p_74990_6_ + 1, p_74990_7_ + 1, p_74990_3_); - this.setBlockState(worldIn, Blocks.stone_button.getStateFromMeta(this.getMetadataWithOffset(Blocks.stone_button, 3)), p_74990_5_ + 2, p_74990_6_ + 1, p_74990_7_ - 1, p_74990_3_); + this.setBlockState(worldIn, Blocks.iron_door.getState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), p_74990_5_ + 1, p_74990_6_ + 1, p_74990_7_, p_74990_3_); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.stone_button.getState().withProperty(BlockButton.FACING, Facing.NORTH)), p_74990_5_ + 2, p_74990_6_ + 1, p_74990_7_ + 1, p_74990_3_); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.stone_button.getState().withProperty(BlockButton.FACING, Facing.SOUTH)), p_74990_5_ + 2, p_74990_6_ + 1, p_74990_7_ - 1, p_74990_3_); } } diff --git a/server/src/main/java/server/worldgen/structure/StructureVillage.java b/server/src/main/java/server/worldgen/structure/StructureVillage.java index 40113de6..518aa086 100755 --- a/server/src/main/java/server/worldgen/structure/StructureVillage.java +++ b/server/src/main/java/server/worldgen/structure/StructureVillage.java @@ -4,6 +4,8 @@ import java.util.Iterator; import java.util.List; import common.biome.Biome; +import common.block.artificial.BlockDoor; +import common.block.artificial.BlockLadder; import common.block.artificial.BlockSlab; import common.block.artificial.BlockStairs; import common.block.foliage.BlockCrops; @@ -320,11 +322,11 @@ public class StructureVillage this.setBlockState(worldIn, Blocks.cobblestone.getState(), 2, 1, 7, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.cobblestone.getState(), 3, 1, 6, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.cobblestone.getState(), 3, 1, 7, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.cobblestone_stairs, 3)), 1, 1, 5, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.cobblestone_stairs, 3)), 2, 1, 6, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.cobblestone_stairs, 3)), 3, 1, 5, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.cobblestone_stairs, 1)), 1, 2, 7, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.cobblestone_stairs, 0)), 3, 2, 7, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)), 1, 1, 5, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)), 2, 1, 6, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)), 3, 1, 5, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.WEST)), 1, 2, 7, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.EAST)), 3, 2, 7, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.glass_pane.getState(), 0, 2, 2, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.glass_pane.getState(), 0, 3, 2, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.glass_pane.getState(), 4, 2, 2, structureBoundingBoxIn); @@ -344,20 +346,20 @@ public class StructureVillage this.setBlockState(worldIn, Blocks.torch.getState().withProperty(BlockTorch.FACING, this.coordBaseMode.rotateY()), 1, 4, 6, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.torch.getState().withProperty(BlockTorch.FACING, this.coordBaseMode.rotateYCCW()), 3, 4, 6, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.torch.getState().withProperty(BlockTorch.FACING, this.coordBaseMode), 2, 4, 5, structureBoundingBoxIn); - int i = this.getMetadataWithOffset(Blocks.ladder, 4); + State i = this.getMetadataWithOffset(Blocks.ladder.getState().withProperty(BlockLadder.FACING, Facing.WEST)); for (int j = 1; j <= 9; ++j) { - this.setBlockState(worldIn, Blocks.ladder.getStateFromMeta(i), 3, j, 3, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 3, j, 3, structureBoundingBoxIn); } this.setBlockState(worldIn, Blocks.air.getState(), 2, 1, 0, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.air.getState(), 2, 2, 0, structureBoundingBoxIn); - this.placeDoorCurrentPosition(worldIn, structureBoundingBoxIn, randomIn, 2, 1, 0, Facing.getHorizontal(this.getMetadataWithOffset(Blocks.oak_door, 1))); + this.placeDoorCurrentPosition(worldIn, structureBoundingBoxIn, randomIn, 2, 1, 0, this.getMetadataWithOffset(Blocks.oak_door.getState().withProperty(BlockDoor.FACING, Facing.SOUTH))); if (this.getBlockStateFromPos(worldIn, 2, 0, -1, structureBoundingBoxIn).getBlock() == Blocks.air && this.getBlockStateFromPos(worldIn, 2, -1, -1, structureBoundingBoxIn).getBlock() != Blocks.air) { - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.cobblestone_stairs, 3)), 2, 0, -1, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)), 2, 0, -1, structureBoundingBoxIn); } for (int l = 0; l < 9; ++l) @@ -643,15 +645,15 @@ public class StructureVillage this.setBlockState(worldIn, Blocks.oak_planks.getState(), 0, 4, 3, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.oak_planks.getState(), 8, 4, 2, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.oak_planks.getState(), 8, 4, 3, structureBoundingBoxIn); - int i = this.getMetadataWithOffset(Blocks.oak_stairs, 3); - int j = this.getMetadataWithOffset(Blocks.oak_stairs, 2); + State i = this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)); + State j = this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.SOUTH)); for (int k = -1; k <= 2; ++k) { for (int l = 0; l <= 8; ++l) { - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(i), l, 4 + k, k, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(j), l, 4 + k, 5 - k, structureBoundingBoxIn); + this.setBlockState(worldIn, i, l, 4 + k, k, structureBoundingBoxIn); + this.setBlockState(worldIn, j, l, 4 + k, 5 - k, structureBoundingBoxIn); } } @@ -670,25 +672,25 @@ public class StructureVillage this.setBlockState(worldIn, Blocks.oak_fence.getState(), 2, 1, 3, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.wooden_pressure_plate.getState(), 2, 2, 3, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.oak_planks.getState(), 1, 1, 4, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.oak_stairs, 3)), 2, 1, 4, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.oak_stairs, 1)), 1, 1, 3, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)), 2, 1, 4, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.WEST)), 1, 1, 3, structureBoundingBoxIn); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 5, 0, 1, 7, 0, 3, Blocks.stone_slab.getState().withProperty(BlockSlab.DOUBLE, true), Blocks.stone_slab.getState().withProperty(BlockSlab.DOUBLE, true), false); this.setBlockState(worldIn, Blocks.stone_slab.getState().withProperty(BlockSlab.DOUBLE, true), 6, 1, 1, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.stone_slab.getState().withProperty(BlockSlab.DOUBLE, true), 6, 1, 2, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.air.getState(), 2, 1, 0, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.air.getState(), 2, 2, 0, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.torch.getState().withProperty(BlockTorch.FACING, this.coordBaseMode), 2, 3, 1, structureBoundingBoxIn); - this.placeDoorCurrentPosition(worldIn, structureBoundingBoxIn, randomIn, 2, 1, 0, Facing.getHorizontal(this.getMetadataWithOffset(Blocks.oak_door, 1))); + this.placeDoorCurrentPosition(worldIn, structureBoundingBoxIn, randomIn, 2, 1, 0, this.getMetadataWithOffset(Blocks.oak_door.getState().withProperty(BlockDoor.FACING, Facing.SOUTH))); if (this.getBlockStateFromPos(worldIn, 2, 0, -1, structureBoundingBoxIn).getBlock() == Blocks.air && this.getBlockStateFromPos(worldIn, 2, -1, -1, structureBoundingBoxIn).getBlock() != Blocks.air) { - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.cobblestone_stairs, 3)), 2, 0, -1, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)), 2, 0, -1, structureBoundingBoxIn); } this.setBlockState(worldIn, Blocks.air.getState(), 6, 1, 5, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.air.getState(), 6, 2, 5, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.torch.getState().withProperty(BlockTorch.FACING, this.coordBaseMode.getOpposite()), 6, 3, 4, structureBoundingBoxIn); - this.placeDoorCurrentPosition(worldIn, structureBoundingBoxIn, randomIn, 6, 1, 5, Facing.getHorizontal(this.getMetadataWithOffset(Blocks.oak_door, 1))); + this.placeDoorCurrentPosition(worldIn, structureBoundingBoxIn, randomIn, 6, 1, 5, this.getMetadataWithOffset(Blocks.oak_door.getState().withProperty(BlockDoor.FACING, Facing.SOUTH))); for (int i1 = 0; i1 < 5; ++i1) { @@ -747,15 +749,15 @@ public class StructureVillage this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 5, 0, 8, 5, 5, Blocks.cobblestone.getState(), Blocks.cobblestone.getState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 6, 1, 8, 6, 4, Blocks.cobblestone.getState(), Blocks.cobblestone.getState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 7, 2, 8, 7, 3, Blocks.cobblestone.getState(), Blocks.cobblestone.getState(), false); - int i = this.getMetadataWithOffset(Blocks.oak_stairs, 3); - int j = this.getMetadataWithOffset(Blocks.oak_stairs, 2); + State i = this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)); + State j = this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.SOUTH)); for (int k = -1; k <= 2; ++k) { for (int l = 0; l <= 8; ++l) { - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(i), l, 6 + k, k, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(j), l, 6 + k, 5 - k, structureBoundingBoxIn); + this.setBlockState(worldIn, i, l, 6 + k, k, structureBoundingBoxIn); + this.setBlockState(worldIn, j, l, 6 + k, 5 - k, structureBoundingBoxIn); } } @@ -793,12 +795,12 @@ public class StructureVillage this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 4, 4, 7, 4, 4, Blocks.oak_planks.getState(), Blocks.oak_planks.getState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 3, 4, 7, 3, 4, Blocks.bookshelf.getState(), Blocks.bookshelf.getState(), false); this.setBlockState(worldIn, Blocks.oak_planks.getState(), 7, 1, 4, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.oak_stairs, 0)), 7, 1, 3, structureBoundingBoxIn); - int j1 = this.getMetadataWithOffset(Blocks.oak_stairs, 3); - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(j1), 6, 1, 4, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(j1), 5, 1, 4, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(j1), 4, 1, 4, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(j1), 3, 1, 4, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.EAST)), 7, 1, 3, structureBoundingBoxIn); + State j1 = this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)); + this.setBlockState(worldIn, j1, 6, 1, 4, structureBoundingBoxIn); + this.setBlockState(worldIn, j1, 5, 1, 4, structureBoundingBoxIn); + this.setBlockState(worldIn, j1, 4, 1, 4, structureBoundingBoxIn); + this.setBlockState(worldIn, j1, 3, 1, 4, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.oak_fence.getState(), 6, 1, 3, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.wooden_pressure_plate.getState(), 6, 2, 3, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.oak_fence.getState(), 4, 1, 3, structureBoundingBoxIn); @@ -806,11 +808,11 @@ public class StructureVillage this.setBlockState(worldIn, Blocks.workbench.getState(), 7, 1, 1, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.air.getState(), 1, 1, 0, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.air.getState(), 1, 2, 0, structureBoundingBoxIn); - this.placeDoorCurrentPosition(worldIn, structureBoundingBoxIn, randomIn, 1, 1, 0, Facing.getHorizontal(this.getMetadataWithOffset(Blocks.oak_door, 1))); + this.placeDoorCurrentPosition(worldIn, structureBoundingBoxIn, randomIn, 1, 1, 0, this.getMetadataWithOffset(Blocks.oak_door.getState().withProperty(BlockDoor.FACING, Facing.SOUTH))); if (this.getBlockStateFromPos(worldIn, 1, 0, -1, structureBoundingBoxIn).getBlock() == Blocks.air && this.getBlockStateFromPos(worldIn, 1, -1, -1, structureBoundingBoxIn).getBlock() != Blocks.air) { - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.cobblestone_stairs, 3)), 1, 0, -1, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)), 1, 0, -1, structureBoundingBoxIn); } for (int k1 = 0; k1 < 6; ++k1) @@ -912,8 +914,8 @@ public class StructureVillage this.setBlockState(worldIn, Blocks.oak_fence.getState(), 2, 1, 4, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.wooden_pressure_plate.getState(), 2, 2, 4, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.oak_planks.getState(), 1, 1, 5, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.oak_stairs, 3)), 2, 1, 5, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.oak_stairs, 1)), 1, 1, 4, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)), 2, 1, 5, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.WEST)), 1, 1, 4, structureBoundingBoxIn); if (!this.hasMadeChest && structureBoundingBoxIn.isVecInside(new BlockPos(this.getXWithOffset(5, 5), this.getYWithOffset(1), this.getZWithOffset(5, 5)))) { @@ -925,7 +927,7 @@ public class StructureVillage { if (this.getBlockStateFromPos(worldIn, i, 0, -1, structureBoundingBoxIn).getBlock() == Blocks.air && this.getBlockStateFromPos(worldIn, i, -1, -1, structureBoundingBoxIn).getBlock() != Blocks.air) { - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.cobblestone_stairs, 3)), i, 0, -1, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)), i, 0, -1, structureBoundingBoxIn); } } @@ -1001,18 +1003,18 @@ public class StructureVillage this.setBlockState(worldIn, Blocks.oak_planks.getState(), 8, 4, 2, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.oak_planks.getState(), 8, 4, 3, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.oak_planks.getState(), 8, 4, 4, structureBoundingBoxIn); - int i = this.getMetadataWithOffset(Blocks.oak_stairs, 3); - int j = this.getMetadataWithOffset(Blocks.oak_stairs, 2); + State i = this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)); + State j = this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.SOUTH)); for (int k = -1; k <= 2; ++k) { for (int l = 0; l <= 8; ++l) { - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(i), l, 4 + k, k, structureBoundingBoxIn); + this.setBlockState(worldIn, i, l, 4 + k, k, structureBoundingBoxIn); if ((k > -1 || l <= 1) && (k > 0 || l <= 3) && (k > 1 || l <= 4 || l >= 6)) { - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(j), l, 4 + k, 5 - k, structureBoundingBoxIn); + this.setBlockState(worldIn, j, l, 4 + k, 5 - k, structureBoundingBoxIn); } } } @@ -1022,7 +1024,7 @@ public class StructureVillage this.fillWithBlocks(worldIn, structureBoundingBoxIn, 4, 5, 4, 4, 5, 10, Blocks.oak_planks.getState(), Blocks.oak_planks.getState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 6, 5, 4, 6, 5, 10, Blocks.oak_planks.getState(), Blocks.oak_planks.getState(), false); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 5, 6, 3, 5, 6, 10, Blocks.oak_planks.getState(), Blocks.oak_planks.getState(), false); - int k1 = this.getMetadataWithOffset(Blocks.oak_stairs, 0); + State k1 = this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.EAST)); for (int l1 = 4; l1 >= 1; --l1) { @@ -1030,20 +1032,20 @@ public class StructureVillage for (int i1 = 8 - l1; i1 <= 10; ++i1) { - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(k1), l1, 2 + l1, i1, structureBoundingBoxIn); + this.setBlockState(worldIn, k1, l1, 2 + l1, i1, structureBoundingBoxIn); } } - int i2 = this.getMetadataWithOffset(Blocks.oak_stairs, 1); + State i2 = this.getMetadataWithOffset(Blocks.oak_stairs.getState().withProperty(BlockStairs.FACING, Facing.WEST)); this.setBlockState(worldIn, Blocks.oak_planks.getState(), 6, 6, 3, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.oak_planks.getState(), 7, 5, 4, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(i2), 6, 6, 4, structureBoundingBoxIn); + this.setBlockState(worldIn, i2, 6, 6, 4, structureBoundingBoxIn); for (int j2 = 6; j2 <= 8; ++j2) { for (int j1 = 5; j1 <= 10; ++j1) { - this.setBlockState(worldIn, Blocks.oak_stairs.getStateFromMeta(i2), j2, 12 - j2, j1, structureBoundingBoxIn); + this.setBlockState(worldIn, i2, j2, 12 - j2, j1, structureBoundingBoxIn); } } @@ -1074,12 +1076,12 @@ public class StructureVillage this.setBlockState(worldIn, Blocks.air.getState(), 2, 1, 0, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.air.getState(), 2, 2, 0, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.torch.getState().withProperty(BlockTorch.FACING, this.coordBaseMode), 2, 3, 1, structureBoundingBoxIn); - this.placeDoorCurrentPosition(worldIn, structureBoundingBoxIn, randomIn, 2, 1, 0, Facing.getHorizontal(this.getMetadataWithOffset(Blocks.oak_door, 1))); + this.placeDoorCurrentPosition(worldIn, structureBoundingBoxIn, randomIn, 2, 1, 0, this.getMetadataWithOffset(Blocks.oak_door.getState().withProperty(BlockDoor.FACING, Facing.SOUTH))); this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 0, -1, 3, 2, -1, Blocks.air.getState(), Blocks.air.getState(), false); if (this.getBlockStateFromPos(worldIn, 2, 0, -1, structureBoundingBoxIn).getBlock() == Blocks.air && this.getBlockStateFromPos(worldIn, 2, -1, -1, structureBoundingBoxIn).getBlock() != Blocks.air) { - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.cobblestone_stairs, 3)), 2, 0, -1, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)), 2, 0, -1, structureBoundingBoxIn); } for (int k2 = 0; k2 < 5; ++k2) @@ -1184,7 +1186,7 @@ public class StructureVillage if (this.getBlockStateFromPos(worldIn, 2, 0, -1, structureBoundingBoxIn).getBlock() == Blocks.air && this.getBlockStateFromPos(worldIn, 2, -1, -1, structureBoundingBoxIn).getBlock() != Blocks.air) { - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.cobblestone_stairs, 3)), 2, 0, -1, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)), 2, 0, -1, structureBoundingBoxIn); } this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 1, 3, 3, 3, Blocks.air.getState(), Blocks.air.getState(), false); @@ -1211,11 +1213,11 @@ public class StructureVillage if (this.isRoofAccessible) { - int i = this.getMetadataWithOffset(Blocks.ladder, 3); - this.setBlockState(worldIn, Blocks.ladder.getStateFromMeta(i), 3, 1, 3, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.ladder.getStateFromMeta(i), 3, 2, 3, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.ladder.getStateFromMeta(i), 3, 3, 3, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.ladder.getStateFromMeta(i), 3, 4, 3, structureBoundingBoxIn); + State i = this.getMetadataWithOffset(Blocks.ladder.getState().withProperty(BlockLadder.FACING, Facing.SOUTH)); + this.setBlockState(worldIn, i, 3, 1, 3, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 3, 2, 3, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 3, 3, 3, structureBoundingBoxIn); + this.setBlockState(worldIn, i, 3, 4, 3, structureBoundingBoxIn); } this.setBlockState(worldIn, Blocks.torch.getState().withProperty(BlockTorch.FACING, this.coordBaseMode), 2, 3, 1, structureBoundingBoxIn); @@ -1863,11 +1865,11 @@ public class StructureVillage this.setBlockState(worldIn, Blocks.air.getState(), 1, 1, 0, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.air.getState(), 1, 2, 0, structureBoundingBoxIn); - this.placeDoorCurrentPosition(worldIn, structureBoundingBoxIn, randomIn, 1, 1, 0, Facing.getHorizontal(this.getMetadataWithOffset(Blocks.oak_door, 1))); + this.placeDoorCurrentPosition(worldIn, structureBoundingBoxIn, randomIn, 1, 1, 0, this.getMetadataWithOffset(Blocks.oak_door.getState().withProperty(BlockDoor.FACING, Facing.SOUTH))); if (this.getBlockStateFromPos(worldIn, 1, 0, -1, structureBoundingBoxIn).getBlock() == Blocks.air && this.getBlockStateFromPos(worldIn, 1, -1, -1, structureBoundingBoxIn).getBlock() != Blocks.air) { - this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(this.getMetadataWithOffset(Blocks.cobblestone_stairs, 3)), 1, 0, -1, structureBoundingBoxIn); + this.setBlockState(worldIn, this.getMetadataWithOffset(Blocks.cobblestone_stairs.getState().withProperty(BlockStairs.FACING, Facing.NORTH)), 1, 0, -1, structureBoundingBoxIn); } for (int i = 0; i < 5; ++i) From 244220f78ceab2a48c56422ed315c4ab7a368891 Mon Sep 17 00:00:00 2001 From: Sen Date: Fri, 27 Jun 2025 21:16:54 +0200 Subject: [PATCH 7/7] remove block metadata functions --- common/src/main/java/common/block/Block.java | 4 -- .../common/block/artificial/BlockBed.java | 5 --- .../common/block/artificial/BlockCake.java | 8 ---- .../common/block/artificial/BlockDoor.java | 8 ---- .../block/artificial/BlockFenceGate.java | 8 ---- .../common/block/artificial/BlockHay.java | 20 ---------- .../common/block/artificial/BlockLadder.java | 15 -------- .../common/block/artificial/BlockPortal.java | 9 ----- .../block/artificial/BlockPortalFrame.java | 8 ---- .../block/artificial/BlockQuartzPillar.java | 18 --------- .../common/block/artificial/BlockSkull.java | 4 -- .../common/block/artificial/BlockSlab.java | 8 ---- .../common/block/artificial/BlockStairs.java | 10 ----- .../block/artificial/BlockTrapDoor.java | 8 ---- .../common/block/foliage/BlockCactus.java | 8 ---- .../java/common/block/foliage/BlockCocoa.java | 8 ---- .../java/common/block/foliage/BlockCrops.java | 8 ---- .../block/foliage/BlockDoublePlant.java | 8 ---- .../common/block/foliage/BlockFarmland.java | 8 ---- .../block/foliage/BlockHugeMushroom.java | 8 ---- .../common/block/foliage/BlockLeaves.java | 4 -- .../common/block/foliage/BlockLilyPad.java | 10 ----- .../java/common/block/foliage/BlockLog.java | 22 ----------- .../common/block/foliage/BlockPumpkin.java | 4 -- .../java/common/block/foliage/BlockReed.java | 8 ---- .../common/block/foliage/BlockSapling.java | 8 ---- .../java/common/block/foliage/BlockStem.java | 8 ---- .../java/common/block/foliage/BlockVine.java | 8 ---- .../java/common/block/foliage/BlockWart.java | 8 ---- .../java/common/block/liquid/BlockLiquid.java | 8 ---- .../java/common/block/natural/BlockFire.java | 8 ---- .../java/common/block/natural/BlockSnow.java | 8 ---- .../java/common/block/tech/BlockAnvil.java | 8 ---- .../common/block/tech/BlockBrewingStand.java | 15 -------- .../java/common/block/tech/BlockButton.java | 37 ------------------- .../java/common/block/tech/BlockCauldron.java | 8 ---- .../java/common/block/tech/BlockChest.java | 15 -------- .../block/tech/BlockDaylightDetector.java | 8 ---- .../common/block/tech/BlockDispenser.java | 8 ---- .../java/common/block/tech/BlockFurnace.java | 15 -------- .../java/common/block/tech/BlockHopper.java | 8 ---- .../java/common/block/tech/BlockLever.java | 8 ---- .../java/common/block/tech/BlockMachine.java | 4 -- .../common/block/tech/BlockPistonBase.java | 8 ---- .../common/block/tech/BlockPistonHead.java | 8 ---- .../common/block/tech/BlockPistonMoving.java | 8 ---- .../common/block/tech/BlockPressurePlate.java | 8 ---- .../tech/BlockPressurePlateWeighted.java | 8 ---- .../java/common/block/tech/BlockRail.java | 8 ---- .../common/block/tech/BlockRailDetector.java | 8 ---- .../common/block/tech/BlockRailPowered.java | 8 ---- .../block/tech/BlockRedstoneComparator.java | 8 ---- .../block/tech/BlockRedstoneRepeater.java | 8 ---- .../common/block/tech/BlockRedstoneWire.java | 8 ---- .../main/java/common/block/tech/BlockTNT.java | 8 ---- .../java/common/block/tech/BlockTorch.java | 33 ----------------- .../java/common/block/tech/BlockTripWire.java | 8 ---- .../common/block/tech/BlockTripWireHook.java | 8 ---- .../common/block/tech/BlockWarpChest.java | 15 -------- .../common/block/tile/BlockBannerHanging.java | 12 ------ .../block/tile/BlockBannerStanding.java | 5 --- .../common/block/tile/BlockStandingSign.java | 8 ---- .../java/common/block/tile/BlockWallSign.java | 15 -------- 63 files changed, 619 deletions(-) diff --git a/common/src/main/java/common/block/Block.java b/common/src/main/java/common/block/Block.java index e7e54576..badb531d 100755 --- a/common/src/main/java/common/block/Block.java +++ b/common/src/main/java/common/block/Block.java @@ -455,10 +455,6 @@ public class Block { return this.savedProps; } - public State getStateFromMeta(int meta) { - return this.getState(); - } - public State getActualState(State state, IWorldAccess worldIn, BlockPos pos) { return state; } diff --git a/common/src/main/java/common/block/artificial/BlockBed.java b/common/src/main/java/common/block/artificial/BlockBed.java index d2697694..dc7701c9 100755 --- a/common/src/main/java/common/block/artificial/BlockBed.java +++ b/common/src/main/java/common/block/artificial/BlockBed.java @@ -180,11 +180,6 @@ public class BlockBed extends Block implements Rotatable { // } // } - public State getStateFromMeta(int meta) { - return this.getState().withProperty(PART, (meta & 8) > 0 ? BlockBed.EnumPartType.HEAD : BlockBed.EnumPartType.FOOT) - .withProperty(FACING, Facing.getHorizontal(meta)); - } - protected Property[] getProperties() { return new Property[] {FACING, PART}; } diff --git a/common/src/main/java/common/block/artificial/BlockCake.java b/common/src/main/java/common/block/artificial/BlockCake.java index 2befa3dc..1bf677da 100755 --- a/common/src/main/java/common/block/artificial/BlockCake.java +++ b/common/src/main/java/common/block/artificial/BlockCake.java @@ -214,14 +214,6 @@ public class BlockCake extends Block return BlockLayer.CUTOUT; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(BITES, Integer.valueOf(meta > 6 ? 0 : meta)); - } - protected Property[] getProperties() { return new Property[] {BITES}; diff --git a/common/src/main/java/common/block/artificial/BlockDoor.java b/common/src/main/java/common/block/artificial/BlockDoor.java index 00e5b7af..4a49dc81 100755 --- a/common/src/main/java/common/block/artificial/BlockDoor.java +++ b/common/src/main/java/common/block/artificial/BlockDoor.java @@ -314,14 +314,6 @@ public class BlockDoor extends Block implements Rotatable return BlockLayer.CUTOUT; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return (meta & 8) > 0 ? this.getState().withProperty(HALF, BlockDoor.EnumDoorHalf.UPPER).withProperty(HINGE, (meta & 1) > 0 ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT).withProperty(POWERED, Boolean.valueOf((meta & 2) > 0)) : this.getState().withProperty(HALF, BlockDoor.EnumDoorHalf.LOWER).withProperty(FACING, Facing.getHorizontal(meta & 3).rotateYCCW()).withProperty(OPEN, Boolean.valueOf((meta & 4) > 0)); - } - public static Facing getFacing(IBlockAccess worldIn, BlockPos pos) { return worldIn.getState(pos).getValue(FACING); diff --git a/common/src/main/java/common/block/artificial/BlockFenceGate.java b/common/src/main/java/common/block/artificial/BlockFenceGate.java index eae45f15..9bea0794 100755 --- a/common/src/main/java/common/block/artificial/BlockFenceGate.java +++ b/common/src/main/java/common/block/artificial/BlockFenceGate.java @@ -171,14 +171,6 @@ public class BlockFenceGate extends Block implements Rotatable return true; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(FACING, Facing.getHorizontal(meta)).withProperty(OPEN, Boolean.valueOf((meta & 4) != 0)).withProperty(POWERED, Boolean.valueOf((meta & 8) != 0)); - } - protected Property[] getProperties() { return new Property[] {FACING, OPEN, POWERED, IN_WALL}; diff --git a/common/src/main/java/common/block/artificial/BlockHay.java b/common/src/main/java/common/block/artificial/BlockHay.java index 55946e64..1f6ddacf 100755 --- a/common/src/main/java/common/block/artificial/BlockHay.java +++ b/common/src/main/java/common/block/artificial/BlockHay.java @@ -21,26 +21,6 @@ public class BlockHay extends BlockRotatedPillar this.setFlammable(60, 20); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - Facing.Axis enumfacing$axis = Facing.Axis.Y; - int i = meta & 12; - - if (i == 4) - { - enumfacing$axis = Facing.Axis.X; - } - else if (i == 8) - { - enumfacing$axis = Facing.Axis.Z; - } - - return this.getState().withProperty(AXIS, enumfacing$axis); - } - protected Property[] getProperties() { return new Property[] {AXIS}; diff --git a/common/src/main/java/common/block/artificial/BlockLadder.java b/common/src/main/java/common/block/artificial/BlockLadder.java index 65bea537..dc25b822 100755 --- a/common/src/main/java/common/block/artificial/BlockLadder.java +++ b/common/src/main/java/common/block/artificial/BlockLadder.java @@ -136,21 +136,6 @@ public class BlockLadder extends Block implements Rotatable return BlockLayer.CUTOUT; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - Facing enumfacing = Facing.getFront(meta); - - if (enumfacing.getAxis() == Facing.Axis.Y) - { - enumfacing = Facing.NORTH; - } - - return this.getState().withProperty(FACING, enumfacing); - } - protected Property[] getProperties() { return new Property[] {FACING}; diff --git a/common/src/main/java/common/block/artificial/BlockPortal.java b/common/src/main/java/common/block/artificial/BlockPortal.java index 1c6a8848..cbcacabf 100755 --- a/common/src/main/java/common/block/artificial/BlockPortal.java +++ b/common/src/main/java/common/block/artificial/BlockPortal.java @@ -259,15 +259,6 @@ public class BlockPortal extends Block return this.getRenderColor(worldIn.getState(pos)); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(AXIS, (meta & 8) == 8 ? Facing.Axis.Z : Facing.Axis.X) - .withProperty(DIM, meta & 7); - } - protected Property[] getProperties() { return new Property[] {AXIS, DIM}; diff --git a/common/src/main/java/common/block/artificial/BlockPortalFrame.java b/common/src/main/java/common/block/artificial/BlockPortalFrame.java index 7b4d8705..c59580c0 100755 --- a/common/src/main/java/common/block/artificial/BlockPortalFrame.java +++ b/common/src/main/java/common/block/artificial/BlockPortalFrame.java @@ -107,14 +107,6 @@ public class BlockPortalFrame extends Block implements Rotatable return ((Boolean)worldIn.getState(pos).getValue(ORB)).booleanValue() ? 15 : 0; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(ORB, Boolean.valueOf((meta & 4) != 0)).withProperty(FACING, Facing.getHorizontal(meta & 3)); - } - protected Property[] getProperties() { return new Property[] {FACING, ORB}; diff --git a/common/src/main/java/common/block/artificial/BlockQuartzPillar.java b/common/src/main/java/common/block/artificial/BlockQuartzPillar.java index b8ca8a2f..8a494719 100644 --- a/common/src/main/java/common/block/artificial/BlockQuartzPillar.java +++ b/common/src/main/java/common/block/artificial/BlockQuartzPillar.java @@ -33,24 +33,6 @@ public class BlockQuartzPillar extends BlockRotatedPillar { return this.getState().withProperty(AXIS, facing.getAxis()); } - - public State getStateFromMeta(int meta) - { - State state = this.getState(); - switch (meta & 3) - { - default: - state = state.withProperty(AXIS, Facing.Axis.Y); - break; - case 1: - state = state.withProperty(AXIS, Facing.Axis.X); - break; - case 2: - state = state.withProperty(AXIS, Facing.Axis.Z); - break; - } - return state; - } protected Property[] getProperties() { diff --git a/common/src/main/java/common/block/artificial/BlockSkull.java b/common/src/main/java/common/block/artificial/BlockSkull.java index 6b307822..df7a2152 100755 --- a/common/src/main/java/common/block/artificial/BlockSkull.java +++ b/common/src/main/java/common/block/artificial/BlockSkull.java @@ -34,10 +34,6 @@ public class BlockSkull extends Block implements Rotatable { return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } - public State getStateFromMeta(int meta) { - return this.getState().withProperty(FACING, Facing.getHorizontal(meta)); - } - protected Property[] getProperties() { return new Property[] {FACING}; } diff --git a/common/src/main/java/common/block/artificial/BlockSlab.java b/common/src/main/java/common/block/artificial/BlockSlab.java index fbb0fd1c..be532f8e 100755 --- a/common/src/main/java/common/block/artificial/BlockSlab.java +++ b/common/src/main/java/common/block/artificial/BlockSlab.java @@ -55,14 +55,6 @@ public class BlockSlab extends Block implements Directional this.textureSide = side; SLABS.add(this); } - - public State getStateFromMeta(int meta) - { - meta = meta & 7; - return this.getState().withProperty(DOUBLE, meta >= 6).withProperty(SEAMLESS, meta == 7) - .withProperty(FACING, (meta == 0 || meta >= 6) ? Facing.DOWN : - (meta == 1 ? Facing.UP : Facing.getHorizontal(meta - 2))); - } protected Property[] getProperties() { diff --git a/common/src/main/java/common/block/artificial/BlockStairs.java b/common/src/main/java/common/block/artificial/BlockStairs.java index 73888e39..ea4f31ec 100755 --- a/common/src/main/java/common/block/artificial/BlockStairs.java +++ b/common/src/main/java/common/block/artificial/BlockStairs.java @@ -736,16 +736,6 @@ public class BlockStairs extends Block implements Rotatable return movingobjectposition1; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - State iblockstate = this.getState().withProperty(HALF, (meta & 4) > 0 ? BlockStairs.EnumHalf.TOP : BlockStairs.EnumHalf.BOTTOM); - iblockstate = iblockstate.withProperty(FACING, Facing.getFront(5 - (meta & 3))); - return iblockstate; - } - /** * Get the actual Block state of this Block at the given position. This applies properties not visible in the * metadata, such as fence connections. diff --git a/common/src/main/java/common/block/artificial/BlockTrapDoor.java b/common/src/main/java/common/block/artificial/BlockTrapDoor.java index ca8e72d0..4261eab8 100755 --- a/common/src/main/java/common/block/artificial/BlockTrapDoor.java +++ b/common/src/main/java/common/block/artificial/BlockTrapDoor.java @@ -257,14 +257,6 @@ public class BlockTrapDoor extends Block implements Rotatable return BlockLayer.CUTOUT; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(FACING, getFacing(meta)).withProperty(OPEN, Boolean.valueOf((meta & 4) != 0)).withProperty(HALF, (meta & 8) == 0 ? BlockTrapDoor.DoorHalf.BOTTOM : BlockTrapDoor.DoorHalf.TOP); - } - protected Property[] getProperties() { return new Property[] {FACING, OPEN, HALF}; diff --git a/common/src/main/java/common/block/foliage/BlockCactus.java b/common/src/main/java/common/block/foliage/BlockCactus.java index 268e767e..3613c652 100755 --- a/common/src/main/java/common/block/foliage/BlockCactus.java +++ b/common/src/main/java/common/block/foliage/BlockCactus.java @@ -145,14 +145,6 @@ public class BlockCactus extends Block return BlockLayer.CUTOUT; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(AGE, Integer.valueOf(meta)); - } - protected Property[] getProperties() { return new Property[] {AGE}; diff --git a/common/src/main/java/common/block/foliage/BlockCocoa.java b/common/src/main/java/common/block/foliage/BlockCocoa.java index aee6d9d9..8d531f36 100755 --- a/common/src/main/java/common/block/foliage/BlockCocoa.java +++ b/common/src/main/java/common/block/foliage/BlockCocoa.java @@ -200,14 +200,6 @@ public class BlockCocoa extends Block implements Rotatable, IGrowable return BlockLayer.CUTOUT; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(FACING, Facing.getHorizontal(meta)).withProperty(AGE, Integer.valueOf((meta & 12) == 12 ? 0 : ((meta & 12) >> 2))); - } - protected Property[] getProperties() { return new Property[] {FACING, AGE}; diff --git a/common/src/main/java/common/block/foliage/BlockCrops.java b/common/src/main/java/common/block/foliage/BlockCrops.java index c0294da8..4157a0a6 100755 --- a/common/src/main/java/common/block/foliage/BlockCrops.java +++ b/common/src/main/java/common/block/foliage/BlockCrops.java @@ -202,14 +202,6 @@ public class BlockCrops extends BlockBush implements IGrowable this.grow(worldIn, pos, state); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(AGE, Integer.valueOf(meta > 7 ? 0 : meta)); - } - protected Property[] getProperties() { return new Property[] {AGE}; diff --git a/common/src/main/java/common/block/foliage/BlockDoublePlant.java b/common/src/main/java/common/block/foliage/BlockDoublePlant.java index d92b04a0..322ebd45 100755 --- a/common/src/main/java/common/block/foliage/BlockDoublePlant.java +++ b/common/src/main/java/common/block/foliage/BlockDoublePlant.java @@ -256,14 +256,6 @@ public class BlockDoublePlant extends BlockBush implements IGrowable spawnAsEntity(worldIn, pos, new ItemStack(this.getItem())); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return (meta & 8) > 0 ? this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER) : this.getState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER); - } - protected Property[] getProperties() { return new Property[] {HALF}; diff --git a/common/src/main/java/common/block/foliage/BlockFarmland.java b/common/src/main/java/common/block/foliage/BlockFarmland.java index a10af9f7..4552ccc2 100755 --- a/common/src/main/java/common/block/foliage/BlockFarmland.java +++ b/common/src/main/java/common/block/foliage/BlockFarmland.java @@ -156,14 +156,6 @@ public class BlockFarmland extends Block return Items.dirt; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(MOISTURE, Integer.valueOf(meta & 7)); - } - protected Property[] getProperties() { return new Property[] {MOISTURE}; diff --git a/common/src/main/java/common/block/foliage/BlockHugeMushroom.java b/common/src/main/java/common/block/foliage/BlockHugeMushroom.java index bb8c78e1..4db30b67 100755 --- a/common/src/main/java/common/block/foliage/BlockHugeMushroom.java +++ b/common/src/main/java/common/block/foliage/BlockHugeMushroom.java @@ -79,14 +79,6 @@ public class BlockHugeMushroom extends Block return this.getState(); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(VARIANT, BlockHugeMushroom.EnumType.byMetadata(meta)); - } - protected Property[] getProperties() { return new Property[] {VARIANT}; diff --git a/common/src/main/java/common/block/foliage/BlockLeaves.java b/common/src/main/java/common/block/foliage/BlockLeaves.java index 0c1cc2ff..7fec8c86 100755 --- a/common/src/main/java/common/block/foliage/BlockLeaves.java +++ b/common/src/main/java/common/block/foliage/BlockLeaves.java @@ -304,10 +304,6 @@ public class BlockLeaves extends BlockLeavesBase == null ? Colorizer.getFoliageColor(worldIn, pos) : this.type.getTintType().getColor()); } - public State getStateFromMeta(int meta) { - return this.getState().withProperty(DECAY, Boolean.valueOf((meta & 8) == 0)); - } - protected Property[] getProperties() { return new Property[] {DECAY}; } diff --git a/common/src/main/java/common/block/foliage/BlockLilyPad.java b/common/src/main/java/common/block/foliage/BlockLilyPad.java index 81a64ba6..a665d5a6 100755 --- a/common/src/main/java/common/block/foliage/BlockLilyPad.java +++ b/common/src/main/java/common/block/foliage/BlockLilyPad.java @@ -81,16 +81,6 @@ public class BlockLilyPad extends BlockBush implements Rotatable return false; } } - -// public int getMetaFromState(IBlockState state) -// { -// return 0; -// } - - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(FACING, Facing.getHorizontal(meta)); - } protected Property[] getProperties() { diff --git a/common/src/main/java/common/block/foliage/BlockLog.java b/common/src/main/java/common/block/foliage/BlockLog.java index aa16b972..eca7705e 100755 --- a/common/src/main/java/common/block/foliage/BlockLog.java +++ b/common/src/main/java/common/block/foliage/BlockLog.java @@ -66,28 +66,6 @@ public class BlockLog extends BlockRotatedPillar .e().rot(90); } } - - public State getStateFromMeta(int meta) - { - State state = this.getState(); - - switch (meta & 3) - { - default: - state = state.withProperty(AXIS, Facing.Axis.Y); - break; - - case 1: - state = state.withProperty(AXIS, Facing.Axis.X); - break; - - case 2: - state = state.withProperty(AXIS, Facing.Axis.Z); - break; - } - - return state; - } protected Property[] getProperties() { diff --git a/common/src/main/java/common/block/foliage/BlockPumpkin.java b/common/src/main/java/common/block/foliage/BlockPumpkin.java index d3b4c9be..74e0d570 100755 --- a/common/src/main/java/common/block/foliage/BlockPumpkin.java +++ b/common/src/main/java/common/block/foliage/BlockPumpkin.java @@ -29,10 +29,6 @@ public class BlockPumpkin extends Block implements Rotatable { return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } - public State getStateFromMeta(int meta) { - return this.getState().withProperty(FACING, Facing.getHorizontal(meta)); - } - protected Property[] getProperties() { return new Property[] {FACING}; } diff --git a/common/src/main/java/common/block/foliage/BlockReed.java b/common/src/main/java/common/block/foliage/BlockReed.java index e791165b..191f7193 100755 --- a/common/src/main/java/common/block/foliage/BlockReed.java +++ b/common/src/main/java/common/block/foliage/BlockReed.java @@ -165,14 +165,6 @@ public class BlockReed extends Block return BlockLayer.CUTOUT; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(AGE, Integer.valueOf(meta)); - } - protected Property[] getProperties() { return new Property[] {AGE}; diff --git a/common/src/main/java/common/block/foliage/BlockSapling.java b/common/src/main/java/common/block/foliage/BlockSapling.java index 7b082d6d..10f3cf17 100755 --- a/common/src/main/java/common/block/foliage/BlockSapling.java +++ b/common/src/main/java/common/block/foliage/BlockSapling.java @@ -114,14 +114,6 @@ public class BlockSapling extends BlockBush implements IGrowable this.grow(worldIn, pos, state, rand); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState() /* .withProperty(TYPE, BlockPlanks.EnumType.byMetadata(meta & 7)) */ .withProperty(STAGE, meta & 1); - } - protected Property[] getProperties() { return new Property[] {STAGE}; diff --git a/common/src/main/java/common/block/foliage/BlockStem.java b/common/src/main/java/common/block/foliage/BlockStem.java index 9e9d448d..50316ce5 100755 --- a/common/src/main/java/common/block/foliage/BlockStem.java +++ b/common/src/main/java/common/block/foliage/BlockStem.java @@ -213,14 +213,6 @@ public class BlockStem extends BlockBush implements DirectionalUp, IGrowable this.growStem(worldIn, pos, state); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(AGE, Integer.valueOf(meta > 7 ? 0 : meta)); - } - protected Property[] getProperties() { return new Property[] {AGE, FACING}; diff --git a/common/src/main/java/common/block/foliage/BlockVine.java b/common/src/main/java/common/block/foliage/BlockVine.java index 8904bd83..15f00556 100755 --- a/common/src/main/java/common/block/foliage/BlockVine.java +++ b/common/src/main/java/common/block/foliage/BlockVine.java @@ -441,14 +441,6 @@ public class BlockVine extends Block return BlockLayer.CUTOUT; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(SOUTH, Boolean.valueOf((meta & 1) > 0)).withProperty(WEST, Boolean.valueOf((meta & 2) > 0)).withProperty(NORTH, Boolean.valueOf((meta & 4) > 0)).withProperty(EAST, Boolean.valueOf((meta & 8) > 0)); - } - protected Property[] getProperties() { return new Property[] {UP, NORTH, EAST, SOUTH, WEST}; diff --git a/common/src/main/java/common/block/foliage/BlockWart.java b/common/src/main/java/common/block/foliage/BlockWart.java index 144493fe..0a2fe850 100755 --- a/common/src/main/java/common/block/foliage/BlockWart.java +++ b/common/src/main/java/common/block/foliage/BlockWart.java @@ -108,14 +108,6 @@ public class BlockWart extends BlockBush return Items.soul_wart; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(AGE, Integer.valueOf(meta > 3 ? 0 : meta)); - } - protected Property[] getProperties() { return new Property[] {AGE}; diff --git a/common/src/main/java/common/block/liquid/BlockLiquid.java b/common/src/main/java/common/block/liquid/BlockLiquid.java index 5f1008e1..5b95adb5 100755 --- a/common/src/main/java/common/block/liquid/BlockLiquid.java +++ b/common/src/main/java/common/block/liquid/BlockLiquid.java @@ -378,14 +378,6 @@ public abstract class BlockLiquid extends Block } } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(LEVEL, Integer.valueOf(meta)); - } - protected Property[] getProperties() { return new Property[] {LEVEL}; diff --git a/common/src/main/java/common/block/natural/BlockFire.java b/common/src/main/java/common/block/natural/BlockFire.java index 3de59193..f6c761a1 100755 --- a/common/src/main/java/common/block/natural/BlockFire.java +++ b/common/src/main/java/common/block/natural/BlockFire.java @@ -437,14 +437,6 @@ public class BlockFire extends Block return BlockLayer.CUTOUT; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(AGE, Integer.valueOf(meta)); - } - protected Property[] getProperties() { return new Property[] {AGE, NORTH, EAST, SOUTH, WEST, UPPER, FLIP, ALT}; diff --git a/common/src/main/java/common/block/natural/BlockSnow.java b/common/src/main/java/common/block/natural/BlockSnow.java index b9c56207..5eeec18a 100755 --- a/common/src/main/java/common/block/natural/BlockSnow.java +++ b/common/src/main/java/common/block/natural/BlockSnow.java @@ -151,14 +151,6 @@ public class BlockSnow extends Block return side == Facing.UP ? true : super.shouldSideBeRendered(worldIn, pos, side); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(LAYERS, Integer.valueOf((meta & 7) + 1)); - } - /** * Whether this Block can be replaced directly by other blocks (true for e.g. tall grass) */ diff --git a/common/src/main/java/common/block/tech/BlockAnvil.java b/common/src/main/java/common/block/tech/BlockAnvil.java index e74bf4f3..cb82bd62 100755 --- a/common/src/main/java/common/block/tech/BlockAnvil.java +++ b/common/src/main/java/common/block/tech/BlockAnvil.java @@ -121,14 +121,6 @@ public class BlockAnvil extends BlockFalling implements Rotatable return this.getState().withProperty(FACING, Facing.SOUTH); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(FACING, Facing.getHorizontal(meta & 3)); - } - protected Property[] getProperties() { return new Property[] {FACING}; diff --git a/common/src/main/java/common/block/tech/BlockBrewingStand.java b/common/src/main/java/common/block/tech/BlockBrewingStand.java index 5f034f20..2176b03b 100755 --- a/common/src/main/java/common/block/tech/BlockBrewingStand.java +++ b/common/src/main/java/common/block/tech/BlockBrewingStand.java @@ -501,21 +501,6 @@ public class BlockBrewingStand extends BlockContainer return BlockLayer.CUTOUT; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - State iblockstate = this.getState(); - - for (int i = 0; i < 3; ++i) - { - iblockstate = iblockstate.withProperty(HAS_BOTTLE[i], Boolean.valueOf((meta & 1 << i) > 0)); - } - - return iblockstate; - } - protected Property[] getProperties() { return new Property[] {HAS_BOTTLE[0], HAS_BOTTLE[1], HAS_BOTTLE[2]}; diff --git a/common/src/main/java/common/block/tech/BlockButton.java b/common/src/main/java/common/block/tech/BlockButton.java index c106c88b..91b6cc5f 100755 --- a/common/src/main/java/common/block/tech/BlockButton.java +++ b/common/src/main/java/common/block/tech/BlockButton.java @@ -316,43 +316,6 @@ public class BlockButton extends Block implements Directional worldIn.notifyNeighborsOfStateChange(pos.offset(facing.getOpposite()), this); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - Facing enumfacing; - - switch (meta & 7) - { - case 0: - enumfacing = Facing.DOWN; - break; - - case 1: - enumfacing = Facing.EAST; - break; - - case 2: - enumfacing = Facing.WEST; - break; - - case 3: - enumfacing = Facing.SOUTH; - break; - - case 4: - enumfacing = Facing.NORTH; - break; - - case 5: - default: - enumfacing = Facing.UP; - } - - return this.getState().withProperty(FACING, enumfacing).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0)); - } - protected Property[] getProperties() { return new Property[] {FACING, POWERED}; diff --git a/common/src/main/java/common/block/tech/BlockCauldron.java b/common/src/main/java/common/block/tech/BlockCauldron.java index 1d274257..fcd2dfe9 100755 --- a/common/src/main/java/common/block/tech/BlockCauldron.java +++ b/common/src/main/java/common/block/tech/BlockCauldron.java @@ -643,14 +643,6 @@ public class BlockCauldron extends Block return ((Integer)worldIn.getState(pos).getValue(LEVEL)).intValue(); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(LEVEL, Integer.valueOf(meta > 3 ? 0 : meta)); - } - protected Property[] getProperties() { return new Property[] {LEVEL}; diff --git a/common/src/main/java/common/block/tech/BlockChest.java b/common/src/main/java/common/block/tech/BlockChest.java index 43f3d33b..19f40489 100755 --- a/common/src/main/java/common/block/tech/BlockChest.java +++ b/common/src/main/java/common/block/tech/BlockChest.java @@ -604,21 +604,6 @@ public class BlockChest extends BlockContainer implements Rotatable return Container.calcRedstoneFromInventory(this.getLockableContainer(worldIn, pos)); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - Facing enumfacing = Facing.getFront(meta); - - if (enumfacing.getAxis() == Facing.Axis.Y) - { - enumfacing = Facing.NORTH; - } - - return this.getState().withProperty(FACING, enumfacing); - } - protected Property[] getProperties() { return new Property[] {FACING}; diff --git a/common/src/main/java/common/block/tech/BlockDaylightDetector.java b/common/src/main/java/common/block/tech/BlockDaylightDetector.java index 1a6e361f..eb84deda 100755 --- a/common/src/main/java/common/block/tech/BlockDaylightDetector.java +++ b/common/src/main/java/common/block/tech/BlockDaylightDetector.java @@ -156,14 +156,6 @@ public class BlockDaylightDetector extends BlockContainer return new TileEntityDaylightDetector(); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(POWER, Integer.valueOf(meta)); - } - protected Property[] getProperties() { return new Property[] {POWER}; diff --git a/common/src/main/java/common/block/tech/BlockDispenser.java b/common/src/main/java/common/block/tech/BlockDispenser.java index ab5ea623..b526f5cc 100755 --- a/common/src/main/java/common/block/tech/BlockDispenser.java +++ b/common/src/main/java/common/block/tech/BlockDispenser.java @@ -274,14 +274,6 @@ public class BlockDispenser extends BlockContainer implements Directional return this.getState().withProperty(FACING, Facing.SOUTH); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(FACING, getFacing(meta)).withProperty(TRIGGERED, Boolean.valueOf((meta & 8) > 0)); - } - protected Property[] getProperties() { return new Property[] {FACING, TRIGGERED}; diff --git a/common/src/main/java/common/block/tech/BlockFurnace.java b/common/src/main/java/common/block/tech/BlockFurnace.java index e69aef68..4fe9f887 100755 --- a/common/src/main/java/common/block/tech/BlockFurnace.java +++ b/common/src/main/java/common/block/tech/BlockFurnace.java @@ -247,21 +247,6 @@ public class BlockFurnace extends BlockContainer implements Rotatable return this.getState().withProperty(FACING, Facing.SOUTH); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - Facing enumfacing = Facing.getFront(meta); - - if (enumfacing.getAxis() == Facing.Axis.Y) - { - enumfacing = Facing.NORTH; - } - - return this.getState().withProperty(FACING, enumfacing); - } - protected Property[] getProperties() { return new Property[] {FACING}; diff --git a/common/src/main/java/common/block/tech/BlockHopper.java b/common/src/main/java/common/block/tech/BlockHopper.java index a6eaddf1..92105e84 100755 --- a/common/src/main/java/common/block/tech/BlockHopper.java +++ b/common/src/main/java/common/block/tech/BlockHopper.java @@ -271,14 +271,6 @@ public class BlockHopper extends BlockContainer implements DirectionalDown return BlockLayer.CUTOUT_MIPPED; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(FACING, getFacing(((meta & 7) == 1 || (meta & 7) > 5) ? 0 : meta)).withProperty(ENABLED, Boolean.valueOf(isEnabled(meta))); - } - protected Property[] getProperties() { return new Property[] {FACING, ENABLED}; diff --git a/common/src/main/java/common/block/tech/BlockLever.java b/common/src/main/java/common/block/tech/BlockLever.java index 00e9edc5..2af9312b 100755 --- a/common/src/main/java/common/block/tech/BlockLever.java +++ b/common/src/main/java/common/block/tech/BlockLever.java @@ -249,14 +249,6 @@ public class BlockLever extends Block return true; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(FACING, BlockLever.EnumOrientation.byMetadata(meta & 7)).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0)); - } - protected Property[] getProperties() { return new Property[] {FACING, POWERED}; diff --git a/common/src/main/java/common/block/tech/BlockMachine.java b/common/src/main/java/common/block/tech/BlockMachine.java index 339459bb..23760ed9 100755 --- a/common/src/main/java/common/block/tech/BlockMachine.java +++ b/common/src/main/java/common/block/tech/BlockMachine.java @@ -85,10 +85,6 @@ public abstract class BlockMachine extends Block implements Rotatable, ITileEnti return this.getState().withProperty(FACING, placer.getHorizontalFacing()); } - public State getStateFromMeta(int meta) { - return this.getState().withProperty(FACING, Facing.getHorizontal(meta)); - } - protected Property[] getProperties() { return new Property[] {FACING}; } diff --git a/common/src/main/java/common/block/tech/BlockPistonBase.java b/common/src/main/java/common/block/tech/BlockPistonBase.java index 7394de33..c8e40eb4 100755 --- a/common/src/main/java/common/block/tech/BlockPistonBase.java +++ b/common/src/main/java/common/block/tech/BlockPistonBase.java @@ -679,14 +679,6 @@ public class BlockPistonBase extends Block implements Directional return this.getState().withProperty(FACING, Facing.UP); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(FACING, getFacing(meta)).withProperty(EXTENDED, Boolean.valueOf((meta & 8) > 0)); - } - protected Property[] getProperties() { return new Property[] {FACING, EXTENDED}; diff --git a/common/src/main/java/common/block/tech/BlockPistonHead.java b/common/src/main/java/common/block/tech/BlockPistonHead.java index 054580e4..add4e4b6 100755 --- a/common/src/main/java/common/block/tech/BlockPistonHead.java +++ b/common/src/main/java/common/block/tech/BlockPistonHead.java @@ -230,14 +230,6 @@ public class BlockPistonHead extends Block implements Directional return worldIn.getState(pos).getValue(TYPE) == BlockPistonHead.EnumPistonType.STICKY ? Items.sticky_piston : Items.piston; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(FACING, getFacing(meta)).withProperty(TYPE, (meta & 8) > 0 ? BlockPistonHead.EnumPistonType.STICKY : BlockPistonHead.EnumPistonType.DEFAULT); - } - protected Property[] getProperties() { return new Property[] {FACING, TYPE, SHORT}; diff --git a/common/src/main/java/common/block/tech/BlockPistonMoving.java b/common/src/main/java/common/block/tech/BlockPistonMoving.java index 479e42e6..558c7503 100755 --- a/common/src/main/java/common/block/tech/BlockPistonMoving.java +++ b/common/src/main/java/common/block/tech/BlockPistonMoving.java @@ -282,14 +282,6 @@ public class BlockPistonMoving extends BlockContainer return null; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(FACING, BlockPistonHead.getFacing(meta)).withProperty(TYPE, (meta & 8) > 0 ? BlockPistonHead.EnumPistonType.STICKY : BlockPistonHead.EnumPistonType.DEFAULT); - } - protected Property[] getProperties() { return new Property[] {FACING, TYPE}; diff --git a/common/src/main/java/common/block/tech/BlockPressurePlate.java b/common/src/main/java/common/block/tech/BlockPressurePlate.java index 2eb17df8..373077e0 100755 --- a/common/src/main/java/common/block/tech/BlockPressurePlate.java +++ b/common/src/main/java/common/block/tech/BlockPressurePlate.java @@ -67,14 +67,6 @@ public class BlockPressurePlate extends BlockBasePressurePlate return 0; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(POWERED, Boolean.valueOf(meta == 1)); - } - protected Property[] getProperties() { return new Property[] {POWERED}; diff --git a/common/src/main/java/common/block/tech/BlockPressurePlateWeighted.java b/common/src/main/java/common/block/tech/BlockPressurePlateWeighted.java index 64d5acf2..90009041 100755 --- a/common/src/main/java/common/block/tech/BlockPressurePlateWeighted.java +++ b/common/src/main/java/common/block/tech/BlockPressurePlateWeighted.java @@ -54,14 +54,6 @@ public class BlockPressurePlateWeighted extends BlockBasePressurePlate return 10; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(POWER, Integer.valueOf(meta)); - } - protected Property[] getProperties() { return new Property[] {POWER}; diff --git a/common/src/main/java/common/block/tech/BlockRail.java b/common/src/main/java/common/block/tech/BlockRail.java index c5f77876..b7d42d5b 100755 --- a/common/src/main/java/common/block/tech/BlockRail.java +++ b/common/src/main/java/common/block/tech/BlockRail.java @@ -30,14 +30,6 @@ public class BlockRail extends BlockRailBase return SHAPE; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(SHAPE, BlockRailBase.EnumRailDirection.byMetadata(meta)); - } - protected Property[] getProperties() { return new Property[] {SHAPE}; diff --git a/common/src/main/java/common/block/tech/BlockRailDetector.java b/common/src/main/java/common/block/tech/BlockRailDetector.java index 126e33d6..e1e032d5 100755 --- a/common/src/main/java/common/block/tech/BlockRailDetector.java +++ b/common/src/main/java/common/block/tech/BlockRailDetector.java @@ -176,14 +176,6 @@ public class BlockRailDetector extends BlockRailBase return new BoundingBox((double)((float)pos.getX() + 0.2F), (double)pos.getY(), (double)((float)pos.getZ() + 0.2F), (double)((float)(pos.getX() + 1) - 0.2F), (double)((float)(pos.getY() + 1) - 0.2F), (double)((float)(pos.getZ() + 1) - 0.2F)); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(SHAPE, BlockRailBase.EnumRailDirection.byMetadata((meta & 7) > 5 ? 0 : (meta & 7))).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0)); - } - protected Property[] getProperties() { return new Property[] {SHAPE, POWERED}; diff --git a/common/src/main/java/common/block/tech/BlockRailPowered.java b/common/src/main/java/common/block/tech/BlockRailPowered.java index cc62294e..f8cc7adc 100755 --- a/common/src/main/java/common/block/tech/BlockRailPowered.java +++ b/common/src/main/java/common/block/tech/BlockRailPowered.java @@ -163,14 +163,6 @@ public class BlockRailPowered extends BlockRailBase return SHAPE; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(SHAPE, BlockRailBase.EnumRailDirection.byMetadata((meta & 7) > 5 ? 0 : (meta & 7))).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0)); - } - protected Property[] getProperties() { return new Property[] {SHAPE, POWERED}; diff --git a/common/src/main/java/common/block/tech/BlockRedstoneComparator.java b/common/src/main/java/common/block/tech/BlockRedstoneComparator.java index d45048ed..2650229c 100755 --- a/common/src/main/java/common/block/tech/BlockRedstoneComparator.java +++ b/common/src/main/java/common/block/tech/BlockRedstoneComparator.java @@ -274,14 +274,6 @@ public class BlockRedstoneComparator extends BlockRedstoneDiode implements ITile return new TileEntityComparator(); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(FACING, Facing.getHorizontal(meta)).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0)).withProperty(MODE, (meta & 4) > 0 ? BlockRedstoneComparator.Mode.SUBTRACT : BlockRedstoneComparator.Mode.COMPARE); - } - protected Property[] getProperties() { return new Property[] {FACING, MODE, POWERED}; diff --git a/common/src/main/java/common/block/tech/BlockRedstoneRepeater.java b/common/src/main/java/common/block/tech/BlockRedstoneRepeater.java index 0d83b6fe..f8783947 100755 --- a/common/src/main/java/common/block/tech/BlockRedstoneRepeater.java +++ b/common/src/main/java/common/block/tech/BlockRedstoneRepeater.java @@ -136,14 +136,6 @@ public class BlockRedstoneRepeater extends BlockRedstoneDiode this.notifyNeighbors(worldIn, pos, state); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(FACING, Facing.getHorizontal(meta)).withProperty(LOCKED, Boolean.valueOf(false)).withProperty(DELAY, Integer.valueOf(1 + (meta >> 2))); - } - protected Property[] getProperties() { return new Property[] {FACING, DELAY, LOCKED}; diff --git a/common/src/main/java/common/block/tech/BlockRedstoneWire.java b/common/src/main/java/common/block/tech/BlockRedstoneWire.java index 7d4ec7d1..a977d246 100755 --- a/common/src/main/java/common/block/tech/BlockRedstoneWire.java +++ b/common/src/main/java/common/block/tech/BlockRedstoneWire.java @@ -803,14 +803,6 @@ public class BlockRedstoneWire extends Block return BlockLayer.CUTOUT; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(POWER, Integer.valueOf(meta)); - } - protected Property[] getProperties() { return new Property[] {NORTH, EAST, SOUTH, WEST, POWER}; diff --git a/common/src/main/java/common/block/tech/BlockTNT.java b/common/src/main/java/common/block/tech/BlockTNT.java index be3bff6a..b7d5cc51 100755 --- a/common/src/main/java/common/block/tech/BlockTNT.java +++ b/common/src/main/java/common/block/tech/BlockTNT.java @@ -158,14 +158,6 @@ public class BlockTNT extends Block return false; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(EXPLODE, Boolean.valueOf((meta & 1) > 0)); - } - protected Property[] getProperties() { return new Property[] {EXPLODE}; diff --git a/common/src/main/java/common/block/tech/BlockTorch.java b/common/src/main/java/common/block/tech/BlockTorch.java index 0af989df..6ae65af8 100755 --- a/common/src/main/java/common/block/tech/BlockTorch.java +++ b/common/src/main/java/common/block/tech/BlockTorch.java @@ -244,39 +244,6 @@ public class BlockTorch extends Block implements DirectionalUp return BlockLayer.CUTOUT; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - State iblockstate = this.getState(); - - switch (meta) - { - case 1: - iblockstate = iblockstate.withProperty(FACING, Facing.EAST); - break; - - case 2: - iblockstate = iblockstate.withProperty(FACING, Facing.WEST); - break; - - case 3: - iblockstate = iblockstate.withProperty(FACING, Facing.SOUTH); - break; - - case 4: - iblockstate = iblockstate.withProperty(FACING, Facing.NORTH); - break; - - case 5: - default: - iblockstate = iblockstate.withProperty(FACING, Facing.UP); - } - - return iblockstate; - } - protected Property[] getProperties() { return new Property[] {FACING}; diff --git a/common/src/main/java/common/block/tech/BlockTripWire.java b/common/src/main/java/common/block/tech/BlockTripWire.java index 398a134d..293bdacc 100755 --- a/common/src/main/java/common/block/tech/BlockTripWire.java +++ b/common/src/main/java/common/block/tech/BlockTripWire.java @@ -264,14 +264,6 @@ public class BlockTripWire extends Block } } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(POWERED, Boolean.valueOf((meta & 1) > 0)).withProperty(SUSPENDED, Boolean.valueOf((meta & 2) > 0)).withProperty(ATTACHED, Boolean.valueOf((meta & 4) > 0)).withProperty(DISARMED, Boolean.valueOf((meta & 8) > 0)); - } - protected Property[] getProperties() { return new Property[] {POWERED, SUSPENDED, ATTACHED, DISARMED, NORTH, EAST, WEST, SOUTH}; diff --git a/common/src/main/java/common/block/tech/BlockTripWireHook.java b/common/src/main/java/common/block/tech/BlockTripWireHook.java index 77024a15..9f6d184b 100755 --- a/common/src/main/java/common/block/tech/BlockTripWireHook.java +++ b/common/src/main/java/common/block/tech/BlockTripWireHook.java @@ -342,14 +342,6 @@ public class BlockTripWireHook extends Block implements Rotatable return BlockLayer.CUTOUT_MIPPED; } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(FACING, Facing.getHorizontal(meta & 3)).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0)).withProperty(ATTACHED, Boolean.valueOf((meta & 4) > 0)); - } - protected Property[] getProperties() { return new Property[] {FACING, POWERED, ATTACHED, SUSPENDED}; diff --git a/common/src/main/java/common/block/tech/BlockWarpChest.java b/common/src/main/java/common/block/tech/BlockWarpChest.java index 4d6c5191..e89180af 100755 --- a/common/src/main/java/common/block/tech/BlockWarpChest.java +++ b/common/src/main/java/common/block/tech/BlockWarpChest.java @@ -131,21 +131,6 @@ public class BlockWarpChest extends Block implements Rotatable } } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - Facing enumfacing = Facing.getFront(meta); - - if (enumfacing.getAxis() == Facing.Axis.Y) - { - enumfacing = Facing.NORTH; - } - - return this.getState().withProperty(FACING, enumfacing); - } - protected Property[] getProperties() { return new Property[] {FACING}; diff --git a/common/src/main/java/common/block/tile/BlockBannerHanging.java b/common/src/main/java/common/block/tile/BlockBannerHanging.java index 00256303..5e109966 100644 --- a/common/src/main/java/common/block/tile/BlockBannerHanging.java +++ b/common/src/main/java/common/block/tile/BlockBannerHanging.java @@ -59,18 +59,6 @@ public class BlockBannerHanging extends BlockBanner super.onNeighborBlockChange(worldIn, pos, state, neighborBlock); } - public State getStateFromMeta(int meta) - { - Facing enumfacing = Facing.getFront(meta); - - if (enumfacing.getAxis() == Facing.Axis.Y) - { - enumfacing = Facing.NORTH; - } - - return this.getState().withProperty(FACING, enumfacing); - } - protected Property[] getProperties() { return new Property[] {FACING}; diff --git a/common/src/main/java/common/block/tile/BlockBannerStanding.java b/common/src/main/java/common/block/tile/BlockBannerStanding.java index 7a50c147..b1002805 100644 --- a/common/src/main/java/common/block/tile/BlockBannerStanding.java +++ b/common/src/main/java/common/block/tile/BlockBannerStanding.java @@ -29,11 +29,6 @@ public class BlockBannerStanding extends BlockBanner super.onNeighborBlockChange(worldIn, pos, state, neighborBlock); } - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(ROTATION, Integer.valueOf(meta)); - } - protected Property[] getProperties() { return new Property[] {ROTATION}; diff --git a/common/src/main/java/common/block/tile/BlockStandingSign.java b/common/src/main/java/common/block/tile/BlockStandingSign.java index bbc45dfe..51e364e5 100755 --- a/common/src/main/java/common/block/tile/BlockStandingSign.java +++ b/common/src/main/java/common/block/tile/BlockStandingSign.java @@ -32,14 +32,6 @@ public class BlockStandingSign extends BlockSign super.onNeighborBlockChange(worldIn, pos, state, neighborBlock); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - return this.getState().withProperty(ROTATION, Integer.valueOf(meta)); - } - protected Property[] getProperties() { return new Property[] {ROTATION}; diff --git a/common/src/main/java/common/block/tile/BlockWallSign.java b/common/src/main/java/common/block/tile/BlockWallSign.java index 3922feaf..62590513 100755 --- a/common/src/main/java/common/block/tile/BlockWallSign.java +++ b/common/src/main/java/common/block/tile/BlockWallSign.java @@ -63,21 +63,6 @@ public class BlockWallSign extends BlockSign implements Rotatable super.onNeighborBlockChange(worldIn, pos, state, neighborBlock); } - /** - * Convert the given metadata into a BlockState for this Block - */ - public State getStateFromMeta(int meta) - { - Facing enumfacing = Facing.getFront(meta); - - if (enumfacing.getAxis() == Facing.Axis.Y) - { - enumfacing = Facing.NORTH; - } - - return this.getState().withProperty(FACING, enumfacing); - } - protected Property[] getProperties() { return new Property[] {FACING};