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)