EntityHealthRegain isFastRegen API
This commit is contained in:
parent
b3a6b5d2a1
commit
a6536804fd
|
@ -0,0 +1,51 @@
|
|||
From 32304a72413a8faddc6192b78f7bbc5850810763 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Fri, 22 Apr 2016 01:43:11 -0500
|
||||
Subject: [PATCH] EntityRegainHealthEvent isFastRegen API
|
||||
|
||||
Don't even get me started
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java b/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java
|
||||
index a7b3517..703520f 100644
|
||||
--- a/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java
|
||||
@@ -13,6 +13,7 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable
|
||||
private boolean cancelled;
|
||||
private double amount;
|
||||
private final RegainReason regainReason;
|
||||
+ private final boolean isFastRegen; // Paper
|
||||
|
||||
@Deprecated
|
||||
public EntityRegainHealthEvent(final Entity entity, final int amount, final RegainReason regainReason) {
|
||||
@@ -20,10 +21,28 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable
|
||||
}
|
||||
|
||||
public EntityRegainHealthEvent(final Entity entity, final double amount, final RegainReason regainReason) {
|
||||
+ // Paper start - Forward
|
||||
+ this(entity, amount, regainReason, false);
|
||||
+ }
|
||||
+
|
||||
+ public EntityRegainHealthEvent(final Entity entity, final double amount, final RegainReason regainReason, boolean isFastRegen) {
|
||||
+ // Paper end
|
||||
super(entity);
|
||||
this.amount = amount;
|
||||
this.regainReason = regainReason;
|
||||
+ this.isFastRegen = isFastRegen; // Paper
|
||||
+ }
|
||||
+
|
||||
+ // Paper start - Add getter for isFastRegen
|
||||
+ /**
|
||||
+ * Is this event a result of the fast regeneration mechanic
|
||||
+ *
|
||||
+ * @return Whether the event is the result of a fast regeneration mechanic
|
||||
+ */
|
||||
+ public boolean isFastRegen() {
|
||||
+ return isFastRegen;
|
||||
}
|
||||
+ // Paper end
|
||||
|
||||
/**
|
||||
* Gets the amount of regained health
|
||||
--
|
||||
2.8.0
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
From f5bd42c33ab6d47c45e359bbe5aaac0fee7f2db1 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Fri, 22 Apr 2016 01:43:11 -0500
|
||||
Subject: [PATCH] EntityRegainHealthEvent isFastRegen API
|
||||
|
||||
Don't even get me started
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
index 41b63ce..adf91bc 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
@@ -731,10 +731,16 @@ public abstract class EntityLiving extends Entity {
|
||||
}
|
||||
|
||||
public void heal(float f, EntityRegainHealthEvent.RegainReason regainReason) {
|
||||
+ // Paper start - Forward
|
||||
+ heal(f, regainReason, false);
|
||||
+ }
|
||||
+
|
||||
+ public void heal(float f, EntityRegainHealthEvent.RegainReason regainReason, boolean isFastRegen) {
|
||||
+ // Paper end
|
||||
float f1 = this.getHealth();
|
||||
|
||||
if (f1 > 0.0F) {
|
||||
- EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason);
|
||||
+ EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason, isFastRegen); // Paper - Add isFastRegen
|
||||
this.world.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
diff --git a/src/main/java/net/minecraft/server/FoodMetaData.java b/src/main/java/net/minecraft/server/FoodMetaData.java
|
||||
index 1a24336..bd367cf 100644
|
||||
--- a/src/main/java/net/minecraft/server/FoodMetaData.java
|
||||
+++ b/src/main/java/net/minecraft/server/FoodMetaData.java
|
||||
@@ -65,7 +65,7 @@ public class FoodMetaData {
|
||||
if (this.foodTickTimer >= 10) {
|
||||
float f = Math.min(this.saturationLevel, 4.0F);
|
||||
|
||||
- entityhuman.heal(f / 4.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // CraftBukkit - added RegainReason
|
||||
+ entityhuman.heal(f / 4.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED, true); // CraftBukkit - added RegainReason // Paper - This is fast regen
|
||||
this.a(f);
|
||||
this.foodTickTimer = 0;
|
||||
}
|
||||
--
|
||||
2.8.0
|
||||
|
Loading…
Reference in New Issue