001    package net.minecraft.src;
002    
003    public class ItemSeeds extends Item
004    {
005        /**
006         * The type of block this seed turns into (wheat or pumpkin stems for instance)
007         */
008        private int blockType;
009    
010        /** BlockID of the block the seeds can be planted on. */
011        private int soilBlockID;
012    
013        public ItemSeeds(int par1, int par2, int par3)
014        {
015            super(par1);
016            this.blockType = par2;
017            this.soilBlockID = par3;
018            this.setCreativeTab(CreativeTabs.tabMaterials);
019        }
020    
021        /**
022         * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
023         * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
024         */
025        public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
026        {
027            if (par7 != 1)
028            {
029                return false;
030            }
031            else if (par2EntityPlayer.canPlayerEdit(par4, par5, par6) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6))
032            {
033                int var11 = par3World.getBlockId(par4, par5, par6);
034    
035                if (var11 == this.soilBlockID && par3World.isAirBlock(par4, par5 + 1, par6))
036                {
037                    par3World.setBlockWithNotify(par4, par5 + 1, par6, this.blockType);
038                    --par1ItemStack.stackSize;
039                    return true;
040                }
041                else
042                {
043                    return false;
044                }
045            }
046            else
047            {
048                return false;
049            }
050        }
051    }