mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-12 12:55:21 +00:00
fixed setting entity scale doesn't resize bounding box, close #484
This commit is contained in:
parent
cd477163cd
commit
afb2e0c51f
@ -396,7 +396,7 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
/**
|
/**
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function getScale(): float{
|
public function getScale() : float{
|
||||||
return $this->getDataProperty(self::DATA_SCALE);
|
return $this->getDataProperty(self::DATA_SCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,7 +404,24 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
* @param float $value
|
* @param float $value
|
||||||
*/
|
*/
|
||||||
public function setScale(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_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(){
|
public function isSneaking(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user