Implement swimming/gliding including AABB recalculation (#4446)

- The following events have been added:
  - PlayerToggleGlideEvent
  - PlayerToggleSwimEvent
- The following API methods have been added:
  - Entity->getSize()
  - Living->isSwimming()
  - Living->setSwimming()
  - Living->isGliding()
  - Living->setSwimming()
  - Player->toggleSwim()
  - Player->toggleGlide()
This commit is contained in:
XenialDan
2021-12-19 18:10:41 +01:00
committed by GitHub
parent 65dabefa3b
commit d41f933e7b
6 changed files with 166 additions and 9 deletions

View File

@ -304,12 +304,8 @@ abstract class Entity{
if($value <= 0){
throw new \InvalidArgumentException("Scale must be greater than 0");
}
$this->size = $this->getInitialSizeInfo()->scale($value);
$this->scale = $value;
$this->recalculateBoundingBox();
$this->networkPropertiesDirty = true;
$this->setSize($this->getInitialSizeInfo()->scale($value));
}
public function getBoundingBox() : AxisAlignedBB{
@ -329,6 +325,16 @@ abstract class Entity{
);
}
public function getSize() : EntitySizeInfo{
return $this->size;
}
protected function setSize(EntitySizeInfo $size) : void{
$this->size = $size;
$this->recalculateBoundingBox();
$this->networkPropertiesDirty = true;
}
public function isImmobile() : bool{
return $this->immobile;
}