diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 618452bc3..9f31ee37d 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -392,21 +392,38 @@ abstract class Entity extends Location implements Metadatable{ public function setNameTagAlwaysVisible($value = true){ $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ALWAYS_SHOW_NAMETAG, $value); } - + /** * @return float */ - public function getScale(): float{ + public function getScale() : float{ return $this->getDataProperty(self::DATA_SCALE); } - + /** * @param float $value */ public function setScale(float $value){ + $multiplier = $value / $this->getScale(); + + $this->width *= $multiplier; + $this->height *= $multiplier; + $halfWidth = $this->width / 2; + + $this->boundingBox->setBounds( + $this->x - $halfWidth, + $this->y, + $this->z - $halfWidth, + $this->x + $halfWidth, + $this->y + $this->height, + $this->z + $halfWidth + ); + $this->setDataProperty(self::DATA_SCALE, self::DATA_TYPE_FLOAT, $value); + $this->setDataProperty(self::DATA_BOUNDING_BOX_WIDTH, self::DATA_TYPE_FLOAT, $this->width); + $this->setDataProperty(self::DATA_BOUNDING_BOX_HEIGHT, self::DATA_TYPE_FLOAT, $this->height); } - + public function isSneaking(){ return $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_SNEAKING); }