--- a/net/minecraft/world/item/FishingRodItem.java +++ b/net/minecraft/world/item/FishingRodItem.java @@ -24,7 +_,7 @@ ItemStack itemInHand = player.getItemInHand(hand); if (player.fishing != null) { if (!level.isClientSide) { - int i = player.fishing.retrieve(itemInHand); + int i = player.fishing.retrieve(hand, itemInHand); // Paper - Add hand parameter to PlayerFishEvent itemInHand.hurtAndBreak(i, player, LivingEntity.getSlotForHand(hand)); } @@ -40,20 +_,31 @@ ); player.gameEvent(GameEvent.ITEM_INTERACT_FINISH); } else { - level.playSound( - null, - player.getX(), - player.getY(), - player.getZ(), - SoundEvents.FISHING_BOBBER_THROW, - SoundSource.NEUTRAL, - 0.5F, - 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F) - ); + // CraftBukkit - moved down if (level instanceof ServerLevel serverLevel) { int i1 = (int)(EnchantmentHelper.getFishingTimeReduction(serverLevel, itemInHand, player) * 20.0F); int fishingLuckBonus = EnchantmentHelper.getFishingLuckBonus(serverLevel, itemInHand, player); - Projectile.spawnProjectile(new FishingHook(player, level, fishingLuckBonus, i1), serverLevel, itemInHand); + // CraftBukkit start + FishingHook entityfishinghook = new FishingHook(player, level, fishingLuckBonus, i1); + org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) player.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), org.bukkit.event.player.PlayerFishEvent.State.FISHING); + level.getCraftServer().getPluginManager().callEvent(playerFishEvent); + + if (playerFishEvent.isCancelled()) { + player.fishing = null; + return InteractionResult.PASS; + } + level.playSound( + null, + player.getX(), + player.getY(), + player.getZ(), + SoundEvents.FISHING_BOBBER_THROW, + SoundSource.NEUTRAL, + 0.5F, + 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F) + ); + Projectile.spawnProjectile(entityfishinghook, serverLevel, itemInHand); + // CraftBukkit end } player.awardStat(Stats.ITEM_USED.get(this));