mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 19:02:59 +00:00
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:
@ -52,9 +52,6 @@ class Arrow extends Projectile{
|
||||
private const TAG_PICKUP = "pickup"; //TAG_Byte
|
||||
public const TAG_CRIT = "crit"; //TAG_Byte
|
||||
|
||||
protected $gravity = 0.05;
|
||||
protected $drag = 0.01;
|
||||
|
||||
/** @var float */
|
||||
protected $damage = 2.0;
|
||||
|
||||
@ -77,6 +74,10 @@ class Arrow extends Projectile{
|
||||
|
||||
protected function getInitialSizeInfo() : EntitySizeInfo{ return new EntitySizeInfo(0.25, 0.25); }
|
||||
|
||||
protected function getInitialDragMultiplier() : float{ return 0.01; }
|
||||
|
||||
protected function getInitialGravity() : float{ return 0.05; }
|
||||
|
||||
protected function initEntity(CompoundTag $nbt) : void{
|
||||
parent::initEntity($nbt);
|
||||
|
||||
|
@ -32,7 +32,7 @@ use function mt_rand;
|
||||
class ExperienceBottle extends Throwable{
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::XP_BOTTLE; }
|
||||
|
||||
protected $gravity = 0.07;
|
||||
protected function getInitialGravity() : float{ return 0.07; }
|
||||
|
||||
public function getResultDamage() : int{
|
||||
return -1;
|
||||
|
@ -52,9 +52,6 @@ class SplashPotion extends Throwable{
|
||||
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::SPLASH_POTION; }
|
||||
|
||||
protected $gravity = 0.05;
|
||||
protected $drag = 0.01;
|
||||
|
||||
/** @var bool */
|
||||
protected $linger = false;
|
||||
protected PotionType $potionType;
|
||||
@ -64,6 +61,8 @@ class SplashPotion extends Throwable{
|
||||
parent::__construct($location, $shootingEntity, $nbt);
|
||||
}
|
||||
|
||||
protected function getInitialGravity() : float{ return 0.05; }
|
||||
|
||||
public function saveNBT() : CompoundTag{
|
||||
$nbt = parent::saveNBT();
|
||||
$nbt->setShort("PotionId", PotionTypeIdMap::getInstance()->toId($this->getPotionType()));
|
||||
|
@ -29,11 +29,12 @@ use pocketmine\math\RayTraceResult;
|
||||
|
||||
abstract class Throwable extends Projectile{
|
||||
|
||||
protected $gravity = 0.03;
|
||||
protected $drag = 0.01;
|
||||
|
||||
protected function getInitialSizeInfo() : EntitySizeInfo{ return new EntitySizeInfo(0.25, 0.25); }
|
||||
|
||||
protected function getInitialDragMultiplier() : float{ return 0.01; }
|
||||
|
||||
protected function getInitialGravity() : float{ return 0.03; }
|
||||
|
||||
protected function onHitBlock(Block $blockHit, RayTraceResult $hitResult) : void{
|
||||
parent::onHitBlock($blockHit, $hitResult);
|
||||
$this->flagForDespawn();
|
||||
|
Reference in New Issue
Block a user