diff options
author | Kyle Wood <[email protected]> | 2021-04-24 17:01:33 -0500 |
---|---|---|
committer | Kyle Wood <[email protected]> | 2021-04-25 18:37:43 -0500 |
commit | 3093b81fee3064603c368ab934eddf66ce304433 (patch) | |
tree | cb99f05b5f31de92c41af4cc40b4bef5f3cbf573 /Spigot-Server-Patches-Unmapped/0068-handle-NaN-health-absorb-values-and-repair-bad-data.patch | |
parent | 1af696a05d21cbdd7b5a7170f95598c013257588 (diff) | |
download | Paper-3093b81fee3064603c368ab934eddf66ce304433.tar.gz Paper-3093b81fee3064603c368ab934eddf66ce304433.zip |
Move patches
Diffstat (limited to 'Spigot-Server-Patches-Unmapped/0068-handle-NaN-health-absorb-values-and-repair-bad-data.patch')
-rw-r--r-- | Spigot-Server-Patches-Unmapped/0068-handle-NaN-health-absorb-values-and-repair-bad-data.patch | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Spigot-Server-Patches-Unmapped/0068-handle-NaN-health-absorb-values-and-repair-bad-data.patch b/Spigot-Server-Patches-Unmapped/0068-handle-NaN-health-absorb-values-and-repair-bad-data.patch new file mode 100644 index 0000000000..318262bd90 --- /dev/null +++ b/Spigot-Server-Patches-Unmapped/0068-handle-NaN-health-absorb-values-and-repair-bad-data.patch @@ -0,0 +1,57 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar <[email protected]> +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/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java +index 9b12e15a6c377ae90193596a35114dd452cf6e0c..acbd10432b09172f7541b2f4081d1aa9812194ac 100644 +--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java ++++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java +@@ -702,7 +702,13 @@ public abstract class EntityLiving extends Entity { + + @Override + public void loadData(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) { + this.getAttributeMap().a(nbttagcompound.getList("Attributes", 10)); + } +@@ -1151,6 +1157,10 @@ public abstract class EntityLiving extends Entity { + } + + 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(); +@@ -3045,7 +3055,7 @@ public abstract class EntityLiving extends Entity { + } + + 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 +index 144faef77e69c6c3bf963327179a51bb4c37cc18..b4a2758ee246252d6076e861b45d11dae6e33096 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -1682,6 +1682,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + } + + public void setRealHealth(double health) { ++ if (Double.isNaN(health)) {return;} // Paper + this.health = health; + } + |