9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00
Files
LeavesMC/leaves-server/minecraft-patches/features/0141-Do-not-check-NaN-values-in-entities.patch
MC_XiaoHei 90080d238e 1.21.10 (#752)
---------

Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com>
Co-authored-by: Helvetica Volubi <88063803+Suisuroru@users.noreply.github.com>
2025-11-28 03:15:54 +08:00

44 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Fortern <blueten.ki@gmail.com>
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;