From 8f0ee842772098370ef679dc40bcc61b3089316c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 11 Oct 2017 18:25:16 +0100 Subject: [PATCH] Cleaned up Ladder AABB calculation code --- src/pocketmine/block/Ladder.php | 49 ++++++++++----------------------- 1 file changed, 15 insertions(+), 34 deletions(-) diff --git a/src/pocketmine/block/Ladder.php b/src/pocketmine/block/Ladder.php index 0dd8221f2..816307f69 100644 --- a/src/pocketmine/block/Ladder.php +++ b/src/pocketmine/block/Ladder.php @@ -65,48 +65,29 @@ class Ladder extends Transparent{ } protected function recalculateBoundingBox(){ - $f = 0.1875; + $minX = $minZ = 0; + $maxX = $maxZ = 1; + if($this->meta === 2){ - return new AxisAlignedBB( - $this->x, - $this->y, - $this->z + 1 - $f, - $this->x + 1, - $this->y + 1, - $this->z + 1 - ); + $minZ = 1 - $f; }elseif($this->meta === 3){ - return new AxisAlignedBB( - $this->x, - $this->y, - $this->z, - $this->x + 1, - $this->y + 1, - $this->z + $f - ); + $maxZ = $f; }elseif($this->meta === 4){ - return new AxisAlignedBB( - $this->x + 1 - $f, - $this->y, - $this->z, - $this->x + 1, - $this->y + 1, - $this->z + 1 - ); + $minX = 1 - $f; }elseif($this->meta === 5){ - return new AxisAlignedBB( - $this->x, - $this->y, - $this->z, - $this->x + $f, - $this->y + 1, - $this->z + 1 - ); + $maxX = $f; } - return null; + return new AxisAlignedBB( + $this->x + $minX, + $this->y, + $this->z + $minZ, + $this->x + $maxX, + $this->y + 1, + $this->z + $maxZ + ); }