@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (!player.capabilities.isCreativeMode && getEnergyStored(stack) < getEnergyPerUse(stack)) {
return new ActionResult<>(EnumActionResult.FAIL, stack);
}
if (player.fishEntity != null) {
player.fishEntity.handleHookRetraction();
if (!player.capabilities.isCreativeMode) {
useEnergy(stack, false);
}
player.swingArm(hand);
} else {
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (ServerHelper.isServerWorld(world)) {
EntityFishHook hook = new EntityFishHook(world, player);
int enchantSpeed = EnchantmentHelper.getFishingSpeedBonus(stack);
hook.setLureSpeed(Math.min(speedModifier + enchantSpeed + (isEmpowered(stack) ? 2 : 0), 5));
int enchantLuck = EnchantmentHelper.getFishingLuckBonus(stack);
hook.setLuck(luckModifier + enchantLuck + (isEmpowered(stack) ? 2 : 0));
world.spawnEntity(hook);
}
player.swingArm(hand);
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}