mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Modernize private property declarations in src/entity
This commit is contained in:
parent
343a12626e
commit
ec6769a6fc
@ -29,7 +29,7 @@ final class AttributeFactory{
|
||||
use SingletonTrait;
|
||||
|
||||
/** @var Attribute[] */
|
||||
private $attributes = [];
|
||||
private array $attributes = [];
|
||||
|
||||
public function __construct(){
|
||||
$this->register(Attribute::ABSORPTION, 0.00, 340282346638528859811704183484516925440.00, 0.00);
|
||||
|
@ -27,7 +27,7 @@ use function array_filter;
|
||||
|
||||
class AttributeMap{
|
||||
/** @var Attribute[] */
|
||||
private $attributes = [];
|
||||
private array $attributes = [];
|
||||
|
||||
public function add(Attribute $attribute) : void{
|
||||
$this->attributes[$attribute->getId()] = $attribute;
|
||||
|
@ -96,8 +96,7 @@ abstract class Entity{
|
||||
/** @var int */
|
||||
protected $id;
|
||||
|
||||
/** @var EntityMetadataCollection */
|
||||
private $networkProperties;
|
||||
private EntityMetadataCollection $networkProperties;
|
||||
|
||||
/** @var EntityDamageEvent|null */
|
||||
protected $lastDamageCause = null;
|
||||
@ -124,10 +123,8 @@ abstract class Entity{
|
||||
/** @var EntitySizeInfo */
|
||||
public $size;
|
||||
|
||||
/** @var float */
|
||||
private $health = 20.0;
|
||||
/** @var int */
|
||||
private $maxHealth = 20;
|
||||
private float $health = 20.0;
|
||||
private int $maxHealth = 20;
|
||||
|
||||
/** @var float */
|
||||
protected $ySize = 0.0;
|
||||
@ -150,8 +147,7 @@ abstract class Entity{
|
||||
/** @var bool */
|
||||
protected $isStatic = false;
|
||||
|
||||
/** @var bool */
|
||||
private $savedWithChunk = true;
|
||||
private bool $savedWithChunk = true;
|
||||
|
||||
/** @var bool */
|
||||
public $isCollided = false;
|
||||
@ -181,8 +177,7 @@ abstract class Entity{
|
||||
/** @var bool */
|
||||
protected $closed = false;
|
||||
private bool $closeInFlight = false;
|
||||
/** @var bool */
|
||||
private $needsDespawn = false;
|
||||
private bool $needsDespawn = false;
|
||||
|
||||
/** @var TimingsHandler */
|
||||
protected $timings;
|
||||
|
@ -70,12 +70,12 @@ final class EntityFactory{
|
||||
* @var \Closure[] save ID => creator function
|
||||
* @phpstan-var array<int|string, \Closure(World, CompoundTag) : Entity>
|
||||
*/
|
||||
private $creationFuncs = [];
|
||||
private array $creationFuncs = [];
|
||||
/**
|
||||
* @var string[]
|
||||
* @phpstan-var array<class-string<Entity>, string>
|
||||
*/
|
||||
private $saveNames = [];
|
||||
private array $saveNames = [];
|
||||
|
||||
public function __construct(){
|
||||
//define legacy save IDs first - use them for saving for maximum compatibility with Minecraft PC
|
||||
|
@ -26,16 +26,13 @@ namespace pocketmine\entity;
|
||||
use function min;
|
||||
|
||||
final class EntitySizeInfo{
|
||||
/** @var float */
|
||||
private $height;
|
||||
/** @var float */
|
||||
private $width;
|
||||
/** @var float */
|
||||
private $eyeHeight;
|
||||
private float $eyeHeight;
|
||||
|
||||
public function __construct(float $height, float $width, ?float $eyeHeight = null){
|
||||
$this->height = $height;
|
||||
$this->width = $width;
|
||||
public function __construct(
|
||||
private float $height,
|
||||
private float $width,
|
||||
?float $eyeHeight = null
|
||||
){
|
||||
$this->eyeHeight = $eyeHeight ?? min($this->height / 2 + 0.1, $this->height);
|
||||
}
|
||||
|
||||
|
@ -38,26 +38,18 @@ use function min;
|
||||
|
||||
class ExperienceManager{
|
||||
|
||||
/** @var Human */
|
||||
private $entity;
|
||||
private Attribute $levelAttr;
|
||||
private Attribute $progressAttr;
|
||||
|
||||
/** @var Attribute */
|
||||
private $levelAttr;
|
||||
/** @var Attribute */
|
||||
private $progressAttr;
|
||||
private int $totalXp = 0;
|
||||
|
||||
/** @var int */
|
||||
private $totalXp = 0;
|
||||
private bool $canAttractXpOrbs = true;
|
||||
|
||||
/** @var bool */
|
||||
private $canAttractXpOrbs = true;
|
||||
|
||||
/** @var int */
|
||||
private $xpCooldown = 0;
|
||||
|
||||
public function __construct(Human $entity){
|
||||
$this->entity = $entity;
|
||||
private int $xpCooldown = 0;
|
||||
|
||||
public function __construct(
|
||||
private Human $entity
|
||||
){
|
||||
$this->levelAttr = self::fetchAttribute($entity, Attribute::EXPERIENCE_LEVEL);
|
||||
$this->progressAttr = self::fetchAttribute($entity, Attribute::EXPERIENCE);
|
||||
}
|
||||
|
@ -32,25 +32,17 @@ use function min;
|
||||
|
||||
class HungerManager{
|
||||
|
||||
/** @var Human */
|
||||
private $entity;
|
||||
private Attribute $hungerAttr;
|
||||
private Attribute $saturationAttr;
|
||||
private Attribute $exhaustionAttr;
|
||||
|
||||
/** @var Attribute */
|
||||
private $hungerAttr;
|
||||
/** @var Attribute */
|
||||
private $saturationAttr;
|
||||
/** @var Attribute */
|
||||
private $exhaustionAttr;
|
||||
private int $foodTickTimer = 0;
|
||||
|
||||
/** @var int */
|
||||
private $foodTickTimer = 0;
|
||||
|
||||
/** @var bool */
|
||||
private $enabled = true;
|
||||
|
||||
public function __construct(Human $entity){
|
||||
$this->entity = $entity;
|
||||
private bool $enabled = true;
|
||||
|
||||
public function __construct(
|
||||
private Human $entity
|
||||
){
|
||||
$this->hungerAttr = self::fetchAttribute($entity, Attribute::HUNGER);
|
||||
$this->saturationAttr = self::fetchAttribute($entity, Attribute::SATURATION);
|
||||
$this->exhaustionAttr = self::fetchAttribute($entity, Attribute::EXHAUSTION);
|
||||
|
@ -39,16 +39,11 @@ final class Skin{
|
||||
128 * 128 * 4
|
||||
];
|
||||
|
||||
/** @var string */
|
||||
private $skinId;
|
||||
/** @var string */
|
||||
private $skinData;
|
||||
/** @var string */
|
||||
private $capeData;
|
||||
/** @var string */
|
||||
private $geometryName;
|
||||
/** @var string */
|
||||
private $geometryData;
|
||||
private string $skinId;
|
||||
private string $skinData;
|
||||
private string $capeData;
|
||||
private string $geometryName;
|
||||
private string $geometryData;
|
||||
|
||||
private static function checkLength(string $string, string $name, int $maxLength) : void{
|
||||
if(strlen($string) > $maxLength){
|
||||
|
@ -44,8 +44,7 @@ class Squid extends WaterAnimal{
|
||||
/** @var float */
|
||||
public $swimSpeed = 0.1;
|
||||
|
||||
/** @var int */
|
||||
private $switchDirectionTicker = 0;
|
||||
private int $switchDirectionTicker = 0;
|
||||
|
||||
protected function getInitialSizeInfo() : EntitySizeInfo{ return new EntitySizeInfo(0.95, 0.95); }
|
||||
|
||||
|
@ -38,10 +38,8 @@ class Villager extends Living implements Ageable{
|
||||
|
||||
public static function getNetworkTypeId() : string{ return EntityIds::VILLAGER; }
|
||||
|
||||
/** @var bool */
|
||||
private $baby = false;
|
||||
/** @var int */
|
||||
private $profession = self::PROFESSION_FARMER;
|
||||
private bool $baby = false;
|
||||
private int $profession = self::PROFESSION_FARMER;
|
||||
|
||||
protected function getInitialSizeInfo() : EntitySizeInfo{
|
||||
return new EntitySizeInfo(1.8, 0.6); //TODO: eye height??
|
||||
|
@ -28,23 +28,12 @@ use pocketmine\utils\Limits;
|
||||
use function max;
|
||||
|
||||
class EffectInstance{
|
||||
/** @var Effect */
|
||||
private $effectType;
|
||||
|
||||
/** @var int */
|
||||
private $duration;
|
||||
|
||||
/** @var int */
|
||||
private $amplifier;
|
||||
|
||||
/** @var bool */
|
||||
private $visible;
|
||||
|
||||
/** @var bool */
|
||||
private $ambient;
|
||||
|
||||
/** @var Color */
|
||||
private $color;
|
||||
private Effect $effectType;
|
||||
private int $duration;
|
||||
private int $amplifier;
|
||||
private bool $visible;
|
||||
private bool $ambient;
|
||||
private Color $color;
|
||||
|
||||
/**
|
||||
* @param int|null $duration Passing null will use the effect type's default duration
|
||||
|
@ -34,9 +34,6 @@ use function spl_object_id;
|
||||
|
||||
class EffectManager{
|
||||
|
||||
/** @var Living */
|
||||
private $entity;
|
||||
|
||||
/** @var EffectInstance[] */
|
||||
protected $effects = [];
|
||||
|
||||
@ -56,8 +53,9 @@ class EffectManager{
|
||||
*/
|
||||
protected $effectRemoveHooks;
|
||||
|
||||
public function __construct(Living $entity){
|
||||
$this->entity = $entity;
|
||||
public function __construct(
|
||||
private Living $entity
|
||||
){
|
||||
$this->bubbleColor = new Color(0, 0, 0, 0);
|
||||
$this->effectAddHooks = new ObjectSet();
|
||||
$this->effectRemoveHooks = new ObjectSet();
|
||||
|
@ -30,9 +30,7 @@ use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\lang\Translatable;
|
||||
|
||||
class PoisonEffect extends Effect{
|
||||
|
||||
/** @var bool */
|
||||
private $fatal;
|
||||
private bool $fatal;
|
||||
|
||||
public function __construct(Translatable|string $name, Color $color, bool $isBad = false, int $defaultDuration = 600, bool $hasBubbles = true, bool $fatal = false){
|
||||
parent::__construct($name, $color, $isBad, $defaultDuration, $hasBubbles);
|
||||
|
Loading…
x
Reference in New Issue
Block a user