001package net.minecraft.block; 002 003import cpw.mods.fml.relauncher.Side; 004import cpw.mods.fml.relauncher.SideOnly; 005import net.minecraft.client.renderer.texture.IconRegister; 006import net.minecraft.item.Item; 007import net.minecraft.item.ItemStack; 008import net.minecraft.util.Icon; 009import net.minecraft.world.World; 010 011public class BlockPotato extends BlockCrops 012{ 013 @SideOnly(Side.CLIENT) 014 private Icon[] iconArray; 015 016 public BlockPotato(int par1) 017 { 018 super(par1); 019 } 020 021 @SideOnly(Side.CLIENT) 022 023 /** 024 * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata 025 */ 026 public Icon getBlockTextureFromSideAndMetadata(int par1, int par2) 027 { 028 if (par2 < 7) 029 { 030 if (par2 == 6) 031 { 032 par2 = 5; 033 } 034 035 return this.iconArray[par2 >> 1]; 036 } 037 else 038 { 039 return this.iconArray[3]; 040 } 041 } 042 043 /** 044 * Generate a seed ItemStack for this crop. 045 */ 046 protected int getSeedItem() 047 { 048 return Item.potato.itemID; 049 } 050 051 /** 052 * Generate a crop produce ItemStack for this crop. 053 */ 054 protected int getCropItem() 055 { 056 return Item.potato.itemID; 057 } 058 059 /** 060 * Drops the block items with a specified chance of dropping the specified items 061 */ 062 public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7) 063 { 064 super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, par7); 065 066 if (!par1World.isRemote) 067 { 068 if (par5 >= 7 && par1World.rand.nextInt(50) == 0) 069 { 070 this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(Item.poisonousPotato)); 071 } 072 } 073 } 074 075 @SideOnly(Side.CLIENT) 076 077 /** 078 * When this method is called, your block should register all the icons it needs with the given IconRegister. This 079 * is the only chance you get to register icons. 080 */ 081 public void registerIcons(IconRegister par1IconRegister) 082 { 083 this.iconArray = new Icon[4]; 084 085 for (int i = 0; i < this.iconArray.length; ++i) 086 { 087 this.iconArray[i] = par1IconRegister.registerIcon("potatoes_" + i); 088 } 089 } 090}