    001    package net.minecraft.src;
    002
    003    import net.minecraftforge.common.MinecraftForge;
    004    import net.minecraftforge.event.entity.UseHoeEvent;
    005    import cpw.mods.fml.common.Side;
    006    import cpw.mods.fml.common.asm.SideOnly;
    007
    008    public class ItemHoe extends Item
    009    {
    010        protected EnumToolMaterial theToolMaterial;
    011
    012        public ItemHoe(int par1, EnumToolMaterial par2EnumToolMaterial)
    013        {
    014            super(par1);
    015            this.theToolMaterial = par2EnumToolMaterial;
    016            this.maxStackSize = 1;
    017            this.setMaxDamage(par2EnumToolMaterial.getMaxUses());
    018            this.setCreativeTab(CreativeTabs.tabTools);
    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 (!par2EntityPlayer.canPlayerEdit(par4, par5, par6))
    028            {
    029                return false;
    030            }
    031            else
    032            {
    033                UseHoeEvent event = new UseHoeEvent(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6);
    034                if (MinecraftForge.EVENT_BUS.post(event))
    035                {
    036                    return false;
    037                }
    038                if (event.isHandeled())
    039                {
    040                    par1ItemStack.damageItem(1, par2EntityPlayer);
    041                    return true;
    042                }
    043
    044                int var11 = par3World.getBlockId(par4, par5, par6);
    045                int var12 = par3World.getBlockId(par4, par5 + 1, par6);
    046
    047                if ((par7 == 0 || var12 != 0 || var11 != Block.grass.blockID) && var11 != Block.dirt.blockID)
    048                {
    049                    return false;
    050                }
    051                else
    052                {
    053                    Block var13 = Block.tilledField;
    054                    par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), var13.stepSound.getStepSound(), (var13.stepSound.getVolume() + 1.0F) / 2.0F, var13.stepSound.getPitch() * 0.8F);
    055
    056                    if (par3World.isRemote)
    057                    {
    058                        return true;
    059                    }
    060                    else
    061                    {
    062                        par3World.setBlockWithNotify(par4, par5, par6, var13.blockID);
    063                        par1ItemStack.damageItem(1, par2EntityPlayer);
    064                        return true;
    065                    }
    066                }
    067            }
    068        }
    069
    070        @SideOnly(Side.CLIENT)
    071
    072        /**
    073         * Returns True is the item is renderer in full 3D when hold.
    074         */
    075        public boolean isFull3D()
    076        {
    077            return true;
    078        }
    079
    080        public String func_77842_f()
    081        {
    082            return this.theToolMaterial.toString();
    083        }
    084    }