diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 7d484a318..f12b04ecd 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -365,7 +365,7 @@ abstract class Entity extends Location{ protected function recalculateBoundingBox() : void{ $halfWidth = $this->width / 2; - $this->boundingBox->setBounds( + $this->boundingBox = new AxisAlignedBB( $this->x - $halfWidth, $this->y, $this->z - $halfWidth, @@ -1222,7 +1222,7 @@ abstract class Entity extends Location{ } */ - $axisalignedbb = clone $this->boundingBox; + $moveBB = clone $this->boundingBox; /*$sneakFlag = $this->onGround and $this instanceof Player; @@ -1252,27 +1252,27 @@ abstract class Entity extends Location{ assert(abs($dx) <= 20 and abs($dy) <= 20 and abs($dz) <= 20, "Movement distance is excessive: dx=$dx, dy=$dy, dz=$dz"); - $list = $this->world->getCollisionBoxes($this, $this->boundingBox->addCoord($dx, $dy, $dz), false); + $list = $this->world->getCollisionBoxes($this, $moveBB->addCoord($dx, $dy, $dz), false); foreach($list as $bb){ - $dy = $bb->calculateYOffset($this->boundingBox, $dy); + $dy = $bb->calculateYOffset($moveBB, $dy); } - $this->boundingBox->offset(0, $dy, 0); + $moveBB->offset(0, $dy, 0); $fallingFlag = ($this->onGround or ($dy != $movY and $movY < 0)); foreach($list as $bb){ - $dx = $bb->calculateXOffset($this->boundingBox, $dx); + $dx = $bb->calculateXOffset($moveBB, $dx); } - $this->boundingBox->offset($dx, 0, 0); + $moveBB->offset($dx, 0, 0); foreach($list as $bb){ - $dz = $bb->calculateZOffset($this->boundingBox, $dz); + $dz = $bb->calculateZOffset($moveBB, $dz); } - $this->boundingBox->offset(0, 0, $dz); + $moveBB->offset(0, 0, $dz); if($this->stepHeight > 0 and $fallingFlag and $this->ySize < 0.05 and ($movX != $dx or $movZ != $dz)){ @@ -1283,39 +1283,39 @@ abstract class Entity extends Location{ $dy = $this->stepHeight; $dz = $movZ; - $axisalignedbb1 = clone $this->boundingBox; + $stepBB = clone $this->boundingBox; - $this->boundingBox->setBB($axisalignedbb); - - $list = $this->world->getCollisionBoxes($this, $this->boundingBox->addCoord($dx, $dy, $dz), false); + $list = $this->world->getCollisionBoxes($this, $stepBB->addCoord($dx, $dy, $dz), false); foreach($list as $bb){ - $dy = $bb->calculateYOffset($this->boundingBox, $dy); + $dy = $bb->calculateYOffset($stepBB, $dy); } - $this->boundingBox->offset(0, $dy, 0); + $stepBB->offset(0, $dy, 0); foreach($list as $bb){ - $dx = $bb->calculateXOffset($this->boundingBox, $dx); + $dx = $bb->calculateXOffset($stepBB, $dx); } - $this->boundingBox->offset($dx, 0, 0); + $stepBB->offset($dx, 0, 0); foreach($list as $bb){ - $dz = $bb->calculateZOffset($this->boundingBox, $dz); + $dz = $bb->calculateZOffset($stepBB, $dz); } - $this->boundingBox->offset(0, 0, $dz); + $stepBB->offset(0, 0, $dz); if(($cx ** 2 + $cz ** 2) >= ($dx ** 2 + $dz ** 2)){ $dx = $cx; $dy = $cy; $dz = $cz; - $this->boundingBox->setBB($axisalignedbb1); }else{ + $moveBB = $stepBB; $this->ySize += 0.5; //FIXME: this should be the height of the block it walked up, not fixed 0.5 } } + + $this->boundingBox = $moveBB; } $this->x = ($this->boundingBox->minX + $this->boundingBox->maxX) / 2; diff --git a/src/entity/object/Painting.php b/src/entity/object/Painting.php index 546d6ff27..01a07d9f6 100644 --- a/src/entity/object/Painting.php +++ b/src/entity/object/Painting.php @@ -125,7 +125,7 @@ class Painting extends Entity{ protected function recalculateBoundingBox() : void{ $side = $this->blockIn->getSide($this->facing); - $this->boundingBox->setBB(self::getPaintingBB($this->facing, $this->getMotive())->offset($side->x, $side->y, $side->z)); + $this->boundingBox = self::getPaintingBB($this->facing, $this->getMotive())->offset($side->x, $side->y, $side->z); } public function onNearbyBlockChange() : void{