aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0076-handle-NaN-health-absorb-values-and-repair-bad-data.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0076-handle-NaN-health-absorb-values-and-repair-bad-data.patch')
-rw-r--r--patches/server/0076-handle-NaN-health-absorb-values-and-repair-bad-data.patch57
1 files changed, 57 insertions, 0 deletions
diff --git a/patches/server/0076-handle-NaN-health-absorb-values-and-repair-bad-data.patch b/patches/server/0076-handle-NaN-health-absorb-values-and-repair-bad-data.patch
new file mode 100644
index 0000000000..e36d19f9b0
--- /dev/null
+++ b/patches/server/0076-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/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
+index d710e20447df4767e10f9250ce91dcd3141eaab0..e1d34c666f88bdbead59aff0d349a49608a7b8cd 100644
+--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
+@@ -833,7 +833,13 @@ public abstract class LivingEntity extends Entity implements Attackable {
+
+ @Override
+ public void readAdditionalSaveData(CompoundTag nbt) {
+- this.internalSetAbsorptionAmount(nbt.getFloat("AbsorptionAmount"));
++ // Paper start - Check for NaN
++ float absorptionAmount = nbt.getFloat("AbsorptionAmount");
++ if (Float.isNaN(absorptionAmount)) {
++ absorptionAmount = 0;
++ }
++ this.internalSetAbsorptionAmount(absorptionAmount);
++ // Paper end - Check for NaN
+ if (nbt.contains("Attributes", 9) && this.level() != null && !this.level().isClientSide) {
+ this.getAttributes().load(nbt.getList("Attributes", 10));
+ }
+@@ -1365,6 +1371,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
+ }
+
+ public void setHealth(float health) {
++ // Paper start - Check for NaN
++ if (Float.isNaN(health)) { health = getMaxHealth(); if (this.valid) {
++ System.err.println("[NAN-HEALTH] " + getScoreboardName() + " had NaN health set");
++ } } // Paper end - Check for NaN
+ // CraftBukkit start - Handle scaled health
+ if (this instanceof ServerPlayer) {
+ org.bukkit.craftbukkit.entity.CraftPlayer player = ((ServerPlayer) this).getBukkitEntity();
+@@ -3643,7 +3653,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
+ }
+
+ public final void setAbsorptionAmount(float absorptionAmount) {
+- this.internalSetAbsorptionAmount(Mth.clamp(absorptionAmount, 0.0F, this.getMaxAbsorption()));
++ this.internalSetAbsorptionAmount(!Float.isNaN(absorptionAmount) ? Mth.clamp(absorptionAmount, 0.0F, this.getMaxAbsorption()) : 0.0F); // Paper - Check for NaN
+ }
+
+ protected void internalSetAbsorptionAmount(float absorptionAmount) {
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+index 155f7053504874758d8d25a21f0ac613f81ca7d1..4923e6bba9eb95c3e7f6fafef63961cec091e1f8 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+@@ -2324,6 +2324,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
+ }
+
+ public void setRealHealth(double health) {
++ if (Double.isNaN(health)) {return;} // Paper - Check for NaN
+ this.health = health;
+ }
+