mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-11 08:19:45 +00:00
Some cleanup to internal sounds handling
This commit is contained in:
parent
c34a4f45d4
commit
f647b1b7a5
@ -25,8 +25,9 @@ namespace pocketmine\level\sound;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
class AnvilBreakSound extends GenericSound{
|
||||
public function __construct(float $pitch = 0){
|
||||
parent::__construct(LevelEventPacket::EVENT_SOUND_ANVIL_BREAK, $pitch);
|
||||
class AnvilBreakSound extends LevelEventSound{
|
||||
|
||||
protected function getLevelEventId() : int{
|
||||
return LevelEventPacket::EVENT_SOUND_ANVIL_BREAK;
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,9 @@ namespace pocketmine\level\sound;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
class AnvilFallSound extends GenericSound{
|
||||
public function __construct(float $pitch = 0){
|
||||
parent::__construct(LevelEventPacket::EVENT_SOUND_ANVIL_FALL, $pitch);
|
||||
class AnvilFallSound extends LevelEventSound{
|
||||
|
||||
protected function getLevelEventId() : int{
|
||||
return LevelEventPacket::EVENT_SOUND_ANVIL_FALL;
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,9 @@ namespace pocketmine\level\sound;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
class AnvilUseSound extends GenericSound{
|
||||
public function __construct(float $pitch = 0){
|
||||
parent::__construct(LevelEventPacket::EVENT_SOUND_ANVIL_USE, $pitch);
|
||||
class AnvilUseSound extends LevelEventSound{
|
||||
|
||||
protected function getLevelEventId() : int{
|
||||
return LevelEventPacket::EVENT_SOUND_ANVIL_USE;
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,9 @@ namespace pocketmine\level\sound;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
class BlazeShootSound extends GenericSound{
|
||||
public function __construct(float $pitch = 0){
|
||||
parent::__construct(LevelEventPacket::EVENT_SOUND_BLAZE_SHOOT, $pitch);
|
||||
class BlazeShootSound extends LevelEventSound{
|
||||
|
||||
protected function getLevelEventId() : int{
|
||||
return LevelEventPacket::EVENT_SOUND_BLAZE_SHOOT;
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,9 @@ namespace pocketmine\level\sound;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
class ClickSound extends GenericSound{
|
||||
public function __construct(float $pitch = 0){
|
||||
parent::__construct(LevelEventPacket::EVENT_SOUND_CLICK, $pitch);
|
||||
class ClickSound extends LevelEventSound{
|
||||
|
||||
protected function getLevelEventId() : int{
|
||||
return LevelEventPacket::EVENT_SOUND_CLICK;
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,9 @@ namespace pocketmine\level\sound;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
class DoorBumpSound extends GenericSound{
|
||||
public function __construct(float $pitch = 0){
|
||||
parent::__construct(LevelEventPacket::EVENT_SOUND_DOOR_BUMP, $pitch);
|
||||
class DoorBumpSound extends LevelEventSound{
|
||||
|
||||
protected function getLevelEventId() : int{
|
||||
return LevelEventPacket::EVENT_SOUND_DOOR_BUMP;
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,9 @@ namespace pocketmine\level\sound;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
class DoorCrashSound extends GenericSound{
|
||||
public function __construct(float $pitch = 0){
|
||||
parent::__construct(LevelEventPacket::EVENT_SOUND_DOOR_CRASH, $pitch);
|
||||
class DoorCrashSound extends LevelEventSound{
|
||||
|
||||
protected function getLevelEventId() : int{
|
||||
return LevelEventPacket::EVENT_SOUND_DOOR_CRASH;
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,9 @@ namespace pocketmine\level\sound;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
class DoorSound extends GenericSound{
|
||||
public function __construct(float $pitch = 0){
|
||||
parent::__construct(LevelEventPacket::EVENT_SOUND_DOOR, $pitch);
|
||||
class DoorSound extends LevelEventSound{
|
||||
|
||||
protected function getLevelEventId() : int{
|
||||
return LevelEventPacket::EVENT_SOUND_DOOR;
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,12 @@ namespace pocketmine\level\sound;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
class EndermanTeleportSound extends GenericSound{
|
||||
public function __construct(){
|
||||
parent::__construct(LevelEventPacket::EVENT_SOUND_ENDERMAN_TELEPORT);
|
||||
class EndermanTeleportSound extends LevelEventSound{
|
||||
public function __construct(){ //don't allow specifying a pitch - TODO: remove pitch from sounds that don't have it
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function getLevelEventId() : int{
|
||||
return LevelEventPacket::EVENT_SOUND_ENDERMAN_TELEPORT;
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,9 @@ namespace pocketmine\level\sound;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
class FizzSound extends GenericSound{
|
||||
public function __construct(float $pitch = 0){
|
||||
parent::__construct(LevelEventPacket::EVENT_SOUND_FIZZ, $pitch);
|
||||
class FizzSound extends LevelEventSound{
|
||||
|
||||
protected function getLevelEventId() : int{
|
||||
return LevelEventPacket::EVENT_SOUND_FIZZ;
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,9 @@ namespace pocketmine\level\sound;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
class GhastShootSound extends GenericSound{
|
||||
public function __construct(float $pitch = 0){
|
||||
parent::__construct(LevelEventPacket::EVENT_SOUND_GHAST_SHOOT, $pitch);
|
||||
class GhastShootSound extends LevelEventSound{
|
||||
|
||||
protected function getLevelEventId() : int{
|
||||
return LevelEventPacket::EVENT_SOUND_GHAST_SHOOT;
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,9 @@ namespace pocketmine\level\sound;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
class GhastSound extends GenericSound{
|
||||
public function __construct(float $pitch = 0){
|
||||
parent::__construct(LevelEventPacket::EVENT_SOUND_GHAST, $pitch);
|
||||
class GhastSound extends LevelEventSound{
|
||||
|
||||
protected function getLevelEventId() : int{
|
||||
return LevelEventPacket::EVENT_SOUND_GHAST;
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,9 @@ namespace pocketmine\level\sound;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
class LaunchSound extends GenericSound{
|
||||
public function __construct(float $pitch = 0){
|
||||
parent::__construct(LevelEventPacket::EVENT_SOUND_SHOOT, $pitch);
|
||||
class LaunchSound extends LevelEventSound{
|
||||
|
||||
protected function getLevelEventId() : int{
|
||||
return LevelEventPacket::EVENT_SOUND_SHOOT;
|
||||
}
|
||||
}
|
||||
|
@ -26,18 +26,20 @@ namespace pocketmine\level\sound;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
class GenericSound extends Sound{
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract class LevelEventSound extends Sound{
|
||||
|
||||
/** @var int */
|
||||
protected $id;
|
||||
/** @var float */
|
||||
protected $pitch = 0;
|
||||
|
||||
public function __construct(int $id, float $pitch = 0){
|
||||
$this->id = $id;
|
||||
public function __construct(float $pitch = 0){
|
||||
$this->pitch = $pitch * 1000;
|
||||
}
|
||||
|
||||
abstract protected function getLevelEventId() : int;
|
||||
|
||||
public function getPitch() : float{
|
||||
return $this->pitch / 1000;
|
||||
}
|
||||
@ -48,7 +50,7 @@ class GenericSound extends Sound{
|
||||
|
||||
public function encode(Vector3 $pos){
|
||||
$pk = new LevelEventPacket;
|
||||
$pk->evid = $this->id;
|
||||
$pk->evid = $this->getLevelEventId();
|
||||
$pk->position = $pos;
|
||||
$pk->data = (int) $this->pitch;
|
||||
|
@ -25,8 +25,9 @@ namespace pocketmine\level\sound;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
|
||||
class PopSound extends GenericSound{
|
||||
public function __construct(float $pitch = 0){
|
||||
parent::__construct(LevelEventPacket::EVENT_SOUND_POP, $pitch);
|
||||
class PopSound extends LevelEventSound{
|
||||
|
||||
protected function getLevelEventId() : int{
|
||||
return LevelEventPacket::EVENT_SOUND_POP;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user