From 09a9bbb63fbfb5bc5e4f5fef2908c86fa533322e Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Fri, 18 Nov 2022 21:48:26 -0500 Subject: [PATCH] Add No Damage Tick Utilities --- .../0407-Add-No-Damage-Tick-Utilities.patch | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 patches/api/0407-Add-No-Damage-Tick-Utilities.patch diff --git a/patches/api/0407-Add-No-Damage-Tick-Utilities.patch b/patches/api/0407-Add-No-Damage-Tick-Utilities.patch new file mode 100644 index 0000000000..1b850f0f61 --- /dev/null +++ b/patches/api/0407-Add-No-Damage-Tick-Utilities.patch @@ -0,0 +1,58 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> +Date: Fri, 18 Nov 2022 21:42:10 -0500 +Subject: [PATCH] Add No Damage Tick Utilities + + +diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java +index 3bd1d100d0c481ae7edaa251869640ab370aeb42..a0a36c7a44ee33e0c532587e0e40d7b861c4c922 100644 +--- a/src/main/java/org/bukkit/entity/LivingEntity.java ++++ b/src/main/java/org/bukkit/entity/LivingEntity.java +@@ -405,6 +405,7 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource + /** + * Returns the living entity's current no damage ticks. + * ++ * @see LivingEntity#getExactNoDamageTicks() + * @return amount of no damage ticks + */ + public int getNoDamageTicks(); +@@ -412,10 +413,39 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource + /** + * Sets the living entity's current no damage ticks. + * ++ * @see LivingEntity#setExactNoDamageTicks(int) + * @param ticks amount of no damage ticks + */ + public void setNoDamageTicks(int ticks); + ++ // Paper start ++ /** ++ * Gets exactly how many ticks this entity will be ++ * invulnerable with its current no damage ticks. ++ *

++ * Note: The difference between this and {@link LivingEntity#getNoDamageTicks()} is that this method ++ * will correctly calculate and account for this entity's current maximum damage ticks in order get ++ * the exact value of how many ticks the current entity will be invulnerable. ++ * @return exact tick count ++ */ ++ default int getExactNoDamageTicks() { ++ return Math.max(0, this.getNoDamageTicks() - (this.getMaximumNoDamageTicks() / 2)); ++ } ++ ++ /** ++ * Sets exactly how many ticks this entity ++ * will be invulnerable for. ++ *

++ * Note: The difference between this and {@link LivingEntity#setNoDamageTicks(int)} is that this method ++ * will correctly calculate and account for this entity's current maximum damage ticks in order to make the ++ * entity invulnerable for the specified tick duration. ++ * @param ticks amount of ticks ++ */ ++ default void setExactNoDamageTicks(int ticks) { ++ this.setNoDamageTicks(ticks + (this.getMaximumNoDamageTicks() / 2)); ++ } ++ // Paper end ++ + /** + * Gets the player identified as the killer of the living entity. + *