Entity: Require declaration of gravity and drag via abstract methods

this guarantees that subclasses will actually declare them.

[bc break]
This commit is contained in:
Dylan K. Taylor
2022-06-01 20:51:18 +01:00
parent f3c9b59856
commit b7e2b3e94a
11 changed files with 52 additions and 30 deletions

View File

@ -76,9 +76,6 @@ use const M_PI;
abstract class Living extends Entity{
protected const DEFAULT_BREATH_TICKS = 300;
protected $gravity = 0.08;
protected $drag = 0.02;
/** @var int */
protected $attackTime = 0;
@ -121,6 +118,10 @@ abstract class Living extends Entity{
/** @var bool */
protected $swimming = false;
protected function getInitialDragMultiplier() : float{ return 0.02; }
protected function getInitialGravity() : float{ return 0.08; }
abstract public function getName() : string;
protected function initEntity(CompoundTag $nbt) : void{