From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Fortern Date: Mon, 29 Sep 2025 10:24:45 +0800 Subject: [PATCH] Do not check NaN values in entities diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java index d9fe2e6d424231c7acd15cd5bb6a05afa2e263c6..50c143bb15108f02918fbacdff1eebfc14ee8aa6 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -2561,10 +2561,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } } // CraftBukkit - this.setDeltaMovement(io.papermc.paper.util.MCUtil.sanitizeNanInf(this.deltaMovement, 0D)); // Paper - remove NaN values before usage in saving + // Leaves start - Do not check NaN values + // this.setDeltaMovement(io.papermc.paper.util.MCUtil.sanitizeNanInf(this.deltaMovement, 0D)); // Paper - remove NaN values before usage in saving // Leaves - Do not check NaN values output.store("Motion", Vec3.CODEC, this.getDeltaMovement()); // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero // TODO: make sure this is the best way to address this. + /* if (Float.isNaN(this.yRot)) { this.yRot = 0; } @@ -2572,7 +2574,9 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name if (Float.isNaN(this.xRot)) { this.xRot = 0; } + */ // CraftBukkit end + // Leaves end - Do not check NaN values output.store("Rotation", Vec2.CODEC, new Vec2(this.getYRot(), this.getXRot())); output.putDouble("fall_distance", this.fallDistance); output.putShort("Fire", (short)this.remainingFireTicks); @@ -2695,7 +2699,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name public void load(ValueInput input) { try { Vec3 vec3 = input.read("Pos", Vec3.CODEC).orElse(Vec3.ZERO); - Vec3 vec31 = input.read("Motion", Vec3.CODEC).orElse(Vec3.ZERO); vec31 = io.papermc.paper.util.MCUtil.sanitizeNanInf(vec31, 0D); // Paper - avoid setting NaN values + Vec3 vec31 = input.read("Motion", Vec3.CODEC).orElse(Vec3.ZERO); // vec31 = io.papermc.paper.util.MCUtil.sanitizeNanInf(vec31, 0D); // Paper - avoid setting NaN values // Leaves - Do not check NaN values Vec2 vec2 = input.read("Rotation", Vec2.CODEC).orElse(Vec2.ZERO); this.setDeltaMovement(Math.abs(vec31.x) > 10.0 ? 0.0 : vec31.x, Math.abs(vec31.y) > 10.0 ? 0.0 : vec31.y, Math.abs(vec31.z) > 10.0 ? 0.0 : vec31.z); this.hasImpulse = true;