diff --git a/patches/api/Add-missing-fishing-event-state.patch b/patches/api/Add-missing-fishing-event-state.patch new file mode 100644 index 0000000000..4db6a84c8f --- /dev/null +++ b/patches/api/Add-missing-fishing-event-state.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: SoSeDiK +Date: Wed, 1 May 2024 07:44:50 +0300 +Subject: [PATCH] Add missing fishing event state + + +diff --git a/src/main/java/org/bukkit/event/player/PlayerFishEvent.java b/src/main/java/org/bukkit/event/player/PlayerFishEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/player/PlayerFishEvent.java ++++ b/src/main/java/org/bukkit/event/player/PlayerFishEvent.java +@@ -0,0 +0,0 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable { + * in. + */ + BITE ++ // Paper start - Add missing fishing event state ++ , ++ /** ++ * Called when a bobber was lured, and is now waiting to be hooked ++ * (when a "fish" starts to swim toward the bobber to bite it). ++ */ ++ LURED, ++ // Paper end - Add missing fishing event state + } + } diff --git a/patches/api/More-Projectile-API.patch b/patches/api/More-Projectile-API.patch index fc63148d06..bb6f431343 100644 --- a/patches/api/More-Projectile-API.patch +++ b/patches/api/More-Projectile-API.patch @@ -4,6 +4,7 @@ Date: Wed, 26 May 2021 19:34:43 -0400 Subject: [PATCH] More Projectile API Co-authored-by: Nassim Jahnke +Co-authored-by: SoSeDiK diff --git a/src/main/java/org/bukkit/entity/AbstractArrow.java b/src/main/java/org/bukkit/entity/AbstractArrow.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -205,6 +206,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param ticks Number of ticks + */ + void setWaitTime(int ticks); ++ ++ /** ++ * Get the number of ticks the fish has to swim until biting the hook. ++ * The {@link #getWaitTime()} has to be zero or below for the fish to start the time until bite timer. ++ * ++ * @return number of ticks. ++ * A value of one indicates that the fish bites the very next time the fish hook is ticked ++ * while a value of zero represents a fish that has already bitten the hook. ++ * @see #getWaitTime() ++ */ ++ @org.jetbrains.annotations.Range(from = 0, to = Integer.MAX_VALUE) ++ int getTimeUntilBite(); ++ ++ /** ++ * Sets the number of ticks the fish has to swim until biting the hook. ++ * ++ * @param ticks number of ticks. ++ * One is the minimum that can be passed to this method and instructs the fish to bite the very next tick. ++ * @throws IllegalArgumentException if the passed tick value is less than one. ++ */ ++ void setTimeUntilBite(@org.jetbrains.annotations.Range(from = 1, to = Integer.MAX_VALUE) int ticks) throws IllegalArgumentException; ++ ++ /** ++ * Completely resets this fishing hook's fishing state, re-randomizing the time needed until a fish is lured and ++ * bites the hook. ++ *

++ * This method takes all properties of the fishing hook into account when resetting said values, such as a lure ++ * enchantment. ++ */ ++ void resetFishingState(); + // Paper end } diff --git a/src/main/java/org/bukkit/entity/Projectile.java b/src/main/java/org/bukkit/entity/Projectile.java diff --git a/patches/server/Add-missing-fishing-event-state.patch b/patches/server/Add-missing-fishing-event-state.patch new file mode 100644 index 0000000000..5af61ea332 --- /dev/null +++ b/patches/server/Add-missing-fishing-event-state.patch @@ -0,0 +1,26 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: SoSeDiK +Date: Wed, 1 May 2024 07:44:50 +0300 +Subject: [PATCH] Add missing fishing event state + + +diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java ++++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +@@ -0,0 +0,0 @@ public class FishingHook extends Projectile { + this.fishAngle = Mth.nextFloat(this.random, this.minLureAngle, this.maxLureAngle); + this.timeUntilHooked = Mth.nextInt(this.random, this.minLureTime, this.maxLureTime); + // CraftBukkit end ++ // Paper start - Add missing fishing event state ++ if (this.getPlayerOwner() != null) { ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.getPlayerOwner().getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.LURED); ++ if (!playerFishEvent.callEvent()) { ++ this.timeUntilHooked = 0; ++ return; ++ } ++ } ++ // Paper end - Add missing fishing event state + } + } else { + // CraftBukkit start - logic to modify fishing wait time diff --git a/patches/server/More-Projectile-API.patch b/patches/server/More-Projectile-API.patch index c85cfc6ab9..ef2647c93b 100644 --- a/patches/server/More-Projectile-API.patch +++ b/patches/server/More-Projectile-API.patch @@ -5,6 +5,7 @@ Subject: [PATCH] More Projectile API == AT == public net.minecraft.world.entity.projectile.FishingHook timeUntilLured +public net.minecraft.world.entity.projectile.FishingHook fishAngle public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaX public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaY public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaZ @@ -19,7 +20,33 @@ public net.minecraft.world.entity.projectile.Projectile canHitEntity(Lnet/minecr public net.minecraft.world.entity.projectile.FireworkRocketEntity getDefaultItem()Lnet/minecraft/world/item/ItemStack; Co-authored-by: Nassim Jahnke +Co-authored-by: SoSeDiK +diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java ++++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +@@ -0,0 +0,0 @@ public class FishingHook extends Projectile { + } + } else { + // CraftBukkit start - logic to modify fishing wait time +- this.timeUntilLured = Mth.nextInt(this.random, this.minWaitTime, this.maxWaitTime); +- this.timeUntilLured -= (this.applyLure) ? (this.lureSpeed * 20 * 5 >= this.maxWaitTime ? this.timeUntilLured - 1 : this.lureSpeed * 20 * 5) : 0; // Paper - Fix Lure infinite loop ++ resetTimeUntilLured(); // Paper - more projectile api - extract time until lured reset logic + // CraftBukkit end + } + } + + } ++ // Paper start - more projectile api - extract time until lured reset logic ++ public void resetTimeUntilLured() { ++ this.timeUntilLured = Mth.nextInt(this.random, this.minWaitTime, this.maxWaitTime); ++ this.timeUntilLured -= (this.applyLure) ? (this.lureSpeed * 20 * 5 >= this.maxWaitTime ? this.timeUntilLured - 1 : this.lureSpeed * 20 * 5) : 0; // Paper - Fix Lure infinite loop ++ } ++ // Paper end - more projectile api - extract time until lured reset logic + + public boolean calculateOpenWater(BlockPos pos) { + FishingHook.OpenWaterType entityfishinghook_waterposition = FishingHook.OpenWaterType.INVALID; diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java @@ -368,6 +395,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void setWaitTime(int ticks) { + this.getHandle().timeUntilLured = ticks; + } ++ ++ @Override ++ public int getTimeUntilBite() { ++ return this.getHandle().timeUntilHooked; ++ } ++ ++ @Override ++ public void setTimeUntilBite(final int ticks) { ++ com.google.common.base.Preconditions.checkArgument(ticks >= 1, "Cannot set time until bite to less than 1 (%s<1)", ticks); ++ final FishingHook hook = this.getHandle(); ++ ++ // Reset the fish angle hook only when this call "enters" the fish into the lure stage. ++ final boolean alreadyInLuringPhase = hook.timeUntilHooked > 0 && hook.timeUntilLured <= 0; ++ if (!alreadyInLuringPhase) { ++ hook.fishAngle = net.minecraft.util.Mth.nextFloat(hook.random, hook.minLureAngle, hook.maxLureAngle); ++ hook.timeUntilLured = 0; ++ } ++ ++ hook.timeUntilHooked = ticks; ++ } ++ ++ @Override ++ public void resetFishingState() { ++ final FishingHook hook = this.getHandle(); ++ hook.resetTimeUntilLured(); ++ hook.timeUntilHooked = 0; // Reset time until hooked, will be repopulated once lured time is ticked down. ++ } + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java