remove LevelEventSound, remove pitch from sounds that don't support it (most of them)

This commit is contained in:
Dylan K. Taylor 2019-08-21 17:59:00 +01:00
parent ea2c418a77
commit e9fd57275a
16 changed files with 131 additions and 102 deletions

View File

@ -23,11 +23,12 @@ declare(strict_types=1);
namespace pocketmine\world\sound; namespace pocketmine\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class AnvilBreakSound extends LevelEventSound{ class AnvilBreakSound implements Sound{
protected function getLevelEventId() : int{ public function encode(?Vector3 $pos){
return LevelEventPacket::EVENT_SOUND_ANVIL_BREAK; return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ANVIL_BREAK, 0, $pos);
} }
} }

View File

@ -23,11 +23,12 @@ declare(strict_types=1);
namespace pocketmine\world\sound; namespace pocketmine\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class AnvilFallSound extends LevelEventSound{ class AnvilFallSound implements Sound{
protected function getLevelEventId() : int{ public function encode(?Vector3 $pos){
return LevelEventPacket::EVENT_SOUND_ANVIL_FALL; return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ANVIL_FALL, 0, $pos);
} }
} }

View File

@ -23,11 +23,12 @@ declare(strict_types=1);
namespace pocketmine\world\sound; namespace pocketmine\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class AnvilUseSound extends LevelEventSound{ class AnvilUseSound implements Sound{
protected function getLevelEventId() : int{ public function encode(?Vector3 $pos){
return LevelEventPacket::EVENT_SOUND_ANVIL_USE; return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ANVIL_USE, 0, $pos);
} }
} }

View File

@ -23,11 +23,12 @@ declare(strict_types=1);
namespace pocketmine\world\sound; namespace pocketmine\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class BlazeShootSound extends LevelEventSound{ class BlazeShootSound implements Sound{
protected function getLevelEventId() : int{ public function encode(?Vector3 $pos){
return LevelEventPacket::EVENT_SOUND_BLAZE_SHOOT; return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_BLAZE_SHOOT, 0, $pos);
} }
} }

View File

@ -23,11 +23,26 @@ declare(strict_types=1);
namespace pocketmine\world\sound; namespace pocketmine\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class ClickSound extends LevelEventSound{ class ClickSound implements Sound{
protected function getLevelEventId() : int{ /** @var float */
return LevelEventPacket::EVENT_SOUND_CLICK; private $pitch;
public function __construct(float $pitch = 0){
$this->pitch = $pitch;
}
/**
* @return float
*/
public function getPitch() : float{
return $this->pitch;
}
public function encode(?Vector3 $pos){
return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_CLICK, (int) ($this->pitch * 1000), $pos);
} }
} }

View File

@ -23,11 +23,12 @@ declare(strict_types=1);
namespace pocketmine\world\sound; namespace pocketmine\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class DoorBumpSound extends LevelEventSound{ class DoorBumpSound implements Sound{
protected function getLevelEventId() : int{ public function encode(?Vector3 $pos){
return LevelEventPacket::EVENT_SOUND_DOOR_BUMP; return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_DOOR_BUMP, 0, $pos);
} }
} }

View File

@ -23,11 +23,12 @@ declare(strict_types=1);
namespace pocketmine\world\sound; namespace pocketmine\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class DoorCrashSound extends LevelEventSound{ class DoorCrashSound implements Sound{
protected function getLevelEventId() : int{ public function encode(?Vector3 $pos){
return LevelEventPacket::EVENT_SOUND_DOOR_CRASH; return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_DOOR_CRASH, 0, $pos);
} }
} }

View File

@ -23,11 +23,26 @@ declare(strict_types=1);
namespace pocketmine\world\sound; namespace pocketmine\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class DoorSound extends LevelEventSound{ class DoorSound implements Sound{
protected function getLevelEventId() : int{ /** @var float */
return LevelEventPacket::EVENT_SOUND_DOOR; private $pitch;
public function __construct(float $pitch = 0){
$this->pitch = $pitch;
}
/**
* @return float
*/
public function getPitch() : float{
return $this->pitch;
}
public function encode(?Vector3 $pos){
return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_DOOR, (int) ($this->pitch * 1000), $pos);
} }
} }

View File

