mirror of https://github.com/PaperMC/Paper.git
Merge b363dfe12d
into 8f7ac62905
This commit is contained in:
commit
d342ad4e22
|
@ -0,0 +1,54 @@
|
|||
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 Exact No Damage Ticks API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
index ffca32ae2464ea5a669029079a50585ca259a4f8..e8e2284d0a841a176b883df0f4250c092e2afd3b 100644
|
||||
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
@@ -467,6 +467,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();
|
||||
@@ -474,10 +475,35 @@ 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.
|
||||
+ * <p>
|
||||
+ * 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
|
||||
+ */
|
||||
+ int getExactNoDamageTicks();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets exactly how many ticks this entity
|
||||
+ * will be invulnerable for.
|
||||
+ * <p>
|
||||
+ * 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
|
||||
+ */
|
||||
+ void setExactNoDamageTicks(int ticks);
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Gets the player identified as the killer of the living entity.
|
||||
* <p>
|
|
@ -0,0 +1,28 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Thu, 6 Apr 2023 21:11:09 -0400
|
||||
Subject: [PATCH] Add Exact No Damage Ticks API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index aec588b41f19b2147a4e7267bafa417fbcf7abc0..cb24bfc70c7e004cc951f8c056a12a2dfc8fd941 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -418,6 +418,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
public void setNoDamageTicks(int ticks) {
|
||||
this.getHandle().invulnerableTime = ticks;
|
||||
}
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public int getExactNoDamageTicks() {
|
||||
+ return Math.max(0, this.getNoDamageTicks() - (this.getMaximumNoDamageTicks() / 2));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setExactNoDamageTicks(int ticks) {
|
||||
+ this.setNoDamageTicks(ticks + (this.getMaximumNoDamageTicks() / 2));
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
@Override
|
||||
public net.minecraft.world.entity.LivingEntity getHandle() {
|
Loading…
Reference in New Issue