package net.minecraft.item; import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.UseHoeEvent; public class ItemHoe extends Item { protected Item.ToolMaterial theToolMaterial; private static final String __OBFID = "CL_00000039"; public ItemHoe(Item.ToolMaterial p_i45343_1_) { this.theToolMaterial = p_i45343_1_; this.maxStackSize = 1; this.setMaxDurability(p_i45343_1_.getMaxUses()); this.setCreativeTab(CreativeTabs.tabTools); } /** * Description : Callback for item usage. If the item does something special on right clicking, he will have one of * those. Return True if something happen and false if it don't. This is for ITEMS, not BLOCKS. Args : stack, * player, world, x, y, z, side, hitX, hitY, hitZ */ public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_)) { return false; } else { UseHoeEvent event = new UseHoeEvent(p_77648_2_, p_77648_1_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_); if (MinecraftForge.EVENT_BUS.post(event)) { return false; } if (event.getResult() == Result.ALLOW) { p_77648_1_.damageItem(1, p_77648_2_); return true; } Block block = p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_); if (p_77648_7_ != 0 && p_77648_3_.getBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_).isAir(p_77648_3_, p_77648_4_, p_77648_5_ + 1, p_77648_6_) && (block == Blocks.grass || block == Blocks.dirt)) { Block block1 = Blocks.farmland; p_77648_3_.playSoundEffect((double)((float)p_77648_4_ + 0.5F), (double)((float)p_77648_5_ + 0.5F), (double)((float)p_77648_6_ + 0.5F), block1.stepSound.getStepSound(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getFrequency() * 0.8F); if (p_77648_3_.isRemote) { return true; } else { p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block1); p_77648_1_.damageItem(1, p_77648_2_); return true; } } else { return false; } } } /** * Returns True is the item is renderer in full 3D when hold. */ @SideOnly(Side.CLIENT) public boolean isFull3D() { return true; } /** * Returns the name of the material this tool is made from as it is declared in EnumToolMaterial (meaning diamond * would return "EMERALD") */ public String getMaterialName() { return this.theToolMaterial.toString(); } }