--- a/net/minecraft/world/item/ItemFishingRod.java +++ b/net/minecraft/world/item/ItemFishingRod.java @@ -12,6 +12,8 @@ import net.minecraft.world.level.World; import net.minecraft.world.level.gameevent.GameEvent; +import org.bukkit.event.player.PlayerFishEvent; // CraftBukkit + public class ItemFishingRod extends Item implements ItemVanishable { public ItemFishingRod(Item.Info item_info) { @@ -34,12 +36,23 @@ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); world.a((Entity) entityhuman, GameEvent.FISHING_ROD_REEL_IN, (Entity) entityhuman); } else { - world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); + // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); if (!world.isClientSide) { i = EnchantmentManager.c(itemstack); int j = EnchantmentManager.b(itemstack); - world.addEntity(new EntityFishingHook(entityhuman, world, j, i)); + // CraftBukkit start + EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, j, i); + PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), PlayerFishEvent.State.FISHING); + world.getCraftServer().getPluginManager().callEvent(playerFishEvent); + + if (playerFishEvent.isCancelled()) { + entityhuman.fishing = null; + return InteractionResultWrapper.pass(itemstack); + } + world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); + world.addEntity(entityfishinghook); + // CraftBukkit end } entityhuman.b(StatisticList.ITEM_USED.b(this));