diff --git a/src/world/particle/BlockBreakParticle.php b/src/world/particle/BlockBreakParticle.php index 40e8d8bea..d45f0f631 100644 --- a/src/world/particle/BlockBreakParticle.php +++ b/src/world/particle/BlockBreakParticle.php @@ -30,15 +30,10 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\LevelEvent; class BlockBreakParticle implements Particle{ - - /** @var Block */ - private $block; - - public function __construct(Block $b){ - $this->block = $b; - } + //TODO: rename this parameter when we can break BC + public function __construct(private Block $b){} public function encode(Vector3 $pos) : array{ - return [LevelEventPacket::create(LevelEvent::PARTICLE_DESTROY, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()), $pos)]; + return [LevelEventPacket::create(LevelEvent::PARTICLE_DESTROY, RuntimeBlockMapping::getInstance()->toRuntimeId($this->b->getFullId()), $pos)]; } } diff --git a/src/world/particle/BlockForceFieldParticle.php b/src/world/particle/BlockForceFieldParticle.php index cfd2d0b2a..282563305 100644 --- a/src/world/particle/BlockForceFieldParticle.php +++ b/src/world/particle/BlockForceFieldParticle.php @@ -28,13 +28,8 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\ParticleIds; class BlockForceFieldParticle implements Particle{ - - /** @var int */ - private $data; - - public function __construct(int $data = 0){ - $this->data = $data; //TODO: proper encode/decode of data - } + //TODO: proper encode/decode of data + public function __construct(private int $data = 0){} public function encode(Vector3 $pos) : array{ return [LevelEventPacket::standardParticle(ParticleIds::BLOCK_FORCE_FIELD, $this->data, $pos)]; diff --git a/src/world/particle/BlockPunchParticle.php b/src/world/particle/BlockPunchParticle.php index 5ee0c3352..2b00e1a26 100644 --- a/src/world/particle/BlockPunchParticle.php +++ b/src/world/particle/BlockPunchParticle.php @@ -33,16 +33,10 @@ use pocketmine\network\mcpe\protocol\types\LevelEvent; * This particle appears when a player is attacking a block face in survival mode attempting to break it. */ class BlockPunchParticle implements Particle{ - - /** @var Block */ - private $block; - /** @var int */ - private $face; - - public function __construct(Block $block, int $face){ - $this->block = $block; - $this->face = $face; - } + public function __construct( + private Block $block, + private int $face + ){} public function encode(Vector3 $pos) : array{ return [LevelEventPacket::create(LevelEvent::PARTICLE_PUNCH_BLOCK, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()) | ($this->face << 24), $pos)]; diff --git a/src/world/particle/CriticalParticle.php b/src/world/particle/CriticalParticle.php index 477d1c7e5..4d26b9709 100644 --- a/src/world/particle/CriticalParticle.php +++ b/src/world/particle/CriticalParticle.php @@ -28,12 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\ParticleIds; class CriticalParticle implements Particle{ - /** @var int */ - private $scale; - - public function __construct(int $scale = 2){ - $this->scale = $scale; - } + public function __construct(private int $scale = 2){} public function encode(Vector3 $pos) : array{ return [LevelEventPacket::standardParticle(ParticleIds::CRITICAL, $this->scale, $pos)]; diff --git a/src/world/particle/DragonEggTeleportParticle.php b/src/world/particle/DragonEggTeleportParticle.php index 924fba112..bfa45249c 100644 --- a/src/world/particle/DragonEggTeleportParticle.php +++ b/src/world/particle/DragonEggTeleportParticle.php @@ -30,12 +30,9 @@ use function abs; class DragonEggTeleportParticle implements Particle{ - /** @var int */ - private $xDiff; - /** @var int */ - private $yDiff; - /** @var int */ - private $zDiff; + private int $xDiff; + private int $yDiff; + private int $zDiff; public function __construct(int $xDiff, int $yDiff, int $zDiff){ $this->xDiff = self::boundOrThrow($xDiff); diff --git a/src/world/particle/DustParticle.php b/src/world/particle/DustParticle.php index 4e0564910..c28b9655d 100644 --- a/src/world/particle/DustParticle.php +++ b/src/world/particle/DustParticle.php @@ -29,12 +29,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\ParticleIds; class DustParticle implements Particle{ - /** @var Color */ - private $color; - - public function __construct(Color $color){ - $this->color = $color; - } + public function __construct(private Color $color){} public function encode(Vector3 $pos) : array{ return [LevelEventPacket::standardParticle(ParticleIds::DUST, $this->color->toARGB(), $pos)]; diff --git a/src/world/particle/EnchantParticle.php b/src/world/particle/EnchantParticle.php index 48f223ae9..a8f7a3d1f 100644 --- a/src/world/particle/EnchantParticle.php +++ b/src/world/particle/EnchantParticle.php @@ -29,13 +29,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\ParticleIds; class EnchantParticle implements Particle{ - - /** @var Color */ - private $color; - - public function __construct(Color $color){ - $this->color = $color; - } + public function __construct(private Color $color){} public function encode(Vector3 $pos) : array{ return [LevelEventPacket::standardParticle(ParticleIds::MOB_SPELL, $this->color->toARGB(), $pos)]; diff --git a/src/world/particle/HeartParticle.php b/src/world/particle/HeartParticle.php index 4d2dddbfe..2552baa6a 100644 --- a/src/world/particle/HeartParticle.php +++ b/src/world/particle/HeartParticle.php @@ -28,12 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\ParticleIds; class HeartParticle implements Particle{ - /** @var int */ - private $scale; - - public function __construct(int $scale = 0){ - $this->scale = $scale; - } + public function __construct(private int $scale = 0){} public function encode(Vector3 $pos) : array{ return [LevelEventPacket::standardParticle(ParticleIds::HEART, $this->scale, $pos)]; diff --git a/src/world/particle/InkParticle.php b/src/world/particle/InkParticle.php index dfe6a5fd7..7eb072211 100644 --- a/src/world/particle/InkParticle.php +++ b/src/world/particle/InkParticle.php @@ -28,12 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\ParticleIds; class InkParticle implements Particle{ - /** @var int */ - private $scale; - - public function __construct(int $scale = 0){ - $this->scale = $scale; - } + public function __construct(private int $scale = 0){} public function encode(Vector3 $pos) : array{ return [LevelEventPacket::standardParticle(ParticleIds::INK, $this->scale, $pos)]; diff --git a/src/world/particle/InstantEnchantParticle.php b/src/world/particle/InstantEnchantParticle.php index 695a4780a..1a4e71abf 100644 --- a/src/world/particle/InstantEnchantParticle.php +++ b/src/world/particle/InstantEnchantParticle.php @@ -29,12 +29,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\ParticleIds; class InstantEnchantParticle implements Particle{ - /** @var Color */ - private $color; - - public function __construct(Color $color){ - $this->color = $color; - } + public function __construct(private Color $color){} public function encode(Vector3 $pos) : array{ return [LevelEventPacket::standardParticle(ParticleIds::MOB_SPELL_INSTANTANEOUS, $this->color->toARGB(), $pos)]; diff --git a/src/world/particle/ItemBreakParticle.php b/src/world/particle/ItemBreakParticle.php index 1a4865a6a..52cde332a 100644 --- a/src/world/particle/ItemBreakParticle.php +++ b/src/world/particle/ItemBreakParticle.php @@ -29,12 +29,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\ParticleIds; class ItemBreakParticle implements Particle{ - /** @var Item */ - private $item; - - public function __construct(Item $item){ - $this->item = $item; - } + public function __construct(private Item $item){} public function encode(Vector3 $pos) : array{ return [LevelEventPacket::standardParticle(ParticleIds::ITEM_BREAK, ($this->item->getId() << 16) | $this->item->getMeta(), $pos)]; diff --git a/src/world/particle/PotionSplashParticle.php b/src/world/particle/PotionSplashParticle.php index 1175e9518..6c7ce1c90 100644 --- a/src/world/particle/PotionSplashParticle.php +++ b/src/world/particle/PotionSplashParticle.php @@ -29,13 +29,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\LevelEvent; class PotionSplashParticle implements Particle{ - - /** @var Color */ - private $color; - - public function __construct(Color $color){ - $this->color = $color; - } + public function __construct(private Color $color){} /** * Returns the default water-bottle splash colour. diff --git a/src/world/particle/RedstoneParticle.php b/src/world/particle/RedstoneParticle.php index f969bcaab..d3fdef581 100644 --- a/src/world/particle/RedstoneParticle.php +++ b/src/world/particle/RedstoneParticle.php @@ -28,12 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\ParticleIds; class RedstoneParticle implements Particle{ - /** @var int */ - private $lifetime; - - public function __construct(int $lifetime = 1){ - $this->lifetime = $lifetime; - } + public function __construct(private int $lifetime = 1){} public function encode(Vector3 $pos) : array{ return [LevelEventPacket::standardParticle(ParticleIds::REDSTONE, $this->lifetime, $pos)]; diff --git a/src/world/particle/SmokeParticle.php b/src/world/particle/SmokeParticle.php index 999f7ffd2..f91f4a1ad 100644 --- a/src/world/particle/SmokeParticle.php +++ b/src/world/particle/SmokeParticle.php @@ -28,12 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\ParticleIds; class SmokeParticle implements Particle{ - /** @var int */ - private $scale; - - public function __construct(int $scale = 0){ - $this->scale = $scale; - } + public function __construct(private int $scale = 0){} public function encode(Vector3 $pos) : array{ return [LevelEventPacket::standardParticle(ParticleIds::SMOKE, $this->scale, $pos)]; diff --git a/src/world/particle/TerrainParticle.php b/src/world/particle/TerrainParticle.php index 5805662e9..829b03adf 100644 --- a/src/world/particle/TerrainParticle.php +++ b/src/world/particle/TerrainParticle.php @@ -30,14 +30,9 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\ParticleIds; class TerrainParticle implements Particle{ - /** @var Block */ - private $block; - - public function __construct(Block $b){ - $this->block = $b; - } + public function __construct(private Block $b){} public function encode(Vector3 $pos) : array{ - return [LevelEventPacket::standardParticle(ParticleIds::TERRAIN, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()), $pos)]; + return [LevelEventPacket::standardParticle(ParticleIds::TERRAIN, RuntimeBlockMapping::getInstance()->toRuntimeId($this->b->getFullId()), $pos)]; } }