001    package net.minecraft.src;
002    
003    import net.minecraftforge.common.EnumPlantType;
004    import net.minecraftforge.common.ForgeDirection;
005    import net.minecraftforge.common.IPlantable;
006    
007    public class ItemSeeds extends Item implements IPlantable
008    {
009        /**
010         * The type of block this seed turns into (wheat or pumpkin stems for instance)
011         */
012        private int blockType;
013    
014        /** BlockID of the block the seeds can be planted on. */
015        private int soilBlockID;
016    
017        public ItemSeeds(int par1, int par2, int par3)
018        {
019            super(par1);
020            this.blockType = par2;
021            this.soilBlockID = par3;
022            this.setCreativeTab(CreativeTabs.tabMaterials);
023        }
024    
025        /**
026         * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
027         * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
028         */
029        public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
030        {
031            if (par7 != 1)
032            {
033                return false;
034            }
035            else if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack))
036            {
037                int var11 = par3World.getBlockId(par4, par5, par6);
038                Block soil = Block.blocksList[var11];
039    
040                if (soil != null && soil.canSustainPlant(par3World, par4, par5, par6, ForgeDirection.UP, this) && par3World.isAirBlock(par4, par5 + 1, par6))
041                {
042                    par3World.setBlockWithNotify(par4, par5 + 1, par6, this.blockType);
043                    --par1ItemStack.stackSize;
044                    return true;
045                }
046                else
047                {
048                    return false;
049                }
050            }
051            else
052            {
053                return false;
054            }
055        }
056    
057        @Override
058        public EnumPlantType getPlantType(World world, int x, int y, int z)
059        {
060            return (blockType == Block.netherStalk.blockID ? EnumPlantType.Nether : EnumPlantType.Crop);
061        }
062    
063        @Override
064        public int getPlantID(World world, int x, int y, int z)
065        {
066            return blockType;
067        }
068    
069        @Override
070        public int getPlantMetadata(World world, int x, int y, int z)
071        {
072            return 0;
073        }
074    }