    001    package net.minecraft.src;
    002
    003    import net.minecraftforge.common.MinecraftForge;
    004    import net.minecraftforge.event.Event.Result;
    005    import net.minecraftforge.event.entity.player.UseHoeEvent;
    006    import cpw.mods.fml.common.Side;
    007    import cpw.mods.fml.common.asm.SideOnly;
    008
    009    public class ItemHoe extends Item
    010    {
    011        protected EnumToolMaterial theToolMaterial;
    012
    013        public ItemHoe(int par1, EnumToolMaterial par2EnumToolMaterial)
    014        {
    015            super(par1);
    016            this.theToolMaterial = par2EnumToolMaterial;
    017            this.maxStackSize = 1;
    018            this.setMaxDamage(par2EnumToolMaterial.getMaxUses());
    019            this.setCreativeTab(CreativeTabs.tabTools);
    020        }
    021
    022        /**
    023         * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
    024         * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
    025         */
    026        public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
    027        {
    028            if (!par2EntityPlayer.func_82247_a(par4, par5, par6, par7, par1ItemStack))
    029            {
    030                return false;
    031            }
    032            else
    033            {
    034                UseHoeEvent event = new UseHoeEvent(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6);
    035                if (MinecraftForge.EVENT_BUS.post(event))
    036                {
    037                    return false;
    038                }
    039
    040                if (event.getResult() == Result.ALLOW)
    041                {
    042                    par1ItemStack.damageItem(1, par2EntityPlayer);
    043                    return true;
    044                }
    045
    046                int var11 = par3World.getBlockId(par4, par5, par6);
    047                int var12 = par3World.getBlockId(par4, par5 + 1, par6);
    048
    049                if ((par7 == 0 || var12 != 0 || var11 != Block.grass.blockID) && var11 != Block.dirt.blockID)
    050                {
    051                    return false;
    052                }
    053                else
    054                {
    055                    Block var13 = Block.tilledField;
    056                    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);
    057
    058                    if (par3World.isRemote)
    059                    {
    060                        return true;
    061                    }
    062                    else
    063                    {
    064                        par3World.setBlockWithNotify(par4, par5, par6, var13.blockID);
    065                        par1ItemStack.damageItem(1, par2EntityPlayer);
    066                        return true;
    067                    }
    068                }
    069            }
    070        }
    071
    072        @SideOnly(Side.CLIENT)
    073
    074        /**
    075         * Returns True is the item is renderer in full 3D when hold.
    076         */
    077        public boolean isFull3D()
    078        {
    079            return true;
    080        }
    081
    082        public String func_77842_f()
    083        {
    084            return this.theToolMaterial.toString();
    085        }
    086    }