diff --git a/src/world/sound/BlockBreakSound.php b/src/world/sound/BlockBreakSound.php index 39323259d..ccebeb126 100644 --- a/src/world/sound/BlockBreakSound.php +++ b/src/world/sound/BlockBreakSound.php @@ -30,13 +30,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; use pocketmine\network\mcpe\protocol\types\LevelSoundEvent; class BlockBreakSound implements Sound{ - - /** @var Block */ - private $block; - - public function __construct(Block $block){ - $this->block = $block; - } + public function __construct(private Block $block){} public function encode(Vector3 $pos) : array{ return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::BREAK, $pos, false, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()))]; diff --git a/src/world/sound/BlockPlaceSound.php b/src/world/sound/BlockPlaceSound.php index 831c879a1..20c02a44e 100644 --- a/src/world/sound/BlockPlaceSound.php +++ b/src/world/sound/BlockPlaceSound.php @@ -30,13 +30,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; use pocketmine\network\mcpe\protocol\types\LevelSoundEvent; class BlockPlaceSound implements Sound{ - - /** @var Block */ - private $block; - - public function __construct(Block $block){ - $this->block = $block; - } + public function __construct(private Block $block){} public function encode(Vector3 $pos) : array{ return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::PLACE, $pos, false, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()))]; diff --git a/src/world/sound/BlockPunchSound.php b/src/world/sound/BlockPunchSound.php index 03d3ded64..0c28ccfb8 100644 --- a/src/world/sound/BlockPunchSound.php +++ b/src/world/sound/BlockPunchSound.php @@ -33,13 +33,7 @@ use pocketmine\network\mcpe\protocol\types\LevelSoundEvent; * Played when a player attacks a block in survival, attempting to break it. */ class BlockPunchSound implements Sound{ - - /** @var Block */ - private $block; - - public function __construct(Block $block){ - $this->block = $block; - } + public function __construct(private Block $block){} public function encode(Vector3 $pos) : array{ return [LevelSoundEventPacket::nonActorSound( diff --git a/src/world/sound/ClickSound.php b/src/world/sound/ClickSound.php index c02471f87..1ac8e18c9 100644 --- a/src/world/sound/ClickSound.php +++ b/src/world/sound/ClickSound.php @@ -28,13 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\LevelEvent; class ClickSound implements Sound{ - - /** @var float */ - private $pitch; - - public function __construct(float $pitch = 0){ - $this->pitch = $pitch; - } + public function __construct(private float $pitch = 0){} public function getPitch() : float{ return $this->pitch; diff --git a/src/world/sound/DoorSound.php b/src/world/sound/DoorSound.php index 368136c91..598d44d45 100644 --- a/src/world/sound/DoorSound.php +++ b/src/world/sound/DoorSound.php @@ -28,13 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\LevelEvent; class DoorSound implements Sound{ - - /** @var float */ - private $pitch; - - public function __construct(float $pitch = 0){ - $this->pitch = $pitch; - } + public function __construct(private float $pitch = 0){} public function getPitch() : float{ return $this->pitch; diff --git a/src/world/sound/EntityLandSound.php b/src/world/sound/EntityLandSound.php index a973e3ba5..5610cbfd2 100644 --- a/src/world/sound/EntityLandSound.php +++ b/src/world/sound/EntityLandSound.php @@ -34,16 +34,10 @@ use pocketmine\network\mcpe\protocol\types\LevelSoundEvent; * Played when an entity hits the ground after falling a distance that doesn't cause damage, e.g. due to jumping. */ class EntityLandSound implements Sound{ - - /** @var Entity */ - private $entity; - /** @var Block */ - private $blockLandedOn; - - public function __construct(Entity $entity, Block $blockLandedOn){ - $this->entity = $entity; - $this->blockLandedOn = $blockLandedOn; - } + public function __construct( + private Entity $entity, + private Block $blockLandedOn + ){} public function encode(Vector3 $pos) : array{ return [LevelSoundEventPacket::create( diff --git a/src/world/sound/EntityLongFallSound.php b/src/world/sound/EntityLongFallSound.php index c6cd2a33a..1ad842dfa 100644 --- a/src/world/sound/EntityLongFallSound.php +++ b/src/world/sound/EntityLongFallSound.php @@ -33,13 +33,7 @@ use pocketmine\network\mcpe\protocol\types\LevelSoundEvent; * This is the bone-breaker "crunch" sound. */ class EntityLongFallSound implements Sound{ - - /** @var Entity */ - private $entity; - - public function __construct(Entity $entity){ - $this->entity = $entity; - } + public function __construct(private Entity $entity){} public function encode(Vector3 $pos) : array{ return [LevelSoundEventPacket::create( diff --git a/src/world/sound/EntityShortFallSound.php b/src/world/sound/EntityShortFallSound.php index 722a3c1a3..86d873940 100644 --- a/src/world/sound/EntityShortFallSound.php +++ b/src/world/sound/EntityShortFallSound.php @@ -32,13 +32,7 @@ use pocketmine\network\mcpe\protocol\types\LevelSoundEvent; * Played when an entity hits the ground after falling a short distance. */ class EntityShortFallSound implements Sound{ - - /** @var Entity */ - private $entity; - - public function __construct(Entity $entity){ - $this->entity = $entity; - } + public function __construct(private Entity $entity){} public function encode(Vector3 $pos) : array{ return [LevelSoundEventPacket::create( diff --git a/src/world/sound/FizzSound.php b/src/world/sound/FizzSound.php index 62b54ee16..035d51280 100644 --- a/src/world/sound/FizzSound.php +++ b/src/world/sound/FizzSound.php @@ -28,13 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\LevelEvent; class FizzSound implements Sound{ - - /** @var float */ - private $pitch; - - public function __construct(float $pitch = 0){ - $this->pitch = $pitch; - } + public function __construct(private float $pitch = 0){} public function getPitch() : float{ return $this->pitch; diff --git a/src/world/sound/LaunchSound.php b/src/world/sound/LaunchSound.php index 11ef5ad1d..e50c27cf9 100644 --- a/src/world/sound/LaunchSound.php +++ b/src/world/sound/LaunchSound.php @@ -28,13 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\LevelEvent; class LaunchSound implements Sound{ - - /** @var float */ - private $pitch; - - public function __construct(float $pitch = 0){ - $this->pitch = $pitch; - } + public function __construct(private float $pitch = 0){} public function getPitch() : float{ return $this->pitch; diff --git a/src/world/sound/NoteInstrument.php b/src/world/sound/NoteInstrument.php index b22bc2149..d4077d31d 100644 --- a/src/world/sound/NoteInstrument.php +++ b/src/world/sound/NoteInstrument.php @@ -52,12 +52,11 @@ final class NoteInstrument{ ); } - /** @var int */ - private $magicNumber; - - private function __construct(string $name, int $magicNumber){ + private function __construct( + string $name, + private int $magicNumber + ){ $this->Enum___construct($name); - $this->magicNumber = $magicNumber; } public function getMagicNumber() : int{ diff --git a/src/world/sound/NoteSound.php b/src/world/sound/NoteSound.php index c8822a1a9..a3a788a57 100644 --- a/src/world/sound/NoteSound.php +++ b/src/world/sound/NoteSound.php @@ -28,18 +28,13 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; use pocketmine\network\mcpe\protocol\types\LevelSoundEvent; class NoteSound implements Sound{ - - /** @var NoteInstrument */ - private $instrument; - /** @var int */ - private $note; - - public function __construct(NoteInstrument $instrument, int $note){ - if($note < 0 || $note > 255){ + public function __construct( + private NoteInstrument $instrument, + private int $note + ){ + if($this->note < 0 || $this->note > 255){ throw new \InvalidArgumentException("Note $note is outside accepted range"); } - $this->instrument = $instrument; - $this->note = $note; } public function encode(Vector3 $pos) : array{ diff --git a/src/world/sound/PopSound.php b/src/world/sound/PopSound.php index a706e6d03..a3fd57ae2 100644 --- a/src/world/sound/PopSound.php +++ b/src/world/sound/PopSound.php @@ -28,13 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\types\LevelEvent; class PopSound implements Sound{ - - /** @var float */ - private $pitch; - - public function __construct(float $pitch = 0){ - $this->pitch = $pitch; - } + public function __construct(private float $pitch = 0){} public function getPitch() : float{ return $this->pitch; diff --git a/src/world/sound/RecordSound.php b/src/world/sound/RecordSound.php index 57051d5b6..97232725f 100644 --- a/src/world/sound/RecordSound.php +++ b/src/world/sound/RecordSound.php @@ -28,13 +28,7 @@ use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; class RecordSound implements Sound{ - - /** @var RecordType */ - private $recordType; - - public function __construct(RecordType $recordType){ - $this->recordType = $recordType; - } + public function __construct(private RecordType $recordType){} public function encode(Vector3 $pos) : array{ return [LevelSoundEventPacket::nonActorSound($this->recordType->getSoundId(), $pos, false)]; diff --git a/src/world/sound/XpLevelUpSound.php b/src/world/sound/XpLevelUpSound.php index b9e2737b2..4e20a067c 100644 --- a/src/world/sound/XpLevelUpSound.php +++ b/src/world/sound/XpLevelUpSound.php @@ -30,13 +30,7 @@ use function intdiv; use function min; class XpLevelUpSound implements Sound{ - - /** @var int */ - private $xpLevel; - - public function __construct(int $xpLevel){ - $this->xpLevel = $xpLevel; - } + public function __construct(private int $xpLevel){} public function getXpLevel() : int{ return $this->xpLevel;