diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 5ea46871..5f632f50 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -1497,8 +1497,6 @@ public class Client implements IThreadListener { return; } - int meta = 0; - boolean flag1 = false; Item item = null; if (this.pointed.type == HitPosition.ObjectType.BLOCK) @@ -1519,8 +1517,7 @@ public class Client implements IThreadListener { } Block block1 = item instanceof ItemBlock && !block.isPickStrict() ? item.getBlock() : block; - meta = block1.getDamageValue(this.world, blockpos); - flag1 = item.getHasSubtypes(); + // meta = block1.getDamageValue(this.world, blockpos); TODO: data } else { @@ -1535,9 +1532,9 @@ public class Client implements IThreadListener { InventoryPlayer inventoryplayer = this.player.inventory; - inventoryplayer.setCurrentItem(item, meta, flag1); + inventoryplayer.setCurrentItem(item); if(this.itemCheat) { - this.player.client.addToSendQueue(new CPacketCheat(new ItemStack(item, 1, meta), inventoryplayer.currentItem, this.ctrl())); + this.player.client.addToSendQueue(new CPacketCheat(new ItemStack(item), inventoryplayer.currentItem, this.ctrl())); } } } @@ -1957,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 + " (" + held.getMetadata() + ")" : "Gegens.: n/a") + "\n" + + "Gegens.: " + ItemRegistry.getNameFromItem(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/init/RenderRegistry.java b/client/src/main/java/client/init/RenderRegistry.java index 254989d7..e69fc53d 100644 --- a/client/src/main/java/client/init/RenderRegistry.java +++ b/client/src/main/java/client/init/RenderRegistry.java @@ -150,7 +150,7 @@ public abstract class RenderRegistry { map.put(EntityBoat.class, new RenderBoat(mgr)); map.put(EntityHook.class, new RenderFish(mgr)); map.put(EntityHorse.class, new RenderHorse(mgr, new ModelHorse())); - map.put(EntityDynamite.class, new RenderDynamite(mgr, Items.dynamite, ritem)); + map.put(EntityDynamite.class, new RenderDynamite(mgr, ritem)); map.put(EntityNuke.class, new RenderBlockEntity(mgr, Blocks.nuke.getState())); map.put(EntityMouse.class, new RenderMouse(mgr, new ModelMouse())); map.put(EntityDie.class, new RenderDie(mgr)); diff --git a/client/src/main/java/client/network/ClientPlayer.java b/client/src/main/java/client/network/ClientPlayer.java index 5981cfc5..e7914270 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), 1, 0); + player.inventory.mainInventory[player.inventory.currentItem] = new ItemStack(ItemRegistry.getItemById(i)); } player.setPositionAndRotation(x, y, z, yaw, pitch); diff --git a/client/src/main/java/client/renderer/ItemModelMesher.java b/client/src/main/java/client/renderer/ItemModelMesher.java index 619016bb..b8402af6 100755 --- a/client/src/main/java/client/renderer/ItemModelMesher.java +++ b/client/src/main/java/client/renderer/ItemModelMesher.java @@ -32,19 +32,13 @@ public class ItemModelMesher public TextureAtlasSprite getParticleIcon(Item item) { - return this.getParticleIcon(item, 0); - } - - public TextureAtlasSprite getParticleIcon(Item item, int meta) - { - return this.getItemModel(new ItemStack(item, 1, meta)).getBaseTexture(); + return this.getItemModel(new ItemStack(item)).getBaseTexture(); } public IBakedModel getItemModel(ItemStack stack) { Item item = stack.getItem(); - IBakedModel ibakedmodel = this.simpleShapesCache.get(Integer.valueOf(this.getIndex(item, - stack.isItemStackDamageable() ? 0 : stack.getMetadata()))); + IBakedModel ibakedmodel = this.simpleShapesCache.get(this.getIndex(item)); if (ibakedmodel == null) { @@ -64,9 +58,9 @@ public class ItemModelMesher return ibakedmodel; } - private int getIndex(Item item, int meta) + private int getIndex(Item item) { - return ItemRegistry.getIdFromItem(item) << 16 | meta; + return ItemRegistry.getIdFromItem(item); } // public void register(Item item, int meta, ResourceLocation location) @@ -122,9 +116,9 @@ public class ItemModelMesher continue; item.getRenderItems(item, stacks); for(ItemStack stack : stacks) { - this.simpleShapesCache.put(this.getIndex(item, stack.getMetadata()), + this.simpleShapesCache.put(this.getIndex(item), this.modelManager.getModel("item/" + - ItemRegistry.getNameFromItem(item).toString() + "#" + stack.getMetadata() + '#' + "inventory")); + ItemRegistry.getNameFromItem(item).toString() + '#' + "inventory")); } stacks.clear(); } diff --git a/client/src/main/java/client/renderer/blockmodel/ModelBakery.java b/client/src/main/java/client/renderer/blockmodel/ModelBakery.java index 3bd370d4..2e581db0 100755 --- a/client/src/main/java/client/renderer/blockmodel/ModelBakery.java +++ b/client/src/main/java/client/renderer/blockmodel/ModelBakery.java @@ -144,8 +144,8 @@ public abstract class ModelBakery // { item.getRenderItems(item, stacks); for(ItemStack stack : stacks) { - String resourcelocation = "item/" + ItemRegistry.getNameFromItem(item).toString() + "#" + stack.getMetadata() + '#' + "inventory"; - models.put(resourcelocation, (ModelBlock)item.getModel(ModelBlock.PROVIDER, ItemRegistry.getNameFromItem(item).toString(), stack.getMetadata())); + String resourcelocation = "item/" + ItemRegistry.getNameFromItem(item).toString() + '#' + "inventory"; + models.put(resourcelocation, (ModelBlock)item.getModel(ModelBlock.PROVIDER, ItemRegistry.getNameFromItem(item).toString())); itemLocations.add(resourcelocation); } stacks.clear(); diff --git a/client/src/main/java/client/renderer/entity/RenderDynamite.java b/client/src/main/java/client/renderer/entity/RenderDynamite.java index 376e2aeb..f23f318f 100755 --- a/client/src/main/java/client/renderer/entity/RenderDynamite.java +++ b/client/src/main/java/client/renderer/entity/RenderDynamite.java @@ -1,16 +1,16 @@ package client.renderer.entity; import common.entity.projectile.EntityDynamite; -import common.item.Item; +import common.init.ItemRegistry; import common.item.ItemStack; public class RenderDynamite extends RenderItemEntity { - public RenderDynamite(RenderManager renderManagerIn, Item itemIn, RenderItem renderItemIn) { - super(renderManagerIn, itemIn, renderItemIn); + public RenderDynamite(RenderManager renderManagerIn, RenderItem renderItemIn) { + super(renderManagerIn, null, renderItemIn); } public ItemStack getStack(EntityDynamite entityIn) { - return new ItemStack(this.item, 1, entityIn.explosionSize); + return new ItemStack(ItemRegistry.getRegisteredItem("dynamite" + (entityIn.explosionSize <= 0 || entityIn.explosionSize >= 8 ? "" : "_" + entityIn.explosionSize))); } } diff --git a/client/src/main/java/client/renderer/entity/RenderItemEntity.java b/client/src/main/java/client/renderer/entity/RenderItemEntity.java index 41da3446..2e660e43 100755 --- a/client/src/main/java/client/renderer/entity/RenderItemEntity.java +++ b/client/src/main/java/client/renderer/entity/RenderItemEntity.java @@ -39,7 +39,7 @@ public class RenderItemEntity extends Render public ItemStack getStack(T entityIn) { - return new ItemStack(this.item, 1, 0); + return new ItemStack(this.item); } protected String getEntityTexture(Entity entity) diff --git a/client/src/main/java/client/renderer/particle/EntityBreakingFX.java b/client/src/main/java/client/renderer/particle/EntityBreakingFX.java index fb192367..7e408b49 100755 --- a/client/src/main/java/client/renderer/particle/EntityBreakingFX.java +++ b/client/src/main/java/client/renderer/particle/EntityBreakingFX.java @@ -10,14 +10,9 @@ import common.world.World; public class EntityBreakingFX extends EntityFX { - protected EntityBreakingFX(World worldIn, double posXIn, double posYIn, double posZIn, Item p_i1195_8_) + protected EntityBreakingFX(World worldIn, double posXIn, double posYIn, double posZIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, Item p_i1197_14_) { - this(worldIn, posXIn, posYIn, posZIn, p_i1195_8_, 0); - } - - protected EntityBreakingFX(World worldIn, double posXIn, double posYIn, double posZIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, Item p_i1197_14_, int p_i1197_15_) - { - this(worldIn, posXIn, posYIn, posZIn, p_i1197_14_, p_i1197_15_); + this(worldIn, posXIn, posYIn, posZIn, p_i1197_14_); this.motionX *= 0.10000000149011612D; this.motionY *= 0.10000000149011612D; this.motionZ *= 0.10000000149011612D; @@ -26,10 +21,10 @@ public class EntityBreakingFX extends EntityFX this.motionZ += zSpeedIn; } - protected EntityBreakingFX(World worldIn, double posXIn, double posYIn, double posZIn, Item p_i1196_8_, int p_i1196_9_) + protected EntityBreakingFX(World worldIn, double posXIn, double posYIn, double posZIn, Item p_i1196_8_) { super(worldIn, posXIn, posYIn, posZIn, 0.0D, 0.0D, 0.0D); - this.setParticleIcon(Client.CLIENT.getRenderItem().getItemModelMesher().getParticleIcon(p_i1196_8_, p_i1196_9_)); + this.setParticleIcon(Client.CLIENT.getRenderItem().getItemModelMesher().getParticleIcon(p_i1196_8_)); this.particleRed = this.particleGreen = this.particleBlue = 1.0F; this.particleGravity = 1.0F; // Blocks.snow.particleGravity; this.particleScale /= 2.0F; @@ -75,8 +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_) { - int i = p_178902_15_.length > 1 ? p_178902_15_[1] : 0; - return new EntityBreakingFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, ItemRegistry.getItemById(p_178902_15_[0]), i); + return new EntityBreakingFX(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, ItemRegistry.getItemById(p_178902_15_[0])); } } diff --git a/client/src/main/java/client/util/PlayerController.java b/client/src/main/java/client/util/PlayerController.java index e18d64fe..13103a48 100755 --- a/client/src/main/java/client/util/PlayerController.java +++ b/client/src/main/java/client/util/PlayerController.java @@ -189,8 +189,7 @@ public class PlayerController { if(this.stack != null && stack != null) { flag = stack.getItem() == this.stack.getItem() - && ItemStack.areItemStackTagsEqual(stack, this.stack) - && (stack.isItemStackDamageable() || stack.getMetadata() == this.stack.getMetadata()); + && ItemStack.areItemStackTagsEqual(stack, this.stack); } return pos.equals(this.position) && flag; diff --git a/client/src/main/java/client/world/WorldClient.java b/client/src/main/java/client/world/WorldClient.java index dbfdf905..e1e28f7a 100755 --- a/client/src/main/java/client/world/WorldClient.java +++ b/client/src/main/java/client/world/WorldClient.java @@ -653,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), data}); + 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)}); } ParticleType enumparticletypes = ParticleType.WATER_SPLASH; diff --git a/common/src/main/java/common/ai/EntityAIShareItems.java b/common/src/main/java/common/ai/EntityAIShareItems.java index a43c7927..ad9cc717 100755 --- a/common/src/main/java/common/ai/EntityAIShareItems.java +++ b/common/src/main/java/common/ai/EntityAIShareItems.java @@ -64,14 +64,14 @@ public class EntityAIShareItems extends EntityAIWatchClosest2 { int l = itemstack.size / 2; itemstack.size -= l; - itemstack1 = new ItemStack(item, l, itemstack.getMetadata()); + itemstack1 = new ItemStack(item, l); } else if (item == Items.wheats && itemstack.size > 5) { int j = itemstack.size / 2 / 3 * 3; int k = j / 3; itemstack.size -= j; - itemstack1 = new ItemStack(Items.bread, k, 0); + itemstack1 = new ItemStack(Items.bread, k); } if (itemstack.size <= 0) diff --git a/common/src/main/java/common/ai/EntityAITakePlace.java b/common/src/main/java/common/ai/EntityAITakePlace.java index 77413613..bfb255b6 100755 --- a/common/src/main/java/common/ai/EntityAITakePlace.java +++ b/common/src/main/java/common/ai/EntityAITakePlace.java @@ -6,7 +6,7 @@ import common.block.Block; import common.collect.Maps; import common.entity.npc.EntityNPC; import common.init.Blocks; -import common.init.ItemRegistry; +import common.item.Item; import common.item.ItemStack; import common.rng.Random; import common.util.BlockPos; @@ -17,45 +17,12 @@ import common.world.World; public class EntityAITakePlace extends EntityAIBase { - private static class StackKey { - public String item; - public int meta; - - public StackKey(String str) { - String[] tok = str.split(":", 2); - this.item = tok[0]; - this.meta = tok.length > 1 ? Integer.parseInt(tok[1]) : -1; - } - - public StackKey(ItemStack stack) { - this.item = ItemRegistry.getNameFromItem(stack.getItem()).toString(); - this.meta = stack.getItem().getMaxDamage() <= 0 ? stack.getMetadata() : -1; - } - -// public boolean isSame(ItemStack stack) { -// return this.item.equals(ItemRegistry.getNameFromItem(stack.getItem()).toString()) && -// (stack.getItem().getMaxDamage() > 0 || stack.getMetadata() == this.meta); -// } - - public boolean equals(Object other) { - return other instanceof StackKey && ((StackKey)other).item.equals(this.item) && ((StackKey)other).meta == this.meta; - } - - public int hashCode() { - return this.item.hashCode() ^ (this.meta << 8); - } - - public String toString() { - return this.item + (this.meta == -1 ? "" : (":" + this.meta)); - } - } - private static final Map STEALABLE = Maps.newHashMap(); - private static final Map PLACEABLE = Maps.newHashMap(); + private static final Map PLACEABLE = Maps.newHashMap(); private static void addPlaceable(State state, ItemStack stack) { STEALABLE.put(state, stack); - PLACEABLE.put(new StackKey(stack), state); + PLACEABLE.put(stack.getItem(), state); } private static void addPlaceable(Block block) { @@ -85,7 +52,7 @@ public class EntityAITakePlace extends EntityAIBase this.place = false; return this.entity.getRNG().chance(20); } - else if(this.entity.getRNG().chance(200) && PLACEABLE.containsKey(new StackKey(this.entity.getHeldItem()))) { + else if(this.entity.getRNG().chance(200) && PLACEABLE.containsKey(this.entity.getHeldItem().getItem())) { this.place = this.entity.getRNG().rarity(10); return true; } @@ -102,11 +69,11 @@ public class EntityAITakePlace extends EntityAIBase BlockPos blockpos = new BlockPos(i, j, k); if(this.place) { ItemStack stack = this.entity.getHeldItem(); - if(stack == null || !PLACEABLE.containsKey(new StackKey(this.entity.getHeldItem()))) + if(stack == null || !PLACEABLE.containsKey(this.entity.getHeldItem().getItem())) return; Block replace = world.getState(blockpos).getBlock(); Block below = world.getState(blockpos.down()).getBlock(); - State state = PLACEABLE.get(new StackKey(this.entity.getHeldItem())); + State state = PLACEABLE.get(this.entity.getHeldItem().getItem()); if (state.getBlock().canPlaceBlockAt(world, blockpos) && replace == Blocks.air && below != Blocks.air && below.isFullCube()) { diff --git a/common/src/main/java/common/block/Block.java b/common/src/main/java/common/block/Block.java index e7d2cc63..eeea0b81 100755 --- a/common/src/main/java/common/block/Block.java +++ b/common/src/main/java/common/block/Block.java @@ -852,14 +852,9 @@ public class Block { } public ItemStack createStackedBlock(State state) { - int i = 0; Item item = ItemRegistry.getItemFromBlock(this); - - if(item != null && item.getHasSubtypes()) { - i = this.getMetaFromState(state); - } - - return new ItemStack(item, 1, i); + // TODO: data + return new ItemStack(item); } public int quantityDroppedWithBonus(int fortune, Random random) { diff --git a/common/src/main/java/common/block/artificial/BlockHay.java b/common/src/main/java/common/block/artificial/BlockHay.java index eefc04f3..b2422bdd 100755 --- a/common/src/main/java/common/block/artificial/BlockHay.java +++ b/common/src/main/java/common/block/artificial/BlockHay.java @@ -68,7 +68,7 @@ public class BlockHay extends BlockRotatedPillar public ItemStack createStackedBlock(State state) { - return new ItemStack(ItemRegistry.getItemFromBlock(this), 1, 0); + return new ItemStack(ItemRegistry.getItemFromBlock(this)); } /** diff --git a/common/src/main/java/common/block/foliage/BlockCocoa.java b/common/src/main/java/common/block/foliage/BlockCocoa.java index 3f8e27c9..172b12a9 100755 --- a/common/src/main/java/common/block/foliage/BlockCocoa.java +++ b/common/src/main/java/common/block/foliage/BlockCocoa.java @@ -169,7 +169,7 @@ public class BlockCocoa extends BlockDirectional implements IGrowable for (int k = 0; k < j; ++k) { - spawnAsEntity(worldIn, pos, new ItemStack(Items.dye, 1, DyeColor.BROWN.getDyeDamage())); + spawnAsEntity(worldIn, pos, new ItemStack(Items.cocoa)); } } diff --git a/common/src/main/java/common/block/foliage/BlockCrops.java b/common/src/main/java/common/block/foliage/BlockCrops.java index db1806e4..826c0b58 100755 --- a/common/src/main/java/common/block/foliage/BlockCrops.java +++ b/common/src/main/java/common/block/foliage/BlockCrops.java @@ -163,7 +163,7 @@ public class BlockCrops extends BlockBush implements IGrowable { if (worldIn.rand.zrange(15) <= i) { - spawnAsEntity(worldIn, pos, new ItemStack(this.getSeed(), 1, 0)); + spawnAsEntity(worldIn, pos, new ItemStack(this.getSeed())); } } } diff --git a/common/src/main/java/common/block/foliage/BlockDeadBush.java b/common/src/main/java/common/block/foliage/BlockDeadBush.java index 9e24f13c..8fa7f144 100755 --- a/common/src/main/java/common/block/foliage/BlockDeadBush.java +++ b/common/src/main/java/common/block/foliage/BlockDeadBush.java @@ -62,7 +62,7 @@ public class BlockDeadBush extends BlockBush if (!worldIn.client && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemShears) { // player.triggerAchievement(StatRegistry.mineBlockStatArray[BlockRegistry.getIdFromBlock(this)]); - spawnAsEntity(worldIn, pos, new ItemStack(Blocks.deadbush, 1, 0)); + spawnAsEntity(worldIn, pos, new ItemStack(Blocks.deadbush)); } else { diff --git a/common/src/main/java/common/block/foliage/BlockVine.java b/common/src/main/java/common/block/foliage/BlockVine.java index 5e0b4e73..ffa56494 100755 --- a/common/src/main/java/common/block/foliage/BlockVine.java +++ b/common/src/main/java/common/block/foliage/BlockVine.java @@ -425,7 +425,7 @@ public class BlockVine extends Block if (!worldIn.client && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemShears) { // player.triggerAchievement(StatRegistry.mineBlockStatArray[BlockRegistry.getIdFromBlock(this)]); - spawnAsEntity(worldIn, pos, new ItemStack(Blocks.vine, 1, 0)); + spawnAsEntity(worldIn, pos, new ItemStack(Blocks.vine)); } else { diff --git a/common/src/main/java/common/block/natural/BlockOre.java b/common/src/main/java/common/block/natural/BlockOre.java index bcf4df17..790754c0 100755 --- a/common/src/main/java/common/block/natural/BlockOre.java +++ b/common/src/main/java/common/block/natural/BlockOre.java @@ -130,11 +130,6 @@ public class BlockOre extends Block return 0; } - public int damageDropped(State state) - { - return this.dropItem == null ? 0 : this.dropItem.getMetadata(); // this == Blocks.lapis_ore ? EnumDyeColor.BLUE.getDyeDamage() : 0; - } - public boolean isXrayVisible() { return true; diff --git a/common/src/main/java/common/block/natural/BlockSnow.java b/common/src/main/java/common/block/natural/BlockSnow.java index 4a412400..220b0266 100755 --- a/common/src/main/java/common/block/natural/BlockSnow.java +++ b/common/src/main/java/common/block/natural/BlockSnow.java @@ -115,7 +115,7 @@ public class BlockSnow extends Block public void harvestBlock(World worldIn, EntityNPC player, BlockPos pos, State state, TileEntity te) { - spawnAsEntity(worldIn, pos, new ItemStack(Items.snowball, ((Integer)state.getValue(LAYERS)).intValue() + 1, 0)); + spawnAsEntity(worldIn, pos, new ItemStack(Items.snowball, ((Integer)state.getValue(LAYERS)).intValue() + 1)); worldIn.setBlockToAir(pos); // player.triggerAchievement(StatRegistry.mineBlockStatArray[BlockRegistry.getIdFromBlock(this)]); } diff --git a/common/src/main/java/common/block/tech/BlockCauldron.java b/common/src/main/java/common/block/tech/BlockCauldron.java index 087c8652..0433d1cc 100755 --- a/common/src/main/java/common/block/tech/BlockCauldron.java +++ b/common/src/main/java/common/block/tech/BlockCauldron.java @@ -492,7 +492,7 @@ public class BlockCauldron extends Block int i = ((Integer)state.getValue(LEVEL)).intValue(); Item item = itemstack.getItem(); - if (item == Items.water_bucket && FluidRegistry.getStaticBlock(itemstack.getMetadata()) == Blocks.water) + if (item == Items.water_bucket) { if (i < 3) { @@ -513,7 +513,7 @@ public class BlockCauldron extends Block { // if (!playerIn.creative) // { - ItemStack itemstack2 = new ItemStack(Items.potion, 1, 0); + ItemStack itemstack2 = new ItemStack(Items.potion); if (!playerIn.inventory.addItemStackToInventory(itemstack2)) { diff --git a/common/src/main/java/common/block/tile/BlockBanner.java b/common/src/main/java/common/block/tile/BlockBanner.java index e34b8e8f..79c2fda8 100755 --- a/common/src/main/java/common/block/tile/BlockBanner.java +++ b/common/src/main/java/common/block/tile/BlockBanner.java @@ -121,7 +121,7 @@ public class BlockBanner extends BlockContainer if (tileentity instanceof TileEntityBanner) { - ItemStack itemstack = new ItemStack(Items.banner, 1, ((TileEntityBanner)tileentity).getBaseColor()); + ItemStack itemstack = new ItemStack(Items.banner); TagObject tag = new TagObject(); tileentity.writeTags(tag); tag.remove("x"); @@ -147,7 +147,7 @@ public class BlockBanner extends BlockContainer if (te instanceof TileEntityBanner) { TileEntityBanner tileentitybanner = (TileEntityBanner)te; - ItemStack itemstack = new ItemStack(Items.banner, 1, ((TileEntityBanner)te).getBaseColor()); + ItemStack itemstack = new ItemStack(Items.banner); TagObject tag = new TagObject(); TileEntityBanner.setBaseColorAndPatterns(tag, tileentitybanner.getBaseColor(), tileentitybanner.getPatterns()); itemstack.setTagInfo("BlockEntityTag", tag); diff --git a/common/src/main/java/common/entity/Entity.java b/common/src/main/java/common/entity/Entity.java index 15a3e9d9..a8490216 100755 --- a/common/src/main/java/common/entity/Entity.java +++ b/common/src/main/java/common/entity/Entity.java @@ -1629,7 +1629,7 @@ public abstract class Entity public EntityItem dropItemWithOffset(Item itemIn, int size, float offsetY) { - return this.entityDropItem(new ItemStack(itemIn, size, 0), offsetY); + return this.entityDropItem(new ItemStack(itemIn, size), offsetY); } /** diff --git a/common/src/main/java/common/entity/animal/EntityCow.java b/common/src/main/java/common/entity/animal/EntityCow.java index 4e14119b..62641f85 100755 --- a/common/src/main/java/common/entity/animal/EntityCow.java +++ b/common/src/main/java/common/entity/animal/EntityCow.java @@ -130,7 +130,7 @@ public class EntityCow extends EntityAnimal } else if (!player.inventory.addItemStackToInventory(new ItemStack(Items.milk_bucket))) { - player.dropPlayerItemWithRandomChoice(new ItemStack(Items.milk_bucket, 1, 0), false); + player.dropPlayerItemWithRandomChoice(new ItemStack(Items.milk_bucket), false); } return true; diff --git a/common/src/main/java/common/entity/animal/EntitySheep.java b/common/src/main/java/common/entity/animal/EntitySheep.java index a2250da5..2e227a97 100755 --- a/common/src/main/java/common/entity/animal/EntitySheep.java +++ b/common/src/main/java/common/entity/animal/EntitySheep.java @@ -26,6 +26,7 @@ import common.init.SoundEvent; import common.inventory.Container; import common.inventory.InventoryCrafting; import common.item.Item; +import common.item.ItemDye; import common.item.ItemShears; import common.item.ItemStack; import common.pathfinding.PathNavigateGround; @@ -75,8 +76,6 @@ public class EntitySheep extends EntityAnimal this.tasks.addTask(6, new EntityAIWander(this, 1.0D)); this.tasks.addTask(7, new EntityAIWatchClosest(this, null, 6.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); - this.inventoryCrafting.setInventorySlotContents(0, new ItemStack(Items.dye, 1, 0)); - this.inventoryCrafting.setInventorySlotContents(1, new ItemStack(Items.dye, 1, 0)); } protected void updateAITasks() @@ -350,28 +349,25 @@ public class EntitySheep extends EntityAnimal return livingdata; } - /** - * Attempts to mix both parent sheep to come up with a mixed dye color. - */ private DyeColor getDyeColorMixFromParents(EntityAnimal father, EntityAnimal mother) { - int i = ((EntitySheep)father).getFleeceColor().getDyeDamage(); - int j = ((EntitySheep)mother).getFleeceColor().getDyeDamage(); - this.inventoryCrafting.getStackInSlot(0).setItemDamage(i); - this.inventoryCrafting.getStackInSlot(1).setItemDamage(j); + DyeColor i = ((EntitySheep)father).getFleeceColor(); + DyeColor j = ((EntitySheep)mother).getFleeceColor(); + this.inventoryCrafting.setInventorySlotContents(0, new ItemStack(ItemDye.getByColor(i))); + this.inventoryCrafting.setInventorySlotContents(1, new ItemStack(ItemDye.getByColor(j))); ItemStack itemstack = CraftingRegistry.getMatching(this.inventoryCrafting, ((EntitySheep)father).worldObj); - int k; + DyeColor k; - if (itemstack != null && itemstack.getItem() == Items.dye) + if (itemstack != null && itemstack.getItem() instanceof ItemDye dye) { - k = itemstack.getMetadata(); + k = dye.getColor(); } else { k = this.worldObj.rand.chance() ? i : j; } - return DyeColor.byDyeDamage(k); + return k; } public float getEyeHeight() diff --git a/common/src/main/java/common/entity/animal/EntitySquid.java b/common/src/main/java/common/entity/animal/EntitySquid.java index 1650e154..20969ed6 100755 --- a/common/src/main/java/common/entity/animal/EntitySquid.java +++ b/common/src/main/java/common/entity/animal/EntitySquid.java @@ -119,7 +119,7 @@ public class EntitySquid extends EntityWaterMob for (int j = 0; j < i; ++j) { - this.entityDropItem(new ItemStack(Items.dye, 1, DyeColor.BLACK.getDyeDamage()), 0.0F); + this.entityDropItem(new ItemStack(Items.ink_sack), 0.0F); } } diff --git a/common/src/main/java/common/entity/animal/EntityWolf.java b/common/src/main/java/common/entity/animal/EntityWolf.java index cf694c07..8aa922b4 100755 --- a/common/src/main/java/common/entity/animal/EntityWolf.java +++ b/common/src/main/java/common/entity/animal/EntityWolf.java @@ -26,6 +26,7 @@ import common.entity.types.EntityTameable; import common.init.Items; import common.init.SoundEvent; import common.item.Item; +import common.item.ItemDye; import common.item.ItemFood; import common.item.ItemStack; import common.model.ParticleType; @@ -380,9 +381,9 @@ public class EntityWolf extends EntityTameable return true; } } - else if (itemstack.getItem() == Items.dye) + else if (itemstack.getItem() instanceof ItemDye dye) { - DyeColor enumdyecolor = DyeColor.byDyeDamage(itemstack.getMetadata()); + DyeColor enumdyecolor = dye.getColor(); if (enumdyecolor != this.getCollarColor()) { diff --git a/common/src/main/java/common/entity/item/EntityItem.java b/common/src/main/java/common/entity/item/EntityItem.java index 00e1f5af..dc0fcadb 100755 --- a/common/src/main/java/common/entity/item/EntityItem.java +++ b/common/src/main/java/common/entity/item/EntityItem.java @@ -67,7 +67,7 @@ public class EntityItem extends Entity // for(int z = 0; z < 8; z++) { ((AWorldServer)this.worldObj).spawnParticle(ParticleType.ITEM_CRACK, this.posX, this.posY, this.posZ, 8, this.rand.gaussian() * 0.15D, this.rand.doublev() * 0.2D, this.rand.gaussian() * 0.15D, 0.1f, - ItemRegistry.getIdFromItem(this.getEntityItem().getItem()), this.getEntityItem().getMetadata()); + ItemRegistry.getIdFromItem(this.getEntityItem().getItem())); // } this.worldObj.playAuxSFX(1023, this.getPosition(), 0); this.setDead(); @@ -233,10 +233,6 @@ public class EntityItem extends Entity { return false; } - else if (itemstack1.getItem().getHasSubtypes() && itemstack1.getMetadata() != itemstack.getMetadata()) - { - return false; - } else if (itemstack1.size < itemstack.size) { return other.combineItems(this); @@ -465,7 +461,7 @@ public class EntityItem extends Entity return this.getCustomNameTag(); String comp = super.getTypeName(); comp += " (" + this.getEntityItem().size + " * " + - ItemRegistry.getNameFromItem(this.getEntityItem().getItem()) + ":" + this.getEntityItem().getMetadata() + ")"; + ItemRegistry.getNameFromItem(this.getEntityItem().getItem()) + ")"; return comp; } diff --git a/common/src/main/java/common/entity/npc/EntityHuman.java b/common/src/main/java/common/entity/npc/EntityHuman.java index 77a4d3df..64c03d4e 100755 --- a/common/src/main/java/common/entity/npc/EntityHuman.java +++ b/common/src/main/java/common/entity/npc/EntityHuman.java @@ -105,7 +105,7 @@ public class EntityHuman extends EntityNPC { } public boolean isBreedingItem(ItemStack stack) { - return stack.getItem() == Items.golden_apple && stack.getMetadata() == 0; + return stack.getItem() == Items.golden_apple; } protected void updateAITasks() { diff --git a/common/src/main/java/common/entity/npc/EntityNPC.java b/common/src/main/java/common/entity/npc/EntityNPC.java index 74452db8..39fa2f46 100755 --- a/common/src/main/java/common/entity/npc/EntityNPC.java +++ b/common/src/main/java/common/entity/npc/EntityNPC.java @@ -1393,7 +1393,7 @@ public abstract class EntityNPC extends EntityLiving flag = itemsword.getDamageVsEntity() > itemsword1.getDamageVsEntity(); } else { - flag = stack.getMetadata() > old.getMetadata() || stack.hasTagCompound() && !old.hasTagCompound(); + flag = stack.getItemDamage() > old.getItemDamage() || stack.hasTagCompound() && !old.hasTagCompound(); } } else if(stack.getItem() instanceof ItemBow && old.getItem() instanceof ItemBow) { @@ -1420,7 +1420,7 @@ public abstract class EntityNPC extends EntityLiving flag = itemarmor.damageReduceAmount > itemarmor1.damageReduceAmount; } else { - flag = stack.getMetadata() > old.getMetadata() || stack.hasTagCompound() && !old.hasTagCompound(); + flag = stack.getItemDamage() > old.getItemDamage() || stack.hasTagCompound() && !old.hasTagCompound(); } } else { diff --git a/common/src/main/java/common/entity/projectile/EntityDie.java b/common/src/main/java/common/entity/projectile/EntityDie.java index bc655a67..3ed4dd63 100755 --- a/common/src/main/java/common/entity/projectile/EntityDie.java +++ b/common/src/main/java/common/entity/projectile/EntityDie.java @@ -5,6 +5,7 @@ import common.entity.npc.EntityNPC; import common.entity.types.EntityLiving; import common.entity.types.EntityThrowable; import common.entity.types.IObjectData; +import common.init.ItemRegistry; import common.init.Items; import common.init.SoundEvent; import common.item.ItemDie; @@ -125,8 +126,16 @@ public class EntityDie extends EntityThrowable implements IObjectData return meta; } + public boolean hasStackMeta() { + for(int z = 0; z < ItemDie.DIE_SIDES.length; z++) { + if(this.sides == ItemDie.DIE_SIDES[z]) + return true; + } + return false; + } + public ItemStack getStack() { - return new ItemStack(Items.die, 1, this.getStackMeta()); + return new ItemStack(this.hasStackMeta() ? ItemRegistry.getRegisteredItem("die_" + this.sides) : Items.die_6); } public boolean interactFirst(EntityNPC player) diff --git a/common/src/main/java/common/entity/projectile/EntityDynamite.java b/common/src/main/java/common/entity/projectile/EntityDynamite.java index e33b81e5..9024243e 100755 --- a/common/src/main/java/common/entity/projectile/EntityDynamite.java +++ b/common/src/main/java/common/entity/projectile/EntityDynamite.java @@ -50,7 +50,7 @@ public class EntityDynamite extends EntityThrowable implements IObjectData 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.dynamite), 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.getIdFromItem(ItemRegistry.getRegisteredItem("dynamite" + (this.explosionSize <= 0 || this.explosionSize >= 8 ? "" : "_" + this.explosionSize)))); } if (!this.worldObj.client) diff --git a/common/src/main/java/common/entity/projectile/EntityPotion.java b/common/src/main/java/common/entity/projectile/EntityPotion.java index bcee5498..37a51877 100755 --- a/common/src/main/java/common/entity/projectile/EntityPotion.java +++ b/common/src/main/java/common/entity/projectile/EntityPotion.java @@ -74,10 +74,10 @@ public class EntityPotion extends EntityThrowable implements IObjectData { if (this.potionDamage == null) { - this.potionDamage = new ItemStack(Items.potion, 1, 0); + this.potionDamage = new ItemStack(Items.potion); } - this.potionDamage.setItemDamage(potionId); + this.potionDamage.setMetadata(potionId); } /** @@ -87,7 +87,7 @@ public class EntityPotion extends EntityThrowable implements IObjectData { if (this.potionDamage == null) { - this.potionDamage = new ItemStack(Items.potion, 1, 0); + this.potionDamage = new ItemStack(Items.potion); } return this.potionDamage.getMetadata(); diff --git a/common/src/main/java/common/entity/projectile/FishConstants.java b/common/src/main/java/common/entity/projectile/FishConstants.java index 890d8c77..eb7dfee1 100644 --- a/common/src/main/java/common/entity/projectile/FishConstants.java +++ b/common/src/main/java/common/entity/projectile/FishConstants.java @@ -13,7 +13,7 @@ public abstract class FishConstants { new RngFishable(new ItemStack(Items.bone), 10), new RngFishable(new ItemStack(Items.potion), 10), new RngFishable(new ItemStack(Items.string), 5), (new RngFishable(new ItemStack(Items.fishing_rod), 2)).setMaxDamagePercent(0.9F), new RngFishable(new ItemStack(Items.bowl), 10), new RngFishable(new ItemStack(Items.stick), 5), - new RngFishable(new ItemStack(Items.dye, 10, DyeColor.BLACK.getDyeDamage()), 1), + new RngFishable(new ItemStack(Items.ink_sack, 10), 1), new RngFishable(new ItemStack(Blocks.tripwire_hook), 10), new RngFishable(new ItemStack(Items.rotten_flesh), 10)); public static final WeightedList FISHING_TREASURE = new WeightedList( new RngFishable(new ItemStack(Blocks.waterlily), 1), new RngFishable(new ItemStack(Items.name_tag), 1), @@ -22,8 +22,8 @@ public abstract class FishConstants { (new RngFishable(new ItemStack(Items.fishing_rod), 1)).setMaxDamagePercent(0.25F).setEnchantable(), (new RngFishable(new ItemStack(Items.book), 1)).setEnchantable()); public static final WeightedList FISH_TYPES = new WeightedList( - new RngFishable(new ItemStack(Items.fish, 1, ItemFishFood.FishType.COD.getMetadata()), 60), - new RngFishable(new ItemStack(Items.fish, 1, ItemFishFood.FishType.SALMON.getMetadata()), 25), - new RngFishable(new ItemStack(Items.fish, 1, ItemFishFood.FishType.CLOWNFISH.getMetadata()), 2), - new RngFishable(new ItemStack(Items.fish, 1, ItemFishFood.FishType.PUFFERFISH.getMetadata()), 13)); + new RngFishable(new ItemStack(Items.cod), 60), + new RngFishable(new ItemStack(Items.salmon), 25), + new RngFishable(new ItemStack(Items.clownfish), 2), + new RngFishable(new ItemStack(Items.pufferfish), 13)); } diff --git a/common/src/main/java/common/init/CraftingRegistry.java b/common/src/main/java/common/init/CraftingRegistry.java index d5d491f0..f75a1dc5 100755 --- a/common/src/main/java/common/init/CraftingRegistry.java +++ b/common/src/main/java/common/init/CraftingRegistry.java @@ -40,7 +40,7 @@ public abstract class CraftingRegistry }; private static final Object[][] COMPRESSED = new Object[][] { {Blocks.emerald_block, new ItemStack(Items.emerald, 9)}, - {Blocks.lapis_block, new ItemStack(Items.dye, 9, DyeColor.BLUE.getDyeDamage())}, + {Blocks.lapis_block, new ItemStack(Items.lapis_lazuli, 9)}, {Blocks.redstone_block, new ItemStack(Items.redstone, 9)}, {Blocks.coal_block, new ItemStack(Items.coal, 9, 0)}, {Blocks.hay_block, new ItemStack(Items.wheats, 9)}, @@ -291,7 +291,7 @@ public abstract class CraftingRegistry add(new ItemStack(Items.sugar, 1), "#", '#', Items.reeds); add(new ItemStack(Blocks.torch, 4), "X", "#", 'X', Items.coal, '#', Items.stick); - add(new ItemStack(Blocks.torch, 4), "X", "#", 'X', new ItemStack(Items.coal, 1, 1), '#', Items.stick); + add(new ItemStack(Blocks.torch, 4), "X", "#", 'X', Items.charcoal, '#', Items.stick); add(new ItemStack(Items.glass_bottle, 3), "# #", " # ", '#', Blocks.glass); add(new ItemStack(Blocks.rail, 16), "X X", "X#X", "X X", 'X', Items.iron_ingot, '#', Items.stick); add(new ItemStack(Blocks.golden_rail, 6), "X X", "X#X", "XRX", 'X', Items.gold_ingot, 'R', Items.redstone, '#', Items.stick); @@ -337,7 +337,7 @@ public abstract class CraftingRegistry add(new ItemStack(Blocks.anvil, 1), "III", " i ", "iii", 'I', Blocks.iron_block, 'i', Items.iron_ingot); addShapeless(new ItemStack(Items.charged_orb, 1), Items.orb, Items.blaze_powder); addShapeless(new ItemStack(Items.fire_charge, 3), Items.gunpowder, Items.blaze_powder, Items.coal); - addShapeless(new ItemStack(Items.fire_charge, 3), Items.gunpowder, Items.blaze_powder, new ItemStack(Items.coal, 1, 1)); + addShapeless(new ItemStack(Items.fire_charge, 3), Items.gunpowder, Items.blaze_powder, Items.charcoal); add(new ItemStack(Blocks.hopper), "I I", "ICI", " I ", 'I', Items.iron_ingot, 'C', Blocks.chest); @@ -422,7 +422,7 @@ public abstract class CraftingRegistry } else if (recipeComponents[i + 1] instanceof Block) { - itemstack = new ItemStack((Block)recipeComponents[i + 1], 1, 32767); + itemstack = new ItemStack((Block)recipeComponents[i + 1]); } else if (recipeComponents[i + 1] instanceof ItemStack) { @@ -608,9 +608,9 @@ public abstract class CraftingRegistry { ItemStack itemstack2 = inv.getStackInSlot(j); - if (itemstack2 != null && itemstack2.getItem() == Items.dye) + if (itemstack2 != null && itemstack2.getItem() instanceof ItemDye dye) { - k = itemstack2.getMetadata(); + k = dye.getColor().getDyeDamage(); break; } } @@ -713,7 +713,7 @@ public abstract class CraftingRegistry } else if (p_179533_1_.getSizeInventory() == tileentitybanner$enumbannerpattern.getCraftingLayers().length * tileentitybanner$enumbannerpattern.getCraftingLayers()[0].length()) { - int j = -1; + DyeColor j = null; for (int k = 0; k < p_179533_1_.getSizeInventory() && flag; ++k) { @@ -723,13 +723,13 @@ public abstract class CraftingRegistry if (itemstack1 != null && itemstack1.getItem() != Items.banner) { - if (itemstack1.getItem() != Items.dye) + if (!(itemstack1.getItem() instanceof ItemDye dye)) { flag = false; break; } - if (j != -1 && j != itemstack1.getMetadata()) + if (j != null && j != dye.getColor()) { flag = false; break; @@ -741,7 +741,7 @@ public abstract class CraftingRegistry break; } - j = itemstack1.getMetadata(); + j = dye.getColor(); } else if (tileentitybanner$enumbannerpattern.getCraftingLayers()[l].charAt(i1) != 32) { @@ -789,7 +789,7 @@ public abstract class CraftingRegistry return false; } - int j = TileEntityBanner.getBaseColor(itemstack2); + DyeColor j = TileEntityBanner.getBaseColor(itemstack2); boolean flag = TileEntityBanner.getPatterns(itemstack2) > 0; if (itemstack != null) @@ -1004,9 +1004,9 @@ public abstract class CraftingRegistry if (itemstack2 != null) { - if (itemstack2.getItem() == Items.dye) + if (itemstack2.getItem() instanceof ItemDye dye) { - list.add(ItemDye.dyeColors[itemstack2.getMetadata() & 15]); + list.add(ItemDye.dyeColors[dye.getColor().getDyeDamage()]); } else if (itemstack2.getItem() == Items.glowstone_dust) { @@ -1058,9 +1058,9 @@ public abstract class CraftingRegistry if (itemstack1 != null) { - if (itemstack1.getItem() == Items.dye) + if (itemstack1.getItem() instanceof ItemDye dye) { - list1.add(ItemDye.dyeColors[itemstack1.getMetadata() & 15]); + list1.add(ItemDye.dyeColors[dye.getColor().getDyeDamage()]); } else if (itemstack1.getItem() == Items.firework_charge) { @@ -1223,7 +1223,9 @@ public abstract class CraftingRegistry i1 = 0; } - return new ItemStack(itemstack2.getItem(), 1, i1); + ItemStack stack = new ItemStack(itemstack2.getItem()); + stack.setItemDamage(i1); + return stack; } } @@ -1347,12 +1349,12 @@ public abstract class CraftingRegistry } else { - if (itemstack1.getItem() != Items.dye) + if (!(itemstack1.getItem() instanceof ItemDye dye)) { return null; } - float[] afloat = EntitySheep.getDyeRgb(DyeColor.byDyeDamage(itemstack1.getMetadata())); + float[] afloat = EntitySheep.getDyeRgb(dye.getColor()); int l1 = (int)(afloat[0] * 255.0F); int i2 = (int)(afloat[1] * 255.0F); int j2 = (int)(afloat[2] * 255.0F); @@ -1524,11 +1526,6 @@ public abstract class CraftingRegistry { return false; } - - if (stack.getMetadata() != 32767 && stack.getMetadata() != ingredient.getMetadata()) - { - return false; - } } } } @@ -1621,7 +1618,7 @@ public abstract class CraftingRegistry for (ItemStack itemstack1 : list) { - if (itemstack.getItem() == itemstack1.getItem() && (itemstack1.getMetadata() == 32767 || itemstack.getMetadata() == itemstack1.getMetadata())) + if (itemstack.getItem() == itemstack1.getItem()) { flag = true; list.remove(itemstack1); diff --git a/common/src/main/java/common/init/DispenserRegistry.java b/common/src/main/java/common/init/DispenserRegistry.java index db74a2af..a1b588ba 100755 --- a/common/src/main/java/common/init/DispenserRegistry.java +++ b/common/src/main/java/common/init/DispenserRegistry.java @@ -62,29 +62,33 @@ public abstract class DispenserRegistry { return new EntityEgg(worldIn, position.getX(), position.getY(), position.getZ()); } }); - REGISTRY.putObject(Items.die, new BehaviorProjectileDispense() - { - protected IProjectile getProjectileEntity(World worldIn, IPosition position, ItemStack item) - { - return new EntityDie(worldIn, position.getX(), position.getY(), position.getZ(), - ItemDie.DIE_SIDES[ExtMath.clampi(item.getMetadata(), 0, ItemDie.DIE_SIDES.length - 1)]); - } - protected float getInaccuracy() - { - return super.getInaccuracy() * 5.0F; - } - protected float getVelocity() - { - return super.getVelocity() * 0.25F; - } - }); - REGISTRY.putObject(Items.dynamite, new BehaviorProjectileDispense() - { - protected IProjectile getProjectileEntity(World worldIn, IPosition position, ItemStack item) - { - return new EntityDynamite(worldIn, position.getX(), position.getY(), position.getZ(), item.getMetadata()); - } - }); + for(final int sides : ItemDie.DIE_SIDES) { + REGISTRY.putObject(ItemRegistry.getRegisteredItem("die_" + sides), new BehaviorProjectileDispense() + { + protected IProjectile getProjectileEntity(World worldIn, IPosition position, ItemStack item) + { + return new EntityDie(worldIn, position.getX(), position.getY(), position.getZ(), sides); + } + protected float getInaccuracy() + { + return super.getInaccuracy() * 5.0F; + } + protected float getVelocity() + { + return super.getVelocity() * 0.25F; + } + }); + } + for(int z = 0; z < 8; z++) { + final int power = z; + REGISTRY.putObject(ItemRegistry.getRegisteredItem("dynamite" + (power == 0 ? "" : "_" + power)), new BehaviorProjectileDispense() + { + protected IProjectile getProjectileEntity(World worldIn, IPosition position, ItemStack item) + { + return new EntityDynamite(worldIn, position.getX(), position.getY(), position.getZ(), power); + } + }); + } REGISTRY.putObject(Items.snowball, new BehaviorProjectileDispense() { protected IProjectile getProjectileEntity(World worldIn, IPosition position, ItemStack item) @@ -307,7 +311,7 @@ public abstract class DispenserRegistry { } else if (((TileEntityDispenser)source.getBlockTileEntity()).addItemStack(new ItemStack(item)) < 0) { - this.field_150840_b.dispense(source, new ItemStack(item, 1, 0)); + this.field_150840_b.dispense(source, new ItemStack(item)); } return stack; @@ -315,7 +319,7 @@ public abstract class DispenserRegistry { }); REGISTRY.putObject(Items.flint_and_steel, new BehaviorDefaultDispenseItem() { - private boolean field_150839_b = true; + private boolean success = true; protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) { World world = source.getWorld(); @@ -329,22 +333,24 @@ public abstract class DispenserRegistry { { stack.size = 0; } + this.success = true; } else if (world.getState(blockpos).getBlock() == Blocks.tnt) { Blocks.tnt.onBlockDestroyedByPlayer(world, blockpos, Blocks.tnt.getState().withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true))); world.setBlockToAir(blockpos); + this.success = true; } else { - this.field_150839_b = false; + this.success = false; } return stack; } protected void playDispenseSound(IBlockSource source) { - if (this.field_150839_b) + if (this.success) { source.getWorld().playAuxSFX(1000, source.getBlockPos(), 0); } @@ -354,59 +360,56 @@ public abstract class DispenserRegistry { } } }); - REGISTRY.putObject(Items.dye, new BehaviorDefaultDispenseItem() - { - private boolean field_150838_b = true; - protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) - { - if (DyeColor.WHITE == DyeColor.byDyeDamage(stack.getMetadata())) - { - World world = source.getWorld(); - BlockPos blockpos = source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata())); - - if (ItemDye.applyBonemeal(stack, world, blockpos)) - { - if (!world.client) - { - world.playAuxSFX(2005, blockpos, 0); - } - } - else - { - this.field_150838_b = false; - } - - return stack; - } - else - { - return super.dispenseStack(source, stack); - } - } - protected void playDispenseSound(IBlockSource source) - { - if (this.field_150838_b) - { - source.getWorld().playAuxSFX(1000, source.getBlockPos(), 0); - } - else - { - source.getWorld().playAuxSFX(1001, source.getBlockPos(), 0); - } - } - }); - REGISTRY.putObject(ItemRegistry.getItemFromBlock(Blocks.tnt), new BehaviorDefaultDispenseItem() + REGISTRY.putObject(ItemDye.getByColor(DyeColor.WHITE), new BehaviorDefaultDispenseItem() { + private boolean success = true; protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) { World world = source.getWorld(); BlockPos blockpos = source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata())); - EntityTnt entitytntprimed = new EntityTnt(world, (double)blockpos.getX() + 0.5D, (double)blockpos.getY(), (double)blockpos.getZ() + 0.5D, (EntityLiving)null, stack.getMetadata()); - world.spawnEntityInWorld(entitytntprimed); - world.playSoundAtEntity(entitytntprimed, SoundEvent.FUSE, 1.0F); - --stack.size; + + if (ItemDye.applyBonemeal(stack, world, blockpos)) + { + if (!world.client) + { + world.playAuxSFX(2005, blockpos, 0); + } + this.success = true; + } + else + { + this.success = false; + } + return stack; } + protected void playDispenseSound(IBlockSource source) + { + if (this.success) + { + source.getWorld().playAuxSFX(1000, source.getBlockPos(), 0); + } + else + { + source.getWorld().playAuxSFX(1001, source.getBlockPos(), 0); + } + } }); + for(int z = 0; z < 8; z++) { + final int power = z; + REGISTRY.putObject(ItemRegistry.getRegisteredItem("tnt" + (power == 0 ? "" : "_" + power)), new BehaviorDefaultDispenseItem() + { + protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) + { + World world = source.getWorld(); + BlockPos blockpos = source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata())); + EntityTnt entitytntprimed = new EntityTnt(world, (double)blockpos.getX() + 0.5D, (double)blockpos.getY(), (double)blockpos.getZ() + 0.5D, (EntityLiving)null, power); + world.spawnEntityInWorld(entitytntprimed); + world.playSoundAtEntity(entitytntprimed, SoundEvent.FUSE, 1.0F); + --stack.size; + return stack; + } + }); + } } } diff --git a/common/src/main/java/common/init/ItemRegistry.java b/common/src/main/java/common/init/ItemRegistry.java index 83b991e9..1b41b450 100755 --- a/common/src/main/java/common/init/ItemRegistry.java +++ b/common/src/main/java/common/init/ItemRegistry.java @@ -51,7 +51,6 @@ import common.item.ItemCarrotOnAStick; import common.item.ItemChargedOrb; import common.item.ItemChest; import common.item.ItemCloth; -import common.item.ItemCoal; import common.item.ItemColored; import common.item.ItemDie; import common.item.ItemDispenser; @@ -156,25 +155,10 @@ public abstract class ItemRegistry { public static ItemStack getFromIdName(String name, ItemStack def) { if(name == null) return def; - String[] tok = name.split(":"); - if(tok.length < 1 || tok.length > 2) - return def; - Item item = REGISTRY.getObject(tok[0]); + Item item = REGISTRY.getObject(name); if(item == null) return def; - short data = 0; - if(tok.length == 2) { - try { - int i = Integer.parseUnsignedInt(tok[1]); - if(i >= 32768) - return def; - data = (short)i; - } - catch(NumberFormatException e) { - return def; - } - } - return new ItemStack(item, 1, data); + return new ItemStack(item); } private static ItemBlock registerFlat(Block block) { @@ -328,7 +312,7 @@ public abstract class ItemRegistry { } })).setDisplay("Bruchsteinmauer")); // registerBlock(Blocks.wooden_button, new ItemButton(Blocks.wooden_button)); - registerBlock(Blocks.anvil, (new ItemAnvilBlock(Blocks.anvil)).setDisplay("Amboss")); + registerBlock(Blocks.anvil, (new ItemAnvilBlock(Blocks.anvil)).setDisplay("Amboss")); // ; , new String[] {"Amboss", "Leicht beschädigter Amboss", "Stark beschädigter Amboss"}); registerBlock(Blocks.trapped_chest, new ItemChest(Blocks.trapped_chest)); registerBlock(Blocks.light_weighted_pressure_plate, new ItemPressurePlate(Blocks.light_weighted_pressure_plate)); registerBlock(Blocks.heavy_weighted_pressure_plate, new ItemPressurePlate(Blocks.heavy_weighted_pressure_plate)); @@ -401,13 +385,13 @@ public abstract class ItemRegistry { .setColor(TextColor.RED)); for(EntityInfo egg : EntityRegistry.SPAWN_EGGS.values()) { registerItem(egg.id().toLowerCase() + "_spawner", (new ItemMonsterPlacer(egg.id())) - .setDisplay("Spawner").setMaxStackSize(ItemStack.MAX_SIZE)); + .setDisplay("Spawner").setMaxAmount(ItemStack.MAX_SIZE)); } for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) { for(CharacterInfo charinfo : species.chars) { if(charinfo.spawner) registerItem(charinfo.skin + "_spawner", (new ItemNpcSpawner(charinfo)).setDisplay("NSC-Spawner") - .setMaxStackSize(ItemStack.MAX_SIZE)); + .setMaxAmount(ItemStack.MAX_SIZE)); } } @@ -415,8 +399,8 @@ public abstract class ItemRegistry { 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).setMaxStackSize(128)); - registerItem("die", (new ItemDie()).setDisplay("Würfel").setMaxStackSize(128)); + registerItem("key", (new ItemKey()).setDisplay("Schlüssel").setTab(CheatTab.TOOLS).setMaxAmount(128)); + registerItem("die", (new ItemDie()).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)); @@ -428,23 +412,24 @@ public abstract class ItemRegistry { 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").setMaxStackSize(128)); + 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 Item()).setDisplay("Pfeil").setTab(CheatTab.COMBAT).setMaxStackSize(128)); - Item coal = (new ItemCoal()).setDisplay("Kohle"); + registerItem("arrow", (new Item()).setDisplay("Pfeil").setTab(CheatTab.COMBAT).setMaxAmount(128)); + Item coal = (new Item()).setDisplay("Kohle").setTab(CheatTab.METALS); registerItem("coal", coal); - registerItem("stick", (new ItemStick()).setDisplay("Stock").setTab(CheatTab.MATERIALS).setMaxStackSize(256)); + 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((new ItemSmallBlock(Blocks.string)).setDisplay("Faden").setTab(CheatTab.TECHNOLOGY).setMaxStackSize(1024)); - registerItem("feather", (new Item()).setDisplay("Feder").setTab(CheatTab.MATERIALS).setMaxStackSize(512)); - registerItem("gunpowder", (new Item()).setDisplay("Schwarzpulver").setPotionEffect(PotionHelper.gunpowderEffect).setTab(CheatTab.MATERIALS).setMaxStackSize(256)); - registerItem((new ItemSeeds(Blocks.wheat, Blocks.farmland)).setDisplay("Weizenkörner").setMaxStackSize(256)); - registerItem("wheats", (new Item()).setDisplay("Weizen").setTab(CheatTab.MATERIALS).setMaxStackSize(128)); + registerItem((new ItemSmallBlock(Blocks.string)).setDisplay("Faden").setTab(CheatTab.TECHNOLOGY).setMaxAmount(1024)); + 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((new ItemSeeds(Blocks.wheat, Blocks.farmland)).setDisplay("Weizenkörner").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).setMaxStackSize(128)); + 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) @@ -455,52 +440,52 @@ public abstract class ItemRegistry { // registerItem("lava_bucket", (new ItemBucket(Blocks.flowing_lava)).setUnlocalizedName("bucketLava").setContainerItem(bucket)); registerItem("saddle", (new ItemSaddle()).setDisplay("Sattel")); // registerItem("iron_door", (new ItemDoor(Blocks.iron_door)).setUnlocalizedName("doorIron")); - registerItem((new ItemRedstone()).setDisplay("Redstone").setPotionEffect(PotionHelper.redstoneEffect).setMaxStackSize(256)); - registerItem("snowball", (new ItemSnowball()).setDisplay("Schneeball").setMaxStackSize(128)); + registerItem((new ItemRedstone()).setDisplay("Redstone").setPotionEffect(PotionHelper.redstoneEffect).setMaxAmount(256)); + 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).setMaxStackSize(128)); - registerItem((new ItemSmallBlock(Blocks.reeds)).setDisplay("Zuckerrohr").setTab(CheatTab.PLANTS).setMaxStackSize(128)); - registerItem("paper", (new Item()).setDisplay("Papier").setTab(CheatTab.MATERIALS).setMaxStackSize(256)); + registerItem("clay_ball", (new Item()).setDisplay("Ton").setTab(CheatTab.MATERIALS).setMaxAmount(128)); + registerItem((new ItemSmallBlock(Blocks.reeds)).setDisplay("Zuckerrohr").setTab(CheatTab.PLANTS).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).setMaxStackSize(128)); - registerItem("egg", (new ItemEgg()).setDisplay("Ei").setMaxStackSize(128)); + 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).setMaxStackSize(256)); - registerItem("fish", (new ItemFishFood(false)).setDisplay("Fisch").setHasSubtypes(true)); - registerItem("cooked_fish", (new ItemFishFood(true)).setDisplay("Fisch").setHasSubtypes(true)); - Item dye = (new ItemDye()).setDisplay("Farbstoff").setMaxStackSize(512); + .setTab(CheatTab.MATERIALS).setMaxAmount(256)); + registerItem("fish", (new ItemFishFood(false)).setDisplay("Fisch")); + registerItem("cooked_fish", (new ItemFishFood(true)).setDisplay("Fisch")); + Item dye = (new ItemDye()).setDisplay("Farbstoff").setMaxAmount(512); registerItem("dye", dye); - registerItem("bone", (new ItemStick()).setDisplay("Knochen").setTab(CheatTab.MATERIALS).setMaxStackSize(128)); - registerItem("sugar", (new Item()).setDisplay("Zucker").setPotionEffect(PotionHelper.sugarEffect).setTab(CheatTab.MATERIALS).setMaxStackSize(512)); - registerItem((new ItemSmallBlock(Blocks.cake)).setMaxStackSize(1).setDisplay("Kuchen").setTab(CheatTab.DECORATION)); + 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((new ItemSmallBlock(Blocks.cake)).setMaxAmount(1).setDisplay("Kuchen").setTab(CheatTab.DECORATION)); registerItem((new ItemSmallBlock(Blocks.repeater)).setDisplay("Redstone-Verstärker").setTab(CheatTab.TECHNOLOGY)); - registerItem("cookie", (new ItemFood(2, false)).setDisplay("Keks").setMaxStackSize(128)); + registerItem("cookie", (new ItemFood(2, false)).setDisplay("Keks").setMaxAmount(128)); registerItem("melon", (new ItemFood(2, false)).setDisplay("Melone")); - registerItem((new ItemSeeds(Blocks.pumpkin_stem, Blocks.farmland)).setDisplay("Kürbiskerne").setMaxStackSize(256)); - registerItem((new ItemSeeds(Blocks.melon_stem, Blocks.farmland)).setDisplay("Melonenkerne").setMaxStackSize(256)); + registerItem((new ItemSeeds(Blocks.pumpkin_stem, Blocks.farmland)).setDisplay("Kürbiskerne").setMaxAmount(256)); + registerItem((new ItemSeeds(Blocks.melon_stem, Blocks.farmland)).setDisplay("Melonenkerne").setMaxAmount(256)); 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).setMaxStackSize(256)); - registerItem("ghast_tear", (new ItemTiny()).setDisplay("Ghastträne").setPotionEffect(PotionHelper.ghastTearEffect).setTab(CheatTab.MATERIALS).setMaxStackSize(256)); - registerItem("gold_nugget", (new ItemNugget()).setDisplay("Goldnugget").setTab(CheatTab.METALS).setMaxStackSize(256)); - registerItem((new ItemSeeds(Blocks.soul_wart, Blocks.soul_sand)).setDisplay("Seelenwarze").setPotionEffect("+4").setMaxStackSize(128)); + registerItem("blaze_rod", (new ItemRod()).setDisplay("Lohenrute").setTab(CheatTab.MATERIALS).setMaxAmount(256)); + registerItem("ghast_tear", (new ItemTiny()).setDisplay("Ghastträne").setPotionEffect(PotionHelper.ghastTearEffect).setTab(CheatTab.MATERIALS).setMaxAmount(256)); + registerItem("gold_nugget", (new ItemNugget()).setDisplay("Goldnugget").setTab(CheatTab.METALS).setMaxAmount(256)); + registerItem((new ItemSeeds(Blocks.soul_wart, Blocks.soul_sand)).setDisplay("Seelenwarze").setPotionEffect("+4").setMaxAmount(128)); registerItem("potion", (new ItemPotion()).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).setMaxStackSize(128)); + .setPotionEffect(PotionHelper.spiderEyeEffect).setMaxAmount(128)); registerItem("fermented_spider_eye", (new Item()).setDisplay("Fermentiertes Spinnenauge") - .setPotionEffect(PotionHelper.fermentedSpiderEyeEffect).setTab(CheatTab.MISC).setMaxStackSize(128)); + .setPotionEffect(PotionHelper.fermentedSpiderEyeEffect).setTab(CheatTab.MISC).setMaxAmount(128)); registerItem("blaze_powder", (new Item()).setDisplay("Lohenstaub").setPotionEffect(PotionHelper.blazePowderEffect) - .setTab(CheatTab.MATERIALS).setMaxStackSize(256)); - registerItem("magma_cream", (new Item()).setDisplay("Magmacreme").setPotionEffect(PotionHelper.magmaCreamEffect).setTab(CheatTab.MATERIALS).setMaxStackSize(128)); + .setTab(CheatTab.MATERIALS).setMaxAmount(256)); + registerItem("magma_cream", (new Item()).setDisplay("Magmacreme").setPotionEffect(PotionHelper.magmaCreamEffect).setTab(CheatTab.MATERIALS).setMaxAmount(128)); registerItem((new ItemSmallBlock(Blocks.brewing_stand)).setDisplay("Braustand").setTab(CheatTab.TECHNOLOGY)); registerItem((new ItemSmallBlock(Blocks.cauldron)).setDisplay("Kessel").setTab(CheatTab.TECHNOLOGY)); registerItem("charged_orb", (new ItemChargedOrb()).setDisplay("Geladene Kugel")); @@ -513,10 +498,10 @@ public abstract class ItemRegistry { Item emerald = (new Item()).setDisplay("Smaragd").setTab(CheatTab.METALS); registerItem("emerald", emerald); registerItem((new ItemSmallBlock(Blocks.flower_pot)).setDisplay("Blumentopf").setTab(CheatTab.DECORATION)); - registerItem((new ItemSeedFood(3, Blocks.carrot, Blocks.farmland)).setDisplay("Karotte").setMaxStackSize(128)); - registerItem((new ItemSeedFood(1, Blocks.potato, Blocks.farmland)).setDisplay("Kartoffel").setMaxStackSize(128)); - registerItem("baked_potato", (new ItemFood(5, false)).setDisplay("Ofenkartoffel").setMaxStackSize(128)); - registerItem("poisonous_potato", (new ItemFood(2, false)).setPotionEffect(Potion.POISON, 5, 0, 0.6F).setDisplay("Giftige Kartoffel").setMaxStackSize(128)); + registerItem((new ItemSeedFood(3, Blocks.carrot, Blocks.farmland)).setDisplay("Karotte").setMaxAmount(128)); + registerItem((new ItemSeedFood(1, Blocks.potato, Blocks.farmland)).setDisplay("Kartoffel").setMaxAmount(128)); + 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((new ItemSmallBlock(Blocks.skull)).setDisplay("Schädel").setTab(CheatTab.DECORATION)); @@ -525,7 +510,7 @@ public abstract class ItemRegistry { 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()).setMaxStackSize(1).setDisplay("Verzaubertes Buch").setTab(CheatTab.MAGIC)); + registerItem("enchanted_book", (new ItemEnchantedBook()).setMaxAmount(1).setDisplay("Verzaubertes Buch").setTab(CheatTab.MAGIC)); registerItem((new ItemSmallBlock(Blocks.comparator)).setDisplay("Redstone-Komparator").setTab(CheatTab.TECHNOLOGY)); registerItem("bloodbrick", (new Item()).setDisplay("Blutroter Ziegel").setTab(CheatTab.MATERIALS)); registerItem("blackbrick", (new Item()).setDisplay("Schwarzer Ziegel").setTab(CheatTab.MATERIALS)); @@ -533,7 +518,7 @@ public abstract class ItemRegistry { registerItem("quartz", quartz); Item bquartz = (new Item()).setDisplay("Schwarzes Quarz").setTab(CheatTab.METALS); registerItem("black_quartz", bquartz); - registerItem("lead", (new ItemLead()).setDisplay("Leine").setMaxStackSize(128)); + registerItem("lead", (new ItemLead()).setDisplay("Leine").setMaxAmount(128)); registerItem("name_tag", (new ItemNameTag()).setDisplay("Namensschild")); registerItem((new ItemBanner()).setDisplay("Banner")); // registerItem("spruce_door", (new ItemDoor(Blocks.spruce_door)).setUnlocalizedName("doorSpruce")); @@ -541,7 +526,9 @@ public abstract class ItemRegistry { // registerItem("jungle_door", (new ItemDoor(Blocks.jungle_door)).setUnlocalizedName("doorJungle")); // registerItem("acacia_door", (new ItemDoor(Blocks.acacia_door)).setUnlocalizedName("doorAcacia")); // registerItem("dark_oak_door", (new ItemDoor(Blocks.dark_oak_door)).setUnlocalizedName("doorDarkOak")); - registerItem("dynamite", (new ItemDynamite()).setDisplay("Dynamit").setColor(TextColor.RED)); + for(int z = 0; z < 8; z++) { + registerItem("dynamite", (new ItemDynamite(z)).setDisplay("Dynamit").setColor(TextColor.RED)); + } // registerItem("cherry_door", (new ItemDoor(Blocks.cherry_door)).setUnlocalizedName("doorCherry")); // registerItem("maple_door", (new ItemDoor(Blocks.maple_door)).setUnlocalizedName("doorMaple")); registerItem("chain", (new ItemMagnetic()).setDisplay("Kette").setTab(CheatTab.MATERIALS)); @@ -591,7 +578,7 @@ public abstract class ItemRegistry { registerItem(new ItemDoor(door)); // .setDisplay(door.getDisplay())); } for(DyeColor color : BlockBed.COLORS) { - registerItem(new ItemBed((BlockBed)BlockRegistry.getRegisteredBlock(color.getName() + "_bed")).setMaxStackSize(1).setDisplay(color.getSubject(0) + " Bett")); + registerItem(new ItemBed((BlockBed)BlockRegistry.getRegisteredBlock(color.getName() + "_bed")).setMaxAmount(1).setDisplay(color.getSubject(0) + " Bett")); } registerItem("record_13", (new ItemRecord()).setDisplay("Protokoll #1 - 13 Tage ohne Kaffee")); @@ -611,7 +598,7 @@ public abstract class ItemRegistry { ((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(dye, 4, DyeColor.BLUE.getDyeDamage()), 4, 2); + ((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); diff --git a/common/src/main/java/common/init/Items.java b/common/src/main/java/common/init/Items.java index ecd134e4..50054de8 100755 --- a/common/src/main/java/common/init/Items.java +++ b/common/src/main/java/common/init/Items.java @@ -163,7 +163,8 @@ public abstract class Items { public static final ItemArmor cloth_chestplate = get("cloth_chestplate"); public static final ItemArmor cloth_helmet = get("cloth_helmet"); public static final ItemArmor cloth_leggings = get("cloth_leggings"); - public static final ItemCoal coal = get("coal"); + public static final Item coal = get("coal"); + public static final Item charcoal = get("charcoal"); public static final ItemBlock coal_block = get("coal_block"); public static final ItemBlock coal_ore = get("coal_ore"); public static final ItemMetalBlock cobalt_block = get("cobalt_block"); diff --git a/common/src/main/java/common/init/SmeltingRegistry.java b/common/src/main/java/common/init/SmeltingRegistry.java index 4a316bc7..295815f5 100755 --- a/common/src/main/java/common/init/SmeltingRegistry.java +++ b/common/src/main/java/common/init/SmeltingRegistry.java @@ -20,7 +20,7 @@ public abstract class SmeltingRegistry private static boolean compareItemStacks(ItemStack stack1, ItemStack stack2) { - return stack2.getItem() == stack1.getItem() && (stack2.getMetadata() == 32767 || stack2.getMetadata() == stack1.getMetadata()); + return stack2.getItem() == stack1.getItem(); } static void register() @@ -35,10 +35,10 @@ public abstract class SmeltingRegistry // addSmelting(Items.rabbit, new ItemStack(Items.cooked_rabbit), 0.35F); // addSmelting(Items.mutton, new ItemStack(Items.cooked_mutton), 0.35F); add(Blocks.cobblestone, new ItemStack(Blocks.stone), 0.1F); - add(new ItemStack(Blocks.stonebrick, 1, BlockStoneBrick.DEFAULT_META), new ItemStack(Blocks.stonebrick, 1, BlockStoneBrick.CRACKED_META), 0.1F); + add(new ItemStack(Blocks.stonebrick), new ItemStack(Blocks.stonebrick_cracked), 0.1F); add(Items.clay_ball, new ItemStack(Items.brick), 0.3F); add(Blocks.clay, new ItemStack(Blocks.hardened_clay), 0.35F); - add(Blocks.cactus, new ItemStack(Items.dye, 1, DyeColor.GREEN.getDyeDamage()), 0.2F); + add(Blocks.cactus, new ItemStack(Items.cactus_green), 0.2F); add(Items.potato, new ItemStack(Items.baked_potato), 0.35F); add(Blocks.hellrock, new ItemStack(Items.bloodbrick), 0.1F); // add(new ItemStack(Blocks.sponge, 1, 1), new ItemStack(Blocks.sponge, 1, 0), 0.15F); @@ -53,7 +53,7 @@ public abstract class SmeltingRegistry add(Blocks.emerald_ore, new ItemStack(Items.emerald), 1.0F); add(Blocks.coal_ore, new ItemStack(Items.coal), 0.1F); - add(Blocks.lapis_ore, new ItemStack(Items.dye, 1, DyeColor.BLUE.getDyeDamage()), 0.2F); + add(Blocks.lapis_ore, new ItemStack(Items.lapis_lazuli), 0.2F); add(Blocks.quartz_ore, new ItemStack(Items.quartz), 0.2F); add(Blocks.redstone_ore, new ItemStack(Items.redstone), 0.7F); @@ -66,7 +66,7 @@ public abstract class SmeltingRegistry add(BlockRegistry.getRegisteredBlock(metal.name + "_ore"), new ItemStack(item), 0.7F); } for(WoodType wood : WoodType.values()) { - add(BlockRegistry.getRegisteredBlock(wood.getName() + "_log"), new ItemStack(Items.coal, 1, 1), 0.15F); + add(BlockRegistry.getRegisteredBlock(wood.getName() + "_log"), new ItemStack(Items.charcoal), 0.15F); // add(Blocks.log2, new ItemStack(Items.coal, 1, 1), 0.15F); } } @@ -78,7 +78,7 @@ public abstract class SmeltingRegistry private static void add(Item input, ItemStack stack, float experience) { - add(new ItemStack(input, 1, 32767), stack, experience); + add(new ItemStack(input), stack, experience); } private static void add(ItemStack input, ItemStack stack, float experience) diff --git a/common/src/main/java/common/init/TradeRegistry.java b/common/src/main/java/common/init/TradeRegistry.java index c9d13561..40b76fd9 100755 --- a/common/src/main/java/common/init/TradeRegistry.java +++ b/common/src/main/java/common/init/TradeRegistry.java @@ -142,7 +142,7 @@ public abstract class TradeRegistry { i = this.price.getPrice(random); } - recipeList.add(new MerchantRecipe(new ItemStack(this.sellItem, i, 0), Items.emerald)); + recipeList.add(new MerchantRecipe(new ItemStack(this.sellItem, i), Items.emerald)); } } @@ -172,8 +172,8 @@ public abstract class TradeRegistry { j = this.field_179408_d.getPrice(random); } - recipeList.add(new MerchantRecipe(new ItemStack(this.buyingItemStack.getItem(), i, this.buyingItemStack.getMetadata()), - new ItemStack(Items.emerald), new ItemStack(this.sellingItemstack.getItem(), j, this.sellingItemstack.getMetadata()))); + recipeList.add(new MerchantRecipe(new ItemStack(this.buyingItemStack.getItem(), i), + new ItemStack(Items.emerald), new ItemStack(this.sellingItemstack.getItem(), j))); } } @@ -208,8 +208,8 @@ public abstract class TradeRegistry { i = this.priceInfo.getPrice(random); } - ItemStack itemstack = new ItemStack(Items.emerald, i, 0); - ItemStack itemstack1 = new ItemStack(this.enchantedItemStack.getItem(), 1, this.enchantedItemStack.getMetadata()); + ItemStack itemstack = new ItemStack(Items.emerald, i); + ItemStack itemstack1 = new ItemStack(this.enchantedItemStack.getItem()); itemstack1 = EnchantmentHelper.addRandomEnchantment(random, itemstack1, random.range(5, 19)); recipeList.add(new MerchantRecipe(itemstack, itemstack1)); } @@ -240,12 +240,12 @@ public abstract class TradeRegistry { ItemStack itemstack1; if(i < 0) { - itemstack = new ItemStack(Items.emerald, 1, 0); - itemstack1 = new ItemStack(this.itemToBuy.getItem(), -i, this.itemToBuy.getMetadata()); + itemstack = new ItemStack(Items.emerald); + itemstack1 = new ItemStack(this.itemToBuy.getItem(), -i); } else { - itemstack = new ItemStack(Items.emerald, i, 0); - itemstack1 = new ItemStack(this.itemToBuy.getItem(), 1, this.itemToBuy.getMetadata()); + itemstack = new ItemStack(Items.emerald, i); + itemstack1 = new ItemStack(this.itemToBuy.getItem()); } recipeList.add(new MerchantRecipe(itemstack, itemstack1)); diff --git a/common/src/main/java/common/inventory/Container.java b/common/src/main/java/common/inventory/Container.java index 59197f1e..c1c0cbe8 100755 --- a/common/src/main/java/common/inventory/Container.java +++ b/common/src/main/java/common/inventory/Container.java @@ -327,7 +327,7 @@ public abstract class Container } else if (slot7.isItemValid(itemstack10)) { - if (itemstack9.getItem() == itemstack10.getItem() && itemstack9.getMetadata() == itemstack10.getMetadata() && ItemStack.areItemStackTagsEqual(itemstack9, itemstack10)) + if (itemstack9.getItem() == itemstack10.getItem() && ItemStack.areItemStackTagsEqual(itemstack9, itemstack10)) { int i2 = clickedButton == 0 ? itemstack10.size : 1; @@ -356,7 +356,7 @@ public abstract class Container inventoryplayer.setItemStack(itemstack9); } } - else if (itemstack9.getItem() == itemstack10.getItem() && itemstack10.getMaxStackSize() > 1 && (!itemstack9.getHasSubtypes() || itemstack9.getMetadata() == itemstack10.getMetadata()) && ItemStack.areItemStackTagsEqual(itemstack9, itemstack10)) + else if (itemstack9.getItem() == itemstack10.getItem() && itemstack10.getMaxStackSize() > 1 && ItemStack.areItemStackTagsEqual(itemstack9, itemstack10)) { int l1 = itemstack9.size; @@ -603,7 +603,7 @@ public abstract class Container Slot slot = (Slot)this.inventorySlots.get(i); ItemStack itemstack = slot.getStack(); - if (itemstack != null && itemstack.getItem() == stack.getItem() && (!stack.getHasSubtypes() || stack.getMetadata() == itemstack.getMetadata()) && ItemStack.areItemStackTagsEqual(stack, itemstack)) + if (itemstack != null && itemstack.getItem() == stack.getItem() && ItemStack.areItemStackTagsEqual(stack, itemstack)) { int j = itemstack.size + stack.size; diff --git a/common/src/main/java/common/inventory/ContainerEnchantment.java b/common/src/main/java/common/inventory/ContainerEnchantment.java index 32e26deb..18d70ff4 100755 --- a/common/src/main/java/common/inventory/ContainerEnchantment.java +++ b/common/src/main/java/common/inventory/ContainerEnchantment.java @@ -332,7 +332,7 @@ public class ContainerEnchantment extends Container } else if (itemstack1.size >= 1) { - ((Slot)this.inventorySlots.get(0)).putStack(new ItemStack(itemstack1.getItem(), 1, itemstack1.getMetadata())); + ((Slot)this.inventorySlots.get(0)).putStack(new ItemStack(itemstack1.getItem())); --itemstack1.size; } } diff --git a/common/src/main/java/common/inventory/ContainerRepair.java b/common/src/main/java/common/inventory/ContainerRepair.java index 522df450..a4c43a33 100755 --- a/common/src/main/java/common/inventory/ContainerRepair.java +++ b/common/src/main/java/common/inventory/ContainerRepair.java @@ -231,7 +231,7 @@ public class ContainerRepair extends Container damage = 0; } - if (damage < newStack.getMetadata()) + if (damage < newStack.getItemDamage()) { newStack.setItemDamage(damage); totalCost += 2; diff --git a/common/src/main/java/common/inventory/InventoryHelper.java b/common/src/main/java/common/inventory/InventoryHelper.java index 97dbb15e..8eb86cb0 100755 --- a/common/src/main/java/common/inventory/InventoryHelper.java +++ b/common/src/main/java/common/inventory/InventoryHelper.java @@ -50,7 +50,7 @@ public class InventoryHelper } stack.size -= i; - EntityItem entityitem = new EntityItem(worldIn, x + (double)f, y + (double)f1, z + (double)f2, new ItemStack(stack.getItem(), i, stack.getMetadata())); + EntityItem entityitem = new EntityItem(worldIn, x + (double)f, y + (double)f1, z + (double)f2, new ItemStack(stack.getItem(), i)); if (stack.hasTagCompound()) { diff --git a/common/src/main/java/common/inventory/InventoryPlayer.java b/common/src/main/java/common/inventory/InventoryPlayer.java index 8802577e..1d8515a8 100755 --- a/common/src/main/java/common/inventory/InventoryPlayer.java +++ b/common/src/main/java/common/inventory/InventoryPlayer.java @@ -65,19 +65,6 @@ public class InventoryPlayer implements IInventory return -1; } - private int getInventorySlotContainItemAndDamage(Item itemIn, int metadataIn) - { - for (int i = 0; i < this.mainInventory.length; ++i) - { - if (this.mainInventory[i] != null && this.mainInventory[i].getItem() == itemIn && this.mainInventory[i].getMetadata() == metadataIn) - { - return i; - } - } - - return -1; - } - /** * stores an itemstack in the users inventory */ @@ -85,7 +72,7 @@ public class InventoryPlayer implements IInventory { for (int i = 0; i < this.mainInventory.length; ++i) { - if (this.mainInventory[i] != null && this.mainInventory[i].getItem() == itemStackIn.getItem() && this.mainInventory[i].isStackable() && this.mainInventory[i].size < this.mainInventory[i].getMaxStackSize() && this.mainInventory[i].size < this.getInventoryStackLimit() && (!this.mainInventory[i].getHasSubtypes() || this.mainInventory[i].getMetadata() == itemStackIn.getMetadata()) && ItemStack.areItemStackTagsEqual(this.mainInventory[i], itemStackIn)) + if (this.mainInventory[i] != null && this.mainInventory[i].getItem() == itemStackIn.getItem() && this.mainInventory[i].isStackable() && this.mainInventory[i].size < this.mainInventory[i].getMaxStackSize() && this.mainInventory[i].size < this.getInventoryStackLimit() && ItemStack.areItemStackTagsEqual(this.mainInventory[i], itemStackIn)) { return i; } @@ -110,10 +97,10 @@ public class InventoryPlayer implements IInventory return -1; } - public boolean setCurrentItem(Item itemIn, int metadataIn, boolean isMetaSpecific) // , boolean p_146030_4_) + public boolean setCurrentItem(Item itemIn) // , boolean p_146030_4_) { // ItemStack itemstack = this.getCurrentItem(); - int i = isMetaSpecific ? this.getInventorySlotContainItemAndDamage(itemIn, metadataIn) : this.getInventorySlotContainItem(itemIn); + int i = this.getInventorySlotContainItem(itemIn); if (i >= 0 && i < 9) { @@ -212,7 +199,7 @@ public class InventoryPlayer implements IInventory { if (this.mainInventory[j] == null) { - this.mainInventory[j] = new ItemStack(item, 0, itemStackIn.getMetadata()); + this.mainInventory[j] = new ItemStack(item, 0); if (itemStackIn.hasTagCompound()) { diff --git a/common/src/main/java/common/item/Item.java b/common/src/main/java/common/item/Item.java index daa6b611..1ec6baf1 100755 --- a/common/src/main/java/common/item/Item.java +++ b/common/src/main/java/common/item/Item.java @@ -26,35 +26,25 @@ import common.world.World; public class Item { - protected static final Random itemRand = new Random(); - - protected int maxStackSize = 64; - private int maxDamage; - protected boolean hasSubtypes; + private int maxAmount = 64; + private int maxDamage = 0; private Item containerItem; private String potionEffect; private String display; - private CheatTab tabToDisplayOn; + private CheatTab tab; private TextColor color = null; - public Item setMaxStackSize(int maxStackSize) + public final Item setMaxAmount(int max) { - this.maxStackSize = maxStackSize; + this.maxAmount = max; + this.maxDamage = 0; return this; } - public Item setHasSubtypes(boolean hasSubtypes) + public final Item setMaxDamage(int max) { - this.hasSubtypes = hasSubtypes; - return this; - } - - /** - * set max damage of an Item - */ - public Item setMaxDamage(int maxDamageIn) - { - this.maxDamage = maxDamageIn; + this.maxAmount = 1; + this.maxDamage = max; return this; } @@ -64,27 +54,21 @@ public class Item return this; } - public Item setContainerItem(Item containerItem) + public final Item setContainerItem(Item containerItem) { this.containerItem = containerItem; return this; } - /** - * Sets the string representing this item's effect on a potion when used as an ingredient. - */ - public Item setPotionEffect(String potionEffect) + public final Item setPotionEffect(String potionEffect) { this.potionEffect = potionEffect; return this; } - /** - * returns this; - */ - public Item setTab(CheatTab tab) + public final Item setTab(CheatTab tab) { - this.tabToDisplayOn = tab; + this.tab = tab; return this; } @@ -93,7 +77,22 @@ public class Item this.color = color; return this; } - + + + public final int getItemStackLimit() + { + return this.maxAmount; + } + + public final int getMaxDamage() + { + return this.maxDamage; + } + + public final boolean isDamageable() + { + return this.maxDamage > 0; + } public Block getBlock() @@ -101,17 +100,6 @@ public class Item return null; } - /** - * Called when an ItemStack with NBT data is read to potentially that ItemStack's NBT data - */ - public boolean updateItemStackNBT(TagObject nbt) - { - return false; - } - - /** - * Called when a Block is right-clicked with this Item - */ public boolean onItemUse(ItemStack stack, EntityNPC playerIn, World worldIn, BlockPos pos, Facing side, float hitX, float hitY, float hitZ) { return false; @@ -126,105 +114,41 @@ public class Item return 1.0F; } - /** - * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer - */ public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) { return itemStackIn; } - /** - * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using - * the Item before the action is complete. - */ public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityNPC playerIn) { return stack; } - /** - * Returns the maximum size of the stack for a specific item. *Isn't this more a Set than a Get?* - */ - public int getItemStackLimit() - { - return this.maxStackSize; - } - - /** - * Converts the given ItemStack damage value into a metadata value to be placed in the world when this Item is - * placed as a Block (mostly used with ItemBlocks). - */ - public int getMetadata(int damage) + public int getMetadata() { return 0; } - public boolean getHasSubtypes() - { - return this.hasSubtypes; - } - - /** - * Returns the maximum damage an item can take. - */ - public int getMaxDamage() - { - return this.maxDamage; - } - - public boolean isDamageable() - { - return this.maxDamage > 0 && !this.hasSubtypes; - } - - /** - * Current implementations of this method in child classes do not use the entry argument beside ev. They just raise - * the damage on the stack. - */ public boolean hitEntity(ItemStack stack, EntityLiving target, EntityLiving attacker) { return false; } - /** - * Called when a Block is destroyed using this Item. Return true to trigger the "Use Item" statistic. - */ public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLiving playerIn) { return false; } - /** - * Check whether this Item can harvest the given Block - */ public boolean canHarvestBlock(Block blockIn) { return false; } - /** - * Returns true if the item can be used on the given entity, e.g. shears on sheep. - */ public boolean itemInteractionForEntity(ItemStack stack, EntityNPC playerIn, EntityLiving target) { return false; } -// public String getUnlocalizedNameInefficiently(ItemStack stack) -// { -// String s = this.getUnlocalizedName(stack); -// return s == null ? "" : s; // I18n.translate(s); -// } - -// /** -// * Returns the unlocalized name of this item. -// */ -// public String getUnlocalizedName() -// { -// return "item." + this.unlocalizedName; -// } - public String getDisplay(ItemStack stack) { return this.display; @@ -235,9 +159,6 @@ public class Item return this.containerItem; } - /** - * True if this Item has a container item (a.k.a. crafting result) - */ public boolean hasContainerItem() { return this.containerItem != null; @@ -248,24 +169,6 @@ public class Item return 16777215; } -// /** -// * Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and -// * update it's contents. -// */ -// public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) -// { -// } -// -// /** -// * Called when item is crafted/smelted. Used only by maps so far. -// */ -// public void onCreated(ItemStack stack, World worldIn, EntityNPC playerIn) -// { -// } - - /** - * returns the action that specifies what animation to play when the items is being used - */ public ItemAction getItemUseAction(ItemStack stack) { return ItemAction.NONE; @@ -276,17 +179,11 @@ public class Item return ItemAction.NONE; } - /** - * How long it takes to use or consume an item - */ public int getMaxItemUseDuration(ItemStack stack) { return 0; } - /** - * Called when the player stops using an Item (stops holding the right mouse button). - */ public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityNPC playerIn, int timeLeft) { } @@ -301,18 +198,10 @@ public class Item return this.getPotionEffect(stack) != null; } - /** - * allows items to add custom lines of information to the mouseover description - */ public void addInformation(ItemStack stack, EntityNPC playerIn, List tooltip) { } -// public String getItemStackDisplayName(ItemStack stack) -// { -// return this.getUnlocalizedName(stack); -// } - public boolean hasEffect(ItemStack stack) { return stack.isItemEnchanted(); @@ -323,9 +212,6 @@ public class Item return this.color != null ? this.color : (stack.isItemEnchanted() ? TextColor.NEON : TextColor.WHITE); } - /** - * Checks isDamagable and if it cannot be stacked - */ public boolean isItemTool(ItemStack stack) { return this.getItemStackLimit() == 1 && this.isDamageable(); @@ -350,38 +236,21 @@ public class Item return worldIn.rayTraceBlocks(vec3, vec31, useLiquids, !useLiquids, false); } - /** - * Return the enchantability factor of the item, most of the time is based on material. - */ public int getItemEnchantability() { return 0; } - /** - * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) - */ public void getSubItems(Item itemIn, CheatTab tab, List subItems) { subItems.add(new ItemStack(itemIn, 1, 0)); } - /** - * gets the tab this item is displayed on - */ public CheatTab getTab() { - return this.tabToDisplayOn; + return this.tab; } -// public boolean canItemEditBlocks() -// { -// return false; -// } - - /** - * Return whether this item is repairable in an anvil. - */ public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { return false; @@ -395,235 +264,13 @@ public class Item { } -// public boolean canBeDyed() { -// return false; -// } - public boolean isFragile() { return false; } -// public boolean isValidMeta(int meta) { -// return true; // meta == 0; -// } -// -// public int getDefaultMeta() { -// return 0; -// } - public final Set getValidTags() { return Sets.newHashSet(); } - -// private static final Set VALID_TAGS = Sets.newHashSet("Name", "ench", "RepairCost"); - - protected final boolean validateNbt(TagObject tag) { - return true; - } - -// private final boolean isValidNbt(ItemStack stack) { -// if(!stack.hasTagCompound()) { -// return true; -// } -// NBTTagCompound tag = stack.getTagCompound(); -// if(tag.hasNoTags()) { -// return false; -// } -// Set keys = tag.getKeySet(); -// int z = keys.size(); -// boolean validate = false; -// if(z > 0) { -// for(String v : VALID_TAGS) { -// if(keys.contains(v)) { -// z--; -// if(z == 0) { -// break; -// } -// } -// } -// } -//// if(adv && z > 0) { -////// for(String v : ADV_TAGS) { -//// if(keys.contains("Unbreakable")) { -//// z--; -////// if(z == 0) { -////// break; -////// } -//// } -////// } -//// } -// if(z > 0) { -// for(String v : this.getValidTags()) { -// if(keys.contains(v)) { -// validate = true; -// z--; -// if(z == 0) { -// break; -// } -// } -// } -// } -// if(z > 0) { -// return false; -// } -//// if(tag.hasKey("display")) { -//// if(!tag.hasTag("display")) { -//// return false; -//// } -//// NBTTagCompound display = tag.getCompoundTag("display"); -//// keys = display.getKeySet(); -//// z = keys.size(); -// if(tag.hasKey("Name")) { -// if(!tag.hasString("Name")) { -// return false; -// } -// if(tag.getString("Name").length() > 64) { -// return false; -// } -//// z--; -// } -//// if(display.hasKey("Lore")) { -//// if(!adv) { -//// display.removeTag("Lore"); -//// if(display.hasNoTags()) { -//// tag.removeTag("display"); -//// if(tag.hasNoTags()) { -//// stack.setTagCompound(null); -//// return true; -//// } -//// } -//// } -//// else { -//// if(!display.hasList("Lore")) { -//// return false; -//// } -//// NBTTagList lore = display.getTagList("Lore", 8); -//// if(lore.hasNoTags()) { -//// return false; -//// } -//// } -//// z--; -//// } -//// if(display.hasKey("color")) { -//// if(!display.hasInt("color")) { -//// return false; -//// } -//// if(!this.canBeDyed()) { -//// return false; -//// } -//// z--; -//// } -//// if(z > 0) { -//// return false; -//// } -//// } -// if(tag.hasKey("RepairCost")) { -// if(!tag.hasInt("RepairCost")) { -// return false; -// } -// if(tag.getInteger("RepairCost") < 1) { -// return false; -// } -// } -// if(tag.hasKey("ench")) { -// if(!tag.hasList("ench")) { -// return false; -// } -// NBTTagList ench = tag.getTagList("ench", 10); -// if(ench.hasNoTags()) { -// return false; -// } -// if(ench.tagCount() > Enchantment.getNames().size()) { -// return false; -// } -// Enchantment[] ecn = new Enchantment[ench.tagCount()]; -// for(int e = 0; e < ench.tagCount(); e++) { -// NBTTagCompound ec = ench.getCompoundTagAt(e); -// if(ec.getKeySet().size() != 2 || !ec.hasShort("id") || !ec.hasShort("lvl")) { -// return false; -// } -// int id = ec.getShort("id"); -// int lvl = ec.getShort("lvl"); -// Enchantment en = Enchantment.getEnchantmentById(id); -// if(en == null) { -// return false; -// } -//// if(!adv && (lvl < en.getMinLevel() || lvl > en.getMaxLevel())) { -//// return false; -//// } -//// if(!adv && !en.canApply(stack)) { -//// return false; -//// } -// ecn[e] = en; -// } -// for(int e = 0; e < ecn.length; e++) { -// for(int f = 0; f < ecn.length; f++) { -// if(f != e && ecn[e] == ecn[f]) { -// return false; -// } -// } -// } -// } -//// if(adv) { -//// if(tag.hasKey("Unbreakable")) { -//// if(!tag.hasBoolean("Unbreakable")) { -//// return false; -//// } -//// } -//// if(tag.hasKey("HideFlags")) { -//// if(!tag.hasInt("HideFlags")) { -//// return false; -//// } -//// } -//// } -// if(validate) { -// if(this.validateNbt(stack.getTagCompound())) { -// if(tag.hasNoTags()) { -// stack.setTagCompound(null); -// } -// } -// else { -// return false; -// } -// } -// return true; -// } - -// boolean validate(ItemStack stack) { -//// if(!bypass && this.isSpecialItem()) { -//// return false; -//// } -// boolean flag = true; -// if(this.isDamageable() && (stack.getItemDamage() < 0 || (stack.getItemDamage() > this.getMaxDamage()))) { -// stack.setItemDamage(0); -// flag = false; -// } -// if(stack.stackSize > stack.getMaxStackSize()) { -// stack.stackSize = stack.getMaxStackSize(); -// flag = false; -// } -// else if(stack.stackSize < 1) { -// stack.stackSize = 1; -// flag = false; -// } -// if(!this.isValidNbt(stack)) { -// stack.setTagCompound(null); -// flag = false; -// } -// return flag; -// } - -// public boolean canBreakBlocks() { -// return true; -// } -// -// public boolean canUseInAir() { -// return false; -// } -// -// public boolean ignoresBlocks() { -// return false; -// } public float getRadiation(ItemStack stack) { return 0.0f; @@ -649,7 +296,7 @@ public class Item return Transforms.ITEM; } - public Model getModel(ModelProvider provider, String name, int meta) { + public Model getModel(ModelProvider provider, String name) { return provider.getModel(this.getTransform(), name); } diff --git a/common/src/main/java/common/item/ItemAmmo.java b/common/src/main/java/common/item/ItemAmmo.java index e76602ab..c11cc9fc 100755 --- a/common/src/main/java/common/item/ItemAmmo.java +++ b/common/src/main/java/common/item/ItemAmmo.java @@ -5,7 +5,7 @@ public class ItemAmmo extends ItemMagnetic { private final float explosion; public ItemAmmo(int damage, float explosion, int stack) { - this.maxStackSize = stack; + this.setMaxAmount(stack); this.setTab(CheatTab.COMBAT); this.damage = damage; this.explosion = explosion; diff --git a/common/src/main/java/common/item/ItemAnvilBlock.java b/common/src/main/java/common/item/ItemAnvilBlock.java index 8bf8549e..dad363d0 100755 --- a/common/src/main/java/common/item/ItemAnvilBlock.java +++ b/common/src/main/java/common/item/ItemAnvilBlock.java @@ -4,18 +4,14 @@ import common.block.Block; public class ItemAnvilBlock extends ItemMultiTexture { - public ItemAnvilBlock(Block block) + public ItemAnvilBlock(Block block, int data) { - super(block, block, new String[] {"Amboss", "Leicht beschädigter Amboss", "Stark beschädigter Amboss"}); + super(block, data); } - /** - * Converts the given ItemStack damage value into a metadata value to be placed in the world when this Item is - * placed as a Block (mostly used with ItemBlocks). - */ - public int getMetadata(int damage) + public int getMetadata() { - return damage << 2; + return this.data << 2; } public boolean isMagnetic() { diff --git a/common/src/main/java/common/item/ItemAppleGold.java b/common/src/main/java/common/item/ItemAppleGold.java index a2b796a3..e2e4d597 100755 --- a/common/src/main/java/common/item/ItemAppleGold.java +++ b/common/src/main/java/common/item/ItemAppleGold.java @@ -1,7 +1,5 @@ package common.item; -import java.util.List; - import common.color.TextColor; import common.entity.npc.EntityNPC; import common.potion.Potion; @@ -10,24 +8,18 @@ import common.world.World; public class ItemAppleGold extends ItemFood { - public ItemAppleGold(int amount, boolean isWolfFood) + private final boolean powered; + + public ItemAppleGold(int amount, boolean powered) { - super(amount, isWolfFood); - this.setHasSubtypes(true); - this.setColor(TextColor.NEON); + super(amount, false); + this.powered = powered; + this.setColor(powered ? TextColor.MAGENTA : TextColor.NEON); } public boolean hasEffect(ItemStack stack) { - return stack.getMetadata() > 0; - } - - /** - * Return an item rarity from EnumRarity - */ - public TextColor getColor(ItemStack stack) - { - return stack.getMetadata() == 0 ? super.getColor(stack) : TextColor.MAGENTA; + return this.powered; } protected void onFoodEaten(ItemStack stack, World worldIn, EntityNPC player) @@ -37,7 +29,7 @@ public class ItemAppleGold extends ItemFood player.addEffect(new PotionEffect(Potion.ABSORPTION, 2400, 0)); } - if (stack.getMetadata() > 0) + if (this.powered) { if (!worldIn.client) { @@ -51,13 +43,4 @@ public class ItemAppleGold extends ItemFood super.onFoodEaten(stack, worldIn, player); } } - - /** - * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) - */ - public void getSubItems(Item itemIn, CheatTab tab, List subItems) - { - subItems.add(new ItemStack(itemIn, 1, 0)); - subItems.add(new ItemStack(itemIn, 1, 1)); - } } diff --git a/common/src/main/java/common/item/ItemArmor.java b/common/src/main/java/common/item/ItemArmor.java index 3c5722cd..4bbcc844 100755 --- a/common/src/main/java/common/item/ItemArmor.java +++ b/common/src/main/java/common/item/ItemArmor.java @@ -91,7 +91,6 @@ public class ItemArmor extends Item // this.renderIndex = renderIndex; this.damageReduceAmount = material.getDamageReduction(armorType); this.setMaxDamage(material.getDurability(armorType)); - this.maxStackSize = 1; this.setTab(CheatTab.COMBAT); DispenserRegistry.REGISTRY.putObject(this, dispenserBehavior); } @@ -272,11 +271,11 @@ public class ItemArmor extends Item super.getTransform()); } - public Model getModel(ModelProvider provider, String name, int meta) { + public Model getModel(ModelProvider provider, String name) { if(this.material.canBeDyed()) return provider.getModel(this.getTransform(), name, name + "_overlay"); else - return super.getModel(provider, name, meta); + return super.getModel(provider, name); } public void addInformation(ItemStack stack, EntityNPC playerIn, List tooltip) { diff --git a/common/src/main/java/common/item/ItemBanner.java b/common/src/main/java/common/item/ItemBanner.java index c5c76f61..d89e9543 100755 --- a/common/src/main/java/common/item/ItemBanner.java +++ b/common/src/main/java/common/item/ItemBanner.java @@ -24,8 +24,6 @@ public class ItemBanner extends ItemBlock { super(Blocks.banner); this.setTab(CheatTab.DECORATION); - this.setHasSubtypes(true); - this.setMaxDamage(0); } /** @@ -140,7 +138,7 @@ public class ItemBanner extends ItemBlock TileEntityBanner.setBaseColorAndPatterns(nbttagcompound, enumdyecolor.getDyeDamage(), null); TagObject nbttagcompound1 = new TagObject(); nbttagcompound1.setObject("BlockEntityTag", nbttagcompound); - ItemStack itemstack = new ItemStack(itemIn, 1, enumdyecolor.getDyeDamage()); + ItemStack itemstack = new ItemStack(itemIn); itemstack.setTagCompound(nbttagcompound1); subItems.add(itemstack); } @@ -165,7 +163,7 @@ public class ItemBanner extends ItemBlock } else { - enumdyecolor = DyeColor.byDyeDamage(stack.getMetadata()); + enumdyecolor = DyeColor.WHITE; } return enumdyecolor; @@ -213,7 +211,7 @@ public class ItemBanner extends ItemBlock subItems.add(new ItemStack(itemIn, 1, 0)); } - public Model getModel(ModelProvider provider, String name, int meta) { + public Model getModel(ModelProvider provider, String name) { return provider.getModel(provider.getEntityModel(), this.getTransform()); } } diff --git a/common/src/main/java/common/item/ItemBlock.java b/common/src/main/java/common/item/ItemBlock.java index 8cdc5013..b611678f 100755 --- a/common/src/main/java/common/item/ItemBlock.java +++ b/common/src/main/java/common/item/ItemBlock.java @@ -34,9 +34,6 @@ public class ItemBlock extends Item this(block, null); } - /** - * Sets the unlocalized name of this item to the string passed as the parameter, prefixed by "item." - */ public ItemBlock setDisplay(String unlocalizedName) { super.setDisplay(unlocalizedName); @@ -72,7 +69,7 @@ public class ItemBlock extends Item } else if (worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity)null, stack)) { - int i = this.getMetadata(stack.getMetadata()); + int i = this.getMetadata(); State iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, i, playerIn); if (worldIn.setState(pos, iblockstate1, 3)) @@ -215,11 +212,11 @@ public class ItemBlock extends Item return this.flatTexture != null ? super.getTransform() : this.block.getTransform(); } - public Model getModel(ModelProvider provider, String name, int meta) { + 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.getStateFromMeta(this.getMetadata(meta))).getPrimary() /* "blocks/" + name */) : + BlockRegistry.getNameFromBlock(this.block).toString(), this.block.getStateFromMeta(this.getMetadata())).getPrimary() /* "blocks/" + name */) : provider.getModel(this.block.getModel(provider, - BlockRegistry.getNameFromBlock(this.block).toString(), this.block.getStateFromMeta(this.getMetadata(meta))), this.getTransform()); + BlockRegistry.getNameFromBlock(this.block).toString(), this.block.getStateFromMeta(this.getMetadata())), this.getTransform()); } } diff --git a/common/src/main/java/common/item/ItemBoat.java b/common/src/main/java/common/item/ItemBoat.java index 2d78fcf3..e99e4cde 100755 --- a/common/src/main/java/common/item/ItemBoat.java +++ b/common/src/main/java/common/item/ItemBoat.java @@ -17,7 +17,7 @@ public class ItemBoat extends Item { public ItemBoat() { - this.maxStackSize = 1; + this.setMaxAmount(1); this.setTab(CheatTab.SPAWNERS); } diff --git a/common/src/main/java/common/item/ItemBow.java b/common/src/main/java/common/item/ItemBow.java index 4ee6e402..198b3792 100755 --- a/common/src/main/java/common/item/ItemBow.java +++ b/common/src/main/java/common/item/ItemBow.java @@ -17,7 +17,6 @@ public class ItemBow extends Item { public ItemBow() { - this.maxStackSize = 1; this.setMaxDamage(384); this.setTab(CheatTab.COMBAT); } @@ -149,8 +148,8 @@ public class ItemBow extends Item return Transforms.RANGED; } - public Model getModel(ModelProvider provider, String name, int meta) { - return provider.getModel(this.getTransform(), meta == 0 ? "bow" : ("bow_pulling_" + (meta - 1))); + public Model getModel(ModelProvider provider, String name) { + return provider.getModel(this.getTransform(), data == 0 ? "bow" : ("bow_pulling_" + (data - 1))); } public boolean canBeWielded() { diff --git a/common/src/main/java/common/item/ItemBucket.java b/common/src/main/java/common/item/ItemBucket.java index ad0b2dd1..e1ab1e72 100755 --- a/common/src/main/java/common/item/ItemBucket.java +++ b/common/src/main/java/common/item/ItemBucket.java @@ -101,7 +101,7 @@ public class ItemBucket extends Item public ItemBucket(BlockDynamicLiquid liquid, boolean recursive) { - this.maxStackSize = liquid == null ? 16 : 1; + this.setMaxAmount(liquid == null ? 16 : 1); this.liquid = liquid; this.recursive = recursive; this.setTab(liquid == null ? CheatTab.TOOLS : CheatTab.LIQUIDS); @@ -178,7 +178,7 @@ public class ItemBucket extends Item return this.fillBucket(itemStackIn, playerIn, new ItemStack( ItemRegistry.getRegisteredItem(BlockRegistry.getNameFromBlock(block instanceof BlockDynamicLiquid ? FluidRegistry.getStaticBlock((BlockDynamicLiquid)block) : block) + - "_bucket"), 1, 0)); + "_bucket"))); } } } @@ -316,8 +316,8 @@ public class ItemBucket extends Item return true; } - public Model getModel(ModelProvider provider, String name, int meta) { - return this.recursive ? provider.getModel(this.getTransform(), name.substring("recursive_".length())) : super.getModel(provider, name, meta); + public Model getModel(ModelProvider provider, String name) { + return this.recursive ? provider.getModel(this.getTransform(), name.substring("recursive_".length())) : super.getModel(provider, name); } // public ItemMeshDefinition getMesher() { diff --git a/common/src/main/java/common/item/ItemBucketMilk.java b/common/src/main/java/common/item/ItemBucketMilk.java index 90f2e490..6485c168 100755 --- a/common/src/main/java/common/item/ItemBucketMilk.java +++ b/common/src/main/java/common/item/ItemBucketMilk.java @@ -11,7 +11,7 @@ public class ItemBucketMilk extends Item { public ItemBucketMilk() { - this.setMaxStackSize(1); + this.setMaxAmount(1); this.setTab(CheatTab.TOOLS); } diff --git a/common/src/main/java/common/item/ItemButton.java b/common/src/main/java/common/item/ItemButton.java index 95b923b0..607d8815 100755 --- a/common/src/main/java/common/item/ItemButton.java +++ b/common/src/main/java/common/item/ItemButton.java @@ -12,7 +12,7 @@ public class ItemButton extends ItemBlock { this.button = block; } - public Model getModel(ModelProvider provider, String name, int meta) { + public Model getModel(ModelProvider provider, String name) { return provider.getModel(provider.getModel(this.button.getTexture()).add(5, 6, 6, 11, 10, 10) .d().uv(5, 6, 11, 10).noCull().u().uv(5, 10, 11, 6).noCull() .ns().uv(5, 12, 11, 16).noCull().we().uv(6, 12, 10, 16).noCull(), this.getTransform()); diff --git a/common/src/main/java/common/item/ItemCamera.java b/common/src/main/java/common/item/ItemCamera.java index 7a19ef90..6682fc47 100755 --- a/common/src/main/java/common/item/ItemCamera.java +++ b/common/src/main/java/common/item/ItemCamera.java @@ -6,7 +6,7 @@ import common.world.World; public class ItemCamera extends ItemMagnetic { public ItemCamera() { - this.setMaxStackSize(1); + this.setMaxAmount(1); } public boolean onAction(ItemStack stack, EntityNPC player, World world, ItemControl control, BlockPos block) { diff --git a/common/src/main/java/common/item/ItemCarrotOnAStick.java b/common/src/main/java/common/item/ItemCarrotOnAStick.java index 83d923ce..580e908c 100755 --- a/common/src/main/java/common/item/ItemCarrotOnAStick.java +++ b/common/src/main/java/common/item/ItemCarrotOnAStick.java @@ -11,7 +11,6 @@ public class ItemCarrotOnAStick extends Item public ItemCarrotOnAStick() { this.setTab(CheatTab.TOOLS); - this.setMaxStackSize(1); this.setMaxDamage(25); } @@ -41,7 +40,7 @@ public class ItemCarrotOnAStick extends Item { EntityPig entitypig = (EntityPig)playerIn.vehicle; - if (entitypig.getAIControlledByPlayer().isControlledByPlayer() && itemStackIn.getMaxDamage() - itemStackIn.getMetadata() >= 7) + if (entitypig.getAIControlledByPlayer().isControlledByPlayer() && itemStackIn.getMaxDamage() - itemStackIn.getItemDamage() >= 7) { entitypig.getAIControlledByPlayer().boostSpeed(); itemStackIn.damageItem(7, playerIn); diff --git a/common/src/main/java/common/item/ItemChargedOrb.java b/common/src/main/java/common/item/ItemChargedOrb.java index 0b295150..3efa71b3 100755 --- a/common/src/main/java/common/item/ItemChargedOrb.java +++ b/common/src/main/java/common/item/ItemChargedOrb.java @@ -17,7 +17,6 @@ public class ItemChargedOrb extends ItemFragile { public ItemChargedOrb() { - this.maxStackSize = 1; this.setTab(CheatTab.TOOLS); this.setMaxDamage(16); this.setColor(TextColor.DMAGENTA); @@ -61,9 +60,9 @@ public class ItemChargedOrb extends ItemFragile for (int i = 0; i < 16; ++i) { - double d0 = (double)((float)pos.getX() + (5.0F + itemRand.floatv() * 6.0F) / 16.0F); + double d0 = (double)((float)pos.getX() + (5.0F + worldIn.rand.floatv() * 6.0F) / 16.0F); double d1 = (double)((float)pos.getY() + 0.8125F); - double d2 = (double)((float)pos.getZ() + (5.0F + itemRand.floatv() * 6.0F) / 16.0F); + double d2 = (double)((float)pos.getZ() + (5.0F + worldIn.rand.floatv() * 6.0F) / 16.0F); double d3 = 0.0D; double d4 = 0.0D; double d5 = 0.0D; diff --git a/common/src/main/java/common/item/ItemChest.java b/common/src/main/java/common/item/ItemChest.java index 57e502cc..93fd5e91 100755 --- a/common/src/main/java/common/item/ItemChest.java +++ b/common/src/main/java/common/item/ItemChest.java @@ -10,7 +10,7 @@ public class ItemChest extends ItemBlock { super(block); } - public Model getModel(ModelProvider provider, String name, int meta) { + public Model getModel(ModelProvider provider, String name) { return provider.getModel(provider.getEntityModel(), this.getTransform()); } diff --git a/common/src/main/java/common/item/ItemCloth.java b/common/src/main/java/common/item/ItemCloth.java index 6c20acbf..f6bc9d0f 100755 --- a/common/src/main/java/common/item/ItemCloth.java +++ b/common/src/main/java/common/item/ItemCloth.java @@ -8,40 +8,32 @@ import common.model.ModelProvider; public class ItemCloth extends ItemBlock { private final Integer display; + private final DyeColor color; - public ItemCloth(Block block, Integer display, String flatTexture) + public ItemCloth(Block block, Integer display, String flatTexture, DyeColor color) { super(block, flatTexture); - this.setMaxDamage(0); - this.setHasSubtypes(true); + this.color = color; this.display = display; } - public ItemCloth(Block block, Integer display) + public ItemCloth(Block block, Integer display, DyeColor color) { - this(block, display, null); + this(block, display, null, color); } - /** - * Converts the given ItemStack damage value into a metadata value to be placed in the world when this Item is - * placed as a Block (mostly used with ItemBlocks). - */ - public int getMetadata(int damage) + public int getMetadata() { - return damage; + return this.color.getMetadata(); } - /** - * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have - * different names based on their damage or NBT. - */ public String getDisplay(ItemStack stack) { - return DyeColor.byMetadata(stack.getMetadata()).getSubject(this.display) + " " + super.getDisplay(stack); + return this.color.getSubject(this.display) + " " + super.getDisplay(stack); } - public Model getModel(ModelProvider provider, String name, int meta) { - return this.flatTexture != null ? provider.getModel(this.getTransform(), "blocks/" + DyeColor.byMetadata(meta).getName() + "_" + - this.flatTexture) : super.getModel(provider, name, meta); + public Model getModel(ModelProvider provider, String name) { + return this.flatTexture != null ? provider.getModel(this.getTransform(), "blocks/" + this.color.getName() + "_" + + this.flatTexture) : super.getModel(provider, name); } } diff --git a/common/src/main/java/common/item/ItemCoal.java b/common/src/main/java/common/item/ItemCoal.java deleted file mode 100755 index aa192aee..00000000 --- a/common/src/main/java/common/item/ItemCoal.java +++ /dev/null @@ -1,38 +0,0 @@ -package common.item; - -import java.util.List; - -import common.model.Model; -import common.model.ModelProvider; - -public class ItemCoal extends Item -{ - public ItemCoal() - { - this.setHasSubtypes(true); - this.setMaxDamage(0); - this.setTab(CheatTab.METALS); - } - - /** - * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have - * different names based on their damage or NBT. - */ - public String getDisplay(ItemStack stack) - { - return stack.getMetadata() == 1 ? "Holzkohle" : super.getDisplay(stack); - } - - /** - * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) - */ - public void getSubItems(Item itemIn, CheatTab tab, List subItems) - { - subItems.add(new ItemStack(itemIn, 1, 0)); - subItems.add(new ItemStack(itemIn, 1, 1)); - } - - public Model getModel(ModelProvider provider, String name, int meta) { - return provider.getModel(this.getTransform(), meta == 1 ? "charcoal" : "coal"); - } -} diff --git a/common/src/main/java/common/item/ItemColored.java b/common/src/main/java/common/item/ItemColored.java index 97f58a3f..b2462092 100755 --- a/common/src/main/java/common/item/ItemColored.java +++ b/common/src/main/java/common/item/ItemColored.java @@ -5,59 +5,27 @@ import common.block.Block; public class ItemColored extends ItemBlock { private final Block coloredBlock; - private String[] subtypeNames; + private final int data; - public ItemColored(Block block, boolean hasSubtypes, String flatTexture) + public ItemColored(Block block, String flatTexture, int data) { super(block, flatTexture); this.coloredBlock = block; - - if (hasSubtypes) - { - this.setMaxDamage(0); - this.setHasSubtypes(true); - } + this.data = data; } - public ItemColored(Block block, boolean hasSubtypes) + public ItemColored(Block block, int data) { - this(block, hasSubtypes, null); + this(block, null, data); } public int getColorFromItemStack(ItemStack stack, int renderPass) { - return this.coloredBlock.getRenderColor(this.coloredBlock.getStateFromMeta(stack.getMetadata())); + return this.coloredBlock.getRenderColor(this.coloredBlock.getStateFromMeta(this.data)); } - /** - * Converts the given ItemStack damage value into a metadata value to be placed in the world when this Item is - * placed as a Block (mostly used with ItemBlocks). - */ - public int getMetadata(int damage) + public int getMetadata() { - return damage; - } - - public ItemColored setSubtypeNames(String[] names) - { - this.subtypeNames = names; - return this; - } - - /** - * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have - * different names based on their damage or NBT. - */ - public String getDisplay(ItemStack stack) - { - if (this.subtypeNames == null) - { - return super.getDisplay(stack); - } - else - { - int i = stack.getMetadata(); - return i >= 0 && i < this.subtypeNames.length ? this.subtypeNames[i] : super.getDisplay(stack); - } + return this.data; } } diff --git a/common/src/main/java/common/item/ItemDie.java b/common/src/main/java/common/item/ItemDie.java index 1afefd93..bbe154b8 100755 --- a/common/src/main/java/common/item/ItemDie.java +++ b/common/src/main/java/common/item/ItemDie.java @@ -1,7 +1,5 @@ package common.item; -import java.util.List; - import common.color.TextColor; import common.entity.npc.EntityNPC; import common.entity.projectile.EntityDie; @@ -9,7 +7,6 @@ import common.init.SoundEvent; import common.model.Model; import common.model.ModelProvider; import common.model.Transforms; -import common.util.ExtMath; import common.world.World; public class ItemDie extends Item @@ -18,11 +15,12 @@ public class ItemDie extends Item public static final TextColor[] DIE_COLORS = new TextColor[] {TextColor.DGREEN, TextColor.NEON, TextColor.DMAGENTA, TextColor.MAGENTA, TextColor.DRED, TextColor.ORANGE}; - public ItemDie() + private final int sides; + + public ItemDie(int sides) { + this.sides = sides; this.setTab(CheatTab.TOOLS); - this.setMaxDamage(0); - this.setHasSubtypes(true); } public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) @@ -36,32 +34,24 @@ public class ItemDie extends Item if (!worldIn.client) { - worldIn.spawnEntityInWorld(new EntityDie(worldIn, playerIn, DIE_SIDES[ExtMath.clampi(itemStackIn.getMetadata(), - 0, DIE_SIDES.length - 1)], false)); // playerIn.creative)); + worldIn.spawnEntityInWorld(new EntityDie(worldIn, playerIn, this.sides, false)); // playerIn.creative)); } // playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); return itemStackIn; } - public void getSubItems(Item itemIn, CheatTab tab, List subItems) - { - for(int z = 0; z < DIE_SIDES.length; z++) { - subItems.add(new ItemStack(itemIn, 1, z)); - } - } - public String getDisplay(ItemStack stack) { - return super.getDisplay(stack) + " W" + DIE_SIDES[ExtMath.clampi(stack.getMetadata(), 0, DIE_SIDES.length - 1)]; + return super.getDisplay(stack) + " W" + this.sides; } public Transforms getTransform() { return Transforms.DICE; } - public Model getModel(ModelProvider provider, String name, int meta) { - return provider.getModel(provider.getModel("items/die_d" + DIE_SIDES[meta] + "_side").add().nswe() - .du("items/die_d" + DIE_SIDES[meta] + "_top"), this.getTransform()); + public Model getModel(ModelProvider provider, String name) { + return provider.getModel(provider.getModel("items/die_d" + this.sides + "_side").add().nswe() + .du("items/die_d" + this.sides + "_top"), this.getTransform()); } } diff --git a/common/src/main/java/common/item/ItemDispenser.java b/common/src/main/java/common/item/ItemDispenser.java index 1a90ccf6..edc5df9e 100755 --- a/common/src/main/java/common/item/ItemDispenser.java +++ b/common/src/main/java/common/item/ItemDispenser.java @@ -7,7 +7,7 @@ public class ItemDispenser extends ItemBlock { super(block); } - public int getMetadata(int damage) { + public int getMetadata() { return 2; } } diff --git a/common/src/main/java/common/item/ItemDoublePlant.java b/common/src/main/java/common/item/ItemDoublePlant.java index 2e1875e8..02883118 100755 --- a/common/src/main/java/common/item/ItemDoublePlant.java +++ b/common/src/main/java/common/item/ItemDoublePlant.java @@ -1,7 +1,5 @@ package common.item; -import java.util.function.Function; - import common.block.Block; import common.block.foliage.BlockDoublePlant; import common.block.foliage.BlockDoublePlant.EnumPlantType; @@ -11,20 +9,20 @@ import common.model.ModelProvider; public class ItemDoublePlant extends ItemMultiTexture { - public ItemDoublePlant(Block block, Block block2, Function nameFunction) + public ItemDoublePlant(Block block, int data) { - super(block, block2, true, nameFunction); + super(block, true, data); } public int getColorFromItemStack(ItemStack stack, int renderPass) { - BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = BlockDoublePlant.EnumPlantType.byMetadata(stack.getMetadata()); + BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = BlockDoublePlant.EnumPlantType.byMetadata(this.data); return blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN ? super.getColorFromItemStack(stack, renderPass) : Colorizer.getGrassColor(0.5D, 1.0D); } - public Model getModel(ModelProvider provider, String name, int meta) { + public Model getModel(ModelProvider provider, String name) { return provider.getModel(this.getTransform(), "blocks/" + ( - BlockDoublePlant.EnumPlantType.byMetadata(meta) == EnumPlantType.SUNFLOWER ? "sunflower_front" : - BlockDoublePlant.EnumPlantType.byMetadata(meta).getName() + "_top")); + BlockDoublePlant.EnumPlantType.byMetadata(this.data) == EnumPlantType.SUNFLOWER ? "sunflower_front" : + BlockDoublePlant.EnumPlantType.byMetadata(this.data).getName() + "_top")); } } diff --git a/common/src/main/java/common/item/ItemDye.java b/common/src/main/java/common/item/ItemDye.java index af0b10b9..04bb79b2 100755 --- a/common/src/main/java/common/item/ItemDye.java +++ b/common/src/main/java/common/item/ItemDye.java @@ -1,7 +1,5 @@ package common.item; -import java.util.List; - import common.block.Block; import common.block.artificial.BlockBed; import common.block.foliage.IGrowable; @@ -25,22 +23,28 @@ import common.world.AWorldServer; public class ItemDye extends Item { public static final int[] dyeColors = new int[] {1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 11250603, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320}; - - public ItemDye() - { - this.setHasSubtypes(true); - this.setMaxDamage(0); - this.setTab(CheatTab.MATERIALS); + private static final ItemDye[] DIES = new ItemDye[DyeColor.values().length]; + + private final DyeColor color; + + public static ItemDye getByColor(DyeColor color) { + return DIES[color.getMetadata()]; + } + + public ItemDye(DyeColor color) + { + this.color = color; + this.setTab(CheatTab.MATERIALS); + DIES[this.color.getMetadata()] = this; + } + + public DyeColor getColor() { + return this.color; } - /** - * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have - * different names based on their damage or NBT. - */ public String getDisplay(ItemStack stack) { - int i = stack.getMetadata(); - return DyeColor.byDyeDamage(i).getDye(); + return this.color.getDye(); } /** @@ -54,9 +58,7 @@ public class ItemDye extends Item } else { - DyeColor enumdyecolor = DyeColor.byDyeDamage(stack.getMetadata()); - - if (enumdyecolor == DyeColor.WHITE) + if (this.color == DyeColor.WHITE) { if (applyBonemeal(stack, worldIn, pos)) { @@ -68,7 +70,7 @@ public class ItemDye extends Item return true; } } - else if (enumdyecolor == DyeColor.BROWN) + else if (this.color == DyeColor.BROWN) { State iblockstate = worldIn.getState(pos); Block block = iblockstate.getBlock(); @@ -103,7 +105,7 @@ public class ItemDye extends Item } State iblockstate = worldIn.getState(pos); if(iblockstate.getBlock() instanceof BlockBed) { - Block bedBlock = BlockRegistry.getRegisteredBlock(enumdyecolor.getName() + "_bed"); + Block bedBlock = BlockRegistry.getRegisteredBlock(this.color.getName() + "_bed"); if(bedBlock != Blocks.air) { if (iblockstate.getValue(BlockBed.PART) == BlockBed.EnumPartType.FOOT) { @@ -134,7 +136,7 @@ public class ItemDye extends Item else if(iblockstate.getBlock() == Blocks.beacon) { TileEntity te = worldIn.getTileEntity(pos); if(te instanceof TileEntityBeacon) { - ((TileEntityBeacon)te).setBeamColor(enumdyecolor); + ((TileEntityBeacon)te).setBeamColor(this.color); // if(!playerIn.creative) --stack.size; } @@ -186,10 +188,10 @@ public class ItemDye extends Item for (int i = 0; i < amount; ++i) { - double d0 = itemRand.gaussian() * 0.02D; - double d1 = itemRand.gaussian() * 0.02D; - double d2 = itemRand.gaussian() * 0.02D; - worldIn.spawnParticle(ParticleType.GROW, (double)((float)pos.getX() + itemRand.floatv()), (double)pos.getY() + (double)itemRand.floatv() * block.getBlockBoundsMaxY(), (double)((float)pos.getZ() + itemRand.floatv()), d0, d1, d2); + double d0 = worldIn.rand.gaussian() * 0.02D; + double d1 = worldIn.rand.gaussian() * 0.02D; + double d2 = worldIn.rand.gaussian() * 0.02D; + worldIn.spawnParticle(ParticleType.GROW, (double)((float)pos.getX() + worldIn.rand.floatv()), (double)pos.getY() + (double)worldIn.rand.floatv() * block.getBlockBoundsMaxY(), (double)((float)pos.getZ() + worldIn.rand.floatv()), d0, d1, d2); } } } @@ -202,11 +204,10 @@ public class ItemDye extends Item if (target instanceof EntitySheep) { EntitySheep entitysheep = (EntitySheep)target; - DyeColor enumdyecolor = DyeColor.byDyeDamage(stack.getMetadata()); - if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != enumdyecolor) + if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != this.color) { - entitysheep.setFleeceColor(enumdyecolor); + entitysheep.setFleeceColor(this.color); --stack.size; } @@ -218,18 +219,7 @@ public class ItemDye extends Item } } - /** - * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) - */ - public void getSubItems(Item itemIn, CheatTab tab, List subItems) - { - for (int i = 0; i < 16; ++i) - { - subItems.add(new ItemStack(itemIn, 1, i)); - } - } - - public Model getModel(ModelProvider provider, String name, int meta) { - return provider.getModel(this.getTransform(), "dye_" + DyeColor.byDyeDamage(meta).getName()); + public Model getModel(ModelProvider provider, String name) { + return provider.getModel(this.getTransform(), "dye_" + this.color.getName()); } } diff --git a/common/src/main/java/common/item/ItemDynamite.java b/common/src/main/java/common/item/ItemDynamite.java index d3433506..c412bb5d 100755 --- a/common/src/main/java/common/item/ItemDynamite.java +++ b/common/src/main/java/common/item/ItemDynamite.java @@ -13,12 +13,13 @@ public class ItemDynamite extends Item { private static final String[] TIERS = new String[] {"II", "III", "IV", "V", "VI", "VII", "VIII"}; - public ItemDynamite() + private final int power; + + public ItemDynamite(int power) { - this.maxStackSize = 32; + this.power = power; + this.setMaxAmount(32); this.setTab(CheatTab.TOOLS); - this.setMaxDamage(0); - this.setHasSubtypes(true); } /** @@ -35,27 +36,19 @@ public class ItemDynamite extends Item if (!worldIn.client) { - worldIn.spawnEntityInWorld(new EntityDynamite(worldIn, playerIn, itemStackIn.getMetadata())); + worldIn.spawnEntityInWorld(new EntityDynamite(worldIn, playerIn, this.power)); } // playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]); return itemStackIn; } - public void getSubItems(Item itemIn, CheatTab tab, List subItems) - { - for(int z = 0; z < 8; z++) { - subItems.add(new ItemStack(itemIn, 1, z)); - } - } - public String getDisplay(ItemStack stack) { - int exp = stack.getMetadata() & 7; - return super.getDisplay(stack) + (exp == 0 ? "" : " " + TIERS[exp-1]); + return super.getDisplay(stack) + (this.power == 0 ? "" : " " + TIERS[this.power-1]); } - public Model getModel(ModelProvider provider, String name, int meta) { - return provider.getModel(this.getTransform(), "dynamite" + (meta == 0 ? "" : ("_" + meta))); + public Model getModel(ModelProvider provider, String name) { + return provider.getModel(this.getTransform(), "dynamite" + (this.power == 0 ? "" : ("_" + this.power))); } } diff --git a/common/src/main/java/common/item/ItemEditWand.java b/common/src/main/java/common/item/ItemEditWand.java index 6d1baa92..ccceb58d 100755 --- a/common/src/main/java/common/item/ItemEditWand.java +++ b/common/src/main/java/common/item/ItemEditWand.java @@ -7,7 +7,7 @@ import common.world.World; public class ItemEditWand extends Item { public ItemEditWand() { - this.maxStackSize = 1; + this.setMaxAmount(1); this.setTab(CheatTab.TOOLS); } diff --git a/common/src/main/java/common/item/ItemEnchantedBook.java b/common/src/main/java/common/item/ItemEnchantedBook.java index 37a1079e..0f0bbf3b 100755 --- a/common/src/main/java/common/item/ItemEnchantedBook.java +++ b/common/src/main/java/common/item/ItemEnchantedBook.java @@ -142,7 +142,7 @@ public class ItemEnchantedBook extends Item public RngLoot getRandom(Random rand, int minChance, int maxChance, int weight) { - ItemStack itemstack = new ItemStack(Items.book, 1, 0); + ItemStack itemstack = new ItemStack(Items.book); EnchantmentHelper.addRandomEnchantment(rand, itemstack, 30); return new RngLoot(itemstack, minChance, maxChance, weight); } diff --git a/common/src/main/java/common/item/ItemExterminator.java b/common/src/main/java/common/item/ItemExterminator.java index cd5287d0..3abe8633 100755 --- a/common/src/main/java/common/item/ItemExterminator.java +++ b/common/src/main/java/common/item/ItemExterminator.java @@ -9,7 +9,7 @@ import common.world.AWorldServer; public class ItemExterminator extends ItemMagnetic { public ItemExterminator() { - this.setMaxStackSize(1); + this.setMaxAmount(1); this.setColor(TextColor.DRED); } diff --git a/common/src/main/java/common/item/ItemFence.java b/common/src/main/java/common/item/ItemFence.java index cd6c5c01..a3691e3d 100755 --- a/common/src/main/java/common/item/ItemFence.java +++ b/common/src/main/java/common/item/ItemFence.java @@ -10,7 +10,7 @@ public class ItemFence extends ItemBlock { super(block); } - public Model getModel(ModelProvider provider, String name, int meta) { + public Model getModel(ModelProvider provider, String name) { return provider.getModel(provider.getModel(((BlockFence)this.block).getTexture()) .add(6, 0, 0, 10, 16, 4) .d().uv(6, 0, 10, 4) diff --git a/common/src/main/java/common/item/ItemFireworkCharge.java b/common/src/main/java/common/item/ItemFireworkCharge.java index 14e9ba12..f26b1963 100755 --- a/common/src/main/java/common/item/ItemFireworkCharge.java +++ b/common/src/main/java/common/item/ItemFireworkCharge.java @@ -178,7 +178,7 @@ public class ItemFireworkCharge extends Item // return Sets.newHashSet("Explosion"); // } - public Model getModel(ModelProvider provider, String name, int meta) { + public Model getModel(ModelProvider provider, String name) { return provider.getModel(this.getTransform(), "firework_charge", "firework_charge_overlay"); } } diff --git a/common/src/main/java/common/item/ItemFishFood.java b/common/src/main/java/common/item/ItemFishFood.java index 2a0f9b4d..1f8474df 100755 --- a/common/src/main/java/common/item/ItemFishFood.java +++ b/common/src/main/java/common/item/ItemFishFood.java @@ -14,31 +14,29 @@ import common.world.World; public class ItemFishFood extends ItemFood { - /** Indicates whether this fish is "cooked" or not. */ private final boolean cooked; + private final FishType type; - public ItemFishFood(boolean cooked) + public ItemFishFood(boolean cooked, FishType type) { super(0, false); this.cooked = cooked; + this.type = type; } public int getHealAmount(ItemStack stack) { - ItemFishFood.FishType itemfishfood$fishtype = ItemFishFood.FishType.byItemStack(stack); - return this.cooked && itemfishfood$fishtype.canCook() ? itemfishfood$fishtype.getCookedHealAmount() : itemfishfood$fishtype.getUncookedHealAmount(); + return this.cooked && this.type.canCook() ? this.type.getCookedHealAmount() : this.type.getUncookedHealAmount(); } public String getPotionEffect(ItemStack stack) { - return ItemFishFood.FishType.byItemStack(stack) == ItemFishFood.FishType.PUFFERFISH ? PotionHelper.pufferfishEffect : null; + return this.type == ItemFishFood.FishType.PUFFERFISH ? PotionHelper.pufferfishEffect : null; } protected void onFoodEaten(ItemStack stack, World worldIn, EntityNPC player) { - ItemFishFood.FishType itemfishfood$fishtype = ItemFishFood.FishType.byItemStack(stack); - - if (itemfishfood$fishtype == ItemFishFood.FishType.PUFFERFISH) + if (this.type == ItemFishFood.FishType.PUFFERFISH) { player.addEffect(new PotionEffect(Potion.POISON, 1200, 3)); player.addEffect(new PotionEffect(Potion.NAUSEA, 300, 1)); @@ -47,32 +45,13 @@ public class ItemFishFood extends ItemFood super.onFoodEaten(stack, worldIn, player); } - /** - * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) - */ - public void getSubItems(Item itemIn, CheatTab tab, List subItems) - { - for (ItemFishFood.FishType itemfishfood$fishtype : ItemFishFood.FishType.values()) - { - if (!this.cooked || itemfishfood$fishtype.canCook()) - { - subItems.add(new ItemStack(this, 1, itemfishfood$fishtype.getMetadata())); - } - } - } - - /** - * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have - * different names based on their damage or NBT. - */ public String getDisplay(ItemStack stack) { - ItemFishFood.FishType type = ItemFishFood.FishType.byItemStack(stack); - return (type.canCook() ? (this.cooked ? "Gebratener " : "Roher ") : "") + type.getName(); + return (this.type.canCook() ? (this.cooked ? "Gebratener " : "Roher ") : "") + this.type.getName(); } - public Model getModel(ModelProvider provider, String name, int meta) { - return provider.getModel(this.getTransform(), (this.cooked ? "cooked_" : "") + FishType.byMetadata(meta).getTexture()); + public Model getModel(ModelProvider provider, String name) { + return provider.getModel(this.getTransform(), (this.cooked ? "cooked_" : "") + this.type.getTexture()); } public static enum FishType @@ -82,7 +61,6 @@ public class ItemFishFood extends ItemFood CLOWNFISH("clownfish", 2, "Clownfisch", 1), PUFFERFISH("pufferfish", 3, "Kugelfisch", 1); - private static final Map META_LOOKUP = Maps.newHashMap(); private final int meta; private final String texture; private final String name; @@ -139,23 +117,5 @@ public class ItemFishFood extends ItemFood { return this.cookable; } - - public static ItemFishFood.FishType byMetadata(int meta) - { - ItemFishFood.FishType itemfishfood$fishtype = (ItemFishFood.FishType)META_LOOKUP.get(Integer.valueOf(meta)); - return itemfishfood$fishtype == null ? COD : itemfishfood$fishtype; - } - - public static ItemFishFood.FishType byItemStack(ItemStack stack) - { - return stack.getItem() instanceof ItemFishFood ? byMetadata(stack.getMetadata()) : COD; - } - - static { - for (ItemFishFood.FishType itemfishfood$fishtype : values()) - { - META_LOOKUP.put(Integer.valueOf(itemfishfood$fishtype.getMetadata()), itemfishfood$fishtype); - } - } } } diff --git a/common/src/main/java/common/item/ItemFishingRod.java b/common/src/main/java/common/item/ItemFishingRod.java index f7278f83..6d5556cb 100755 --- a/common/src/main/java/common/item/ItemFishingRod.java +++ b/common/src/main/java/common/item/ItemFishingRod.java @@ -15,7 +15,6 @@ public class ItemFishingRod extends Item public ItemFishingRod() { this.setMaxDamage(64); - this.setMaxStackSize(1); this.setTab(CheatTab.TOOLS); } @@ -88,7 +87,7 @@ public class ItemFishingRod extends Item return Transforms.TOOL_FLIP; } - public Model getModel(ModelProvider provider, String name, int meta) { - return provider.getModel(this.getTransform(), meta == 1 ? "fishing_rod_cast" : "fishing_rod"); + public Model getModel(ModelProvider provider, String name) { + return provider.getModel(this.getTransform(), data == 1 ? "fishing_rod_cast" : "fishing_rod"); } } diff --git a/common/src/main/java/common/item/ItemFlintAndSteel.java b/common/src/main/java/common/item/ItemFlintAndSteel.java index 55ff3be0..a32f0139 100755 --- a/common/src/main/java/common/item/ItemFlintAndSteel.java +++ b/common/src/main/java/common/item/ItemFlintAndSteel.java @@ -15,7 +15,6 @@ public class ItemFlintAndSteel extends Item public ItemFlintAndSteel(BlockFire fireBlock) { this.fireBlock = fireBlock; - this.maxStackSize = 1; this.setMaxDamage(64); this.setTab(CheatTab.TOOLS); } diff --git a/common/src/main/java/common/item/ItemGlassBottle.java b/common/src/main/java/common/item/ItemGlassBottle.java index d4b046a7..3b2811cf 100755 --- a/common/src/main/java/common/item/ItemGlassBottle.java +++ b/common/src/main/java/common/item/ItemGlassBottle.java @@ -55,7 +55,7 @@ public class ItemGlassBottle extends Item if (!playerIn.inventory.addItemStackToInventory(new ItemStack(Items.potion))) { - playerIn.dropPlayerItemWithRandomChoice(new ItemStack(Items.potion, 1, 0), false); + playerIn.dropPlayerItemWithRandomChoice(new ItemStack(Items.potion), false); } } } @@ -64,7 +64,7 @@ public class ItemGlassBottle extends Item } } - public Model getModel(ModelProvider provider, String name, int meta) { + public Model getModel(ModelProvider provider, String name) { return provider.getModel(this.getTransform(), "potion_bottle_empty"); } } diff --git a/common/src/main/java/common/item/ItemGunBase.java b/common/src/main/java/common/item/ItemGunBase.java index 73f56abe..4ae5041d 100755 --- a/common/src/main/java/common/item/ItemGunBase.java +++ b/common/src/main/java/common/item/ItemGunBase.java @@ -15,7 +15,6 @@ public abstract class ItemGunBase extends Item public ItemGunBase(int durability) { - this.maxStackSize = 1; this.setMaxDamage(durability); this.setTab(CheatTab.COMBAT); } diff --git a/common/src/main/java/common/item/ItemHoe.java b/common/src/main/java/common/item/ItemHoe.java index 9e7b7b76..274182df 100755 --- a/common/src/main/java/common/item/ItemHoe.java +++ b/common/src/main/java/common/item/ItemHoe.java @@ -18,7 +18,6 @@ public class ItemHoe extends Item public ItemHoe(ToolMaterial material) { this.theToolMaterial = material; - this.maxStackSize = 1; this.setMaxDamage(material.getDurability()); this.setTab(CheatTab.TOOLS); } diff --git a/common/src/main/java/common/item/ItemHorseArmor.java b/common/src/main/java/common/item/ItemHorseArmor.java index 3b60d1f2..86d14c20 100755 --- a/common/src/main/java/common/item/ItemHorseArmor.java +++ b/common/src/main/java/common/item/ItemHorseArmor.java @@ -9,7 +9,7 @@ public class ItemHorseArmor extends Item { public ItemHorseArmor(ToolMaterial material, String texture) { this.material = material; this.texture = texture; - this.setMaxStackSize(1); + this.setMaxAmount(1); this.setTab(CheatTab.COMBAT); } diff --git a/common/src/main/java/common/item/ItemHugeMushroom.java b/common/src/main/java/common/item/ItemHugeMushroom.java index 9ed68418..eb1c35d5 100755 --- a/common/src/main/java/common/item/ItemHugeMushroom.java +++ b/common/src/main/java/common/item/ItemHugeMushroom.java @@ -7,7 +7,7 @@ public class ItemHugeMushroom extends ItemBlock { super(block); } - public int getMetadata(int damage) { + public int getMetadata() { return 14; } } diff --git a/common/src/main/java/common/item/ItemLeaves.java b/common/src/main/java/common/item/ItemLeaves.java index efe717c4..e2027d97 100755 --- a/common/src/main/java/common/item/ItemLeaves.java +++ b/common/src/main/java/common/item/ItemLeaves.java @@ -6,40 +6,27 @@ import common.block.foliage.LeavesType; public class ItemLeaves extends ItemBlock { protected final BlockLeaves leaves; + private final LeavesType type; - public ItemLeaves(BlockLeaves block) + public ItemLeaves(BlockLeaves block, LeavesType type) { super(block); this.leaves = block; - this.setMaxDamage(0); - this.setHasSubtypes(true); + this.type = type; } - /** - * Converts the given ItemStack damage value into a metadata value to be placed in the world when this Item is - * placed as a Block (mostly used with ItemBlocks). - */ - public int getMetadata(int damage) + public int getMetadata() { - return damage | 8; + return this.type.getIndex() | 8; } public int getColorFromItemStack(ItemStack stack, int renderPass) { - return this.leaves.getRenderColor(this.leaves.getStateFromMeta(stack.getMetadata())); + return this.leaves.getRenderColor(this.leaves.getState().withProperty(BlockLeaves.TYPE, this.type)); } - -// /** -// * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have -// * different names based on their damage or NBT. -// */ -// public String getUnlocalizedName(ItemStack stack) -// { -// return super.getUnlocalizedName() + "." + this.leaves.getWoodType().getUnlocalizedName(); -// } public String getDisplay(ItemStack stack) { - return this.block.getDisplay() + " (" + LeavesType.getById(stack.getMetadata()).getDisplayName() + ")"; + return this.block.getDisplay() + " (" + this.type.getDisplayName() + ")"; } } diff --git a/common/src/main/java/common/item/ItemLilyPad.java b/common/src/main/java/common/item/ItemLilyPad.java index efe834d0..091b79c7 100755 --- a/common/src/main/java/common/item/ItemLilyPad.java +++ b/common/src/main/java/common/item/ItemLilyPad.java @@ -63,6 +63,6 @@ public class ItemLilyPad extends ItemColored public int getColorFromItemStack(ItemStack stack, int renderPass) { - return Blocks.waterlily.getRenderColor(Blocks.waterlily.getStateFromMeta(stack.getMetadata())); + return Blocks.waterlily.getRenderColor(Blocks.waterlily.getState()); } } diff --git a/common/src/main/java/common/item/ItemMagnet.java b/common/src/main/java/common/item/ItemMagnet.java index f2b85279..53aca673 100755 --- a/common/src/main/java/common/item/ItemMagnet.java +++ b/common/src/main/java/common/item/ItemMagnet.java @@ -16,7 +16,7 @@ public class ItemMagnet extends Item { public ItemMagnet(boolean chicken) { this.setTab(CheatTab.TOOLS); - this.setMaxStackSize(1); + this.setMaxAmount(1); this.chicken = chicken; } diff --git a/common/src/main/java/common/item/ItemMinecart.java b/common/src/main/java/common/item/ItemMinecart.java index ccc8a414..7ed0e155 100755 --- a/common/src/main/java/common/item/ItemMinecart.java +++ b/common/src/main/java/common/item/ItemMinecart.java @@ -82,7 +82,7 @@ public class ItemMinecart extends Item public ItemMinecart(EntityCart.EnumMinecartType type) { - this.maxStackSize = 1; + this.setMaxAmount(1); this.minecartType = type; this.setTab(CheatTab.SPAWNERS); // if(type != EntityMinecart.EnumMinecartType.COMMAND_BLOCK) diff --git a/common/src/main/java/common/item/ItemMonsterPlacer.java b/common/src/main/java/common/item/ItemMonsterPlacer.java index c7faf25f..ee1209c8 100755 --- a/common/src/main/java/common/item/ItemMonsterPlacer.java +++ b/common/src/main/java/common/item/ItemMonsterPlacer.java @@ -226,7 +226,7 @@ public class ItemMonsterPlacer extends Item // subItems.add(new ItemStack(itemIn, 1, 0)); // } - public Model getModel(ModelProvider provider, String name, int meta) { + public Model getModel(ModelProvider provider, String name) { return provider.getModel(this.getTransform(), "spawn_egg", "spawn_egg_overlay"); } } diff --git a/common/src/main/java/common/item/ItemMultiTexture.java b/common/src/main/java/common/item/ItemMultiTexture.java index 4a85c9f0..1ce1854a 100755 --- a/common/src/main/java/common/item/ItemMultiTexture.java +++ b/common/src/main/java/common/item/ItemMultiTexture.java @@ -1,61 +1,24 @@ package common.item; -import java.util.function.Function; - import common.block.Block; public class ItemMultiTexture extends ItemBlock { - protected final Block theBlock; - protected final Function nameFunction; + protected final int data; - public ItemMultiTexture(Block block, Block block2, boolean flatTexture, Function nameFunction) + public ItemMultiTexture(Block block, boolean flatTexture, int data) { super(block, flatTexture ? "" : null); - this.theBlock = block2; - this.nameFunction = nameFunction; - this.setMaxDamage(0); - this.setHasSubtypes(true); + this.data = data; } - public ItemMultiTexture(Block block, Block block2, Function nameFunction) + public ItemMultiTexture(Block block, int data) { - this(block, block2, false, nameFunction); + this(block, false, data); } - public ItemMultiTexture(Block block, Block block2, final String[] namesByMeta) + public int getMetadata() { - this(block, block2, false, new Function() - { - public String apply(ItemStack p_apply_1_) - { - int i = p_apply_1_.getMetadata(); - - if (i < 0 || i >= namesByMeta.length) - { - i = 0; - } - - return namesByMeta[i]; - } - }); - } - - /** - * Converts the given ItemStack damage value into a metadata value to be placed in the world when this Item is - * placed as a Block (mostly used with ItemBlocks). - */ - public int getMetadata(int damage) - { - return damage; - } - - /** - * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have - * different names based on their damage or NBT. - */ - public String getDisplay(ItemStack stack) - { - return this.nameFunction.apply(stack); + return this.data; } } diff --git a/common/src/main/java/common/item/ItemNpcSpawner.java b/common/src/main/java/common/item/ItemNpcSpawner.java index edc04b25..eddd7f21 100755 --- a/common/src/main/java/common/item/ItemNpcSpawner.java +++ b/common/src/main/java/common/item/ItemNpcSpawner.java @@ -211,7 +211,7 @@ public class ItemNpcSpawner extends Item // subItems.add(new ItemStack(itemIn, 1, 0)); // } - public Model getModel(ModelProvider provider, String name, int meta) { + public Model getModel(ModelProvider provider, String name) { return provider.getModel(this.getTransform(), "npc_spawner", "npc_spawner_overlay"); } } diff --git a/common/src/main/java/common/item/ItemPiston.java b/common/src/main/java/common/item/ItemPiston.java index 1b83d880..7e758130 100755 --- a/common/src/main/java/common/item/ItemPiston.java +++ b/common/src/main/java/common/item/ItemPiston.java @@ -16,7 +16,7 @@ public class ItemPiston extends ItemBlock * Converts the given ItemStack damage value into a metadata value to be placed in the world when this Item is * placed as a Block (mostly used with ItemBlocks). */ - public int getMetadata(int damage) + public int getMetadata() { return 7; } @@ -25,7 +25,7 @@ public class ItemPiston extends ItemBlock return true; } - public Model getModel(ModelProvider provider, String name, int meta) { + public Model getModel(ModelProvider provider, String name) { return provider.getModel(provider.getModel("piston_side").add().nswe().d("piston_bottom").u("piston_top" + (this.block == Blocks.sticky_piston ? "_sticky" : "")), this.getTransform()); } diff --git a/common/src/main/java/common/item/ItemPotion.java b/common/src/main/java/common/item/ItemPotion.java index 29a9c7bd..8b6232fc 100755 --- a/common/src/main/java/common/item/ItemPotion.java +++ b/common/src/main/java/common/item/ItemPotion.java @@ -25,9 +25,7 @@ public class ItemPotion extends Item public ItemPotion() { - this.setMaxStackSize(1); - this.setHasSubtypes(true); - this.setMaxDamage(0); + this.setMaxAmount(1); this.setTab(CheatTab.MAGIC); this.setColor(TextColor.ORK); } @@ -389,8 +387,7 @@ public class ItemPotion extends Item subItems.add(new ItemStack(itemIn, 1, 16384)); } - public Model getModel(ModelProvider provider, String name, int meta) { - return provider.getModel(this.getTransform(), "potion_overlay", - isSplash(meta) ? "potion_bottle_splash" : "potion_bottle_drinkable"); + public Model getModel(ModelProvider provider, String name) { + return provider.getModel(this.getTransform(), "potion_overlay"); } } diff --git a/common/src/main/java/common/item/ItemPressurePlate.java b/common/src/main/java/common/item/ItemPressurePlate.java index e644b4b5..3338435c 100755 --- a/common/src/main/java/common/item/ItemPressurePlate.java +++ b/common/src/main/java/common/item/ItemPressurePlate.java @@ -10,7 +10,7 @@ public class ItemPressurePlate extends ItemBlock { super(block); } - public Model getModel(ModelProvider provider, String name, int meta) { + public Model getModel(ModelProvider provider, String name) { return provider.getModel(provider.getModel(((BlockBasePressurePlate)this.block).getTexture()) .add(1, 6, 1, 15, 10, 15) .d().uv(1, 1, 15, 15).noCull() diff --git a/common/src/main/java/common/item/ItemRecord.java b/common/src/main/java/common/item/ItemRecord.java index d43a90ef..5f5f032f 100755 --- a/common/src/main/java/common/item/ItemRecord.java +++ b/common/src/main/java/common/item/ItemRecord.java @@ -8,7 +8,7 @@ public class ItemRecord extends Item { this.setTab(CheatTab.MISC); } - public Model getModel(ModelProvider provider, String name, int meta) { + public Model getModel(ModelProvider provider, String name) { return provider.getModel(this.getTransform(), "record_old"); } } diff --git a/common/src/main/java/common/item/ItemSaddle.java b/common/src/main/java/common/item/ItemSaddle.java index be30a91d..b25254d5 100755 --- a/common/src/main/java/common/item/ItemSaddle.java +++ b/common/src/main/java/common/item/ItemSaddle.java @@ -8,7 +8,7 @@ public class ItemSaddle extends Item { public ItemSaddle() { - this.maxStackSize = 1; + this.setMaxAmount(1); this.setTab(CheatTab.TOOLS); } diff --git a/common/src/main/java/common/item/ItemShears.java b/common/src/main/java/common/item/ItemShears.java index b3e3556b..d82b517e 100755 --- a/common/src/main/java/common/item/ItemShears.java +++ b/common/src/main/java/common/item/ItemShears.java @@ -14,7 +14,6 @@ public class ItemShears extends Item public ItemShears(ToolMaterial material) { - this.setMaxStackSize(1); this.setMaxDamage(material.getDurability() - 12); this.setTab(CheatTab.TOOLS); this.material = material; diff --git a/common/src/main/java/common/item/ItemSlab.java b/common/src/main/java/common/item/ItemSlab.java index e30370b7..043a0cc3 100755 --- a/common/src/main/java/common/item/ItemSlab.java +++ b/common/src/main/java/common/item/ItemSlab.java @@ -16,8 +16,6 @@ public class ItemSlab extends ItemBlock { super(slab); this.slab = slab; -// this.setMaxDamage(0); -// this.setHasSubtypes(true); } // /** diff --git a/common/src/main/java/common/item/ItemSnow.java b/common/src/main/java/common/item/ItemSnow.java index f19ba090..a1bb1954 100755 --- a/common/src/main/java/common/item/ItemSnow.java +++ b/common/src/main/java/common/item/ItemSnow.java @@ -14,13 +14,8 @@ public class ItemSnow extends ItemBlock public ItemSnow(Block block) { super(block); - this.setMaxDamage(0); - this.setHasSubtypes(true); } - /** - * Called when a Block is right-clicked with this Item - */ public boolean onItemUse(ItemStack stack, EntityNPC playerIn, World worldIn, BlockPos pos, Facing side, float hitX, float hitY, float hitZ) { if (stack.size == 0) @@ -65,13 +60,4 @@ public class ItemSnow extends ItemBlock return super.onItemUse(stack, playerIn, worldIn, blockpos, side, hitX, hitY, hitZ); } } - - /** - * Converts the given ItemStack damage value into a metadata value to be placed in the world when this Item is - * placed as a Block (mostly used with ItemBlocks). - */ - public int getMetadata(int damage) - { - return damage; - } } diff --git a/common/src/main/java/common/item/ItemSoup.java b/common/src/main/java/common/item/ItemSoup.java index daf6ebaa..39d7c223 100755 --- a/common/src/main/java/common/item/ItemSoup.java +++ b/common/src/main/java/common/item/ItemSoup.java @@ -10,7 +10,7 @@ public class ItemSoup extends ItemFood public ItemSoup(int healAmount) { super(healAmount, false); - this.setMaxStackSize(1); + this.setMaxAmount(1); } /** diff --git a/common/src/main/java/common/item/ItemSpaceNavigator.java b/common/src/main/java/common/item/ItemSpaceNavigator.java index eb3841f6..14633f63 100755 --- a/common/src/main/java/common/item/ItemSpaceNavigator.java +++ b/common/src/main/java/common/item/ItemSpaceNavigator.java @@ -25,7 +25,7 @@ public class ItemSpaceNavigator extends ItemMagnetic { } public ItemSpaceNavigator() { - this.setMaxStackSize(1); + this.setMaxAmount(1); this.setColor(TextColor.DGREEN); } diff --git a/common/src/main/java/common/item/ItemStack.java b/common/src/main/java/common/item/ItemStack.java index abe7cbb5..6baa83f1 100755 --- a/common/src/main/java/common/item/ItemStack.java +++ b/common/src/main/java/common/item/ItemStack.java @@ -15,7 +15,6 @@ import common.enchantment.Enchantment; import common.enchantment.EnchantmentHelper; import common.entity.npc.EntityNPC; import common.entity.types.EntityLiving; -import common.init.BlockRegistry; import common.init.ItemRegistry; import common.rng.Random; import common.tags.TagObject; @@ -26,12 +25,11 @@ import common.world.World; public final class ItemStack { public static final int MAX_SIZE = 67108864; - public static final DecimalFormat DECIMALFORMAT = new DecimalFormat("#.###"); + private static final DecimalFormat DECIMALFORMAT = new DecimalFormat("#.###"); public int size; private Item item; private TagObject tag; - private int meta; public ItemStack(Block block) { @@ -40,12 +38,7 @@ public final class ItemStack public ItemStack(Block block, int amount) { - this(block, amount, 0); - } - - public ItemStack(Block block, int amount, int meta) - { - this(ItemRegistry.getItemFromBlock(block), amount, meta); + this(ItemRegistry.getItemFromBlock(block), amount); } public ItemStack(Item item) @@ -55,23 +48,8 @@ public final class ItemStack public ItemStack(Item item, int amount) { - this(item, amount, 0); - } - - public ItemStack(Item item, int amount, int meta) - { -// this.canDestroyCacheBlock = null; -// this.canDestroyCacheResult = false; -// this.canPlaceOnCacheBlock = null; -// this.canPlaceOnCacheResult = false; this.item = item; this.size = amount; - this.meta = meta; - - if (this.meta < 0) - { - this.meta = 0; - } } public static String formatAmount(int amount) { @@ -100,10 +78,6 @@ public final class ItemStack private ItemStack() { -// this.canDestroyCacheBlock = null; -// this.canDestroyCacheResult = false; -// this.canPlaceOnCacheBlock = null; -// this.canPlaceOnCacheResult = false; } /** @@ -111,7 +85,7 @@ public final class ItemStack */ public ItemStack splitStack(int amount) { - ItemStack itemstack = new ItemStack(this.item, amount, this.meta); + ItemStack itemstack = new ItemStack(this.item, amount); if (this.tag != null) { @@ -168,136 +142,70 @@ public final class ItemStack return this.getItem().onItemUseFinish(this, worldIn, playerIn); } - /** - * Write the stack fields to a object. Return the new object. - */ public TagObject writeTags(TagObject tag) { - String resourcelocation = ItemRegistry.getNameFromItem(this.item); - tag.setString("id", resourcelocation == null ? "air" : resourcelocation.toString()); - tag.setInt("Count", this.size); - tag.setShort("Damage", (short)this.meta); - - if (this.tag != null) - { - tag.setObject("tag", this.tag); - } - + if(this.tag != null) + tag.merge(this.tag); + tag.setString("id", this.item == null ? "air" : ItemRegistry.getNameFromItem(this.item)); + tag.setInt("size", this.size); return tag; } - /** - * Read the stack fields from a object. - */ - public void readTags(TagObject tag) + private void readTags(TagObject tag) { - if (tag.hasString("id")) - { - this.item = ItemRegistry.getRegisteredItem(tag.getString("id")); - } - else - { - this.item = ItemRegistry.getItemById(tag.getShort("id")); - } - - this.size = tag.getInt("Count"); - this.meta = tag.getShort("Damage"); - - if (this.meta < 0) - { - this.meta = 0; - } - - if (tag.hasObject("tag")) - { - this.tag = tag.getObject("tag"); - - if (this.item != null) - { - this.item.updateItemStackNBT(this.tag); - } - } + if(!tag.hasString("id") || !tag.hasInt("size")) + return; + this.item = ItemRegistry.getRegisteredItem(tag.getString("id")); + this.size = tag.getInt("size"); + tag.remove("id"); + tag.remove("size"); + if(!tag.isEmpty()) + this.tag = tag; } - /** - * Returns maximum size of the stack. - */ public int getMaxStackSize() { return this.getItem().getItemStackLimit(); } - /** - * Returns true if the ItemStack can hold 2 or more units of the item. - */ public boolean isStackable() { return this.getMaxStackSize() > 1 && (!this.isItemStackDamageable() || !this.isItemDamaged()); } - /** - * true if this itemStack is damageable - */ public boolean isItemStackDamageable() { return this.item != null && this.item.getMaxDamage() > 0; } - -// public void setItemStackDamageable(boolean breakable) -// { -// if(!breakable) { -// if(this.stackTagCompound == null) { -// this.setTagCompound(new TagObject()); -// } -// this.stackTagCompound.setBoolean("Unbreakable", true); -// this.setItemDamage(0); -// } -// else { -// if(this.stackTagCompound != null) { -// this.stackTagCompound.removeTag("Unbreakable"); -// if(this.stackTagCompound.hasNoTags()) { -// this.stackTagCompound = null; -// } -// } -// } -// } - public boolean getHasSubtypes() - { - return this.item.getHasSubtypes(); - } - - /** - * returns true when a damageable item is damaged - */ public boolean isItemDamaged() { - return this.isItemStackDamageable() && this.meta > 0; + return this.isItemStackDamageable() && this.getItemDamage() > 0; } public int getItemDamage() { - return this.meta; + return this.isItemStackDamageable() && this.tag != null && this.tag.hasInt("dmg") ? this.tag.getInt("dmg") : 0; } - public int getMetadata() + public void setItemDamage(int damage) { - return this.meta; + if(!this.isItemStackDamageable()) + return; + if(damage <= 0) { + if(this.tag != null) { + this.tag.remove("dmg"); + if(this.tag.isEmpty()) + this.tag = null; + } + } + else { + if(this.tag == null) + this.tag = new TagObject(); + this.tag.setInt("dmg", damage); + } } - public void setItemDamage(int meta) - { - this.meta = meta; - - if (this.meta < 0) - { - this.meta = 0; - } - } - - /** - * Returns the max damage an item in the stack can take. - */ public int getMaxDamage() { return this.item.getMaxDamage(); @@ -338,18 +246,14 @@ public final class ItemStack } } - this.meta += amount; - return this.meta > this.getMaxDamage(); + int damage = this.getItemDamage() + amount; + this.setItemDamage(damage); + return damage > this.getMaxDamage(); } } - /** - * Damages the item in the ItemStack - */ public void damageItem(int amount, EntityLiving entityIn) { -// if (!(entityIn.isPlayer()) || !((EntityNPC)entityIn).creative) -// { if (this.isItemStackDamageable()) { if (this.attemptDamageItem(amount, entityIn.getRNG())) @@ -360,7 +264,6 @@ public final class ItemStack if (entityIn.isPlayer()) { EntityNPC entityplayer = (EntityNPC)entityIn; -// entityplayer.triggerAchievement(StatRegistry.objectBreakStats[ItemRegistry.getIdFromItem(this.item)]); if (this.size == 0 && this.getItem() instanceof ItemBow) { @@ -373,10 +276,9 @@ public final class ItemStack this.size = 0; } - this.meta = 0; + this.setItemDamage(0); } } -// } } /** @@ -418,12 +320,9 @@ public final class ItemStack return this.item.itemInteractionForEntity(this, playerIn, entityIn); } - /** - * Returns a new stack with the same properties. - */ public ItemStack copy() { - ItemStack itemstack = new ItemStack(this.item, this.size, this.meta); + ItemStack itemstack = new ItemStack(this.item, this.size); if (this.tag != null) { @@ -451,7 +350,7 @@ public final class ItemStack */ private boolean isItemStackEqual(ItemStack other) { - return this.size != other.size ? false : (this.item != other.item ? false : (this.meta != other.meta ? false : (this.tag == null && other.tag != null ? false : this.tag == null || this.tag.equals(other.tag)))); + return this.size != other.size ? false : (this.item != other.item ? false : (this.tag == null && other.tag != null ? false : this.tag == null || this.tag.equals(other.tag))); } /** @@ -468,7 +367,7 @@ public final class ItemStack */ public boolean isItemEqual(ItemStack other) { - return other != null && this.item == other.item && this.meta == other.meta; + return other != null && this.item == other.item; } // public String getUnlocalizedName() @@ -579,29 +478,18 @@ public final class ItemStack return this.tag == null ? null : this.tag.getList("ench"); } - /** - * Assigns a NBTTagCompound to the ItemStack, does not validate that only non-stackable items can have it. - */ public void setTagCompound(TagObject nbt) { this.tag = nbt; } - /** - * returns the display name of the itemstack - */ public String getDisplayName() { String s = this.getItem().getDisplay(this); if (this.tag != null && this.tag.hasString("Name")) { -// NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display"); -// -// if (nbttagcompound.hasString("Name")) -// { s = this.tag.getString("Name"); -// } } return s; @@ -622,131 +510,26 @@ public final class ItemStack this.tag = new TagObject(); } -// if (!this.stackTagCompound.hasTag("display")) -// { -// this.stackTagCompound.setTag("display", new NBTTagCompound()); -// } - this.tag.setString("Name", displayName); return this; } -// public ItemStack setStackLore(String displayLore) -// { -// if (this.stackTagCompound == null) -// { -// this.stackTagCompound = new NBTTagCompound(); -// } -// -// if (!this.stackTagCompound.hasTag("display")) -// { -// this.stackTagCompound.setTag("display", new NBTTagCompound()); -// } -// -// NBTTagList nbttaglist = new NBTTagList(); -// for(String s : displayLore.split("\\n")) { -// nbttaglist.appendTag(new NBTTagString(s)); -// } -// this.stackTagCompound.getCompoundTag("display").setTag("Lore", nbttaglist); -// return this; -// } -// -// public String getStackLore() -// { -// if (this.stackTagCompound == null) -// { -// return null; -// } -// -// if (!this.stackTagCompound.hasTag("display")) -// { -// return null; -// } -// -// NBTTagList nbttaglist = this.stackTagCompound.getCompoundTag("display").getTagList("Lore", 8); -// StringBuilder sb = new StringBuilder(); -// for(int z = 0; z < nbttaglist.tagCount(); z++) { -// if(sb.length() > 0) { -// sb.append("\n"); -// } -// sb.append(nbttaglist.getStringTagAt(z)); -// } -// return sb.toString(); -// } - -// public ItemStack setStackFlags(int flags) -// { -// if(flags != 0) { -// if (this.stackTagCompound == null) -// { -// this.stackTagCompound = new NBTTagCompound(); -// } -// -// this.stackTagCompound.setInteger("HideFlags", flags); -// } -// else { -// if (this.stackTagCompound != null) -// { -// this.stackTagCompound.removeTag("HideFlags"); -// if (this.stackTagCompound.hasNoTags()) -// { -// this.setTagCompound((NBTTagCompound)null); -// } -// } -// } -// return this; -// } - - /** - * Clear any custom name set for this ItemStack - */ public void clearCustomName() { if (this.tag != null) { if (this.tag.hasString("Name")) { -// NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display"); this.tag.remove("Name"); if (this.tag.isEmpty()) { -// this.stackTagCompound.removeTag("display"); -// -// if (this.stackTagCompound.hasNoTags()) -// { this.setTagCompound(null); -// } } } } } -// public void clearLore() -// { -// if (this.stackTagCompound != null) -// { -// if (this.stackTagCompound.hasTag("display")) -// { -// NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display"); -// nbttagcompound.removeTag("Lore"); -// -// if (nbttagcompound.hasNoTags()) -// { -// this.stackTagCompound.removeTag("display"); -// -// if (this.stackTagCompound.hasNoTags()) -// { -// this.setTagCompound((NBTTagCompound)null); -// } -// } -// } -// } -// } - - /** - * Returns true if the itemstack has a display name - */ public boolean hasDisplayName() { return this.tag != null && this.tag.hasString("Name"); @@ -756,59 +539,14 @@ public final class ItemStack { List list = Lists.newArrayList(); String s = this.getColoredName(); - -// if (this.hasDisplayName()) -// { -// s = ChatFormat.ITALIC + s; -// } - if(this.size != 1) s = TextColor.YELLOW + "" + this.size + " " + TextColor.RESET + s; - s = s + TextColor.RESET; - -// if (advanced) -// { - String s1 = ""; - - if (this.getHasSubtypes()) - { - s1 = s1 + String.format("%d", this.meta); - } -// else -// { -// s = s + String.format("#%04d", i); -// } - - if (s1.length() > 0) - { - s = s + " (" + s1 + ")"; - } - -// s = s + s1; -// } -// else if (!this.hasDisplayName() && this.item == Items.filled_map) -// { -// s = s + " #" + this.itemDamage; -// } - list.add(s); -// int i1 = 0; -// -// if (this.hasTagCompound() && this.stackTagCompound.hasKey("HideFlags", 99)) -// { -// i1 = this.stackTagCompound.getInteger("HideFlags"); -// } - -// if ((i1 & 32) == 0) -// { this.item.addInformation(this, playerIn, list); -// } if (this.hasTagCompound()) { -// if ((i1 & 1) == 0) -// { List nbttaglist = this.getEnchantmentTagList(); if (nbttaglist != null) @@ -824,37 +562,6 @@ public final class ItemStack } } } -// } - -// if (this.stackTagCompound.hasTag("display")) -// { -// NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display"); -// -// if (nbttagcompound.hasInt("color")) -// { -// if (advanced) -// { -// list.add("Color: #" + Integer.toHexString(nbttagcompound.getInteger("color")).toUpperCase()); -// } -// else -// { -// list.add(ChatFormat.ITALIC + I18n.translate("item.dyed")); -// } -// } -// -//// if (nbttagcompound.getTagId("Lore") == 9) -//// { -//// NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); -//// -//// if (nbttaglist1.tagCount() > 0) -//// { -//// for (int j1 = 0; j1 < nbttaglist1.tagCount(); ++j1) -//// { -//// list.add(ChatFormat.DARK_PURPLE + "" + ChatFormat.ITALIC + nbttaglist1.getStringTagAt(j1)); -//// } -//// } -//// } -// } } int damage = this.item.getAttackDamageBonus(); @@ -890,58 +597,6 @@ public final class ItemStack } } -// if (this.hasTagCompound() && this.stackTagCompound.hasList("CanDestroy") && (i1 & 8) == 0) -// { -// NBTTagList nbttaglist2 = this.stackTagCompound.getTagList("CanDestroy", 8); -// -// if (nbttaglist2.tagCount() > 0) -// { -// list.add(""); -// list.add(ChatFormat.GRAY + I18n.formatKey("item.canBreak")); -// -// for (int k1 = 0; k1 < nbttaglist2.tagCount(); ++k1) -// { -// Block block = BlockRegistry.getByIdFallback(nbttaglist2.getStringTagAt(k1)); -// -// if (block != null) -// { -// list.add(ChatFormat.DARK_GRAY + block.getLocalizedName()); -// } -// else -// { -// list.add(ChatFormat.DARK_GRAY + "missingno"); -// } -// } -// } -// } -// -// if (this.hasTagCompound() && this.stackTagCompound.hasList("CanPlaceOn") && (i1 & 16) == 0) -// { -// NBTTagList nbttaglist3 = this.stackTagCompound.getTagList("CanPlaceOn", 8); -// -// if (nbttaglist3.tagCount() > 0) -// { -// list.add(""); -// list.add(ChatFormat.GRAY + I18n.formatKey("item.canPlace")); -// -// for (int l1 = 0; l1 < nbttaglist3.tagCount(); ++l1) -// { -// Block block1 = BlockRegistry.getByIdFallback(nbttaglist3.getStringTagAt(l1)); -// -// if (block1 != null) -// { -// list.add(ChatFormat.DARK_GRAY + block1.getLocalizedName()); -// } -// else -// { -// list.add(ChatFormat.DARK_GRAY + "missingno"); -// } -// } -// } -// } - -// if (advanced) -// { if (this.isItemStackDamageable()) { list.add(String.format("Haltbarkeit: %d" + (this.isItemDamaged() ? " / %d" : ""), @@ -957,7 +612,6 @@ public final class ItemStack { list.add(TextColor.GRAY + String.format("NBT-Tags: %d", this.getTagCompound().keySet().size())); } -// } return list; } @@ -1085,46 +739,11 @@ public final class ItemStack this.tag.setList(key, value); } -// public boolean canEditBlocks() -// { -// return this.getItem().canItemEditBlocks(); -// } - - /** - * Return whether this stack is on an item frame. - */ -// public boolean isOnItemFrame() -// { -// return this.itemFrame != null; -// } -// -// /** -// * Set the item frame this stack is on. -// */ -// public void setItemFrame(EntityFrame frame) -// { -// this.itemFrame = frame; -// } -// -// /** -// * Return the item frame this stack is on. Returns null if not on an item frame. -// */ -// public EntityFrame getItemFrame() -// { -// return this.itemFrame; -// } - - /** - * Get this stack's repair cost, or 0 if no repair cost is defined. - */ public int getRepairCost() { return this.hasTagCompound() && this.tag.hasInt("RepairCost") ? this.tag.getInt("RepairCost") : 0; } - /** - * Set this stack's repair cost. - */ public void setRepairCost(int cost) { if(cost == 0) { @@ -1159,74 +778,4 @@ public final class ItemStack { this.item = newItem; } - -// public boolean canDestroy(Block blockIn) -// { -// if (blockIn == this.canDestroyCacheBlock) -// { -// return this.canDestroyCacheResult; -// } -// else -// { -// this.canDestroyCacheBlock = blockIn; -// -// if (this.hasTagCompound() && this.stackTagCompound.hasList("CanDestroy")) -// { -// NBTTagList nbttaglist = this.stackTagCompound.getTagList("CanDestroy", 8); -// -// for (int i = 0; i < nbttaglist.tagCount(); ++i) -// { -// Block block = BlockRegistry.getByIdFallback(nbttaglist.getStringTagAt(i)); -// -// if (block == blockIn) -// { -// this.canDestroyCacheResult = true; -// return true; -// } -// } -// } -// -// this.canDestroyCacheResult = false; -// return false; -// } -// } - -// public boolean canPlaceOn(Block blockIn) -// { -// if (blockIn == this.canPlaceOnCacheBlock) -// { -// return this.canPlaceOnCacheResult; -// } -// else -// { -// this.canPlaceOnCacheBlock = blockIn; -// -// if (this.hasTagCompound() && this.stackTagCompound.hasList("CanPlaceOn")) -// { -// NBTTagList nbttaglist = this.stackTagCompound.getTagList("CanPlaceOn", 8); -// -// for (int i = 0; i < nbttaglist.tagCount(); ++i) -// { -// Block block = BlockRegistry.getByIdFallback(nbttaglist.getStringTagAt(i)); -// -// if (block == blockIn) -// { -// this.canPlaceOnCacheResult = true; -// return true; -// } -// } -// } -// -// this.canPlaceOnCacheResult = false; -// return false; -// } -// } - -// public boolean validate() { -// return this.item != null && this.item.validate(this); -// } - -// public StackID getStackId() { -// return new StackID(this); -// } } diff --git a/common/src/main/java/common/item/ItemSword.java b/common/src/main/java/common/item/ItemSword.java index 2a741fa3..ea1610a3 100755 --- a/common/src/main/java/common/item/ItemSword.java +++ b/common/src/main/java/common/item/ItemSword.java @@ -18,7 +18,6 @@ public class ItemSword extends Item public ItemSword(ToolMaterial material) { this.material = material; - this.maxStackSize = 1; this.setMaxDamage(material.getDurability()); this.setTab(CheatTab.COMBAT); this.attackDamage = 4 + material.getDamage(); diff --git a/common/src/main/java/common/item/ItemTNT.java b/common/src/main/java/common/item/ItemTNT.java index 6aa1b7de..4f600074 100755 --- a/common/src/main/java/common/item/ItemTNT.java +++ b/common/src/main/java/common/item/ItemTNT.java @@ -7,22 +7,22 @@ public class ItemTNT extends ItemBlock { private static final String[] TIERS = new String[] {"II", "III", "IV", "V", "VI", "VII", "VIII"}; - public ItemTNT(Block block) + private final int power; + + public ItemTNT(Block block, int power) { super(block); - this.setMaxDamage(0); - this.setHasSubtypes(true); + this.power = power; this.setColor(TextColor.RED); } - public int getMetadata(int damage) + public int getMetadata() { - return (damage & 7) << 1; + return (this.power & 7) << 1; } public String getDisplay(ItemStack stack) { - int exp = stack.getMetadata() & 7; - return super.getDisplay(stack) + (exp == 0 ? "" : " " + TIERS[exp-1]); + return super.getDisplay(stack) + (this.power == 0 ? "" : " " + TIERS[this.power-1]); } } diff --git a/common/src/main/java/common/item/ItemTool.java b/common/src/main/java/common/item/ItemTool.java index 28e0768f..b287c04c 100755 --- a/common/src/main/java/common/item/ItemTool.java +++ b/common/src/main/java/common/item/ItemTool.java @@ -14,7 +14,6 @@ public abstract class ItemTool extends Item { public ItemTool(int damage, ToolMaterial material) { this.material = material; - this.maxStackSize = 1; this.setMaxDamage(material.getDurability()); this.efficiency = material.getEfficiency(); this.damage = damage + material.getDamage(); diff --git a/common/src/main/java/common/item/ItemWall.java b/common/src/main/java/common/item/ItemWall.java index 9e138fdc..a161c0ba 100755 --- a/common/src/main/java/common/item/ItemWall.java +++ b/common/src/main/java/common/item/ItemWall.java @@ -1,20 +1,18 @@ package common.item; -import java.util.function.Function; - import common.block.Block; import common.block.artificial.BlockWall; import common.model.Model; import common.model.ModelProvider; public class ItemWall extends ItemMultiTexture { - public ItemWall(Block block, Block block2, Function nameFunction) { - super(block, block2, nameFunction); + public ItemWall(Block block, int data) { + super(block, data); } - public Model getModel(ModelProvider provider, String name, int meta) { + public Model getModel(ModelProvider provider, String name) { return provider.getModel( - provider.getModel(this.block.getStateFromMeta(this.getMetadata(meta)).getValue(BlockWall.VARIANT).getName()) + provider.getModel(this.block.getStateFromMeta(this.data).getValue(BlockWall.VARIANT).getName()) .add(4, 0, 4, 12, 16, 12) .d().uv(4, 4, 12, 12) .u().uv(4, 4, 12, 12).noCull() diff --git a/common/src/main/java/common/item/ItemWand.java b/common/src/main/java/common/item/ItemWand.java index f0a494d0..c5a2017a 100755 --- a/common/src/main/java/common/item/ItemWand.java +++ b/common/src/main/java/common/item/ItemWand.java @@ -14,7 +14,7 @@ import common.world.AWorldServer; public abstract class ItemWand extends Item { public ItemWand() { - this.maxStackSize = 1; + this.setMaxAmount(1); this.setTab(CheatTab.TOOLS); } diff --git a/common/src/main/java/common/item/ItemWeatherToken.java b/common/src/main/java/common/item/ItemWeatherToken.java index bff9568e..a0937dd2 100755 --- a/common/src/main/java/common/item/ItemWeatherToken.java +++ b/common/src/main/java/common/item/ItemWeatherToken.java @@ -12,7 +12,7 @@ public class ItemWeatherToken extends ItemMagnetic { public ItemWeatherToken(Weather weather) { this.weather = weather; - this.setMaxStackSize(1); + this.setMaxAmount(1); this.setColor(TextColor.VIOLET); } diff --git a/common/src/main/java/common/item/RngLoot.java b/common/src/main/java/common/item/RngLoot.java index b8c9c4e2..b23b215e 100755 --- a/common/src/main/java/common/item/RngLoot.java +++ b/common/src/main/java/common/item/RngLoot.java @@ -14,12 +14,12 @@ public class RngLoot extends RngItem private int minStackSize; private int maxStackSize; - public RngLoot(Item item, int amount, int min, int max, int weight) + public RngLoot(Item item, int min, int max, int weight) { super(weight); - this.item = new ItemStack(item, 1, amount); + this.item = new ItemStack(item); this.minStackSize = min; - this.maxStackSize = max; + this.setMaxAmount(max); } public RngLoot(ItemStack stack, int min, int max, int weight) @@ -27,7 +27,7 @@ public class RngLoot extends RngItem super(weight); this.item = stack; this.minStackSize = min; - this.maxStackSize = max; + this.setMaxAmount(max); } public ItemStack getItem(Random rand) { diff --git a/common/src/main/java/common/network/PacketBuffer.java b/common/src/main/java/common/network/PacketBuffer.java index 5de7b2f3..9adf71bd 100755 --- a/common/src/main/java/common/network/PacketBuffer.java +++ b/common/src/main/java/common/network/PacketBuffer.java @@ -119,7 +119,6 @@ public class PacketBuffer { } this.writeShort(ItemRegistry.getIdFromItem(stack.getItem())); this.writeVarInt(stack.size); - this.writeShort(stack.getMetadata()); this.writeTag(stack.getTagCompound()); } @@ -128,8 +127,7 @@ public class PacketBuffer { if(id < 0) return null; int amt = this.readVarInt(); - int meta = this.readShort(); - ItemStack stack = new ItemStack(ItemRegistry.getItemById(id), amt, meta); + ItemStack stack = new ItemStack(ItemRegistry.getItemById(id), amt); stack.setTagCompound(this.readTag()); return stack; } diff --git a/common/src/main/java/common/tileentity/TileEntityBanner.java b/common/src/main/java/common/tileentity/TileEntityBanner.java index 6f09ac23..7664cbff 100755 --- a/common/src/main/java/common/tileentity/TileEntityBanner.java +++ b/common/src/main/java/common/tileentity/TileEntityBanner.java @@ -49,12 +49,12 @@ public class TileEntityBanner extends TileEntity } else { - this.baseColor = stack.getMetadata() & 15; + this.baseColor = DyeColor.WHITE.getDyeDamage(); } } else { - this.baseColor = stack.getMetadata() & 15; + this.baseColor = DyeColor.WHITE.getDyeDamage(); } this.patternList = null; @@ -104,10 +104,10 @@ public class TileEntityBanner extends TileEntity return this.baseColor; } - public static int getBaseColor(ItemStack stack) + public static DyeColor getBaseColor(ItemStack stack) { TagObject nbttagcompound = stack.getSubCompound("BlockEntityTag", false); - return nbttagcompound != null && nbttagcompound.hasInt("Base") ? nbttagcompound.getInt("Base") : stack.getMetadata(); + return nbttagcompound != null && nbttagcompound.hasInt("Base") ? DyeColor.byDyeDamage(nbttagcompound.getInt("Base")) : DyeColor.WHITE; } /** @@ -248,13 +248,13 @@ public class TileEntityBanner extends TileEntity HALF_HORIZONTAL_MIRROR("half_horizontal_bottom", "hhb", "Unten %s geteilt", null, true, " ", "###", "###"), BORDER("border", "bo", "%s Bord", 1, false, "###", "# #", "###"), CURLY_BORDER("curly_border", "cbo", "%s Spickelbord", 1, false, new ItemStack(Blocks.vine)), - RUNE("rune", "run", "%s Rune", -1, false, new ItemStack(Items.golden_apple, 1, 0)), + RUNE("rune", "run", "%s Rune", -1, false, new ItemStack(Items.golden_apple)), GRADIENT("gradient", "gra", "%s Farbverlauf", 1, false, "# #", " # ", " # "), GRADIENT_UP("gradient_up", "gru", "%s Farbverlauf (Invertiert)", 1, false, " # ", " # ", "# #"), BRICKS("bricks", "bri", "Feld %s gemauert", null, true, new ItemStack(Blocks.brick_block)), - SKULL("skull", "sku", "%s Schädel", 1, false, new ItemStack(Items.skull, 1, 0)), - FLOWER("flower", "flo", "%s Blume", -1, false, new ItemStack(Blocks.flower, 1, BlockFlower.EnumFlowerType.OXEYE_DAISY.getMeta())), - THING("thing", "thi", "%s ", 0, false, new ItemStack(Items.golden_apple, 1, 1)); + SKULL("skull", "sku", "%s Schädel", 1, false, new ItemStack(Items.skull)), + FLOWER("flower", "flo", "%s Blume", -1, false, new ItemStack(Items.daisy)), + THING("thing", "thi", "%s ", 0, false, new ItemStack(Items.golden_apple_powered)); private String patternName; private String patternID; diff --git a/common/src/main/java/common/tileentity/TileEntityBrewingStand.java b/common/src/main/java/common/tileentity/TileEntityBrewingStand.java index f883e9b8..36ecbb96 100755 --- a/common/src/main/java/common/tileentity/TileEntityBrewingStand.java +++ b/common/src/main/java/common/tileentity/TileEntityBrewingStand.java @@ -193,12 +193,12 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka { if (!ItemPotion.isSplash(j) && ItemPotion.isSplash(k)) { - this.brewingItemStacks[i].setItemDamage(k); + this.brewingItemStacks[i].setMetadata(k); } } else if (j != k) { - this.brewingItemStacks[i].setItemDamage(k); + this.brewingItemStacks[i].setMetadata(k); } } } diff --git a/common/src/main/java/common/tileentity/TileEntityFurnace.java b/common/src/main/java/common/tileentity/TileEntityFurnace.java index 519647cb..cd25eea3 100755 --- a/common/src/main/java/common/tileentity/TileEntityFurnace.java +++ b/common/src/main/java/common/tileentity/TileEntityFurnace.java @@ -398,10 +398,11 @@ public class TileEntityFurnace extends TileEntityLockable implements ITickable, (item instanceof ItemHoe && ((ItemHoe)item).getToolMaterial() == ToolType.WOOD.material ? 200 : (item == Items.stick ? 100 : (item == Items.coal ? 1600 : + (item == Items.charcoal ? 1200 : (item instanceof ItemBucket && ((ItemBucket)item).getLiquid() != null && ((ItemBucket)item).getLiquid().getMaterial() == Material.LAVA ? 20000 : (item.getBlock() instanceof BlockSapling ? 100 : - (item == Items.blaze_rod ? 2400 : 0))))))); + (item == Items.blaze_rod ? 2400 : 0)))))))); } } diff --git a/common/src/main/java/common/tileentity/TileEntityHopper.java b/common/src/main/java/common/tileentity/TileEntityHopper.java index 5da8f318..b866b247 100755 --- a/common/src/main/java/common/tileentity/TileEntityHopper.java +++ b/common/src/main/java/common/tileentity/TileEntityHopper.java @@ -685,7 +685,7 @@ public class TileEntityHopper extends TileEntityLockable implements IHopper, ITi public static boolean canCombine(ItemStack stack1, ItemStack stack2) { - return stack1.getItem() != stack2.getItem() ? false : (stack1.getMetadata() != stack2.getMetadata() ? false : (stack1.size > stack1.getMaxStackSize() ? false : ItemStack.areItemStackTagsEqual(stack1, stack2))); + return stack1.getItem() != stack2.getItem() ? false : (stack1.size > stack1.getMaxStackSize() ? false : ItemStack.areItemStackTagsEqual(stack1, stack2)); } /** diff --git a/server/src/main/java/server/network/Player.java b/server/src/main/java/server/network/Player.java index 52995821..8b9a84a3 100755 --- a/server/src/main/java/server/network/Player.java +++ b/server/src/main/java/server/network/Player.java @@ -284,7 +284,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer this.entity.inventory.dropAllItems(); } if(SVars.skullDrop) { - ItemStack stack = new ItemStack(Items.skull, 1, 0); + ItemStack stack = new ItemStack(Items.skull); this.entity.dropItem(stack, true, false); } @@ -1247,10 +1247,10 @@ public class Player extends User implements ICrafting, Executor, IPlayer // return true; // } int i = stack.size; - int j = stack.getMetadata(); + int j = stack.getItemDamage(); ItemStack itemstack = stack.useItemRightClick(this.entity.worldObj, this.entity); - if (itemstack != stack || itemstack != null && (itemstack.size != i || itemstack.getMaxItemUseDuration() > 0 || itemstack.getMetadata() != j)) + if (itemstack != stack || itemstack != null && (itemstack.size != i || itemstack.getMaxItemUseDuration() > 0 || itemstack.getItemDamage() != j)) { this.entity.inventory.mainInventory[this.entity.inventory.currentItem] = itemstack; @@ -2925,7 +2925,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer // boolean validSlot = packetIn.getSlotId() >= 1 && packetIn.getSlotId() < 36 + InventoryPlayer.getHotbarSize(); boolean validItem = itemstack.getItem() != null; - boolean validData = itemstack.getMetadata() >= 0 && itemstack.size <= itemstack.getMaxStackSize() && itemstack.size > 0; // TODO: max + boolean validData = itemstack.size <= itemstack.getMaxStackSize() && itemstack.size > 0; // TODO: max if (validItem && validData) { diff --git a/server/src/main/java/server/worldgen/LootConstants.java b/server/src/main/java/server/worldgen/LootConstants.java index a26738fd..4d392b22 100755 --- a/server/src/main/java/server/worldgen/LootConstants.java +++ b/server/src/main/java/server/worldgen/LootConstants.java @@ -8,64 +8,64 @@ import common.item.RngLoot; import common.rng.WeightedList; public abstract class LootConstants { - public static final WeightedList VILLAGE_BLACKSMITH = new WeightedList(new RngLoot(Items.diamond, 0, 1, 3, 3), - new RngLoot(Items.iron_ingot, 0, 1, 5, 10), new RngLoot(Items.gold_ingot, 0, 1, 3, 5), new RngLoot(Items.bread, 0, 1, 3, 15), - new RngLoot(Items.apple, 0, 1, 3, 15), new RngLoot(Items.iron_pickaxe, 0, 1, 1, 5), new RngLoot(Items.iron_sword, 0, 1, 1, 5), - new RngLoot(Items.iron_chestplate, 0, 1, 1, 5), new RngLoot(Items.iron_helmet, 0, 1, 1, 5), new RngLoot(Items.iron_leggings, 0, 1, 1, 5), - new RngLoot(Items.iron_boots, 0, 1, 1, 5), new RngLoot(ItemRegistry.getItemFromBlock(Blocks.obsidian), 0, 3, 7, 5), - new RngLoot(ItemRegistry.getItemFromBlock(Blocks.oak_sapling), 0, 3, 7, 5), new RngLoot(Items.saddle, 0, 1, 1, 3), - new RngLoot(Items.iron_horse_armor, 0, 1, 1, 1), new RngLoot(Items.gold_horse_armor, 0, 1, 1, 1), - new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 1)); - public static final WeightedList STRONGHOLD_CHEST = new WeightedList(new RngLoot(Items.orb, 0, 1, 1, 10), - new RngLoot(Items.diamond, 0, 1, 3, 3), new RngLoot(Items.iron_ingot, 0, 1, 5, 10), new RngLoot(Items.gold_ingot, 0, 1, 3, 5), - new RngLoot(Items.redstone, 0, 4, 9, 5), new RngLoot(Items.bread, 0, 1, 3, 15), new RngLoot(Items.apple, 0, 1, 3, 15), - new RngLoot(Items.iron_pickaxe, 0, 1, 1, 5), new RngLoot(Items.iron_sword, 0, 1, 1, 5), new RngLoot(Items.iron_chestplate, 0, 1, 1, 5), - new RngLoot(Items.iron_helmet, 0, 1, 1, 5), new RngLoot(Items.iron_leggings, 0, 1, 1, 5), new RngLoot(Items.iron_boots, 0, 1, 1, 5), - new RngLoot(Items.golden_apple, 0, 1, 1, 1), new RngLoot(Items.saddle, 0, 1, 1, 1), new RngLoot(Items.iron_horse_armor, 0, 1, 1, 1), - new RngLoot(Items.gold_horse_armor, 0, 1, 1, 1), new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 1)); - public static final WeightedList STRONGHOLD_LIBRARY = new WeightedList(new RngLoot(Items.book, 0, 1, 3, 20), - new RngLoot(Items.paper, 0, 2, 7, 20), new RngLoot(Items.string, 0, 1, 1, 1), new RngLoot(Items.navigator, 0, 1, 1, 1)); - public static final WeightedList STRONGHOLD_CROSS = new WeightedList(new RngLoot(Items.iron_ingot, 0, 1, 5, 10), - new RngLoot(Items.gold_ingot, 0, 1, 3, 5), new RngLoot(Items.redstone, 0, 4, 9, 5), new RngLoot(Items.coal, 0, 3, 8, 10), - new RngLoot(Items.bread, 0, 1, 3, 15), new RngLoot(Items.apple, 0, 1, 3, 15), new RngLoot(Items.iron_pickaxe, 0, 1, 1, 1)); - public static final WeightedList DESERT_PYRAMID = new WeightedList(new RngLoot(Items.diamond, 0, 1, 3, 3), - new RngLoot(Items.iron_ingot, 0, 1, 5, 10), new RngLoot(Items.gold_ingot, 0, 2, 7, 15), new RngLoot(Items.emerald, 0, 1, 3, 2), - new RngLoot(Items.bone, 0, 4, 6, 20), new RngLoot(Items.rotten_flesh, 0, 3, 7, 16), new RngLoot(Items.saddle, 0, 1, 1, 3), - new RngLoot(Items.iron_horse_armor, 0, 1, 1, 1), new RngLoot(Items.gold_horse_armor, 0, 1, 1, 1), - new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 1)); - public static final WeightedList JUNGLE_MAIN = new WeightedList(new RngLoot(Items.diamond, 0, 1, 3, 3), - new RngLoot(Items.iron_ingot, 0, 1, 5, 10), new RngLoot(Items.gold_ingot, 0, 2, 7, 15), new RngLoot(Items.emerald, 0, 1, 3, 2), - new RngLoot(Items.bone, 0, 4, 6, 20), new RngLoot(Items.rotten_flesh, 0, 3, 7, 16), new RngLoot(Items.saddle, 0, 1, 1, 3), - new RngLoot(Items.iron_horse_armor, 0, 1, 1, 1), new RngLoot(Items.gold_horse_armor, 0, 1, 1, 1), - new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 1)); - public static final WeightedList JUNGLE_TRAP = new WeightedList(new RngLoot(Items.arrow, 0, 2, 7, 30)); - public static final WeightedList MINESHAFT_CHEST = new WeightedList(new RngLoot(Items.iron_ingot, 0, 1, 5, 10), - new RngLoot(Items.gold_ingot, 0, 1, 3, 5), new RngLoot(Items.redstone, 0, 4, 9, 5), - new RngLoot(Items.dye, DyeColor.BLUE.getDyeDamage(), 4, 9, 5), new RngLoot(Items.diamond, 0, 1, 2, 3), - new RngLoot(Items.coal, 0, 3, 8, 10), new RngLoot(Items.bread, 0, 1, 3, 15), new RngLoot(Items.iron_pickaxe, 0, 1, 1, 1), - new RngLoot(ItemRegistry.getItemFromBlock(Blocks.rail), 0, 4, 8, 1), new RngLoot(Items.melon_stem, 0, 2, 4, 10), - new RngLoot(Items.pumpkin_stem, 0, 2, 4, 10), new RngLoot(Items.saddle, 0, 1, 1, 3), new RngLoot(Items.iron_horse_armor, 0, 1, 1, 1)); - public static final WeightedList HELL_FORTRESS = new WeightedList(new RngLoot(Items.diamond, 0, 1, 3, 5), - new RngLoot(Items.iron_ingot, 0, 1, 5, 5), new RngLoot(Items.gold_ingot, 0, 1, 3, 15), new RngLoot(Items.gold_sword, 0, 1, 1, 5), - new RngLoot(Items.gold_chestplate, 0, 1, 1, 5), new RngLoot(Items.flint_and_steel, 0, 1, 1, 5), - new RngLoot(Items.soul_wart, 0, 3, 7, 5), new RngLoot(Items.saddle, 0, 1, 1, 10), new RngLoot(Items.gold_horse_armor, 0, 1, 1, 8), - new RngLoot(Items.iron_horse_armor, 0, 1, 1, 5), new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 3), - new RngLoot(ItemRegistry.getItemFromBlock(Blocks.obsidian), 0, 2, 4, 2)); - public static final WeightedList DUNGEON_CHEST = new WeightedList(new RngLoot(Items.saddle, 0, 1, 1, 11), - new RngLoot(Items.iron_ingot, 0, 1, 4, 11), new RngLoot(Items.bread, 0, 1, 1, 11), new RngLoot(Items.wheats, 0, 1, 4, 11), - new RngLoot(Items.gunpowder, 0, 1, 4, 11), new RngLoot(Items.string, 0, 1, 4, 11), new RngLoot(Items.bucket, 0, 1, 1, 11), - new RngLoot(Items.golden_apple, 0, 1, 1, 1), new RngLoot(Items.redstone, 0, 1, 4, 11), new RngLoot(Items.aluminium_ingot, 0, 1, 1, 5), - new RngLoot(Items.copper_ingot, 0, 1, 1, 5), new RngLoot(Items.name_tag, 0, 1, 1, 11), new RngLoot(Items.gold_horse_armor, 0, 1, 1, 3), - new RngLoot(Items.iron_horse_armor, 0, 1, 1, 6), new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 2), - new RngLoot(Items.record_13, 0, 1, 1, 1), new RngLoot(Items.record_cat, 0, 1, 1, 1), new RngLoot(Items.record_blocks, 0, 1, 1, 1), - new RngLoot(Items.record_chirp, 0, 1, 1, 1), new RngLoot(Items.record_far, 0, 1, 1, 1), new RngLoot(Items.record_mall, 0, 1, 1, 1), - new RngLoot(Items.record_mellohi, 0, 1, 1, 1), new RngLoot(Items.record_stal, 0, 1, 1, 1), new RngLoot(Items.record_strad, 0, 1, 1, 1), - new RngLoot(Items.record_ward, 0, 1, 1, 1), new RngLoot(Items.record_11, 0, 1, 1, 1), new RngLoot(Items.record_wait, 0, 1, 1, 1), - new RngLoot(Items.record_delay, 0, 1, 1, 1), new RngLoot(Items.record_extend, 0, 1, 1, 1)); - public static final WeightedList ABANDONED_ITEMS = new WeightedList(new RngLoot(Items.stick, 0, 1, 3, 10), - new RngLoot(ItemRegistry.getItemFromBlock(Blocks.oak_planks), 0, 1, 3, 10), - new RngLoot(ItemRegistry.getItemFromBlock(Blocks.oak_log), 0, 1, 3, 10), new RngLoot(Items.stone_axe, 0, 1, 1, 3), - new RngLoot(Items.wood_axe, 0, 1, 1, 5), new RngLoot(Items.stone_pickaxe, 0, 1, 1, 3), new RngLoot(Items.wood_pickaxe, 0, 1, 1, 5), - new RngLoot(Items.apple, 0, 2, 3, 5), new RngLoot(Items.bread, 0, 2, 3, 3), - new RngLoot(ItemRegistry.getItemFromBlock(Blocks.acacia_log), 0, 1, 3, 10)); + public static final WeightedList VILLAGE_BLACKSMITH = new WeightedList(new RngLoot(Items.diamond, 1, 3, 3), + new RngLoot(Items.iron_ingot, 1, 5, 10), new RngLoot(Items.gold_ingot, 1, 3, 5), new RngLoot(Items.bread, 1, 3, 15), + new RngLoot(Items.apple, 1, 3, 15), new RngLoot(Items.iron_pickaxe, 1, 1, 5), new RngLoot(Items.iron_sword, 1, 1, 5), + new RngLoot(Items.iron_chestplate, 1, 1, 5), new RngLoot(Items.iron_helmet, 1, 1, 5), new RngLoot(Items.iron_leggings, 1, 1, 5), + new RngLoot(Items.iron_boots, 1, 1, 5), new RngLoot(ItemRegistry.getItemFromBlock(Blocks.obsidian), 3, 7, 5), + new RngLoot(ItemRegistry.getItemFromBlock(Blocks.oak_sapling), 3, 7, 5), new RngLoot(Items.saddle, 1, 1, 3), + new RngLoot(Items.iron_horse_armor, 1, 1, 1), new RngLoot(Items.gold_horse_armor, 1, 1, 1), + new RngLoot(Items.diamond_horse_armor, 1, 1, 1)); + public static final WeightedList STRONGHOLD_CHEST = new WeightedList(new RngLoot(Items.orb, 1, 1, 10), + new RngLoot(Items.diamond, 1, 3, 3), new RngLoot(Items.iron_ingot, 1, 5, 10), new RngLoot(Items.gold_ingot, 1, 3, 5), + new RngLoot(Items.redstone, 4, 9, 5), new RngLoot(Items.bread, 1, 3, 15), new RngLoot(Items.apple, 1, 3, 15), + new RngLoot(Items.iron_pickaxe, 1, 1, 5), new RngLoot(Items.iron_sword, 1, 1, 5), new RngLoot(Items.iron_chestplate, 1, 1, 5), + new RngLoot(Items.iron_helmet, 1, 1, 5), new RngLoot(Items.iron_leggings, 1, 1, 5), new RngLoot(Items.iron_boots, 1, 1, 5), + new RngLoot(Items.golden_apple, 1, 1, 1), new RngLoot(Items.saddle, 1, 1, 1), new RngLoot(Items.iron_horse_armor, 1, 1, 1), + new RngLoot(Items.gold_horse_armor, 1, 1, 1), new RngLoot(Items.diamond_horse_armor, 1, 1, 1)); + public static final WeightedList STRONGHOLD_LIBRARY = new WeightedList(new RngLoot(Items.book, 1, 3, 20), + new RngLoot(Items.paper, 2, 7, 20), new RngLoot(Items.string, 1, 1, 1), new RngLoot(Items.navigator, 1, 1, 1)); + public static final WeightedList STRONGHOLD_CROSS = new WeightedList(new RngLoot(Items.iron_ingot, 1, 5, 10), + new RngLoot(Items.gold_ingot, 1, 3, 5), new RngLoot(Items.redstone, 4, 9, 5), new RngLoot(Items.coal, 3, 8, 10), + new RngLoot(Items.bread, 1, 3, 15), new RngLoot(Items.apple, 1, 3, 15), new RngLoot(Items.iron_pickaxe, 1, 1, 1)); + public static final WeightedList DESERT_PYRAMID = new WeightedList(new RngLoot(Items.diamond, 1, 3, 3), + new RngLoot(Items.iron_ingot, 1, 5, 10), new RngLoot(Items.gold_ingot, 2, 7, 15), new RngLoot(Items.emerald, 1, 3, 2), + new RngLoot(Items.bone, 4, 6, 20), new RngLoot(Items.rotten_flesh, 3, 7, 16), new RngLoot(Items.saddle, 1, 1, 3), + new RngLoot(Items.iron_horse_armor, 1, 1, 1), new RngLoot(Items.gold_horse_armor, 1, 1, 1), + new RngLoot(Items.diamond_horse_armor, 1, 1, 1)); + public static final WeightedList JUNGLE_MAIN = new WeightedList(new RngLoot(Items.diamond, 1, 3, 3), + new RngLoot(Items.iron_ingot, 1, 5, 10), new RngLoot(Items.gold_ingot, 2, 7, 15), new RngLoot(Items.emerald, 1, 3, 2), + new RngLoot(Items.bone, 4, 6, 20), new RngLoot(Items.rotten_flesh, 3, 7, 16), new RngLoot(Items.saddle, 1, 1, 3), + new RngLoot(Items.iron_horse_armor, 1, 1, 1), new RngLoot(Items.gold_horse_armor, 1, 1, 1), + new RngLoot(Items.diamond_horse_armor, 1, 1, 1)); + public static final WeightedList JUNGLE_TRAP = new WeightedList(new RngLoot(Items.arrow, 2, 7, 30)); + public static final WeightedList MINESHAFT_CHEST = new WeightedList(new RngLoot(Items.iron_ingot, 1, 5, 10), + new RngLoot(Items.gold_ingot, 1, 3, 5), new RngLoot(Items.redstone, 4, 9, 5), + new RngLoot(Items.lapis_lazuli, 4, 9, 5), new RngLoot(Items.diamond, 1, 2, 3), + new RngLoot(Items.coal, 3, 8, 10), new RngLoot(Items.bread, 1, 3, 15), new RngLoot(Items.iron_pickaxe, 1, 1, 1), + new RngLoot(ItemRegistry.getItemFromBlock(Blocks.rail), 4, 8, 1), new RngLoot(Items.melon_stem, 2, 4, 10), + new RngLoot(Items.pumpkin_stem, 2, 4, 10), new RngLoot(Items.saddle, 1, 1, 3), new RngLoot(Items.iron_horse_armor, 1, 1, 1)); + public static final WeightedList HELL_FORTRESS = new WeightedList(new RngLoot(Items.diamond, 1, 3, 5), + new RngLoot(Items.iron_ingot, 1, 5, 5), new RngLoot(Items.gold_ingot, 1, 3, 15), new RngLoot(Items.gold_sword, 1, 1, 5), + new RngLoot(Items.gold_chestplate, 1, 1, 5), new RngLoot(Items.flint_and_steel, 1, 1, 5), + new RngLoot(Items.soul_wart, 3, 7, 5), new RngLoot(Items.saddle, 1, 1, 10), new RngLoot(Items.gold_horse_armor, 1, 1, 8), + new RngLoot(Items.iron_horse_armor, 1, 1, 5), new RngLoot(Items.diamond_horse_armor, 1, 1, 3), + new RngLoot(ItemRegistry.getItemFromBlock(Blocks.obsidian), 2, 4, 2)); + public static final WeightedList DUNGEON_CHEST = new WeightedList(new RngLoot(Items.saddle, 1, 1, 11), + new RngLoot(Items.iron_ingot, 1, 4, 11), new RngLoot(Items.bread, 1, 1, 11), new RngLoot(Items.wheats, 1, 4, 11), + new RngLoot(Items.gunpowder, 1, 4, 11), new RngLoot(Items.string, 1, 4, 11), new RngLoot(Items.bucket, 1, 1, 11), + new RngLoot(Items.golden_apple, 1, 1, 1), new RngLoot(Items.redstone, 1, 4, 11), new RngLoot(Items.aluminium_ingot, 1, 1, 5), + new RngLoot(Items.copper_ingot, 1, 1, 5), new RngLoot(Items.name_tag, 1, 1, 11), new RngLoot(Items.gold_horse_armor, 1, 1, 3), + new RngLoot(Items.iron_horse_armor, 1, 1, 6), new RngLoot(Items.diamond_horse_armor, 1, 1, 2), + new RngLoot(Items.record_13, 1, 1, 1), new RngLoot(Items.record_cat, 1, 1, 1), new RngLoot(Items.record_blocks, 1, 1, 1), + new RngLoot(Items.record_chirp, 1, 1, 1), new RngLoot(Items.record_far, 1, 1, 1), new RngLoot(Items.record_mall, 1, 1, 1), + new RngLoot(Items.record_mellohi, 1, 1, 1), new RngLoot(Items.record_stal, 1, 1, 1), new RngLoot(Items.record_strad, 1, 1, 1), + new RngLoot(Items.record_ward, 1, 1, 1), new RngLoot(Items.record_11, 1, 1, 1), new RngLoot(Items.record_wait, 1, 1, 1), + new RngLoot(Items.record_delay, 1, 1, 1), new RngLoot(Items.record_extend, 1, 1, 1)); + public static final WeightedList ABANDONED_ITEMS = new WeightedList(new RngLoot(Items.stick, 1, 3, 10), + new RngLoot(ItemRegistry.getItemFromBlock(Blocks.oak_planks), 1, 3, 10), + new RngLoot(ItemRegistry.getItemFromBlock(Blocks.oak_log), 1, 3, 10), new RngLoot(Items.stone_axe, 1, 1, 3), + new RngLoot(Items.wood_axe, 1, 1, 5), new RngLoot(Items.stone_pickaxe, 1, 1, 3), new RngLoot(Items.wood_pickaxe, 1, 1, 5), + new RngLoot(Items.apple, 2, 3, 5), new RngLoot(Items.bread, 2, 3, 3), + new RngLoot(ItemRegistry.getItemFromBlock(Blocks.acacia_log), 1, 3, 10)); }