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;
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()))];

View File

@ -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()))];

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.
*/
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(

View File

@ -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;

View File

@ -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;

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.
*/
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(

View File

@ -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(

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.
*/
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(

View File

@ -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;

View File

@ -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;

View File

@ -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{

View File

@ -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{

View File

@ -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;

View File

@ -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)];

View File

@ -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;