From 03d5d38a6ae9a54b761fcd544f3d928ed5f5ab66 Mon Sep 17 00:00:00 2001 From: Tamion <70228790+notTamion@users.noreply.github.com> Date: Fri, 9 Feb 2024 21:56:13 +0100 Subject: [PATCH] Add Arrow/Stinger Removal Time API (#10193) --- ...working-with-arrows-stuck-in-living-.patch | 18 +++++++++++++++ patches/api/Stinger-API.patch | 20 +++++++++++++++-- ...working-with-arrows-stuck-in-living-.patch | 14 ++++++++++++ patches/server/Stinger-API.patch | 22 +++++++++++++++++-- 4 files changed, 70 insertions(+), 4 deletions(-) diff --git a/patches/api/Add-methods-for-working-with-arrows-stuck-in-living-.patch b/patches/api/Add-methods-for-working-with-arrows-stuck-in-living-.patch index 5e04a3cb1b..51848e555b 100644 --- a/patches/api/Add-methods-for-working-with-arrows-stuck-in-living-.patch +++ b/patches/api/Add-methods-for-working-with-arrows-stuck-in-living-.patch @@ -35,6 +35,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 */ - public void setArrowsInBody(int count); + void setArrowsInBody(int count, boolean fireEvent); // Paper ++ ++ // Paper start - Add methods for working with arrows stuck in living entities ++ /** ++ * Sets the amount of ticks before the next arrow gets removed from the entities body. ++ *
++ * A value of 0 will cause the server to re-calculate the amount of ticks on the next tick. ++ * ++ * @param ticks Amount of ticks ++ */ ++ void setNextArrowRemoval(@org.jetbrains.annotations.Range(from = 0, to = Integer.MAX_VALUE) int ticks); ++ ++ /** ++ * Gets the amount of ticks before the next arrow gets removed from the entities body. ++ * ++ * @return ticks Amount of ticks ++ */ ++ int getNextArrowRemoval(); ++ // Paper end - Add methods for working with arrows stuck in living entities /** * Returns the living entity's current maximum no damage ticks. diff --git a/patches/api/Stinger-API.patch b/patches/api/Stinger-API.patch index 55649a4b21..1c8445fb54 100644 --- a/patches/api/Stinger-API.patch +++ b/patches/api/Stinger-API.patch @@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java @@ -0,0 +0,0 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource - */ - void setArrowsInBody(int count, boolean fireEvent); // Paper + int getNextArrowRemoval(); + // Paper end - Add methods for working with arrows stuck in living entities + // Paper start - Bee Stinger API + /** @@ -40,6 +40,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param count amount of bee stingers in entity's body + */ + public void setBeeStingersInBody(int count); ++ ++ /** ++ * Sets the amount of ticks before the next bee stinger gets removed from the entities body. ++ *
++ * A value of 0 will cause the server to re-calculate the amount of ticks on the next tick. ++ * ++ * @param ticks Amount of ticks ++ */ ++ void setNextBeeStingerRemoval(@org.jetbrains.annotations.Range(from = 0, to = Integer.MAX_VALUE) int ticks); ++ ++ /** ++ * Gets the amount of ticks before the next bee stinger gets removed from the entities body. ++ * ++ * @return ticks Amount of ticks ++ */ ++ int getNextBeeStingerRemoval(); + // Paper end - Stinger API + /** diff --git a/patches/server/Add-methods-for-working-with-arrows-stuck-in-living-.patch b/patches/server/Add-methods-for-working-with-arrows-stuck-in-living-.patch index ec65d40e92..4752343498 100644 --- a/patches/server/Add-methods-for-working-with-arrows-stuck-in-living-.patch +++ b/patches/server/Add-methods-for-working-with-arrows-stuck-in-living-.patch @@ -24,9 +24,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.getHandle().setArrowCount(count); + } + // Paper end ++ } ++ ++ // Paper start - Add methods for working with arrows stuck in living entities ++ @Override ++ public void setNextArrowRemoval(final int ticks) { ++ Preconditions.checkArgument(ticks >= 0, "New amount of ticks before next arrow removal must be >= 0"); ++ this.getHandle().removeArrowTime = ticks; ++ } ++ ++ @Override ++ public int getNextArrowRemoval() { ++ return this.getHandle().removeArrowTime; } ++ // Paper end - Add methods for working with arrows stuck in living entities @Override + public void damage(double amount) { @@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { this.getHandle().persistentInvisibility = invisible; this.getHandle().setSharedFlag(5, invisible); diff --git a/patches/server/Stinger-API.patch b/patches/server/Stinger-API.patch index b5b1fb3430..14583dd001 100644 --- a/patches/server/Stinger-API.patch +++ b/patches/server/Stinger-API.patch @@ -17,12 +17,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public int getBeeStingerCooldown() { + return getHandle().removeStingerTime; + } -+ + + // Paper start - Add methods for working with arrows stuck in living entities + @Override +@@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { + } + // Paper end - Add methods for working with arrows stuck in living entities + + @Override + public void setBeeStingerCooldown(int ticks) { + getHandle().removeStingerTime = ticks; + } - ++ + @Override + public int getBeeStingersInBody() { + return getHandle().getStingerCount(); @@ -33,7 +39,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + Preconditions.checkArgument(count >= 0, "New bee stinger amount must be >= 0"); + getHandle().setStingerCount(count); + } ++ ++ @Override ++ public void setNextBeeStingerRemoval(final int ticks) { ++ Preconditions.checkArgument(ticks >= 0, "New amount of ticks before next bee stinger removal must be >= 0"); ++ this.getHandle().removeStingerTime = ticks; ++ } ++ ++ @Override ++ public int getNextBeeStingerRemoval() { ++ return this.getHandle().removeStingerTime; ++ } + // Paper end - Bee Stinger API ++ @Override public void damage(double amount) { this.damage(amount, null);