Entity: Added recalculateBoundingBox()

This commit is contained in:
Dylan K. Taylor 2018-01-18 16:35:38 +00:00
parent 9551e5b8e5
commit 857b63ba8f

View File

@ -608,6 +608,17 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->width *= $multiplier;
$this->height *= $multiplier;
$this->eyeHeight *= $multiplier;
$this->recalculateBoundingBox();
$this->setDataProperty(self::DATA_SCALE, self::DATA_TYPE_FLOAT, $value);
}
public function getBoundingBox(){
return $this->boundingBox;
}
protected function recalculateBoundingBox() : void{
$halfWidth = $this->width / 2;
$this->boundingBox->setBounds(
@ -618,15 +629,8 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->y + $this->height,
$this->z + $halfWidth
);
$this->setDataProperty(self::DATA_SCALE, self::DATA_TYPE_FLOAT, $value);
}
public function getBoundingBox(){
return $this->boundingBox;
}
public function isSneaking() : bool{
return $this->getGenericFlag(self::DATA_FLAG_SNEAKING);
}
@ -1717,8 +1721,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->y = $pos->y;
$this->z = $pos->z;
$radius = $this->width / 2;
$this->boundingBox->setBounds($pos->x - $radius, $pos->y, $pos->z - $radius, $pos->x + $radius, $pos->y + $this->height, $pos->z + $radius);
$this->recalculateBoundingBox();
$this->blocksAround = null;