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