mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-12 01:41:05 +01:00
694b120d0b
Now the only tracker field is from the entity tracker optimisations.
65 lines
3.2 KiB
Diff
65 lines
3.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sun, 10 May 2020 22:12:46 -0400
|
|
Subject: [PATCH] Ensure Entity position and AABB are never invalid
|
|
|
|
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index bd5291ca4680572d2c5f3cec1231b1a3dcf72fa8..284d0f88968d386559be94d1e1e7af361658da3f 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -669,8 +669,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
|
|
public void setPos(double x, double y, double z) {
|
|
- this.setPosRaw(x, y, z);
|
|
- this.setBoundingBox(this.makeBoundingBox());
|
|
+ this.setPosRaw(x, y, z, true); // Paper - Block invalid positions and bounding box; force update
|
|
+ // this.setBoundingBox(this.makeBoundingBox()); // Paper - Block invalid positions and bounding box; move into setPosRaw
|
|
}
|
|
|
|
protected AABB makeBoundingBox() {
|
|
@@ -4223,7 +4223,29 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
return this.getZ((2.0D * this.random.nextDouble() - 1.0D) * widthScale);
|
|
}
|
|
|
|
+ // Paper start - Block invalid positions and bounding box
|
|
+ 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;
|
|
+ try {
|
|
+ entityInfo = entity.toString();
|
|
+ } catch (Exception ex) {
|
|
+ entityInfo = "[Entity info unavailable] ";
|
|
+ }
|
|
+ LOGGER.error("New entity position is invalid! Tried to set invalid position ({},{},{}) for entity {} located at {}, entity info: {}", newX, newY, newZ, entity.getClass().getName(), entity.position, entityInfo, new Throwable());
|
|
+ return false;
|
|
+ }
|
|
public final void setPosRaw(double x, double y, double z) {
|
|
+ this.setPosRaw(x, y, z, false);
|
|
+ }
|
|
+ public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) {
|
|
+ if (!checkPosition(this, x, y, z)) {
|
|
+ return;
|
|
+ }
|
|
+ // Paper end - Block invalid positions and bounding box
|
|
if (this.position.x != x || this.position.y != y || this.position.z != z) {
|
|
this.position = new Vec3(x, y, z);
|
|
int i = Mth.floor(x);
|
|
@@ -4241,6 +4263,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
this.levelCallback.onMove();
|
|
}
|
|
|
|
+ // Paper start - Block invalid positions and bounding box; don't allow desync of pos and AABB
|
|
+ // hanging has its own special logic
|
|
+ if (!(this instanceof net.minecraft.world.entity.decoration.HangingEntity) && (forceBoundingBoxUpdate || this.position.x != x || this.position.y != y || this.position.z != z)) {
|
|
+ this.setBoundingBox(this.makeBoundingBox());
|
|
+ }
|
|
+ // Paper end - Block invalid positions and bounding box
|
|
}
|
|
|
|
public void checkDespawn() {}
|