return EnumActionResult.FAIL; if(event.getResult() == Result.ALLOW) { ToolCommons.damageItem(stack, 1, player, MANA_PER_DAMAGE); return EnumActionResult.SUCCESS;
private int onHoeUse(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos) { UseHoeEvent event = new UseHoeEvent(player, stack, worldIn, pos); if (MinecraftForge.EVENT_BUS.post(event)) return -1; if (event.getResult() == Result.ALLOW) { displayParticle(worldIn, pos, EnumParticleTypes.BLOCK_CRACK, Blocks.DIRT.getDefaultState()); playSound(worldIn, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS); ToolHelper.performTask(player, stack, this); return 1; } return 0; }
@SubscribeEvent(priority = EventPriority.LOW) public void onHoe(UseHoeEvent event){ if(ConfigBoolValues.WORMS.isEnabled() && event.getResult() != Result.DENY){ World world = event.getWorld(); if(!world.isRemote){ BlockPos pos = event.getPos(); if(world.isAirBlock(pos.up())){ IBlockState state = world.getBlockState(pos); if(state.getBlock() instanceof BlockGrass && world.rand.nextFloat() >= 0.95F){ ItemStack stack = new ItemStack(InitItems.itemWorm, world.rand.nextInt(2)+1); EntityItem item = new EntityItem(event.getWorld(), pos.getX()+0.5, pos.getY()+1, pos.getZ()+0.5, stack); world.spawnEntity(item); } } } } }
return EnumActionResult.FAIL; if (event.getResult() == Result.ALLOW) { if (!player.capabilities.isCreativeMode) { useEnergy(stack, false);