geforkt von Mirrors/Paper
58 Zeilen
2.7 KiB
Diff
58 Zeilen
2.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
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/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
index 571f170c7816d37ff1f082f00cab3725c660a10a..7e3378861990034015a6796013b78d504dcb8b5e 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -795,7 +795,13 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
|
|
@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));
|
|
}
|
|
@@ -1313,6 +1319,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
}
|
|
|
|
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();
|
|
@@ -3482,7 +3492,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
}
|
|
|
|
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 5fe88000bb29f5fd83ca8708b24a2c9ad2f5a562..55715c017e4e08a0e3db95dea5b8ec4fd4acf00d 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -2096,6 +2096,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
}
|
|
|
|
public void setRealHealth(double health) {
|
|
+ if (Double.isNaN(health)) {return;} // Paper
|
|
this.health = health;
|
|
}
|
|
|