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

41 lines
2.6 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-04-24 01:15:00 +10:00
@@ -12,6 +12,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-04-24 01:15:00 +10:00
@@ -32,12 +37,23 @@
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));
2015-02-26 22:41:06 +00:00
if (!world.isClientSide) {
2021-11-22 09:00:00 +11:00
i = EnchantmentManager.getFishingSpeedBonus(itemstack);
int j = EnchantmentManager.getFishingLuckBonus(itemstack);
2016-12-21 07:00:00 +11:00
2021-11-22 09:00:00 +11:00
- world.addFreshEntity(new EntityFishingHook(entityhuman, world, j, i));
2016-12-21 07:00:00 +11:00
+ // CraftBukkit start
2019-04-23 12:00:00 +10:00
+ 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(), 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));