craftbukkit/nms-patches/net/minecraft/world/item/ItemFishingRod.patch

42 lines
2.7 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/item/ItemFishingRod.java
+++ b/net/minecraft/world/item/ItemFishingRod.java
2024-06-14 01:05:00 +10:00
@@ -13,6 +13,11 @@
2021-03-16 09:00:00 +11:00
import net.minecraft.world.level.World;
2021-06-11 15:00:00 +10:00
import net.minecraft.world.level.gameevent.GameEvent;
+// CraftBukkit start
+import org.bukkit.event.player.PlayerFishEvent;
+import org.bukkit.craftbukkit.CraftEquipmentSlot;
+// CraftBukkit end
+
2024-04-24 01:15:00 +10:00
public class ItemFishingRod extends Item {
2018-07-15 10:00:00 +10:00
public ItemFishingRod(Item.Info item_info) {
2024-06-14 01:05:00 +10:00
@@ -33,13 +38,24 @@
2021-11-22 09:00:00 +11:00
world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
2022-06-08 02:00:00 +10:00
entityhuman.gameEvent(GameEvent.ITEM_INTERACT_FINISH);
} else {
2021-11-22 09:00:00 +11:00
- world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
+ // world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
2024-06-14 01:05:00 +10:00
if (world instanceof WorldServer) {
WorldServer worldserver = (WorldServer) world;
int j = (int) (EnchantmentManager.getFishingTimeReduction(worldserver, itemstack, entityhuman) * 20.0F);
int k = EnchantmentManager.getFishingLuckBonus(worldserver, itemstack, entityhuman);
2016-12-21 07:00:00 +11:00
2024-06-14 01:05:00 +10:00
- world.addFreshEntity(new EntityFishingHook(entityhuman, world, k, j));
2016-12-21 07:00:00 +11:00
+ // CraftBukkit start
2024-06-14 01:05:00 +10:00
+ EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, k, j);
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand), PlayerFishEvent.State.FISHING);
+ world.getCraftServer().getPluginManager().callEvent(playerFishEvent);
2016-11-17 12:41:03 +11:00
+
+ if (playerFishEvent.isCancelled()) {
2021-06-11 15:00:00 +10:00
+ entityhuman.fishing = null;
2021-03-16 09:00:00 +11:00
+ return InteractionResultWrapper.pass(itemstack);
2016-11-17 12:41:03 +11:00
+ }
2021-11-22 09:00:00 +11:00
+ world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
+ world.addFreshEntity(entityfishinghook);
2016-11-17 12:41:03 +11:00
+ // CraftBukkit end
}
2016-12-21 07:00:00 +11:00
2021-11-22 09:00:00 +11:00
entityhuman.awardStat(StatisticList.ITEM_USED.get(this));