Modernize property declarations in src/world/sound

This commit is contained in:
Dylan K. Taylor 2022-04-28 14:57:01 +01:00
parent cb76c149e1
commit 2f03af51dd
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
15 changed files with 25 additions and 109 deletions

View File

@ -30,13 +30,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent; use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
class BlockBreakSound implements Sound{ class BlockBreakSound implements Sound{
public function __construct(private Block $block){}
/** @var Block */
private $block;
public function __construct(Block $block){
$this->block = $block;
}
public function encode(Vector3 $pos) : array{ public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::BREAK, $pos, false, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()))]; return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::BREAK, $pos, false, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()))];

View File

@ -30,13 +30,7 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent; use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
class BlockPlaceSound implements Sound{ class BlockPlaceSound implements Sound{
public function __construct(private Block $block){}
/** @var Block */
private $block;
public function __construct(Block $block){
$this->block = $block;
}
public function encode(Vector3 $pos) : array{ public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::PLACE, $pos, false, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()))]; return [LevelSoundEventPacket::nonActorSound(LevelSoundEvent::PLACE, $pos, false, RuntimeBlockMapping::getInstance()->toRuntimeId($this->block->getFullId()))];

View File

@ -33,13 +33,7 @@ use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
* Played when a player attacks a block in survival, attempting to break it. * Played when a player attacks a block in survival, attempting to break it.
*/ */
class BlockPunchSound implements Sound{ class BlockPunchSound implements Sound{
public function __construct(private Block $block){}
/** @var Block */
private $block;
public function __construct(Block $block){
$this->block = $block;
}
public function encode(Vector3 $pos) : array{ public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound( return [LevelSoundEventPacket::nonActorSound(

View File

@ -28,13 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelEvent; use pocketmine\network\mcpe\protocol\types\LevelEvent;
class ClickSound implements Sound{ class ClickSound implements Sound{
public function __construct(private float $pitch = 0){}
/** @var float */
private $pitch;
public function __construct(float $pitch = 0){
$this->pitch = $pitch;
}
public function getPitch() : float{ public function getPitch() : float{
return $this->pitch; return $this->pitch;

View File

@ -28,13 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelEvent; use pocketmine\network\mcpe\protocol\types\LevelEvent;
class DoorSound implements Sound{ class DoorSound implements Sound{
public function __construct(private float $pitch = 0){}
/** @var float */
private $pitch;
public function __construct(float $pitch = 0){
$this->pitch = $pitch;
}
public function getPitch() : float{ public function getPitch() : float{
return $this->pitch; return $this->pitch;

View File

@ -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. * 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{ class EntityLandSound implements Sound{
public function __construct(
/** @var Entity */ private Entity $entity,
private $entity; private Block $blockLandedOn
/** @var Block */ ){}
private $blockLandedOn;
public function __construct(Entity $entity, Block $blockLandedOn){
$this->entity = $entity;
$this->blockLandedOn = $blockLandedOn;
}
public function encode(Vector3 $pos) : array{ public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::create( return [LevelSoundEventPacket::create(

View File

@ -33,13 +33,7 @@ use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
* This is the bone-breaker "crunch" sound. * This is the bone-breaker "crunch" sound.
*/ */
class EntityLongFallSound implements Sound{ class EntityLongFallSound implements Sound{
public function __construct(private Entity $entity){}
/** @var Entity */
private $entity;
public function __construct(Entity $entity){
$this->entity = $entity;
}
public function encode(Vector3 $pos) : array{ public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::create( return [LevelSoundEventPacket::create(

View File

@ -32,13 +32,7 @@ use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
* Played when an entity hits the ground after falling a short distance. * Played when an entity hits the ground after falling a short distance.
*/ */
class EntityShortFallSound implements Sound{ class EntityShortFallSound implements Sound{
public function __construct(private Entity $entity){}
/** @var Entity */
private $entity;
public function __construct(Entity $entity){
$this->entity = $entity;
}
public function encode(Vector3 $pos) : array{ public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::create( return [LevelSoundEventPacket::create(

View File

@ -28,13 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelEvent; use pocketmine\network\mcpe\protocol\types\LevelEvent;
class FizzSound implements Sound{ class FizzSound implements Sound{
public function __construct(private float $pitch = 0){}
/** @var float */
private $pitch;
public function __construct(float $pitch = 0){
$this->pitch = $pitch;
}
public function getPitch() : float{ public function getPitch() : float{
return $this->pitch; return $this->pitch;

View File

@ -28,13 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelEvent; use pocketmine\network\mcpe\protocol\types\LevelEvent;
class LaunchSound implements Sound{ class LaunchSound implements Sound{
public function __construct(private float $pitch = 0){}
/** @var float */
private $pitch;
public function __construct(float $pitch = 0){
$this->pitch = $pitch;
}
public function getPitch() : float{ public function getPitch() : float{
return $this->pitch; return $this->pitch;

View File

@ -52,12 +52,11 @@ final class NoteInstrument{
); );
} }
/** @var int */ private function __construct(
private $magicNumber; string $name,
private int $magicNumber
private function __construct(string $name, int $magicNumber){ ){
$this->Enum___construct($name); $this->Enum___construct($name);
$this->magicNumber = $magicNumber;
} }
public function getMagicNumber() : int{ public function getMagicNumber() : int{

View File

@ -28,18 +28,13 @@ use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelSoundEvent; use pocketmine\network\mcpe\protocol\types\LevelSoundEvent;
class NoteSound implements Sound{ class NoteSound implements Sound{
public function __construct(
/** @var NoteInstrument */ private NoteInstrument $instrument,
private $instrument; private int $note
/** @var int */ ){
private $note; if($this->note < 0 || $this->note > 255){
public function __construct(NoteInstrument $instrument, int $note){
if($note < 0 || $note > 255){
throw new \InvalidArgumentException("Note $note is outside accepted range"); throw new \InvalidArgumentException("Note $note is outside accepted range");
} }
$this->instrument = $instrument;
$this->note = $note;
} }
public function encode(Vector3 $pos) : array{ public function encode(Vector3 $pos) : array{

View File

@ -28,13 +28,7 @@ use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\types\LevelEvent; use pocketmine\network\mcpe\protocol\types\LevelEvent;
class PopSound implements Sound{ class PopSound implements Sound{
public function __construct(private float $pitch = 0){}
/** @var float */
private $pitch;
public function __construct(float $pitch = 0){
$this->pitch = $pitch;
}
public function getPitch() : float{ public function getPitch() : float{
return $this->pitch; return $this->pitch;

View File

@ -28,13 +28,7 @@ use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
class RecordSound implements Sound{ class RecordSound implements Sound{
public function __construct(private RecordType $recordType){}
/** @var RecordType */
private $recordType;
public function __construct(RecordType $recordType){
$this->recordType = $recordType;
}
public function encode(Vector3 $pos) : array{ public function encode(Vector3 $pos) : array{
return [LevelSoundEventPacket::nonActorSound($this->recordType->getSoundId(), $pos, false)]; return [LevelSoundEventPacket::nonActorSound($this->recordType->getSoundId(), $pos, false)];

View File

@ -30,13 +30,7 @@ use function intdiv;
use function min; use function min;
class XpLevelUpSound implements Sound{ class XpLevelUpSound implements Sound{
public function __construct(private int $xpLevel){}
/** @var int */
private $xpLevel;
public function __construct(int $xpLevel){
$this->xpLevel = $xpLevel;
}
public function getXpLevel() : int{ public function getXpLevel() : int{
return $this->xpLevel; return $this->xpLevel;