@ -23,14 +23,12 @@ declare(strict_types=1);
namespace pocketmine\world\sound; namespace pocketmine\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class EndermanTeleportSound extends LevelEventSound{ class EndermanTeleportSound implements Sound{
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{ public function encode(?Vector3 $pos){
return LevelEventPacket::EVENT_SOUND_ENDERMAN_TELEPORT; return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ENDERMAN_TELEPORT, 0, $pos);
} }
} }

View File

@ -23,11 +23,26 @@ declare(strict_types=1);
namespace pocketmine\world\sound; namespace pocketmine\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class FizzSound extends LevelEventSound{ class FizzSound implements Sound{
protected function getLevelEventId() : int{ /** @var float */
return LevelEventPacket::EVENT_SOUND_FIZZ; private $pitch;
public function __construct(float $pitch = 0){
$this->pitch = $pitch;
}
/**
* @return float
*/
public function getPitch() : float{
return $this->pitch;
}
public function encode(?Vector3 $pos){
return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_FIZZ, (int) ($this->pitch * 1000), $pos);
} }
} }

View File

@ -23,11 +23,12 @@ declare(strict_types=1);
namespace pocketmine\world\sound; namespace pocketmine\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class GhastShootSound extends LevelEventSound{ class GhastShootSound implements Sound{
protected function getLevelEventId() : int{ public function encode(?Vector3 $pos){
return LevelEventPacket::EVENT_SOUND_GHAST_SHOOT; return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_GHAST_SHOOT, 0, $pos);
} }
} }

View File

@ -23,11 +23,12 @@ declare(strict_types=1);
namespace pocketmine\world\sound; namespace pocketmine\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class GhastSound extends LevelEventSound{ class GhastSound implements Sound{
protected function getLevelEventId() : int{ public function encode(?Vector3 $pos){
return LevelEventPacket::EVENT_SOUND_GHAST; return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_GHAST, 0, $pos);
} }
} }

View File

@ -23,11 +23,26 @@ declare(strict_types=1);
namespace pocketmine\world\sound; namespace pocketmine\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class LaunchSound extends LevelEventSound{ class LaunchSound implements Sound{
protected function getLevelEventId() : int{ /** @var float */
return LevelEventPacket::EVENT_SOUND_SHOOT; private $pitch;
public function __construct(float $pitch = 0){
$this->pitch = $pitch;
}
/**
* @return float
*/
public function getPitch() : float{
return $this->pitch;
}
public function encode(?Vector3 $pos){
return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_SHOOT, (int) ($this->pitch * 1000), $pos);
} }
} }

View File

@ -1,54 +0,0 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
/**
* @internal
*/
abstract class LevelEventSound implements Sound{
/** @var float */
protected $pitch = 0;
public function __construct(float $pitch = 0){
$this->pitch = $pitch * 1000;
}
abstract protected function getLevelEventId() : int;
public function getPitch() : float{
return $this->pitch / 1000;
}
public function setPitch(float $pitch) : void{
$this->pitch = $pitch * 1000;
}
public function encode(?Vector3 $pos){
return LevelEventPacket::create($this->getLevelEventId(), (int) $this->pitch, $pos);
}
}

View File

@ -23,11 +23,13 @@ declare(strict_types=1);
namespace pocketmine\world\sound; namespace pocketmine\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class PaintingPlaceSound extends LevelEventSound{ class PaintingPlaceSound implements Sound{
protected function getLevelEventId() : int{ public function encode(?Vector3 $pos){
return LevelEventPacket::EVENT_SOUND_ITEMFRAME_PLACE; //item frame and painting have the same sound //item frame and painting have the same sound
return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_ITEMFRAME_PLACE, 0, $pos);
} }
} }

View File

@ -23,11 +23,26 @@ declare(strict_types=1);
namespace pocketmine\world\sound; namespace pocketmine\world\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket; use pocketmine\network\mcpe\protocol\LevelEventPacket;
class PopSound extends LevelEventSound{ class PopSound implements Sound{
protected function getLevelEventId() : int{ /** @var float */
return LevelEventPacket::EVENT_SOUND_POP; private $pitch;
public function __construct(float $pitch = 0){
$this->pitch = $pitch;
}
/**
* @return float
*/
public function getPitch() : float{
return $this->pitch;
}
public function encode(?Vector3 $pos){
return LevelEventPacket::create(LevelEventPacket::EVENT_SOUND_POP, (int) ($this->pitch * 1000), $pos);
} }
} }