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