aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/FishingRodItem.java.patch
blob: e7042e73eb3897bd2168c30683c172d694713905 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
--- a/net/minecraft/world/item/FishingRodItem.java
+++ b/net/minecraft/world/item/FishingRodItem.java
@@ -11,7 +11,10 @@
 import net.minecraft.world.level.Level;
 import net.minecraft.world.level.gameevent.GameEvent;
 
-public class FishingRodItem extends Item implements Vanishable {
+// CraftBukkit start
+import org.bukkit.event.player.PlayerFishEvent;
+import org.bukkit.craftbukkit.CraftEquipmentSlot;
+// CraftBukkit end
 
     public FishingRodItem(Item.Properties item_properties) {
         super(item_properties);
@@ -39,7 +43,18 @@
                 i = EnchantmentHelper.getFishingSpeedBonus(itemstack);
                 int j = EnchantmentHelper.getFishingLuckBonus(itemstack);
 
-                level.addFreshEntity(new FishingHook(player, level, j, i));
+                // CraftBukkit start
+                FishingHook entityfishinghook = new FishingHook(player, level, j, i);
+                PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) player.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), CraftEquipmentSlot.getHand(hand), PlayerFishEvent.State.FISHING);
+                level.getCraftServer().getPluginManager().callEvent(playerFishEvent);
+
+                if (playerFishEvent.isCancelled()) {
+                    player.fishing = null;
+                    return InteractionResultHolder.pass(itemstack);
+                }
+                level.playSound((Player) null, player.getX(), player.getY(), player.getZ(), SoundEvents.FISHING_BOBBER_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F));
+                level.addFreshEntity(entityfishinghook);
+                // CraftBukkit end
             }
 
             player.awardStat(Stats.ITEM_USED.get(this));