2016-12-17 04:13:45 +00:00
|
|
|
From 04b8471c6a6152c2658e668e0431e5e76bc212d9 Mon Sep 17 00:00:00 2001
|
2016-03-20 04:35:02 +00: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
|
2016-12-10 23:50:31 +00:00
|
|
|
index 539d016..1eee8a3 100644
|
2016-03-20 04:35:02 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
2016-11-17 02:23:38 +00:00
|
|
|
@@ -481,7 +481,13 @@ public abstract class EntityLiving extends Entity {
|
2016-03-20 04:35:02 +00: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));
|
|
|
|
}
|
2016-11-17 02:23:38 +00:00
|
|
|
@@ -779,6 +785,10 @@ public abstract class EntityLiving extends Entity {
|
2016-03-20 04:35:02 +00: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();
|
2016-12-10 23:50:31 +00:00
|
|
|
@@ -2210,7 +2220,7 @@ public abstract class EntityLiving extends Entity {
|
2016-03-20 04:35:02 +00: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
|
2016-12-17 04:13:45 +00:00
|
|
|
index 9ef6ba2..eba73cf 100644
|
2016-03-20 04:35:02 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2016-11-27 23:39:16 +00:00
|
|
|
@@ -1412,6 +1412,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2016-03-20 04:35:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setRealHealth(double health) {
|
|
|
|
+ if (Double.isNaN(health)) {return;} // Paper
|
|
|
|
this.health = health;
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2016-12-10 23:50:31 +00:00
|
|
|
2.9.3
|
2016-03-20 04:35:02 +00:00
|
|
|
|