Use saner Entity bounding box limits
CB only protected from > 64 but there's no reason an entity should ever be more than 2x its width or 1x height as the BB is supposed to represent the entity size. BB is / 2 to calculate position.
This commit is contained in:
parent
edd6b6a2ba
commit
281181c7c7
1 changed files with 67 additions and 0 deletions
|
@ -0,0 +1,67 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Fri, 22 May 2020 00:29:52 -0400
|
||||
Subject: [PATCH] Use saner Entity bounding box limits
|
||||
|
||||
CB only protected from > 64 but there's no reason an entity should ever
|
||||
be more than 2x its width or 1x height as the BB is supposed to represent
|
||||
the entity size.
|
||||
|
||||
BB is / 2 to calculate position.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index e0ab058bf947ea10b37eadf6122292e708bd3809..76fcde33416995ef46693b75dc4484e13d3daf1f 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -2991,18 +2991,45 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
||||
maxX = axisalignedbb.maxX,
|
||||
maxY = axisalignedbb.maxY,
|
||||
maxZ = axisalignedbb.maxZ;
|
||||
+ // Paper start - use saner max's for bounding box
|
||||
+ boolean illegal = false;
|
||||
+ double maxW = this.getWidth() * 2;
|
||||
+ double maxH = this.getHeight();
|
||||
double len = axisalignedbb.maxX - axisalignedbb.minX;
|
||||
- if (len < 0) maxX = minX;
|
||||
- if (len > 64) maxX = minX + 64.0;
|
||||
+ if (len < 0) {
|
||||
+ maxX = minX;
|
||||
+ illegal = true;
|
||||
+ }
|
||||
+ if (len > maxW+1.0E-7D) {
|
||||
+ maxX = minX + maxW;
|
||||
+ illegal = true;
|
||||
+ }
|
||||
|
||||
len = axisalignedbb.maxY - axisalignedbb.minY;
|
||||
- if (len < 0) maxY = minY;
|
||||
- if (len > 64) maxY = minY + 64.0;
|
||||
+ if (len < 0) {
|
||||
+ maxY = minY;
|
||||
+ illegal = true;
|
||||
+ }
|
||||
+ if (len > maxH+1.0E-7D) {
|
||||
+ maxY = minY + maxH;
|
||||
+ illegal = true;
|
||||
+ }
|
||||
|
||||
len = axisalignedbb.maxZ - axisalignedbb.minZ;
|
||||
- if (len < 0) maxZ = minZ;
|
||||
- if (len > 64) maxZ = minZ + 64.0;
|
||||
+ if (len < 0) {
|
||||
+ maxZ = minZ;
|
||||
+ illegal = true;
|
||||
+ }
|
||||
+ if (len > maxW+1.0E-7D) {
|
||||
+ maxZ = minZ + maxW;
|
||||
+ illegal = true;
|
||||
+ }
|
||||
+
|
||||
this.boundingBox = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
+ if (illegal) {
|
||||
+ new Throwable("Illegal Entity bounding box attempt on (" + this + ") - tried: " + axisalignedbb + " - using: " + boundingBox).printStackTrace();
|
||||
+ }
|
||||
+ // Paper end
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
Loading…
Reference in a new issue