diff options
author | Spottedleaf <[email protected]> | 2022-09-01 09:51:59 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2022-09-01 09:51:59 -0700 |
commit | 046466f3ba72d6bdaa0213cde64676dd0024ace0 (patch) | |
tree | 717d69c8521cac0e4881c009e636891e116c2378 /patches/server/0077-handle-NaN-health-absorb-values-and-repair-bad-data.patch | |
parent | eff22eb0541559f05cf9a8c370d70c3b346f80f6 (diff) | |
download | Paper-046466f3ba72d6bdaa0213cde64676dd0024ace0.tar.gz Paper-046466f3ba72d6bdaa0213cde64676dd0024ace0.zip |
Re-arrange most chunk system patches to front (#8338)
* Re-arrange most chunk system patches to front
Co-authored-by: Spottedleaf <[email protected]>
Diffstat (limited to 'patches/server/0077-handle-NaN-health-absorb-values-and-repair-bad-data.patch')
-rw-r--r-- | patches/server/0077-handle-NaN-health-absorb-values-and-repair-bad-data.patch | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/patches/server/0077-handle-NaN-health-absorb-values-and-repair-bad-data.patch b/patches/server/0077-handle-NaN-health-absorb-values-and-repair-bad-data.patch new file mode 100644 index 0000000000..9e4b4b1cbb --- /dev/null +++ b/patches/server/0077-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 1dcf41a4105c05c3182afa8585dee20723d2c136..54e7fa7a483e15c440f562559601292c2a064208 100644 +--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java ++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +@@ -784,7 +784,13 @@ public abstract class LivingEntity extends Entity { + + @Override + public void readAdditionalSaveData(CompoundTag nbt) { +- this.setAbsorptionAmount(nbt.getFloat("AbsorptionAmount")); ++ // Paper start - jvm keeps optimizing the setter ++ float absorptionAmount = nbt.getFloat("AbsorptionAmount"); ++ if (Float.isNaN(absorptionAmount)) { ++ absorptionAmount = 0; ++ } ++ this.setAbsorptionAmount(absorptionAmount); ++ // Paper end + if (nbt.contains("Attributes", 9) && this.level != null && !this.level.isClientSide) { + this.getAttributes().load(nbt.getList("Attributes", 10)); + } +@@ -1271,6 +1277,10 @@ public abstract class LivingEntity extends Entity { + } + + public void setHealth(float health) { ++ // Paper start ++ if (Float.isNaN(health)) { health = getMaxHealth(); if (this.valid) { ++ System.err.println("[NAN-HEALTH] " + getScoreboardName() + " had NaN health set"); ++ } } // Paper end + // CraftBukkit start - Handle scaled health + if (this instanceof ServerPlayer) { + org.bukkit.craftbukkit.entity.CraftPlayer player = ((ServerPlayer) this).getBukkitEntity(); +@@ -3422,7 +3432,7 @@ public abstract class LivingEntity extends Entity { + } + + public void setAbsorptionAmount(float amount) { +- if (amount < 0.0F) { ++ if (amount < 0.0F || Float.isNaN(amount)) { // Paper + amount = 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 6ae934c6c7c50dd38ff2e762fddfe650e97aa4ae..da91150f7462c2743d7394b148ddb52e9af8b797 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -1932,6 +1932,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + } + + public void setRealHealth(double health) { ++ if (Double.isNaN(health)) {return;} // Paper + this.health = health; + } + |