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