-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
Spigot-Server-Patches/0529-Use-saner-Entity-bounding-box-limits.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
|