Sound no longer extends Vector3

This commit is contained in:
Dylan K. Taylor
2018-12-16 14:26:42 +00:00
parent 3c520aa786
commit 20aaa8373a
23 changed files with 48 additions and 61 deletions

View File

@ -450,15 +450,15 @@ class Level implements ChunkManager, Metadatable{
$this->closed = true;
}
public function addSound(Sound $sound, array $players = null){
$pk = $sound->encode();
public function addSound(Vector3 $pos, Sound $sound, array $players = null){
$pk = $sound->encode($pos);
if(!is_array($pk)){
$pk = [$pk];
}
if(!empty($pk)){
if($players === null){
foreach($pk as $e){
$this->broadcastPacketToViewers($sound, $e);
$this->broadcastPacketToViewers($pos, $e);
}
}else{
$this->server->broadcastPackets($players, $pk);

View File

@ -23,11 +23,10 @@ declare(strict_types=1);
namespace pocketmine\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class AnvilBreakSound extends GenericSound{
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_ANVIL_BREAK, $pitch);
public function __construct(float $pitch = 0){
parent::__construct(LevelEventPacket::EVENT_SOUND_ANVIL_BREAK, $pitch);
}
}

View File

@ -23,11 +23,10 @@ declare(strict_types=1);
namespace pocketmine\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class AnvilFallSound extends GenericSound{
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_ANVIL_FALL, $pitch);
public function __construct(float $pitch = 0){
parent::__construct(LevelEventPacket::EVENT_SOUND_ANVIL_FALL, $pitch);
}
}

View File

@ -23,11 +23,10 @@ declare(strict_types=1);
namespace pocketmine\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class AnvilUseSound extends GenericSound{
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_ANVIL_USE, $pitch);
public function __construct(float $pitch = 0){
parent::__construct(LevelEventPacket::EVENT_SOUND_ANVIL_USE, $pitch);
}
}

View File

@ -23,11 +23,10 @@ declare(strict_types=1);
namespace pocketmine\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class BlazeShootSound extends GenericSound{
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_BLAZE_SHOOT, $pitch);
public function __construct(float $pitch = 0){
parent::__construct(LevelEventPacket::EVENT_SOUND_BLAZE_SHOOT, $pitch);
}
}

View File

@ -23,11 +23,10 @@ declare(strict_types=1);
namespace pocketmine\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class ClickSound extends GenericSound{
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_CLICK, $pitch);
public function __construct(float $pitch = 0){
parent::__construct(LevelEventPacket::EVENT_SOUND_CLICK, $pitch);
}
}

View File

@ -23,11 +23,10 @@ declare(strict_types=1);
namespace pocketmine\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class DoorBumpSound extends GenericSound{
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_DOOR_BUMP, $pitch);
public function __construct(float $pitch = 0){
parent::__construct(LevelEventPacket::EVENT_SOUND_DOOR_BUMP, $pitch);
}
}

View File

@ -23,11 +23,10 @@ declare(strict_types=1);
namespace pocketmine\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class DoorCrashSound extends GenericSound{
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_DOOR_CRASH, $pitch);
public function __construct(float $pitch = 0){
parent::__construct(LevelEventPacket::EVENT_SOUND_DOOR_CRASH, $pitch);
}
}

View File

@ -23,11 +23,10 @@ declare(strict_types=1);
namespace pocketmine\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class DoorSound extends GenericSound{
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_DOOR, $pitch);
public function __construct(float $pitch = 0){
parent::__construct(LevelEventPacket::EVENT_SOUND_DOOR, $pitch);
}
}

View File

@ -23,11 +23,10 @@ declare(strict_types=1);
namespace pocketmine\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class EndermanTeleportSound extends GenericSound{
public function __construct(Vector3 $pos){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_ENDERMAN_TELEPORT);
public function __construct(){
parent::__construct(LevelEventPacket::EVENT_SOUND_ENDERMAN_TELEPORT);
}
}

View File

@ -23,11 +23,10 @@ declare(strict_types=1);
namespace pocketmine\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class FizzSound extends GenericSound{
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_FIZZ, $pitch);
public function __construct(float $pitch = 0){
parent::__construct(LevelEventPacket::EVENT_SOUND_FIZZ, $pitch);
}
}

View File

@ -33,8 +33,7 @@ class GenericSound extends Sound{
/** @var float */
protected $pitch = 0;
public function __construct(Vector3 $pos, int $id, float $pitch = 0){
parent::__construct($pos->x, $pos->y, $pos->z);
public function __construct(int $id, float $pitch = 0){
$this->id = $id;
$this->pitch = $pitch * 1000;
}
@ -47,10 +46,10 @@ class GenericSound extends Sound{
$this->pitch = $pitch * 1000;
}
public function encode(){
public function encode(Vector3 $pos){
$pk = new LevelEventPacket;
$pk->evid = $this->id;
$pk->position = $this->asVector3();
$pk->position = $pos;
$pk->data = (int) $this->pitch;
return $pk;

View File

@ -23,11 +23,10 @@ declare(strict_types=1);
namespace pocketmine\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class GhastShootSound extends GenericSound{
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_GHAST_SHOOT, $pitch);
public function __construct(float $pitch = 0){
parent::__construct(LevelEventPacket::EVENT_SOUND_GHAST_SHOOT, $pitch);
}
}

View File

@ -23,11 +23,10 @@ declare(strict_types=1);
namespace pocketmine\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class GhastSound extends GenericSound{
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_GHAST, $pitch);
public function __construct(float $pitch = 0){
parent::__construct(LevelEventPacket::EVENT_SOUND_GHAST, $pitch);
}
}

View File

@ -23,11 +23,10 @@ declare(strict_types=1);
namespace pocketmine\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class LaunchSound extends GenericSound{
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_SHOOT, $pitch);
public function __construct(float $pitch = 0){
parent::__construct(LevelEventPacket::EVENT_SOUND_SHOOT, $pitch);
}
}

View File

@ -23,11 +23,10 @@ declare(strict_types=1);
namespace pocketmine\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
class PopSound extends GenericSound{
public function __construct(Vector3 $pos, float $pitch = 0){
parent::__construct($pos, LevelEventPacket::EVENT_SOUND_POP, $pitch);
public function __construct(float $pitch = 0){
parent::__construct(LevelEventPacket::EVENT_SOUND_POP, $pitch);
}
}

View File

@ -26,11 +26,13 @@ namespace pocketmine\level\sound;
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\protocol\DataPacket;
abstract class Sound extends Vector3{
abstract class Sound{
/**
* @param Vector3 $pos
*
* @return DataPacket|DataPacket[]
*/
abstract public function encode();
abstract public function encode(Vector3 $pos);
}