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