001    package net.minecraft.src;
002    
003    import cpw.mods.fml.common.Side;
004    import cpw.mods.fml.common.asm.SideOnly;
005    import java.util.List;
006    import java.util.Random;
007    
008    public class Item
009    {
010        private CreativeTabs field_77701_a = null;
011    
012        /** The RNG used by the Item subclasses. */
013        protected static Random itemRand = new Random();
014    
015        /** A 32000 elements Item array. */
016        public static Item[] itemsList = new Item[32000];
017        public static Item shovelSteel = (new ItemSpade(0, EnumToolMaterial.IRON)).setIconCoord(2, 5).setItemName("shovelIron");
018        public static Item pickaxeSteel = (new ItemPickaxe(1, EnumToolMaterial.IRON)).setIconCoord(2, 6).setItemName("pickaxeIron");
019        public static Item axeSteel = (new ItemAxe(2, EnumToolMaterial.IRON)).setIconCoord(2, 7).setItemName("hatchetIron");
020        public static Item flintAndSteel = (new ItemFlintAndSteel(3)).setIconCoord(5, 0).setItemName("flintAndSteel");
021        public static Item appleRed = (new ItemFood(4, 4, 0.3F, false)).setIconCoord(10, 0).setItemName("apple");
022        public static Item bow = (new ItemBow(5)).setIconCoord(5, 1).setItemName("bow");
023        public static Item arrow = (new Item(6)).setIconCoord(5, 2).setItemName("arrow").setTabToDisplayOn(CreativeTabs.tabCombat);
024        public static Item coal = (new ItemCoal(7)).setIconCoord(7, 0).setItemName("coal");
025        public static Item diamond = (new Item(8)).setIconCoord(7, 3).setItemName("diamond").setTabToDisplayOn(CreativeTabs.tabMaterials);
026        public static Item ingotIron = (new Item(9)).setIconCoord(7, 1).setItemName("ingotIron").setTabToDisplayOn(CreativeTabs.tabMaterials);
027        public static Item ingotGold = (new Item(10)).setIconCoord(7, 2).setItemName("ingotGold").setTabToDisplayOn(CreativeTabs.tabMaterials);
028        public static Item swordSteel = (new ItemSword(11, EnumToolMaterial.IRON)).setIconCoord(2, 4).setItemName("swordIron");
029        public static Item swordWood = (new ItemSword(12, EnumToolMaterial.WOOD)).setIconCoord(0, 4).setItemName("swordWood");
030        public static Item shovelWood = (new ItemSpade(13, EnumToolMaterial.WOOD)).setIconCoord(0, 5).setItemName("shovelWood");
031        public static Item pickaxeWood = (new ItemPickaxe(14, EnumToolMaterial.WOOD)).setIconCoord(0, 6).setItemName("pickaxeWood");
032        public static Item axeWood = (new ItemAxe(15, EnumToolMaterial.WOOD)).setIconCoord(0, 7).setItemName("hatchetWood");
033        public static Item swordStone = (new ItemSword(16, EnumToolMaterial.STONE)).setIconCoord(1, 4).setItemName("swordStone");
034        public static Item shovelStone = (new ItemSpade(17, EnumToolMaterial.STONE)).setIconCoord(1, 5).setItemName("shovelStone");
035        public static Item pickaxeStone = (new ItemPickaxe(18, EnumToolMaterial.STONE)).setIconCoord(1, 6).setItemName("pickaxeStone");
036        public static Item axeStone = (new ItemAxe(19, EnumToolMaterial.STONE)).setIconCoord(1, 7).setItemName("hatchetStone");
037        public static Item swordDiamond = (new ItemSword(20, EnumToolMaterial.EMERALD)).setIconCoord(3, 4).setItemName("swordDiamond");
038        public static Item shovelDiamond = (new ItemSpade(21, EnumToolMaterial.EMERALD)).setIconCoord(3, 5).setItemName("shovelDiamond");
039        public static Item pickaxeDiamond = (new ItemPickaxe(22, EnumToolMaterial.EMERALD)).setIconCoord(3, 6).setItemName("pickaxeDiamond");
040        public static Item axeDiamond = (new ItemAxe(23, EnumToolMaterial.EMERALD)).setIconCoord(3, 7).setItemName("hatchetDiamond");
041        public static Item stick = (new Item(24)).setIconCoord(5, 3).setFull3D().setItemName("stick").setTabToDisplayOn(CreativeTabs.tabMaterials);
042        public static Item bowlEmpty = (new Item(25)).setIconCoord(7, 4).setItemName("bowl").setTabToDisplayOn(CreativeTabs.tabMaterials);
043        public static Item bowlSoup = (new ItemSoup(26, 8)).setIconCoord(8, 4).setItemName("mushroomStew");
044        public static Item swordGold = (new ItemSword(27, EnumToolMaterial.GOLD)).setIconCoord(4, 4).setItemName("swordGold");
045        public static Item shovelGold = (new ItemSpade(28, EnumToolMaterial.GOLD)).setIconCoord(4, 5).setItemName("shovelGold");
046        public static Item pickaxeGold = (new ItemPickaxe(29, EnumToolMaterial.GOLD)).setIconCoord(4, 6).setItemName("pickaxeGold");
047        public static Item axeGold = (new ItemAxe(30, EnumToolMaterial.GOLD)).setIconCoord(4, 7).setItemName("hatchetGold");
048        public static Item silk = (new ItemReed(31, Block.tripWire)).setIconCoord(8, 0).setItemName("string").setTabToDisplayOn(CreativeTabs.tabMaterials);
049        public static Item feather = (new Item(32)).setIconCoord(8, 1).setItemName("feather").setTabToDisplayOn(CreativeTabs.tabMaterials);
050        public static Item gunpowder = (new Item(33)).setIconCoord(8, 2).setItemName("sulphur").setPotionEffect(PotionHelper.gunpowderEffect).setTabToDisplayOn(CreativeTabs.tabMaterials);
051        public static Item hoeWood = (new ItemHoe(34, EnumToolMaterial.WOOD)).setIconCoord(0, 8).setItemName("hoeWood");
052        public static Item hoeStone = (new ItemHoe(35, EnumToolMaterial.STONE)).setIconCoord(1, 8).setItemName("hoeStone");
053        public static Item hoeSteel = (new ItemHoe(36, EnumToolMaterial.IRON)).setIconCoord(2, 8).setItemName("hoeIron");
054        public static Item hoeDiamond = (new ItemHoe(37, EnumToolMaterial.EMERALD)).setIconCoord(3, 8).setItemName("hoeDiamond");
055        public static Item hoeGold = (new ItemHoe(38, EnumToolMaterial.GOLD)).setIconCoord(4, 8).setItemName("hoeGold");
056        public static Item seeds = (new ItemSeeds(39, Block.crops.blockID, Block.tilledField.blockID)).setIconCoord(9, 0).setItemName("seeds");
057        public static Item wheat = (new Item(40)).setIconCoord(9, 1).setItemName("wheat").setTabToDisplayOn(CreativeTabs.tabMaterials);
058        public static Item bread = (new ItemFood(41, 5, 0.6F, false)).setIconCoord(9, 2).setItemName("bread");
059        public static Item helmetLeather = (new ItemArmor(42, EnumArmorMaterial.CLOTH, 0, 0)).setIconCoord(0, 0).setItemName("helmetCloth");
060        public static Item plateLeather = (new ItemArmor(43, EnumArmorMaterial.CLOTH, 0, 1)).setIconCoord(0, 1).setItemName("chestplateCloth");
061        public static Item legsLeather = (new ItemArmor(44, EnumArmorMaterial.CLOTH, 0, 2)).setIconCoord(0, 2).setItemName("leggingsCloth");
062        public static Item bootsLeather = (new ItemArmor(45, EnumArmorMaterial.CLOTH, 0, 3)).setIconCoord(0, 3).setItemName("bootsCloth");
063        public static Item helmetChain = (new ItemArmor(46, EnumArmorMaterial.CHAIN, 1, 0)).setIconCoord(1, 0).setItemName("helmetChain");
064        public static Item plateChain = (new ItemArmor(47, EnumArmorMaterial.CHAIN, 1, 1)).setIconCoord(1, 1).setItemName("chestplateChain");
065        public static Item legsChain = (new ItemArmor(48, EnumArmorMaterial.CHAIN, 1, 2)).setIconCoord(1, 2).setItemName("leggingsChain");
066        public static Item bootsChain = (new ItemArmor(49, EnumArmorMaterial.CHAIN, 1, 3)).setIconCoord(1, 3).setItemName("bootsChain");
067        public static Item helmetSteel = (new ItemArmor(50, EnumArmorMaterial.IRON, 2, 0)).setIconCoord(2, 0).setItemName("helmetIron");
068        public static Item plateSteel = (new ItemArmor(51, EnumArmorMaterial.IRON, 2, 1)).setIconCoord(2, 1).setItemName("chestplateIron");
069        public static Item legsSteel = (new ItemArmor(52, EnumArmorMaterial.IRON, 2, 2)).setIconCoord(2, 2).setItemName("leggingsIron");
070        public static Item bootsSteel = (new ItemArmor(53, EnumArmorMaterial.IRON, 2, 3)).setIconCoord(2, 3).setItemName("bootsIron");
071        public static Item helmetDiamond = (new ItemArmor(54, EnumArmorMaterial.DIAMOND, 3, 0)).setIconCoord(3, 0).setItemName("helmetDiamond");
072        public static Item plateDiamond = (new ItemArmor(55, EnumArmorMaterial.DIAMOND, 3, 1)).setIconCoord(3, 1).setItemName("chestplateDiamond");
073        public static Item legsDiamond = (new ItemArmor(56, EnumArmorMaterial.DIAMOND, 3, 2)).setIconCoord(3, 2).setItemName("leggingsDiamond");
074        public static Item bootsDiamond = (new ItemArmor(57, EnumArmorMaterial.DIAMOND, 3, 3)).setIconCoord(3, 3).setItemName("bootsDiamond");
075        public static Item helmetGold = (new ItemArmor(58, EnumArmorMaterial.GOLD, 4, 0)).setIconCoord(4, 0).setItemName("helmetGold");
076        public static Item plateGold = (new ItemArmor(59, EnumArmorMaterial.GOLD, 4, 1)).setIconCoord(4, 1).setItemName("chestplateGold");
077        public static Item legsGold = (new ItemArmor(60, EnumArmorMaterial.GOLD, 4, 2)).setIconCoord(4, 2).setItemName("leggingsGold");
078        public static Item bootsGold = (new ItemArmor(61, EnumArmorMaterial.GOLD, 4, 3)).setIconCoord(4, 3).setItemName("bootsGold");
079        public static Item flint = (new Item(62)).setIconCoord(6, 0).setItemName("flint").setTabToDisplayOn(CreativeTabs.tabMaterials);
080        public static Item porkRaw = (new ItemFood(63, 3, 0.3F, true)).setIconCoord(7, 5).setItemName("porkchopRaw");
081        public static Item porkCooked = (new ItemFood(64, 8, 0.8F, true)).setIconCoord(8, 5).setItemName("porkchopCooked");
082        public static Item painting = (new ItemPainting(65)).setIconCoord(10, 1).setItemName("painting");
083        public static Item appleGold = (new ItemAppleGold(66, 4, 1.2F, false)).setAlwaysEdible().setPotionEffect(Potion.regeneration.id, 5, 0, 1.0F).setIconCoord(11, 0).setItemName("appleGold");
084        public static Item sign = (new ItemSign(67)).setIconCoord(10, 2).setItemName("sign");
085        public static Item doorWood = (new ItemDoor(68, Material.wood)).setIconCoord(11, 2).setItemName("doorWood");
086        public static Item bucketEmpty = (new ItemBucket(69, 0)).setIconCoord(10, 4).setItemName("bucket").setMaxStackSize(16);
087        public static Item bucketWater = (new ItemBucket(70, Block.waterMoving.blockID)).setIconCoord(11, 4).setItemName("bucketWater").setContainerItem(bucketEmpty);
088        public static Item bucketLava = (new ItemBucket(71, Block.lavaMoving.blockID)).setIconCoord(12, 4).setItemName("bucketLava").setContainerItem(bucketEmpty);
089        public static Item minecartEmpty = (new ItemMinecart(72, 0)).setIconCoord(7, 8).setItemName("minecart");
090        public static Item saddle = (new ItemSaddle(73)).setIconCoord(8, 6).setItemName("saddle");
091        public static Item doorSteel = (new ItemDoor(74, Material.iron)).setIconCoord(12, 2).setItemName("doorIron");
092        public static Item redstone = (new ItemRedstone(75)).setIconCoord(8, 3).setItemName("redstone").setPotionEffect(PotionHelper.redstoneEffect);
093        public static Item snowball = (new ItemSnowball(76)).setIconCoord(14, 0).setItemName("snowball");
094        public static Item boat = (new ItemBoat(77)).setIconCoord(8, 8).setItemName("boat");
095        public static Item leather = (new Item(78)).setIconCoord(7, 6).setItemName("leather").setTabToDisplayOn(CreativeTabs.tabMaterials);
096        public static Item bucketMilk = (new ItemBucketMilk(79)).setIconCoord(13, 4).setItemName("milk").setContainerItem(bucketEmpty);
097        public static Item brick = (new Item(80)).setIconCoord(6, 1).setItemName("brick").setTabToDisplayOn(CreativeTabs.tabMaterials);
098        public static Item clay = (new Item(81)).setIconCoord(9, 3).setItemName("clay").setTabToDisplayOn(CreativeTabs.tabMaterials);
099        public static Item reed = (new ItemReed(82, Block.reed)).setIconCoord(11, 1).setItemName("reeds").setTabToDisplayOn(CreativeTabs.tabMaterials);
100        public static Item paper = (new Item(83)).setIconCoord(10, 3).setItemName("paper").setTabToDisplayOn(CreativeTabs.tabMisc);
101        public static Item book = (new Item(84)).setIconCoord(11, 3).setItemName("book").setTabToDisplayOn(CreativeTabs.tabMisc);
102        public static Item slimeBall = (new Item(85)).setIconCoord(14, 1).setItemName("slimeball").setTabToDisplayOn(CreativeTabs.tabMisc);
103        public static Item minecartCrate = (new ItemMinecart(86, 1)).setIconCoord(7, 9).setItemName("minecartChest");
104        public static Item minecartPowered = (new ItemMinecart(87, 2)).setIconCoord(7, 10).setItemName("minecartFurnace");
105        public static Item egg = (new ItemEgg(88)).setIconCoord(12, 0).setItemName("egg");
106        public static Item compass = (new Item(89)).setIconCoord(6, 3).setItemName("compass").setTabToDisplayOn(CreativeTabs.tabTools);
107        public static Item fishingRod = (new ItemFishingRod(90)).setIconCoord(5, 4).setItemName("fishingRod");
108        public static Item pocketSundial = (new Item(91)).setIconCoord(6, 4).setItemName("clock").setTabToDisplayOn(CreativeTabs.tabTools);
109        public static Item lightStoneDust = (new Item(92)).setIconCoord(9, 4).setItemName("yellowDust").setPotionEffect(PotionHelper.glowstoneEffect).setTabToDisplayOn(CreativeTabs.tabMaterials);
110        public static Item fishRaw = (new ItemFood(93, 2, 0.3F, false)).setIconCoord(9, 5).setItemName("fishRaw");
111        public static Item fishCooked = (new ItemFood(94, 5, 0.6F, false)).setIconCoord(10, 5).setItemName("fishCooked");
112        public static Item dyePowder = (new ItemDye(95)).setIconCoord(14, 4).setItemName("dyePowder");
113        public static Item bone = (new Item(96)).setIconCoord(12, 1).setItemName("bone").setFull3D().setTabToDisplayOn(CreativeTabs.tabMisc);
114        public static Item sugar = (new Item(97)).setIconCoord(13, 0).setItemName("sugar").setPotionEffect(PotionHelper.sugarEffect).setTabToDisplayOn(CreativeTabs.tabMaterials);
115        public static Item cake = (new ItemReed(98, Block.cake)).setMaxStackSize(1).setIconCoord(13, 1).setItemName("cake").setTabToDisplayOn(CreativeTabs.tabFood);
116        public static Item bed = (new ItemBed(99)).setMaxStackSize(1).setIconCoord(13, 2).setItemName("bed");
117        public static Item redstoneRepeater = (new ItemReed(100, Block.redstoneRepeaterIdle)).setIconCoord(6, 5).setItemName("diode").setTabToDisplayOn(CreativeTabs.tabRedstone);
118        public static Item cookie = (new ItemFood(101, 2, 0.1F, false)).setIconCoord(12, 5).setItemName("cookie");
119        public static ItemMap map = (ItemMap)(new ItemMap(102)).setIconCoord(12, 3).setItemName("map");
120    
121        /**
122         * Item introduced on 1.7 version, is a shear to cut leaves (you can keep the block) or get wool from sheeps.
123         */
124        public static ItemShears shears = (ItemShears)(new ItemShears(103)).setIconCoord(13, 5).setItemName("shears");
125        public static Item melon = (new ItemFood(104, 2, 0.3F, false)).setIconCoord(13, 6).setItemName("melon");
126        public static Item pumpkinSeeds = (new ItemSeeds(105, Block.pumpkinStem.blockID, Block.tilledField.blockID)).setIconCoord(13, 3).setItemName("seeds_pumpkin");
127        public static Item melonSeeds = (new ItemSeeds(106, Block.melonStem.blockID, Block.tilledField.blockID)).setIconCoord(14, 3).setItemName("seeds_melon");
128        public static Item beefRaw = (new ItemFood(107, 3, 0.3F, true)).setIconCoord(9, 6).setItemName("beefRaw");
129        public static Item beefCooked = (new ItemFood(108, 8, 0.8F, true)).setIconCoord(10, 6).setItemName("beefCooked");
130        public static Item chickenRaw = (new ItemFood(109, 2, 0.3F, true)).setPotionEffect(Potion.hunger.id, 30, 0, 0.3F).setIconCoord(9, 7).setItemName("chickenRaw");
131        public static Item chickenCooked = (new ItemFood(110, 6, 0.6F, true)).setIconCoord(10, 7).setItemName("chickenCooked");
132        public static Item rottenFlesh = (new ItemFood(111, 4, 0.1F, true)).setPotionEffect(Potion.hunger.id, 30, 0, 0.8F).setIconCoord(11, 5).setItemName("rottenFlesh");
133        public static Item enderPearl = (new ItemEnderPearl(112)).setIconCoord(11, 6).setItemName("enderPearl");
134        public static Item blazeRod = (new Item(113)).setIconCoord(12, 6).setItemName("blazeRod").setTabToDisplayOn(CreativeTabs.tabMaterials);
135        public static Item ghastTear = (new Item(114)).setIconCoord(11, 7).setItemName("ghastTear").setPotionEffect(PotionHelper.ghastTearEffect).setTabToDisplayOn(CreativeTabs.tabBrewing);
136        public static Item goldNugget = (new Item(115)).setIconCoord(12, 7).setItemName("goldNugget").setTabToDisplayOn(CreativeTabs.tabMaterials);
137        public static Item netherStalkSeeds = (new ItemSeeds(116, Block.netherStalk.blockID, Block.slowSand.blockID)).setIconCoord(13, 7).setItemName("netherStalkSeeds").setPotionEffect("+4");
138        public static ItemPotion potion = (ItemPotion)(new ItemPotion(117)).setIconCoord(13, 8).setItemName("potion");
139        public static Item glassBottle = (new ItemGlassBottle(118)).setIconCoord(12, 8).setItemName("glassBottle");
140        public static Item spiderEye = (new ItemFood(119, 2, 0.8F, false)).setPotionEffect(Potion.poison.id, 5, 0, 1.0F).setIconCoord(11, 8).setItemName("spiderEye").setPotionEffect(PotionHelper.spiderEyeEffect);
141        public static Item fermentedSpiderEye = (new Item(120)).setIconCoord(10, 8).setItemName("fermentedSpiderEye").setPotionEffect(PotionHelper.fermentedSpiderEyeEffect).setTabToDisplayOn(CreativeTabs.tabBrewing);
142        public static Item blazePowder = (new Item(121)).setIconCoord(13, 9).setItemName("blazePowder").setPotionEffect(PotionHelper.blazePowderEffect).setTabToDisplayOn(CreativeTabs.tabBrewing);
143        public static Item magmaCream = (new Item(122)).setIconCoord(13, 10).setItemName("magmaCream").setPotionEffect(PotionHelper.magmaCreamEffect).setTabToDisplayOn(CreativeTabs.tabBrewing);
144        public static Item brewingStand = (new ItemReed(123, Block.brewingStand)).setIconCoord(12, 10).setItemName("brewingStand").setTabToDisplayOn(CreativeTabs.tabBrewing);
145        public static Item cauldron = (new ItemReed(124, Block.cauldron)).setIconCoord(12, 9).setItemName("cauldron").setTabToDisplayOn(CreativeTabs.tabBrewing);
146        public static Item eyeOfEnder = (new ItemEnderEye(125)).setIconCoord(11, 9).setItemName("eyeOfEnder");
147        public static Item speckledMelon = (new Item(126)).setIconCoord(9, 8).setItemName("speckledMelon").setPotionEffect(PotionHelper.speckledMelonEffect).setTabToDisplayOn(CreativeTabs.tabBrewing);
148        public static Item monsterPlacer = (new ItemMonsterPlacer(127)).setIconCoord(9, 9).setItemName("monsterPlacer");
149    
150        /**
151         * Bottle o' Enchanting. Drops between 1 and 3 experience orbs when thrown.
152         */
153        public static Item expBottle = (new ItemExpBottle(128)).setIconCoord(11, 10).setItemName("expBottle");
154    
155        /**
156         * Fire Charge. When used in a dispenser it fires a fireball similiar to a Ghast's.
157         */
158        public static Item fireballCharge = (new ItemFireball(129)).setIconCoord(14, 2).setItemName("fireball");
159        public static Item writableBook = (new ItemWritableBook(130)).setIconCoord(11, 11).setItemName("writingBook").setTabToDisplayOn(CreativeTabs.tabMisc);
160        public static Item writtenBook = (new ItemEditableBook(131)).setIconCoord(12, 11).setItemName("writtenBook");
161        public static Item emerald = (new Item(132)).setIconCoord(10, 11).setItemName("emerald").setTabToDisplayOn(CreativeTabs.tabMaterials);
162        public static Item record13 = (new ItemRecord(2000, "13")).setIconCoord(0, 15).setItemName("record");
163        public static Item recordCat = (new ItemRecord(2001, "cat")).setIconCoord(1, 15).setItemName("record");
164        public static Item recordBlocks = (new ItemRecord(2002, "blocks")).setIconCoord(2, 15).setItemName("record");
165        public static Item recordChirp = (new ItemRecord(2003, "chirp")).setIconCoord(3, 15).setItemName("record");
166        public static Item recordFar = (new ItemRecord(2004, "far")).setIconCoord(4, 15).setItemName("record");
167        public static Item recordMall = (new ItemRecord(2005, "mall")).setIconCoord(5, 15).setItemName("record");
168        public static Item recordMellohi = (new ItemRecord(2006, "mellohi")).setIconCoord(6, 15).setItemName("record");
169        public static Item recordStal = (new ItemRecord(2007, "stal")).setIconCoord(7, 15).setItemName("record");
170        public static Item recordStrad = (new ItemRecord(2008, "strad")).setIconCoord(8, 15).setItemName("record");
171        public static Item recordWard = (new ItemRecord(2009, "ward")).setIconCoord(9, 15).setItemName("record");
172        public static Item record11 = (new ItemRecord(2010, "11")).setIconCoord(10, 15).setItemName("record");
173    
174        /** Item index + 256 */
175        public final int shiftedIndex;
176    
177        /** Maximum size of the stack. */
178        protected int maxStackSize = 64;
179    
180        /** Maximum damage an item can handle. */
181        private int maxDamage = 0;
182    
183        /** Icon index in the icons table. */
184        protected int iconIndex;
185    
186        /** If true, render the object in full 3D, like weapons and tools. */
187        protected boolean bFull3D = false;
188    
189        /**
190         * Some items (like dyes) have multiple subtypes on same item, this is field define this behavior
191         */
192        protected boolean hasSubtypes = false;
193        private Item containerItem = null;
194        private String potionEffect = null;
195    
196        /** full name of item from language file */
197        private String itemName;
198    
199        /** FORGE: To disable repair recipes. */
200        protected boolean canRepair = true;
201    
202        protected Item(int par1)
203        {
204            this.shiftedIndex = 256 + par1;
205    
206            if (itemsList[256 + par1] != null)
207            {
208                System.out.println("CONFLICT @ " + par1 + " item slot already occupied by " + itemsList[256 + par1] + " while adding " + this);
209            }
210    
211            itemsList[256 + par1] = this;
212    
213            if (!(this instanceof ItemBlock))
214            {
215                isDefaultTexture = "/gui/items.png".equals(getTextureFile());
216            }
217        }
218    
219        /**
220         * Sets the icon index for this item. Returns the item.
221         */
222        public Item setIconIndex(int par1)
223        {
224            this.iconIndex = par1;
225            return this;
226        }
227    
228        public Item setMaxStackSize(int par1)
229        {
230            this.maxStackSize = par1;
231            return this;
232        }
233    
234        public Item setIconCoord(int par1, int par2)
235        {
236            this.iconIndex = par1 + par2 * 16;
237            return this;
238        }
239    
240        @SideOnly(Side.CLIENT)
241    
242        /**
243         * Gets an icon index based on an item's damage value
244         */
245        public int getIconFromDamage(int par1)
246        {
247            return this.iconIndex;
248        }
249    
250        public boolean tryPlaceIntoWorld(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
251        {
252            return false;
253        }
254    
255        /**
256         * Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
257         * sword
258         */
259        public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
260        {
261            return 1.0F;
262        }
263    
264        /**
265         * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
266         */
267        public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
268        {
269            return par1ItemStack;
270        }
271    
272        @SideOnly(Side.CLIENT)
273    
274        /**
275         * Returns the icon index of the stack given as argument.
276         */
277        public final int getIconIndex(ItemStack par1ItemStack)
278        {
279            return this.getIconFromDamage(par1ItemStack.getItemDamage());
280        }
281    
282        public ItemStack onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
283        {
284            return par1ItemStack;
285        }
286    
287        /**
288         * Returns the maximum size of the stack for a specific item. *Isn't this more a Set than a Get?*
289         */
290        public int getItemStackLimit()
291        {
292            return this.maxStackSize;
293        }
294    
295        /**
296         * Returns the metadata of the block which this Item (ItemBlock) can place
297         */
298        public int getMetadata(int par1)
299        {
300            return 0;
301        }
302    
303        public boolean getHasSubtypes()
304        {
305            return this.hasSubtypes;
306        }
307    
308        protected Item setHasSubtypes(boolean par1)
309        {
310            this.hasSubtypes = par1;
311            return this;
312        }
313    
314        /**
315         * Returns the maximum damage an item can take.
316         */
317        public int getMaxDamage()
318        {
319            return this.maxDamage;
320        }
321    
322        /**
323         * set max damage of an Item
324         */
325        public Item setMaxDamage(int par1)
326        {
327            this.maxDamage = par1;
328            return this;
329        }
330    
331        public boolean isDamageable()
332        {
333            return this.maxDamage > 0 && !this.hasSubtypes;
334        }
335    
336        /**
337         * Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
338         * the damage on the stack.
339         */
340        public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
341        {
342            return false;
343        }
344    
345        public boolean func_77660_a(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving)
346        {
347            return false;
348        }
349    
350        /**
351         * Returns the damage against a given entity.
352         */
353        public int getDamageVsEntity(Entity par1Entity)
354        {
355            return 1;
356        }
357    
358        /**
359         * Returns if the item (tool) can harvest results from the block type.
360         */
361        public boolean canHarvestBlock(Block par1Block)
362        {
363            return false;
364        }
365    
366        /**
367         * die sheep, place saddles, etc ...
368         */
369        public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving)
370        {
371            return false;
372        }
373    
374        /**
375         * Sets bFull3D to True and return the object.
376         */
377        public Item setFull3D()
378        {
379            this.bFull3D = true;
380            return this;
381        }
382    
383        @SideOnly(Side.CLIENT)
384    
385        /**
386         * Returns True is the item is renderer in full 3D when hold.
387         */
388        public boolean isFull3D()
389        {
390            return this.bFull3D;
391        }
392    
393        @SideOnly(Side.CLIENT)
394    
395        /**
396         * Returns true if this item should be rotated by 180 degrees around the Y axis when being held in an entities
397         * hands.
398         */
399        public boolean shouldRotateAroundWhenRendering()
400        {
401            return false;
402        }
403    
404        /**
405         * set name of item from language file
406         */
407        public Item setItemName(String par1Str)
408        {
409            this.itemName = "item." + par1Str;
410            return this;
411        }
412    
413        @SideOnly(Side.CLIENT)
414        public String getLocalItemName(ItemStack par1ItemStack)
415        {
416            String var2 = this.getItemNameIS(par1ItemStack);
417            return var2 == null ? "" : StatCollector.translateToLocal(var2);
418        }
419    
420        public String getItemName()
421        {
422            return this.itemName;
423        }
424    
425        public String getItemNameIS(ItemStack par1ItemStack)
426        {
427            return this.itemName;
428        }
429    
430        public Item setContainerItem(Item par1Item)
431        {
432            this.containerItem = par1Item;
433            return this;
434        }
435    
436        /**
437         * If this returns true, after a recipe involving this item is crafted the container item will be added to the
438         * player's inventory instead of remaining in the crafting grid.
439         */
440        public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack)
441        {
442            return true;
443        }
444    
445        /**
446         * If this function returns true (or the item is damageable), the ItemStack's NBT tag will be sent to the client.
447         */
448        public boolean getShareTag()
449        {
450            return false;
451        }
452    
453        public Item getContainerItem()
454        {
455            return this.containerItem;
456        }
457    
458        /**
459         * True if this Item has a container item (a.k.a. crafting result)
460         */
461        public boolean hasContainerItem()
462        {
463            return this.containerItem != null;
464        }
465    
466        public String getStatName()
467        {
468            return StatCollector.translateToLocal(this.getItemName() + ".name");
469        }
470    
471        public String func_77653_i(ItemStack par1ItemStack)
472        {
473            return StatCollector.translateToLocal(this.getItemNameIS(par1ItemStack) + ".name");
474        }
475    
476        @SideOnly(Side.CLIENT)
477        public int getColorFromDamage(int par1, int par2)
478        {
479            return 16777215;
480        }
481    
482        /**
483         * Called each tick as long the item is on a player inventory. Uses by maps to check if is on a player hand and
484         * update it's contents.
485         */
486        public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {}
487    
488        /**
489         * Called when item is crafted/smelted. Used only by maps so far.
490         */
491        public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {}
492    
493        /**
494         * false for all Items except sub-classes of ItemMapBase
495         */
496        public boolean isMap()
497        {
498            return false;
499        }
500    
501        /**
502         * returns the action that specifies what animation to play when the items is being used
503         */
504        public EnumAction getItemUseAction(ItemStack par1ItemStack)
505        {
506            return EnumAction.none;
507        }
508    
509        /**
510         * How long it takes to use or consume an item
511         */
512        public int getMaxItemUseDuration(ItemStack par1ItemStack)
513        {
514            return 0;
515        }
516    
517        /**
518         * called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
519         */
520        public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) {}
521    
522        /**
523         * Sets the string representing this item's effect on a potion when used as an ingredient.
524         */
525        protected Item setPotionEffect(String par1Str)
526        {
527            this.potionEffect = par1Str;
528            return this;
529        }
530    
531        /**
532         * Returns a string representing what this item does to a potion.
533         */
534        public String getPotionEffect()
535        {
536            return this.potionEffect;
537        }
538    
539        /**
540         * Returns true if this item serves as a potion ingredient (its ingredient information is not null).
541         */
542        public boolean isPotionIngredient()
543        {
544            return this.potionEffect != null;
545        }
546    
547        @SideOnly(Side.CLIENT)
548    
549        /**
550         * allows items to add custom lines of information to the mouseover description
551         */
552        public void addInformation(ItemStack par1ItemStack, List par2List) {}
553    
554        @SideOnly(Side.CLIENT)
555        public String getItemDisplayName(ItemStack par1ItemStack)
556        {
557            return ("" + StringTranslate.getInstance().translateNamedKey(this.getLocalItemName(par1ItemStack))).trim();
558        }
559    
560        @SideOnly(Side.CLIENT)
561        public boolean hasEffect(ItemStack par1ItemStack)
562        {
563            return par1ItemStack.isItemEnchanted();
564        }
565    
566        @SideOnly(Side.CLIENT)
567    
568        /**
569         * Return an item rarity from EnumRarity
570         */
571        public EnumRarity getRarity(ItemStack par1ItemStack)
572        {
573            return par1ItemStack.isItemEnchanted() ? EnumRarity.rare : EnumRarity.common;
574        }
575    
576        /**
577         * Checks isDamagable and if it cannot be stacked
578         */
579        public boolean isItemTool(ItemStack par1ItemStack)
580        {
581            return this.getItemStackLimit() == 1 && this.isDamageable();
582        }
583    
584        protected MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
585        {
586            float var4 = 1.0F;
587            float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
588            float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
589            double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * (double)var4;
590            double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * (double)var4 + 1.62D - (double)par2EntityPlayer.yOffset;
591            double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * (double)var4;
592            Vec3 var13 = Vec3.getVec3Pool().getVecFromPool(var7, var9, var11);
593            float var14 = MathHelper.cos(-var6 * 0.017453292F - (float)Math.PI);
594            float var15 = MathHelper.sin(-var6 * 0.017453292F - (float)Math.PI);
595            float var16 = -MathHelper.cos(-var5 * 0.017453292F);
596            float var17 = MathHelper.sin(-var5 * 0.017453292F);
597            float var18 = var15 * var16;
598            float var20 = var14 * var16;
599            double var21 = 5.0D;
600            if (par2EntityPlayer instanceof EntityPlayerMP)
601            {
602                var21 = ((EntityPlayerMP)par2EntityPlayer).theItemInWorldManager.getBlockReachDistance();
603            }
604            Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21);
605            return par1World.rayTraceBlocks_do_do(var13, var23, par3, !par3);
606        }
607    
608        /**
609         * Return the enchantability factor of the item, most of the time is based on material.
610         */
611        public int getItemEnchantability()
612        {
613            return 0;
614        }
615    
616        @SideOnly(Side.CLIENT)
617        public boolean requiresMultipleRenderPasses()
618        {
619            return false;
620        }
621    
622        @SideOnly(Side.CLIENT)
623    
624        /**
625         * Gets an icon index based on an item's damage value and the given render pass
626         */
627        public int getIconFromDamageForRenderPass(int par1, int par2)
628        {
629            return this.getIconFromDamage(par1);
630        }
631    
632        @SideOnly(Side.CLIENT)
633    
634        /**
635         * returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
636         */
637        public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
638        {
639            par3List.add(new ItemStack(par1, 1, 0));
640        }
641    
642        /**
643         * returns this;
644         */
645        public Item setTabToDisplayOn(CreativeTabs par1CreativeTabs)
646        {
647            this.field_77701_a = par1CreativeTabs;
648            return this;
649        }
650    
651        @SideOnly(Side.CLIENT)
652    
653        /**
654         * gets the CreativeTab this item is displayed on
655         */
656        public CreativeTabs getCreativeTab()
657        {
658            return this.field_77701_a;
659        }
660    
661        static
662        {
663            StatList.initStats();
664        }
665    
666        /* =========================================================== FORGE START ===============================================================*/
667        public boolean isDefaultTexture = true;
668        private String currentTexture = "/gui/items.png";
669    
670        /**
671         * Called when a player drops the item into the world,
672         * returning false from this will prevent the item from
673         * being removed from the players inventory and spawning
674         * in the world
675         * 
676         * @param player The player that dropped the item
677         * @param item The item stack, before the item is removed.
678         */
679        public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player)
680        {
681            return true;
682        }
683    
684        /**
685         * This is called when the item is used, before the block is activated.
686         * @param stack The Item Stack
687         * @param player The Player that used the item
688         * @param world The Current World
689         * @param x Target X Position
690         * @param y Target Y Position
691         * @param z Target Z Position
692         * @param side The side of the target hit
693         * @return Return true to prevent any further processing.
694         */
695        public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) 
696        {
697            return onItemUseFirst(stack, player, world, x, y, z, side);
698        }
699        
700        /**
701         * See onItemUseFirst above, this is deprecated in favor of the more aware version.
702         * Only here for compaibility.
703         */
704        @Deprecated
705        public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side) 
706        {
707            return false;
708        }
709    
710        /**
711         * Metadata-sensitive version of getStrVsBlock
712         * @param itemstack The Item Stack
713         * @param block The block the item is trying to break
714         * @param metadata The items current metadata
715         * @return The damage strength
716         */
717        public float getStrVsBlock(ItemStack itemstack, Block block, int metadata)
718        {
719            return getStrVsBlock(itemstack, block);
720        }
721    
722        /**
723         * Called by CraftingManager to determine if an item is reparable.
724         * @return True if reparable
725         */
726        public boolean isRepairable() 
727        {
728            return canRepair && isDamageable();
729        }
730    
731        /**
732         * Call to disable repair recipes.
733         * @return The current Item instance
734         */
735        public Item setNoRepair() 
736        {
737            canRepair = false;
738            return this;
739        }
740    
741        /**
742         * Called before a block is broken.  Return true to prevent default block harvesting.
743         *
744         * Note: In SMP, this is called on both client and server sides!
745         * 
746         * @param itemstack The current ItemStack
747         * @param X The X Position
748         * @param Y The X Position
749         * @param Z The X Position
750         * @param player The Player that is wielding the item
751         * @return True to prevent harvesting, false to continue as normal
752         */
753        public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer player) 
754        {
755            return false;
756        }
757    
758        /**
759         * Called each tick while using an item.
760         * @param stack The Item being used
761         * @param player The Player using the item
762         * @param count The amount of time in tick the item has been used for continuously
763         */
764        public void onUsingItemTick(ItemStack stack, EntityPlayer player, int count) 
765        {
766        }
767    
768        /**
769         * Called when the player Left Clicks (attacks) an entity.
770         * Processed before damage is done, if return value is true further processing is canceled
771         * and the entity is not attacked.
772         * 
773         * @param stack The Item being used
774         * @param player The player that is attacking
775         * @param entity The entity being attacked
776         * @return True to cancel the rest of the interaction.
777         */
778        public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) 
779        {
780            return false;
781        }
782    
783        /**
784         * Player, Render pass, and item usage sensitive version of getIconIndex.
785         *   
786         * @param stack The item stack to get the icon for. (Usually this, and usingItem will be the same if usingItem is not null)
787         * @param renderPass The pass to get the icon for, 0 is default.
788         * @param player The player holding the item
789         * @param usingItem The item the player is actively using. Can be null if not using anything.
790         * @param useRemaining The ticks remaining for the active item.
791         * @return The icon index
792         */
793        public int getIconIndex(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
794        {
795            /*
796             * Here is an example usage for Vanilla bows.
797            if (usingItem != null && usingItem.getItem().shiftedIndex == Item.bow.shiftedIndex)
798            {
799                int k = usingItem.getMaxItemUseDuration() - useRemaining;
800                if (k >= 18) return 133;
801                if (k >  13) return 117;
802                if (k >   0) return 101;
803            }
804             */
805            return getIconIndex(stack);
806        }
807    
808        /**
809         * Returns the number of render passes/layers this item has.
810         * Usually equates to ItemRenderer.renderItem being called for this many passes.
811         * Does not get called unless requiresMultipleRenderPasses() is true;
812         * 
813         * @param metadata The item's metadata
814         * @return The number of passes to run.
815         */
816        public int getRenderPasses(int metadata)
817        {
818            return requiresMultipleRenderPasses() ? 2 : 1;
819        }
820    
821        /**
822         * Grabs the current texture file used for this block
823         */
824        public String getTextureFile()
825        {
826            if (this instanceof ItemBlock)
827            {
828                return Block.blocksList[((ItemBlock)this).getBlockID()].getTextureFile();
829            }
830            return currentTexture;
831        }
832    
833        /**
834         * Sets the current texture file for this item, used when rendering.
835         * Default is "/gui/items.png"
836         * 
837         * @param texture The texture file
838         */
839        public void setTextureFile(String texture)
840        {
841            currentTexture = texture;
842            isDefaultTexture = false;
843        }
844    
845        /**
846         * ItemStack sensitive version of getContainerItem.
847         * Returns a full ItemStack instance of the result.
848         * 
849         * @param itemStack The current ItemStack
850         * @return The resulting ItemStack
851         */
852        public ItemStack getContainerItemStack(ItemStack itemStack)
853        {
854            if (!hasContainerItem())
855            {
856                return null;
857            }
858            return new ItemStack(getContainerItem());
859        }
860    
861        /**
862         * Retrieves the normal 'lifespan' of this item when it is dropped on the ground as a EntityItem.
863         * This is in ticks, standard result is 6000, or 5 mins.
864         * 
865         * @param itemStack The current ItemStack
866         * @param world The world the entity is in
867         * @return The normal lifespan in ticks.
868         */
869        public int getEntityLifespan(ItemStack itemStack, World world)
870        {
871            return 6000;
872        }
873    
874        /**
875         * Determines if this Item has a special entity for when they are in the world.
876         * Is called when a EntityItem is spawned in the world, if true and Item#createCustomEntity 
877         * returns non null, the EntityItem will be destroyed and the new Entity will be added to the world.
878         * 
879         * @param stack The current item stack
880         * @return True of the item has a custom entity, If true, Item#createCustomEntity will be called
881         */
882        public boolean hasCustomEntity(ItemStack stack)
883        {
884            return false;
885        }
886    
887        /**
888         * This function should return a new entity to replace the dropped item.
889         * Returning null here will not kill the EntityItem and will leave it to function normally.
890         * Called when the item it placed in a world.
891         * 
892         * @param world The world object
893         * @param location The EntityItem object, useful for getting the position of the entity
894         * @param itemstack The current item stack
895         * @return A new Entity object to spawn or null
896         */
897        public Entity createEntity(World world, Entity location, ItemStack itemstack)
898        {
899            return null;
900        }
901    }