2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 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
|
2021-01-28 23:32:05 +00:00
|
|
|
index a001629eda462ba34555aed6fe162078c18e0c02..d20f405287fb25fd4b221345b0845a0c6713298e 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
|
2020-12-21 07:56:22 +00:00
|
|
|
@@ -609,7 +609,13 @@ public abstract class EntityLiving extends Entity {
|
2016-03-20 04:35:02 +00:00
|
|
|
|
2019-04-26 01:24:00 +00:00
|
|
|
@Override
|
2020-06-25 11:00:35 +00:00
|
|
|
public void loadData(NBTTagCompound nbttagcompound) {
|
2016-03-20 04:35:02 +00:00
|
|
|
- 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) {
|
2020-06-25 11:00:35 +00:00
|
|
|
this.getAttributeMap().a(nbttagcompound.getList("Attributes", 10));
|
2016-03-20 04:35:02 +00:00
|
|
|
}
|
2020-12-21 07:56:22 +00:00
|
|
|
@@ -1058,6 +1064,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();
|
2021-01-28 23:32:05 +00:00
|
|
|
@@ -2952,7 +2962,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
|
2021-02-05 22:52:27 +00:00
|
|
|
index 5e3b36c1cc3346b2a1b6f84ea4a412beaff8b7b3..35c6c4871f21157fe349e87cb8fd0d5ab77a8c2a 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
|
2021-02-05 22:52:27 +00:00
|
|
|
@@ -1629,6 +1629,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;
|
|
|
|
}
|
|
|
|
|