diff options
author | Spottedleaf <[email protected]> | 2024-07-17 10:24:53 -0700 |
---|---|---|
committer | Spottedleaf <[email protected]> | 2024-07-17 10:28:32 -0700 |
commit | 00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6 (patch) | |
tree | 82639515bc5e9ae00c1e639e72137ed51e1ac688 /patches/server/0074-handle-NaN-health-absorb-values-and-repair-bad-data.patch | |
parent | 967f98aa81da851740aeb429778e46159fd188df (diff) | |
download | Paper-00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6.tar.gz Paper-00b949f1bbbf444e2b5e7b8de7c9b14fbd2133c6.zip |
Remove Moonrise utils to MCUtils, remove duplicated/unused utils
Diffstat (limited to 'patches/server/0074-handle-NaN-health-absorb-values-and-repair-bad-data.patch')
-rw-r--r-- | patches/server/0074-handle-NaN-health-absorb-values-and-repair-bad-data.patch | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/patches/server/0074-handle-NaN-health-absorb-values-and-repair-bad-data.patch b/patches/server/0074-handle-NaN-health-absorb-values-and-repair-bad-data.patch new file mode 100644 index 0000000000..1d38bc8302 --- /dev/null +++ b/patches/server/0074-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 e7b308ba4a253b270aebebd19e2671514c5357ca..fae7c493c9be741f019fc49f45a59976e6b01ed7 100644 +--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java ++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +@@ -808,7 +808,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)); + } +@@ -1342,6 +1348,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(); +@@ -3688,7 +3698,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 174c86a7213ecf3c8dc03aeaf55c56a4c4ce55ad..c399264ccffe646be10b3f13ebe0c0103d97f62c 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -2338,6 +2338,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; + } + |