001package net.minecraft.item; 002 003import cpw.mods.fml.common.registry.GameData; 004import cpw.mods.fml.relauncher.Side; 005import cpw.mods.fml.relauncher.SideOnly; 006import java.util.List; 007import java.util.Random; 008import net.minecraft.block.Block; 009import net.minecraft.block.material.Material; 010import net.minecraft.client.gui.FontRenderer; 011import net.minecraft.client.model.ModelBiped; 012import net.minecraft.client.renderer.texture.IconRegister; 013import net.minecraft.creativetab.CreativeTabs; 014import net.minecraft.entity.Entity; 015import net.minecraft.entity.EntityLiving; 016import net.minecraft.entity.item.EntityItem; 017import net.minecraft.entity.item.EntityItemFrame; 018import net.minecraft.entity.item.EntityPainting; 019import net.minecraft.entity.player.EntityPlayer; 020import net.minecraft.entity.player.EntityPlayerMP; 021import net.minecraft.potion.Potion; 022import net.minecraft.potion.PotionHelper; 023import net.minecraft.stats.StatList; 024import net.minecraft.util.Icon; 025import net.minecraft.util.MathHelper; 026import net.minecraft.util.MovingObjectPosition; 027import net.minecraft.util.StatCollector; 028import net.minecraft.util.StringTranslate; 029import net.minecraft.util.Vec3; 030import net.minecraft.util.WeightedRandomChestContent; 031import net.minecraft.world.World; 032import net.minecraftforge.common.ChestGenHooks; 033import net.minecraftforge.common.IArmorTextureProvider; 034 035public class Item 036{ 037 private CreativeTabs tabToDisplayOn = null; 038 039 /** The RNG used by the Item subclasses. */ 040 protected static Random itemRand = new Random(); 041 042 /** A 32000 elements Item array. */ 043 public static Item[] itemsList = new Item[32000]; 044 public static Item shovelIron = (new ItemSpade(0, EnumToolMaterial.IRON)).setUnlocalizedName("shovelIron"); 045 public static Item pickaxeIron = (new ItemPickaxe(1, EnumToolMaterial.IRON)).setUnlocalizedName("pickaxeIron"); 046 public static Item axeIron = (new ItemAxe(2, EnumToolMaterial.IRON)).setUnlocalizedName("hatchetIron"); 047 public static Item flintAndSteel = (new ItemFlintAndSteel(3)).setUnlocalizedName("flintAndSteel"); 048 public static Item appleRed = (new ItemFood(4, 4, 0.3F, false)).setUnlocalizedName("apple"); 049 public static ItemBow bow = (ItemBow)(new ItemBow(5)).setUnlocalizedName("bow"); 050 public static Item arrow = (new Item(6)).setUnlocalizedName("arrow").setCreativeTab(CreativeTabs.tabCombat); 051 public static Item coal = (new ItemCoal(7)).setUnlocalizedName("coal"); 052 public static Item diamond = (new Item(8)).setUnlocalizedName("diamond").setCreativeTab(CreativeTabs.tabMaterials); 053 public static Item ingotIron = (new Item(9)).setUnlocalizedName("ingotIron").setCreativeTab(CreativeTabs.tabMaterials); 054 public static Item ingotGold = (new Item(10)).setUnlocalizedName("ingotGold").setCreativeTab(CreativeTabs.tabMaterials); 055 public static Item swordIron = (new ItemSword(11, EnumToolMaterial.IRON)).setUnlocalizedName("swordIron"); 056 public static Item swordWood = (new ItemSword(12, EnumToolMaterial.WOOD)).setUnlocalizedName("swordWood"); 057 public static Item shovelWood = (new ItemSpade(13, EnumToolMaterial.WOOD)).setUnlocalizedName("shovelWood"); 058 public static Item pickaxeWood = (new ItemPickaxe(14, EnumToolMaterial.WOOD)).setUnlocalizedName("pickaxeWood"); 059 public static Item axeWood = (new ItemAxe(15, EnumToolMaterial.WOOD)).setUnlocalizedName("hatchetWood"); 060 public static Item swordStone = (new ItemSword(16, EnumToolMaterial.STONE)).setUnlocalizedName("swordStone"); 061 public static Item shovelStone = (new ItemSpade(17, EnumToolMaterial.STONE)).setUnlocalizedName("shovelStone"); 062 public static Item pickaxeStone = (new ItemPickaxe(18, EnumToolMaterial.STONE)).setUnlocalizedName("pickaxeStone"); 063 public static Item axeStone = (new ItemAxe(19, EnumToolMaterial.STONE)).setUnlocalizedName("hatchetStone"); 064 public static Item swordDiamond = (new ItemSword(20, EnumToolMaterial.EMERALD)).setUnlocalizedName("swordDiamond"); 065 public static Item shovelDiamond = (new ItemSpade(21, EnumToolMaterial.EMERALD)).setUnlocalizedName("shovelDiamond"); 066 public static Item pickaxeDiamond = (new ItemPickaxe(22, EnumToolMaterial.EMERALD)).setUnlocalizedName("pickaxeDiamond"); 067 public static Item axeDiamond = (new ItemAxe(23, EnumToolMaterial.EMERALD)).setUnlocalizedName("hatchetDiamond"); 068 public static Item stick = (new Item(24)).setFull3D().setUnlocalizedName("stick").setCreativeTab(CreativeTabs.tabMaterials); 069 public static Item bowlEmpty = (new Item(25)).setUnlocalizedName("bowl").setCreativeTab(CreativeTabs.tabMaterials); 070 public static Item bowlSoup = (new ItemSoup(26, 6)).setUnlocalizedName("mushroomStew"); 071 public static Item swordGold = (new ItemSword(27, EnumToolMaterial.GOLD)).setUnlocalizedName("swordGold"); 072 public static Item shovelGold = (new ItemSpade(28, EnumToolMaterial.GOLD)).setUnlocalizedName("shovelGold"); 073 public static Item pickaxeGold = (new ItemPickaxe(29, EnumToolMaterial.GOLD)).setUnlocalizedName("pickaxeGold"); 074 public static Item axeGold = (new ItemAxe(30, EnumToolMaterial.GOLD)).setUnlocalizedName("hatchetGold"); 075 public static Item silk = (new ItemReed(31, Block.tripWire)).setUnlocalizedName("string").setCreativeTab(CreativeTabs.tabMaterials); 076 public static Item feather = (new Item(32)).setUnlocalizedName("feather").setCreativeTab(CreativeTabs.tabMaterials); 077 public static Item gunpowder = (new Item(33)).setUnlocalizedName("sulphur").setPotionEffect(PotionHelper.gunpowderEffect).setCreativeTab(CreativeTabs.tabMaterials); 078 public static Item hoeWood = (new ItemHoe(34, EnumToolMaterial.WOOD)).setUnlocalizedName("hoeWood"); 079 public static Item hoeStone = (new ItemHoe(35, EnumToolMaterial.STONE)).setUnlocalizedName("hoeStone"); 080 public static Item hoeIron = (new ItemHoe(36, EnumToolMaterial.IRON)).setUnlocalizedName("hoeIron"); 081 public static Item hoeDiamond = (new ItemHoe(37, EnumToolMaterial.EMERALD)).setUnlocalizedName("hoeDiamond"); 082 public static Item hoeGold = (new ItemHoe(38, EnumToolMaterial.GOLD)).setUnlocalizedName("hoeGold"); 083 public static Item seeds = (new ItemSeeds(39, Block.crops.blockID, Block.tilledField.blockID)).setUnlocalizedName("seeds"); 084 public static Item wheat = (new Item(40)).setUnlocalizedName("wheat").setCreativeTab(CreativeTabs.tabMaterials); 085 public static Item bread = (new ItemFood(41, 5, 0.6F, false)).setUnlocalizedName("bread"); 086 public static ItemArmor helmetLeather = (ItemArmor)(new ItemArmor(42, EnumArmorMaterial.CLOTH, 0, 0)).setUnlocalizedName("helmetCloth"); 087 public static ItemArmor plateLeather = (ItemArmor)(new ItemArmor(43, EnumArmorMaterial.CLOTH, 0, 1)).setUnlocalizedName("chestplateCloth"); 088 public static ItemArmor legsLeather = (ItemArmor)(new ItemArmor(44, EnumArmorMaterial.CLOTH, 0, 2)).setUnlocalizedName("leggingsCloth"); 089 public static ItemArmor bootsLeather = (ItemArmor)(new ItemArmor(45, EnumArmorMaterial.CLOTH, 0, 3)).setUnlocalizedName("bootsCloth"); 090 public static ItemArmor helmetChain = (ItemArmor)(new ItemArmor(46, EnumArmorMaterial.CHAIN, 1, 0)).setUnlocalizedName("helmetChain"); 091 public static ItemArmor plateChain = (ItemArmor)(new ItemArmor(47, EnumArmorMaterial.CHAIN, 1, 1)).setUnlocalizedName("chestplateChain"); 092 public static ItemArmor legsChain = (ItemArmor)(new ItemArmor(48, EnumArmorMaterial.CHAIN, 1, 2)).setUnlocalizedName("leggingsChain"); 093 public static ItemArmor bootsChain = (ItemArmor)(new ItemArmor(49, EnumArmorMaterial.CHAIN, 1, 3)).setUnlocalizedName("bootsChain"); 094 public static ItemArmor helmetIron = (ItemArmor)(new ItemArmor(50, EnumArmorMaterial.IRON, 2, 0)).setUnlocalizedName("helmetIron"); 095 public static ItemArmor plateIron = (ItemArmor)(new ItemArmor(51, EnumArmorMaterial.IRON, 2, 1)).setUnlocalizedName("chestplateIron"); 096 public static ItemArmor legsIron = (ItemArmor)(new ItemArmor(52, EnumArmorMaterial.IRON, 2, 2)).setUnlocalizedName("leggingsIron"); 097 public static ItemArmor bootsIron = (ItemArmor)(new ItemArmor(53, EnumArmorMaterial.IRON, 2, 3)).setUnlocalizedName("bootsIron"); 098 public static ItemArmor helmetDiamond = (ItemArmor)(new ItemArmor(54, EnumArmorMaterial.DIAMOND, 3, 0)).setUnlocalizedName("helmetDiamond"); 099 public static ItemArmor plateDiamond = (ItemArmor)(new ItemArmor(55, EnumArmorMaterial.DIAMOND, 3, 1)).setUnlocalizedName("chestplateDiamond"); 100 public static ItemArmor legsDiamond = (ItemArmor)(new ItemArmor(56, EnumArmorMaterial.DIAMOND, 3, 2)).setUnlocalizedName("leggingsDiamond"); 101 public static ItemArmor bootsDiamond = (ItemArmor)(new ItemArmor(57, EnumArmorMaterial.DIAMOND, 3, 3)).setUnlocalizedName("bootsDiamond"); 102 public static ItemArmor helmetGold = (ItemArmor)(new ItemArmor(58, EnumArmorMaterial.GOLD, 4, 0)).setUnlocalizedName("helmetGold"); 103 public static ItemArmor plateGold = (ItemArmor)(new ItemArmor(59, EnumArmorMaterial.GOLD, 4, 1)).setUnlocalizedName("chestplateGold"); 104 public static ItemArmor legsGold = (ItemArmor)(new ItemArmor(60, EnumArmorMaterial.GOLD, 4, 2)).setUnlocalizedName("leggingsGold"); 105 public static ItemArmor bootsGold = (ItemArmor)(new ItemArmor(61, EnumArmorMaterial.GOLD, 4, 3)).setUnlocalizedName("bootsGold"); 106 public static Item flint = (new Item(62)).setUnlocalizedName("flint").setCreativeTab(CreativeTabs.tabMaterials); 107 public static Item porkRaw = (new ItemFood(63, 3, 0.3F, true)).setUnlocalizedName("porkchopRaw"); 108 public static Item porkCooked = (new ItemFood(64, 8, 0.8F, true)).setUnlocalizedName("porkchopCooked"); 109 public static Item painting = (new ItemHangingEntity(65, EntityPainting.class)).setUnlocalizedName("painting"); 110 public static Item appleGold = (new ItemAppleGold(66, 4, 1.2F, false)).setAlwaysEdible().setPotionEffect(Potion.regeneration.id, 5, 0, 1.0F).setUnlocalizedName("appleGold"); 111 public static Item sign = (new ItemSign(67)).setUnlocalizedName("sign"); 112 public static Item doorWood = (new ItemDoor(68, Material.wood)).setUnlocalizedName("doorWood"); 113 public static Item bucketEmpty = (new ItemBucket(69, 0)).setUnlocalizedName("bucket").setMaxStackSize(16); 114 public static Item bucketWater = (new ItemBucket(70, Block.waterMoving.blockID)).setUnlocalizedName("bucketWater").setContainerItem(bucketEmpty); 115 public static Item bucketLava = (new ItemBucket(71, Block.lavaMoving.blockID)).setUnlocalizedName("bucketLava").setContainerItem(bucketEmpty); 116 public static Item minecartEmpty = (new ItemMinecart(72, 0)).setUnlocalizedName("minecart"); 117 public static Item saddle = (new ItemSaddle(73)).setUnlocalizedName("saddle"); 118 public static Item doorIron = (new ItemDoor(74, Material.iron)).setUnlocalizedName("doorIron"); 119 public static Item redstone = (new ItemRedstone(75)).setUnlocalizedName("redstone").setPotionEffect(PotionHelper.redstoneEffect); 120 public static Item snowball = (new ItemSnowball(76)).setUnlocalizedName("snowball"); 121 public static Item boat = (new ItemBoat(77)).setUnlocalizedName("boat"); 122 public static Item leather = (new Item(78)).setUnlocalizedName("leather").setCreativeTab(CreativeTabs.tabMaterials); 123 public static Item bucketMilk = (new ItemBucketMilk(79)).setUnlocalizedName("milk").setContainerItem(bucketEmpty); 124 public static Item brick = (new Item(80)).setUnlocalizedName("brick").setCreativeTab(CreativeTabs.tabMaterials); 125 public static Item clay = (new Item(81)).setUnlocalizedName("clay").setCreativeTab(CreativeTabs.tabMaterials); 126 public static Item reed = (new ItemReed(82, Block.reed)).setUnlocalizedName("reeds").setCreativeTab(CreativeTabs.tabMaterials); 127 public static Item paper = (new Item(83)).setUnlocalizedName("paper").setCreativeTab(CreativeTabs.tabMisc); 128 public static Item book = (new ItemBook(84)).setUnlocalizedName("book").setCreativeTab(CreativeTabs.tabMisc); 129 public static Item slimeBall = (new Item(85)).setUnlocalizedName("slimeball").setCreativeTab(CreativeTabs.tabMisc); 130 public static Item minecartCrate = (new ItemMinecart(86, 1)).setUnlocalizedName("minecartChest"); 131 public static Item minecartPowered = (new ItemMinecart(87, 2)).setUnlocalizedName("minecartFurnace"); 132 public static Item egg = (new ItemEgg(88)).setUnlocalizedName("egg"); 133 public static Item compass = (new Item(89)).setUnlocalizedName("compass").setCreativeTab(CreativeTabs.tabTools); 134 public static ItemFishingRod fishingRod = (ItemFishingRod)(new ItemFishingRod(90)).setUnlocalizedName("fishingRod"); 135 public static Item pocketSundial = (new Item(91)).setUnlocalizedName("clock").setCreativeTab(CreativeTabs.tabTools); 136 public static Item lightStoneDust = (new Item(92)).setUnlocalizedName("yellowDust").setPotionEffect(PotionHelper.glowstoneEffect).setCreativeTab(CreativeTabs.tabMaterials); 137 public static Item fishRaw = (new ItemFood(93, 2, 0.3F, false)).setUnlocalizedName("fishRaw"); 138 public static Item fishCooked = (new ItemFood(94, 5, 0.6F, false)).setUnlocalizedName("fishCooked"); 139 public static Item dyePowder = (new ItemDye(95)).setUnlocalizedName("dyePowder"); 140 public static Item bone = (new Item(96)).setUnlocalizedName("bone").setFull3D().setCreativeTab(CreativeTabs.tabMisc); 141 public static Item sugar = (new Item(97)).setUnlocalizedName("sugar").setPotionEffect(PotionHelper.sugarEffect).setCreativeTab(CreativeTabs.tabMaterials); 142 public static Item cake = (new ItemReed(98, Block.cake)).setMaxStackSize(1).setUnlocalizedName("cake").setCreativeTab(CreativeTabs.tabFood); 143 public static Item bed = (new ItemBed(99)).setMaxStackSize(1).setUnlocalizedName("bed"); 144 public static Item redstoneRepeater = (new ItemReed(100, Block.redstoneRepeaterIdle)).setUnlocalizedName("diode").setCreativeTab(CreativeTabs.tabRedstone); 145 public static Item cookie = (new ItemFood(101, 2, 0.1F, false)).setUnlocalizedName("cookie"); 146 public static ItemMap map = (ItemMap)(new ItemMap(102)).setUnlocalizedName("map"); 147 148 /** 149 * Item introduced on 1.7 version, is a shear to cut leaves (you can keep the block) or get wool from sheeps. 150 */ 151 public static ItemShears shears = (ItemShears)(new ItemShears(103)).setUnlocalizedName("shears"); 152 public static Item melon = (new ItemFood(104, 2, 0.3F, false)).setUnlocalizedName("melon"); 153 public static Item pumpkinSeeds = (new ItemSeeds(105, Block.pumpkinStem.blockID, Block.tilledField.blockID)).setUnlocalizedName("seeds_pumpkin"); 154 public static Item melonSeeds = (new ItemSeeds(106, Block.melonStem.blockID, Block.tilledField.blockID)).setUnlocalizedName("seeds_melon"); 155 public static Item beefRaw = (new ItemFood(107, 3, 0.3F, true)).setUnlocalizedName("beefRaw"); 156 public static Item beefCooked = (new ItemFood(108, 8, 0.8F, true)).setUnlocalizedName("beefCooked"); 157 public static Item chickenRaw = (new ItemFood(109, 2, 0.3F, true)).setPotionEffect(Potion.hunger.id, 30, 0, 0.3F).setUnlocalizedName("chickenRaw"); 158 public static Item chickenCooked = (new ItemFood(110, 6, 0.6F, true)).setUnlocalizedName("chickenCooked"); 159 public static Item rottenFlesh = (new ItemFood(111, 4, 0.1F, true)).setPotionEffect(Potion.hunger.id, 30, 0, 0.8F).setUnlocalizedName("rottenFlesh"); 160 public static Item enderPearl = (new ItemEnderPearl(112)).setUnlocalizedName("enderPearl"); 161 public static Item blazeRod = (new Item(113)).setUnlocalizedName("blazeRod").setCreativeTab(CreativeTabs.tabMaterials); 162 public static Item ghastTear = (new Item(114)).setUnlocalizedName("ghastTear").setPotionEffect(PotionHelper.ghastTearEffect).setCreativeTab(CreativeTabs.tabBrewing); 163 public static Item goldNugget = (new Item(115)).setUnlocalizedName("goldNugget").setCreativeTab(CreativeTabs.tabMaterials); 164 public static Item netherStalkSeeds = (new ItemSeeds(116, Block.netherStalk.blockID, Block.slowSand.blockID)).setUnlocalizedName("netherStalkSeeds").setPotionEffect("+4"); 165 public static ItemPotion potion = (ItemPotion)(new ItemPotion(117)).setUnlocalizedName("potion"); 166 public static Item glassBottle = (new ItemGlassBottle(118)).setUnlocalizedName("glassBottle"); 167 public static Item spiderEye = (new ItemFood(119, 2, 0.8F, false)).setPotionEffect(Potion.poison.id, 5, 0, 1.0F).setUnlocalizedName("spiderEye").setPotionEffect(PotionHelper.spiderEyeEffect); 168 public static Item fermentedSpiderEye = (new Item(120)).setUnlocalizedName("fermentedSpiderEye").setPotionEffect(PotionHelper.fermentedSpiderEyeEffect).setCreativeTab(CreativeTabs.tabBrewing); 169 public static Item blazePowder = (new Item(121)).setUnlocalizedName("blazePowder").setPotionEffect(PotionHelper.blazePowderEffect).setCreativeTab(CreativeTabs.tabBrewing); 170 public static Item magmaCream = (new Item(122)).setUnlocalizedName("magmaCream").setPotionEffect(PotionHelper.magmaCreamEffect).setCreativeTab(CreativeTabs.tabBrewing); 171 public static Item brewingStand = (new ItemReed(123, Block.brewingStand)).setUnlocalizedName("brewingStand").setCreativeTab(CreativeTabs.tabBrewing); 172 public static Item cauldron = (new ItemReed(124, Block.cauldron)).setUnlocalizedName("cauldron").setCreativeTab(CreativeTabs.tabBrewing); 173 public static Item eyeOfEnder = (new ItemEnderEye(125)).setUnlocalizedName("eyeOfEnder"); 174 public static Item speckledMelon = (new Item(126)).setUnlocalizedName("speckledMelon").setPotionEffect(PotionHelper.speckledMelonEffect).setCreativeTab(CreativeTabs.tabBrewing); 175 public static Item monsterPlacer = (new ItemMonsterPlacer(127)).setUnlocalizedName("monsterPlacer"); 176 177 /** 178 * Bottle o' Enchanting. Drops between 1 and 3 experience orbs when thrown. 179 */ 180 public static Item expBottle = (new ItemExpBottle(128)).setUnlocalizedName("expBottle"); 181 182 /** 183 * Fire Charge. When used in a dispenser it fires a fireball similiar to a Ghast's. 184 */ 185 public static Item fireballCharge = (new ItemFireball(129)).setUnlocalizedName("fireball"); 186 public static Item writableBook = (new ItemWritableBook(130)).setUnlocalizedName("writingBook").setCreativeTab(CreativeTabs.tabMisc); 187 public static Item writtenBook = (new ItemEditableBook(131)).setUnlocalizedName("writtenBook"); 188 public static Item emerald = (new Item(132)).setUnlocalizedName("emerald").setCreativeTab(CreativeTabs.tabMaterials); 189 public static Item itemFrame = (new ItemHangingEntity(133, EntityItemFrame.class)).setUnlocalizedName("frame"); 190 public static Item flowerPot = (new ItemReed(134, Block.flowerPot)).setUnlocalizedName("flowerPot").setCreativeTab(CreativeTabs.tabDecorations); 191 public static Item carrot = (new ItemSeedFood(135, 4, 0.6F, Block.carrot.blockID, Block.tilledField.blockID)).setUnlocalizedName("carrots"); 192 public static Item potato = (new ItemSeedFood(136, 1, 0.3F, Block.potato.blockID, Block.tilledField.blockID)).setUnlocalizedName("potato"); 193 public static Item bakedPotato = (new ItemFood(137, 6, 0.6F, false)).setUnlocalizedName("potatoBaked"); 194 public static Item poisonousPotato = (new ItemFood(138, 2, 0.3F, false)).setPotionEffect(Potion.poison.id, 5, 0, 0.6F).setUnlocalizedName("potatoPoisonous"); 195 public static ItemEmptyMap emptyMap = (ItemEmptyMap)(new ItemEmptyMap(139)).setUnlocalizedName("emptyMap"); 196 public static Item goldenCarrot = (new ItemFood(140, 6, 1.2F, false)).setUnlocalizedName("carrotGolden").setPotionEffect(PotionHelper.goldenCarrotEffect); 197 public static Item skull = (new ItemSkull(141)).setUnlocalizedName("skull"); 198 public static Item carrotOnAStick = (new ItemCarrotOnAStick(142)).setUnlocalizedName("carrotOnAStick"); 199 public static Item netherStar = (new ItemSimpleFoiled(143)).setUnlocalizedName("netherStar").setCreativeTab(CreativeTabs.tabMaterials); 200 public static Item pumpkinPie = (new ItemFood(144, 8, 0.3F, false)).setUnlocalizedName("pumpkinPie").setCreativeTab(CreativeTabs.tabFood); 201 public static Item firework = (new ItemFirework(145)).setUnlocalizedName("fireworks"); 202 public static Item fireworkCharge = (new ItemFireworkCharge(146)).setUnlocalizedName("fireworksCharge").setCreativeTab(CreativeTabs.tabMisc); 203 public static ItemEnchantedBook enchantedBook = (ItemEnchantedBook)(new ItemEnchantedBook(147)).setMaxStackSize(1).setUnlocalizedName("enchantedBook"); 204 public static Item comparator = (new ItemReed(148, Block.redstoneComparatorIdle)).setUnlocalizedName("comparator").setCreativeTab(CreativeTabs.tabRedstone); 205 public static Item netherrackBrick = (new Item(149)).setUnlocalizedName("netherbrick").setCreativeTab(CreativeTabs.tabMaterials); 206 public static Item netherQuartz = (new Item(150)).setUnlocalizedName("netherquartz").setCreativeTab(CreativeTabs.tabMaterials); 207 public static Item tntMinecart = (new ItemMinecart(151, 3)).setUnlocalizedName("minecartTnt"); 208 public static Item hopperMinecart = (new ItemMinecart(152, 5)).setUnlocalizedName("minecartHopper"); 209 public static Item record13 = (new ItemRecord(2000, "13")).setUnlocalizedName("record"); 210 public static Item recordCat = (new ItemRecord(2001, "cat")).setUnlocalizedName("record"); 211 public static Item recordBlocks = (new ItemRecord(2002, "blocks")).setUnlocalizedName("record"); 212 public static Item recordChirp = (new ItemRecord(2003, "chirp")).setUnlocalizedName("record"); 213 public static Item recordFar = (new ItemRecord(2004, "far")).setUnlocalizedName("record"); 214 public static Item recordMall = (new ItemRecord(2005, "mall")).setUnlocalizedName("record"); 215 public static Item recordMellohi = (new ItemRecord(2006, "mellohi")).setUnlocalizedName("record"); 216 public static Item recordStal = (new ItemRecord(2007, "stal")).setUnlocalizedName("record"); 217 public static Item recordStrad = (new ItemRecord(2008, "strad")).setUnlocalizedName("record"); 218 public static Item recordWard = (new ItemRecord(2009, "ward")).setUnlocalizedName("record"); 219 public static Item record11 = (new ItemRecord(2010, "11")).setUnlocalizedName("record"); 220 public static Item recordWait = (new ItemRecord(2011, "wait")).setUnlocalizedName("record"); 221 222 /** The ID of this item. */ 223 public final int itemID; 224 225 /** Maximum size of the stack. */ 226 protected int maxStackSize = 64; 227 228 /** Maximum damage an item can handle. */ 229 private int maxDamage = 0; 230 231 /** If true, render the object in full 3D, like weapons and tools. */ 232 protected boolean bFull3D = false; 233 234 /** 235 * Some items (like dyes) have multiple subtypes on same item, this is field define this behavior 236 */ 237 protected boolean hasSubtypes = false; 238 private Item containerItem = null; 239 private String potionEffect = null; 240 241 /** The unlocalized name of this item. */ 242 private String unlocalizedName; 243 @SideOnly(Side.CLIENT) 244 245 /** Icon index in the icons table. */ 246 protected Icon itemIcon; 247 248 /** FORGE: To disable repair recipes. */ 249 protected boolean canRepair = true; 250 251 public Item(int par1) 252 { 253 this.itemID = 256 + par1; 254 255 if (itemsList[256 + par1] != null) 256 { 257 System.out.println("CONFLICT @ " + par1 + " item slot already occupied by " + itemsList[256 + par1] + " while adding " + this); 258 } 259 260 itemsList[256 + par1] = this; 261 262 GameData.newItemAdded(this); 263 } 264 265 public Item setMaxStackSize(int par1) 266 { 267 this.maxStackSize = par1; 268 return this; 269 } 270 271 @SideOnly(Side.CLIENT) 272 273 /** 274 * Returns 0 for /terrain.png, 1 for /gui/items.png 275 */ 276 public int getSpriteNumber() 277 { 278 return 1; 279 } 280 281 @SideOnly(Side.CLIENT) 282 283 /** 284 * Gets an icon index based on an item's damage value 285 */ 286 public Icon getIconFromDamage(int par1) 287 { 288 return this.itemIcon; 289 } 290 291 @SideOnly(Side.CLIENT) 292 293 /** 294 * Returns the icon index of the stack given as argument. 295 */ 296 public final Icon getIconIndex(ItemStack par1ItemStack) 297 { 298 return this.getIconFromDamage(par1ItemStack.getItemDamage()); 299 } 300 301 /** 302 * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return 303 * True if something happen and false if it don't. This is for ITEMS, not BLOCKS 304 */ 305 public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) 306 { 307 return false; 308 } 309 310 /** 311 * Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if 312 * sword 313 */ 314 public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block) 315 { 316 return 1.0F; 317 } 318 319 /** 320 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer 321 */ 322 public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) 323 { 324 return par1ItemStack; 325 } 326 327 public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) 328 { 329 return par1ItemStack; 330 } 331 332 /** 333 * Returns the maximum size of the stack for a specific item. *Isn't this more a Set than a Get?* 334 */ 335 public int getItemStackLimit() 336 { 337 return this.maxStackSize; 338 } 339 340 /** 341 * Returns the metadata of the block which this Item (ItemBlock) can place 342 */ 343 public int getMetadata(int par1) 344 { 345 return 0; 346 } 347 348 public boolean getHasSubtypes() 349 { 350 return this.hasSubtypes; 351 } 352 353 protected Item setHasSubtypes(boolean par1) 354 { 355 this.hasSubtypes = par1; 356 return this; 357 } 358 359 /** 360 * Returns the maximum damage an item can take. 361 */ 362 public int getMaxDamage() 363 { 364 return this.maxDamage; 365 } 366 367 /** 368 * set max damage of an Item 369 */ 370 public Item setMaxDamage(int par1) 371 { 372 this.maxDamage = par1; 373 return this; 374 } 375 376 public boolean isDamageable() 377 { 378 return this.maxDamage > 0 && !this.hasSubtypes; 379 } 380 381 /** 382 * Current implementations of this method in child classes do not use the entry argument beside ev. They just raise 383 * the damage on the stack. 384 */ 385 public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving) 386 { 387 return false; 388 } 389 390 public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving) 391 { 392 return false; 393 } 394 395 /** 396 * Returns the damage against a given entity. 397 */ 398 public int getDamageVsEntity(Entity par1Entity) 399 { 400 return 1; 401 } 402 403 /** 404 * Returns if the item (tool) can harvest results from the block type. 405 */ 406 public boolean canHarvestBlock(Block par1Block) 407 { 408 return false; 409 } 410 411 /** 412 * Called when a player right clicks an entity with an item. 413 */ 414 public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving) 415 { 416 return false; 417 } 418 419 /** 420 * Sets bFull3D to True and return the object. 421 */ 422 public Item setFull3D() 423 { 424 this.bFull3D = true; 425 return this; 426 } 427 428 @SideOnly(Side.CLIENT) 429 430 /** 431 * Returns True is the item is renderer in full 3D when hold. 432 */ 433 public boolean isFull3D() 434 { 435 return this.bFull3D; 436 } 437 438 @SideOnly(Side.CLIENT) 439 440 /** 441 * Returns true if this item should be rotated by 180 degrees around the Y axis when being held in an entities 442 * hands. 443 */ 444 public boolean shouldRotateAroundWhenRendering() 445 { 446 return false; 447 } 448 449 /** 450 * Sets the unlocalized name of this item to the string passed as the parameter, prefixed by "item." 451 */ 452 public Item setUnlocalizedName(String par1Str) 453 { 454 this.unlocalizedName = par1Str; 455 return this; 456 } 457 458 /** 459 * Gets the localized name of the given item stack. 460 */ 461 public String getLocalizedName(ItemStack par1ItemStack) 462 { 463 String s = this.getUnlocalizedName(par1ItemStack); 464 return s == null ? "" : StatCollector.translateToLocal(s); 465 } 466 467 /** 468 * Returns the unlocalized name of this item. 469 */ 470 public String getUnlocalizedName() 471 { 472 return "item." + this.unlocalizedName; 473 } 474 475 /** 476 * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have 477 * different names based on their damage or NBT. 478 */ 479 public String getUnlocalizedName(ItemStack par1ItemStack) 480 { 481 return "item." + this.unlocalizedName; 482 } 483 484 public Item setContainerItem(Item par1Item) 485 { 486 this.containerItem = par1Item; 487 return this; 488 } 489 490 /** 491 * If this returns true, after a recipe involving this item is crafted the container item will be added to the 492 * player's inventory instead of remaining in the crafting grid. 493 */ 494 public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) 495 { 496 return true; 497 } 498 499 /** 500 * If this function returns true (or the item is damageable), the ItemStack's NBT tag will be sent to the client. 501 */ 502 public boolean getShareTag() 503 { 504 return true; 505 } 506 507 public Item getContainerItem() 508 { 509 return this.containerItem; 510 } 511 512 /** 513 * True if this Item has a container item (a.k.a. crafting result) 514 */ 515 public boolean hasContainerItem() 516 { 517 return this.containerItem != null; 518 } 519 520 public String getStatName() 521 { 522 return StatCollector.translateToLocal(this.getUnlocalizedName() + ".name"); 523 } 524 525 public String func_77653_i(ItemStack par1ItemStack) 526 { 527 return StatCollector.translateToLocal(this.getUnlocalizedName(par1ItemStack) + ".name"); 528 } 529 530 @SideOnly(Side.CLIENT) 531 public int getColorFromItemStack(ItemStack par1ItemStack, int par2) 532 { 533 return 16777215; 534 } 535 536 /** 537 * Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and 538 * update it's contents. 539 */ 540 public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {} 541 542 /** 543 * Called when item is crafted/smelted. Used only by maps so far. 544 */ 545 public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {} 546 547 /** 548 * false for all Items except sub-classes of ItemMapBase 549 */ 550 public boolean isMap() 551 { 552 return false; 553 } 554 555 /** 556 * returns the action that specifies what animation to play when the items is being used 557 */ 558 public EnumAction getItemUseAction(ItemStack par1ItemStack) 559 { 560 return EnumAction.none; 561 } 562 563 /** 564 * How long it takes to use or consume an item 565 */ 566 public int getMaxItemUseDuration(ItemStack par1ItemStack) 567 { 568 return 0; 569 } 570 571 /** 572 * called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount 573 */ 574 public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) {} 575 576 /** 577 * Sets the string representing this item's effect on a potion when used as an ingredient. 578 */ 579 public Item setPotionEffect(String par1Str) 580 { 581 this.potionEffect = par1Str; 582 return this; 583 } 584 585 /** 586 * Returns a string representing what this item does to a potion. 587 */ 588 public String getPotionEffect() 589 { 590 return this.potionEffect; 591 } 592 593 /** 594 * Returns true if this item serves as a potion ingredient (its ingredient information is not null). 595 */ 596 public boolean isPotionIngredient() 597 { 598 return this.potionEffect != null; 599 } 600 601 @SideOnly(Side.CLIENT) 602 603 /** 604 * allows items to add custom lines of information to the mouseover description 605 */ 606 public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {} 607 608 public String getItemDisplayName(ItemStack par1ItemStack) 609 { 610 return ("" + StringTranslate.getInstance().translateNamedKey(this.getLocalizedName(par1ItemStack))).trim(); 611 } 612 613 @SideOnly(Side.CLIENT) 614 public boolean hasEffect(ItemStack par1ItemStack) 615 { 616 return par1ItemStack.isItemEnchanted(); 617 } 618 619 @SideOnly(Side.CLIENT) 620 621 /** 622 * Return an item rarity from EnumRarity 623 */ 624 public EnumRarity getRarity(ItemStack par1ItemStack) 625 { 626 return par1ItemStack.isItemEnchanted() ? EnumRarity.rare : EnumRarity.common; 627 } 628 629 /** 630 * Checks isDamagable and if it cannot be stacked 631 */ 632 public boolean isItemTool(ItemStack par1ItemStack) 633 { 634 return this.getItemStackLimit() == 1 && this.isDamageable(); 635 } 636 637 protected MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3) 638 { 639 float f = 1.0F; 640 float f1 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * f; 641 float f2 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * f; 642 double d0 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * (double)f; 643 double d1 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * (double)f + 1.62D - (double)par2EntityPlayer.yOffset; 644 double d2 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * (double)f; 645 Vec3 vec3 = par1World.getWorldVec3Pool().getVecFromPool(d0, d1, d2); 646 float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI); 647 float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI); 648 float f5 = -MathHelper.cos(-f1 * 0.017453292F); 649 float f6 = MathHelper.sin(-f1 * 0.017453292F); 650 float f7 = f4 * f5; 651 float f8 = f3 * f5; 652 double d3 = 5.0D; 653 if (par2EntityPlayer instanceof EntityPlayerMP) 654 { 655 d3 = ((EntityPlayerMP)par2EntityPlayer).theItemInWorldManager.getBlockReachDistance(); 656 } 657 Vec3 vec31 = vec3.addVector((double)f7 * d3, (double)f6 * d3, (double)f8 * d3); 658 return par1World.rayTraceBlocks_do_do(vec3, vec31, par3, !par3); 659 } 660 661 /** 662 * Return the enchantability factor of the item, most of the time is based on material. 663 */ 664 public int getItemEnchantability() 665 { 666 return 0; 667 } 668 669 @SideOnly(Side.CLIENT) 670 public boolean requiresMultipleRenderPasses() 671 { 672 return false; 673 } 674 675 @SideOnly(Side.CLIENT) 676 677 /** 678 * Gets an icon index based on an item's damage value and the given render pass 679 */ 680 public Icon getIconFromDamageForRenderPass(int par1, int par2) 681 { 682 return this.getIconFromDamage(par1); 683 } 684 685 @SideOnly(Side.CLIENT) 686 687 /** 688 * returns a list of items with the same ID, but different meta (eg: dye returns 16 items) 689 */ 690 public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) 691 { 692 par3List.add(new ItemStack(par1, 1, 0)); 693 } 694 695 /** 696 * returns this; 697 */ 698 public Item setCreativeTab(CreativeTabs par1CreativeTabs) 699 { 700 this.tabToDisplayOn = par1CreativeTabs; 701 return this; 702 } 703 704 @SideOnly(Side.CLIENT) 705 706 /** 707 * gets the CreativeTab this item is displayed on 708 */ 709 public CreativeTabs getCreativeTab() 710 { 711 return this.tabToDisplayOn; 712 } 713 714 public boolean func_82788_x() 715 { 716 return true; 717 } 718 719 /** 720 * Return whether this item is repairable in an anvil. 721 */ 722 public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) 723 { 724 return false; 725 } 726 727 @SideOnly(Side.CLIENT) 728 public void registerIcons(IconRegister par1IconRegister) 729 { 730 this.itemIcon = par1IconRegister.registerIcon(this.unlocalizedName); 731 } 732 733 static 734 { 735 StatList.initStats(); 736 } 737 738 /* =========================================================== FORGE START ===============================================================*/ 739 /** 740 * Called when a player drops the item into the world, 741 * returning false from this will prevent the item from 742 * being removed from the players inventory and spawning 743 * in the world 744 * 745 * @param player The player that dropped the item 746 * @param item The item stack, before the item is removed. 747 */ 748 public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player) 749 { 750 return true; 751 } 752 753 /** 754 * This is called when the item is used, before the block is activated. 755 * @param stack The Item Stack 756 * @param player The Player that used the item 757 * @param world The Current World 758 * @param x Target X Position 759 * @param y Target Y Position 760 * @param z Target Z Position 761 * @param side The side of the target hit 762 * @return Return true to prevent any further processing. 763 */ 764 public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) 765 { 766 return false; 767 } 768 769 /** 770 * Metadata-sensitive version of getStrVsBlock 771 * @param itemstack The Item Stack 772 * @param block The block the item is trying to break 773 * @param metadata The items current metadata 774 * @return The damage strength 775 */ 776 public float getStrVsBlock(ItemStack itemstack, Block block, int metadata) 777 { 778 return getStrVsBlock(itemstack, block); 779 } 780 781 /** 782 * Called by CraftingManager to determine if an item is reparable. 783 * @return True if reparable 784 */ 785 public boolean isRepairable() 786 { 787 return canRepair && isDamageable(); 788 } 789 790 /** 791 * Call to disable repair recipes. 792 * @return The current Item instance 793 */ 794 public Item setNoRepair() 795 { 796 canRepair = false; 797 return this; 798 } 799 800 /** 801 * Called before a block is broken. Return true to prevent default block harvesting. 802 * 803 * Note: In SMP, this is called on both client and server sides! 804 * 805 * @param itemstack The current ItemStack 806 * @param X The X Position 807 * @param Y The X Position 808 * @param Z The X Position 809 * @param player The Player that is wielding the item 810 * @return True to prevent harvesting, false to continue as normal 811 */ 812 public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer player) 813 { 814 return false; 815 } 816 817 /** 818 * Called each tick while using an item. 819 * @param stack The Item being used 820 * @param player The Player using the item 821 * @param count The amount of time in tick the item has been used for continuously 822 */ 823 public void onUsingItemTick(ItemStack stack, EntityPlayer player, int count) 824 { 825 } 826 827 /** 828 * Called when the player Left Clicks (attacks) an entity. 829 * Processed before damage is done, if return value is true further processing is canceled 830 * and the entity is not attacked. 831 * 832 * @param stack The Item being used 833 * @param player The player that is attacking 834 * @param entity The entity being attacked 835 * @return True to cancel the rest of the interaction. 836 */ 837 public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) 838 { 839 return false; 840 } 841 842 /** 843 * Player, Render pass, and item usage sensitive version of getIconIndex. 844 * 845 * @param stack The item stack to get the icon for. (Usually this, and usingItem will be the same if usingItem is not null) 846 * @param renderPass The pass to get the icon for, 0 is default. 847 * @param player The player holding the item 848 * @param usingItem The item the player is actively using. Can be null if not using anything. 849 * @param useRemaining The ticks remaining for the active item. 850 * @return The icon index 851 */ 852 public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) 853 { 854 return getIcon(stack, renderPass); 855 } 856 857 /** 858 * Returns the number of render passes/layers this item has. 859 * Usually equates to ItemRenderer.renderItem being called for this many passes. 860 * Does not get called unless requiresMultipleRenderPasses() is true; 861 * 862 * @param metadata The item's metadata 863 * @return The number of passes to run. 864 */ 865 public int getRenderPasses(int metadata) 866 { 867 return requiresMultipleRenderPasses() ? 2 : 1; 868 } 869 870 /** 871 * ItemStack sensitive version of getContainerItem. 872 * Returns a full ItemStack instance of the result. 873 * 874 * @param itemStack The current ItemStack 875 * @return The resulting ItemStack 876 */ 877 public ItemStack getContainerItemStack(ItemStack itemStack) 878 { 879 if (!hasContainerItem()) 880 { 881 return null; 882 } 883 return new ItemStack(getContainerItem()); 884 } 885 886 /** 887 * Retrieves the normal 'lifespan' of this item when it is dropped on the ground as a EntityItem. 888 * This is in ticks, standard result is 6000, or 5 mins. 889 * 890 * @param itemStack The current ItemStack 891 * @param world The world the entity is in 892 * @return The normal lifespan in ticks. 893 */ 894 public int getEntityLifespan(ItemStack itemStack, World world) 895 { 896 return 6000; 897 } 898 899 /** 900 * Determines if this Item has a special entity for when they are in the world. 901 * Is called when a EntityItem is spawned in the world, if true and Item#createCustomEntity 902 * returns non null, the EntityItem will be destroyed and the new Entity will be added to the world. 903 * 904 * @param stack The current item stack 905 * @return True of the item has a custom entity, If true, Item#createCustomEntity will be called 906 */ 907 public boolean hasCustomEntity(ItemStack stack) 908 { 909 return false; 910 } 911 912 /** 913 * This function should return a new entity to replace the dropped item. 914 * Returning null here will not kill the EntityItem and will leave it to function normally. 915 * Called when the item it placed in a world. 916 * 917 * @param world The world object 918 * @param location The EntityItem object, useful for getting the position of the entity 919 * @param itemstack The current item stack 920 * @return A new Entity object to spawn or null 921 */ 922 public Entity createEntity(World world, Entity location, ItemStack itemstack) 923 { 924 return null; 925 } 926 927 /** 928 * Called by the default implemetation of EntityItem's onUpdate method, allowing for cleaner 929 * control over the update of the item without having to write a subclass. 930 * 931 * @param entityItem The entity Item 932 * @return Return true to skip any further update code. 933 */ 934 public boolean onEntityItemUpdate(EntityItem entityItem) 935 { 936 return false; 937 } 938 939 /** 940 * Gets a list of tabs that items belonging to this class can display on, 941 * combined properly with getSubItems allows for a single item to span 942 * many sub-items across many tabs. 943 * 944 * @return A list of all tabs that this item could possibly be one. 945 */ 946 public CreativeTabs[] getCreativeTabs() 947 { 948 return new CreativeTabs[]{ getCreativeTab() }; 949 } 950 951 /** 952 * Determines the base experience for a player when they remove this item from a furnace slot. 953 * This number must be between 0 and 1 for it to be valid. 954 * This number will be multiplied by the stack size to get the total experience. 955 * 956 * @param item The item stack the player is picking up. 957 * @return The amount to award for each item. 958 */ 959 public float getSmeltingExperience(ItemStack item) 960 { 961 return -1; //-1 will default to the old lookups. 962 } 963 964 /** 965 * Return the correct icon for rendering based on the supplied ItemStack and render pass. 966 * 967 * Defers to {@link #getIconFromDamageForRenderPass(int, int)} 968 * @param stack to render for 969 * @param pass the multi-render pass 970 * @return the icon 971 */ 972 public Icon getIcon(ItemStack stack, int pass) 973 { 974 return getIconFromDamageForRenderPass(stack.getItemDamage(), pass); 975 } 976 977 /** 978 * Generates the base Random item for a specific instance of the chest gen, 979 * Enchanted books use this to pick a random enchantment. 980 * 981 * @param chest The chest category to generate for 982 * @param rnd World RNG 983 * @param original Original result registered with the chest gen hooks. 984 * @return New values to use as the random item, typically this will be original 985 */ 986 public WeightedRandomChestContent getChestGenBase(ChestGenHooks chest, Random rnd, WeightedRandomChestContent original) 987 { 988 if (this instanceof ItemEnchantedBook) 989 { 990 return ((ItemEnchantedBook)this).func_92112_a(rnd, 991 original.theMinimumChanceToGenerateItem, 992 original.theMaximumChanceToGenerateItem, original.itemWeight); 993 } 994 return original; 995 } 996 997 /** 998 * 999 * Should this item, when held, allow sneak-clicks to pass through to the underlying block? 1000 * 1001 * @param par2World 1002 * @param par4 1003 * @param par5 1004 * @param par6 1005 * @return 1006 */ 1007 public boolean shouldPassSneakingClickToBlock(World par2World, int par4, int par5, int par6) 1008 { 1009 return false; 1010 } 1011 1012 1013 /** 1014 * Called to tick armor in the armor slot. Override to do something 1015 * 1016 * @param world 1017 * @param player 1018 * @param itemStack 1019 */ 1020 public void onArmorTickUpdate(World world, EntityPlayer player, ItemStack itemStack) 1021 { 1022 1023 } 1024 1025 /** 1026 * Determines if the specific ItemStack can be placed in the specified armor slot. 1027 * 1028 * @param stack The ItemStack 1029 * @param armorType Armor slot ID: 0: Helmet, 1: Chest, 2: Legs, 3: Boots 1030 * @return True if the given ItemStack can be inserted in the slot 1031 */ 1032 public boolean isValidArmor(ItemStack stack, int armorType) 1033 { 1034 if (this instanceof ItemArmor) 1035 { 1036 return ((ItemArmor)this).armorType == armorType; 1037 } 1038 1039 if (armorType == 0) 1040 { 1041 return itemID == Block.pumpkin.blockID || itemID == Item.skull.itemID; 1042 } 1043 1044 return false; 1045 } 1046 1047 /** 1048 * ItemStack sensitive version of isPotionIngredient 1049 * 1050 * @param stack The item stack 1051 * @return True if this stack can be used as a potion ingredient 1052 */ 1053 public boolean isPotionIngredient(ItemStack stack) 1054 { 1055 return isPotionIngredient(); 1056 } 1057 1058 /** 1059 * ItemStack sensitive version of getPotionEffect 1060 * 1061 * @param stack The item stack 1062 * @return A string containing the bit manipulation to apply the the potion. 1063 */ 1064 public String getPotionEffect(ItemStack stack) 1065 { 1066 return getPotionEffect(); 1067 } 1068 1069 /** 1070 * Allow or forbid the specific book/item combination as an anvil enchant 1071 * 1072 * @param itemstack1 The item 1073 * @param itemstack2 The book 1074 * @return if the enchantment is allowed 1075 */ 1076 public boolean isBookEnchantable(ItemStack itemstack1, ItemStack itemstack2) 1077 { 1078 return true; 1079 } 1080 1081 /** 1082 * An itemstack sensitive version of getDamageVsEntity - allows items to handle damage based on 1083 * itemstack data, like tags. Falls back to getDamageVsEntity. 1084 * 1085 * @param par1Entity The entity being attacked (or the attacking mob, if it's a mob - vanilla bug?) 1086 * @param itemStack The itemstack 1087 * @return the damage 1088 */ 1089 public int getDamageVsEntity(Entity par1Entity, ItemStack itemStack) 1090 { 1091 return getDamageVsEntity(par1Entity); 1092 } 1093 1094 @Deprecated private final boolean isArmorProvider = this instanceof IArmorTextureProvider; 1095 /** 1096 * Called by RenderBiped and RenderPlayer to determine the armor texture that 1097 * should be use for the currently equiped item. 1098 * This will only be called on instances of ItemArmor. 1099 * 1100 * Returning null from this function will use the default value. 1101 * 1102 * @param stack ItemStack for the equpt armor 1103 * @param entity The entity wearing the armor 1104 * @param slot The slot the armor is in 1105 * @param layer The render layer, either 1 or 2, 2 is only used for CLOTH armor by default 1106 * @return Path of texture to bind, or null to use default 1107 */ 1108 public String getArmorTexture(ItemStack stack, Entity entity, int slot, int layer) 1109 { 1110 return isArmorProvider ? ((IArmorTextureProvider)this).getArmorTextureFile(stack) : null; 1111 } 1112 1113 /** 1114 * Returns the font renderer used to render tooltips and overlays for this item. 1115 * Returning null will use the standard font renderer. 1116 * 1117 * @param stack The current item stack 1118 * @return A instance of FontRenderer or null to use default 1119 */ 1120 @SideOnly(Side.CLIENT) 1121 public FontRenderer getFontRenderer(ItemStack stack) 1122 { 1123 return null; 1124 } 1125 1126 /** 1127 * Override this method to have an item handle its own armor rendering. 1128 * 1129 * @param entityLiving The entity wearing the armor 1130 * @param itemStack The itemStack to render the model of 1131 * @param armorSlot 0=head, 1=torso, 2=legs, 3=feet 1132 * 1133 * @return A ModelBiped to render instead of the default 1134 */ 1135 @SideOnly(Side.CLIENT) 1136 public ModelBiped getArmorModel(EntityLiving entityLiving, ItemStack itemStack, int armorSlot) 1137 { 1138 return null; 1139 } 1140 1141 /** 1142 * Called when a entity tries to play the 'swing' animation. 1143 * 1144 * @param entityLiving The entity swinging the item. 1145 * @param stack The Item stack 1146 * @return True to cancel any further processing by EntityLiving 1147 */ 1148 public boolean onEntitySwing(EntityLiving entityLiving, ItemStack stack) 1149 { 1150 return false; 1151 } 1152}