mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Modernize property declarations in src/world/sound
This commit is contained in:
parent
cb76c149e1
commit
2f03af51dd
@ -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()))];
|
||||
|
@ -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()))];
|
||||
|
@ -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(
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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(
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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{
|
||||
|
@ -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{
|
||||
|
@ -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;
|
||||
|
@ -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)];
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user