2018-07-29 18:42:07 +02:00
|
|
|
From e6beddb2a3b1f55eb4be581dff0980d66cb1833d Mon Sep 17 00:00:00 2001
|
2016-03-20 05:35:02 +01:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Sun, 27 Sep 2015 01:18:02 -0400
|
|
|
|
Subject: [PATCH] handle NaN health/absorb values and repair bad data
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
2018-07-29 18:42:07 +02:00
|
|
|
index acd8034e8..2448d22ca 100644
|
2016-03-20 05:35:02 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
2018-07-20 21:57:43 +02:00
|
|
|
@@ -498,7 +498,13 @@ public abstract class EntityLiving extends Entity {
|
2016-03-20 05:35:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
|
|
- this.setAbsorptionHearts(nbttagcompound.getFloat("AbsorptionAmount"));
|
|
|
|
+ // Paper start - jvm keeps optimizing the setter
|
|
|
|
+ float absorptionAmount = nbttagcompound.getFloat("AbsorptionAmount");
|
|
|
|
+ if (Float.isNaN(absorptionAmount)) {
|
|
|
|
+ absorptionAmount = 0;
|
|
|
|
+ }
|
|
|
|
+ this.setAbsorptionHearts(absorptionAmount);
|
|
|
|
+ // Paper end
|
|
|
|
if (nbttagcompound.hasKeyOfType("Attributes", 9) && this.world != null && !this.world.isClientSide) {
|
|
|
|
GenericAttributes.a(this.getAttributeMap(), nbttagcompound.getList("Attributes", 10));
|
|
|
|
}
|
2018-07-21 22:03:10 +02:00
|
|
|
@@ -890,6 +896,10 @@ public abstract class EntityLiving extends Entity {
|
2016-03-20 05:35:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setHealth(float f) {
|
|
|
|
+ // Paper start
|
|
|
|
+ if (Float.isNaN(f)) { f = getMaxHealth(); if (this.valid) {
|
|
|
|
+ System.err.println("[NAN-HEALTH] " + getName() + " had NaN health set");
|
|
|
|
+ } } // Paper end
|
|
|
|
// CraftBukkit start - Handle scaled health
|
|
|
|
if (this instanceof EntityPlayer) {
|
|
|
|
org.bukkit.craftbukkit.entity.CraftPlayer player = ((EntityPlayer) this).getBukkitEntity();
|
2018-07-21 22:03:10 +02:00
|
|
|
@@ -2428,7 +2438,7 @@ public abstract class EntityLiving extends Entity {
|
2016-03-20 05:35:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setAbsorptionHearts(float f) {
|
|
|
|
- if (f < 0.0F) {
|
|
|
|
+ if (f < 0.0F || Float.isNaN(f)) { // Paper
|
|
|
|
f = 0.0F;
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2018-07-29 18:42:07 +02:00
|
|
|
index 1f716013a..be29f85a0 100644
|
2016-03-20 05:35:02 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2018-07-29 18:42:07 +02:00
|
|
|
@@ -1552,6 +1552,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2016-03-20 05:35:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setRealHealth(double health) {
|
|
|
|
+ if (Double.isNaN(health)) {return;} // Paper
|
|
|
|
this.health = health;
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2018-07-04 09:55:24 +02:00
|
|
|
2.18.0
|
2016-03-20 05:35:02 +01:00
|
|
|
|