aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0842-Guard-against-invalid-entity-positions.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0842-Guard-against-invalid-entity-positions.patch')
-rw-r--r--patches/server/0842-Guard-against-invalid-entity-positions.patch45
1 files changed, 45 insertions, 0 deletions
diff --git a/patches/server/0842-Guard-against-invalid-entity-positions.patch b/patches/server/0842-Guard-against-invalid-entity-positions.patch
new file mode 100644
index 0000000000..0a21359168
--- /dev/null
+++ b/patches/server/0842-Guard-against-invalid-entity-positions.patch
@@ -0,0 +1,45 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Spottedleaf <[email protected]>
+Date: Thu, 31 Mar 2022 05:18:28 -0700
+Subject: [PATCH] Guard against invalid entity positions
+
+Anything not finite should be blocked and logged
+
+diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
+index 4aa46029c42dc8a87a354fe6215ce78c59879bf2..25618b33760a3b1f39e6bbf774c75134afe94160 100644
+--- a/src/main/java/net/minecraft/world/entity/Entity.java
++++ b/src/main/java/net/minecraft/world/entity/Entity.java
+@@ -4198,11 +4198,33 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
+ return this.getZ((2.0D * this.random.nextDouble() - 1.0D) * widthScale);
+ }
+
++ // Paper start - block invalid positions
++ public static boolean checkPosition(Entity entity, double newX, double newY, double newZ) {
++ if (Double.isFinite(newX) && Double.isFinite(newY) && Double.isFinite(newZ)) {
++ return true;
++ }
++
++ String entityInfo = null;
++ try {
++ entityInfo = entity.toString();
++ } catch (Exception ex) {
++ entityInfo = "[Entity info unavailable] ";
++ }
++ LOGGER.error("New entity position is invalid! Tried to set invalid position (" + newX + "," + newY + "," + newZ + ") for entity " + entity.getClass().getName() + " located at " + entity.position + ", entity info: " + entityInfo, new Throwable());
++ return false;
++ }
++ // Paper end - block invalid positions
++
+ public final void setPosRaw(double x, double y, double z) {
+ // Paper start
+ this.setPosRaw(x, y, z, false);
+ }
+ public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) {
++ // Paper start - block invalid positions
++ if (!checkPosition(this, x, y, z)) {
++ return;
++ }
++ // Paper end - block invalid positions
+ // Paper end
+ // Paper start - rewrite chunk system
+ if (this.updatingSectionStatus) {