mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 22:45:28 +00:00
Sound no longer extends Vector3
This commit is contained in:
parent
3c520aa786
commit
20aaa8373a
@ -141,7 +141,7 @@ abstract class Door extends Transparent{
|
||||
}
|
||||
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->level->addSound(new DoorSound($this));
|
||||
$this->level->addSound($this, new DoorSound());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class FenceGate extends Transparent{
|
||||
}
|
||||
|
||||
$this->getLevel()->setBlock($this, $this);
|
||||
$this->level->addSound(new DoorSound($this));
|
||||
$this->level->addSound($this, new DoorSound());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -476,7 +476,7 @@ abstract class Liquid extends Transparent{
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->level->setBlock($this, $ev->getNewState());
|
||||
$this->level->addSound(new FizzSound($this->add(0.5, 0.5, 0.5), 2.6 + (lcg_value() - lcg_value()) * 0.8));
|
||||
$this->level->addSound($this->add(0.5, 0.5, 0.5), new FizzSound(2.6 + (lcg_value() - lcg_value()) * 0.8));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class Trapdoor extends Transparent{
|
||||
public function onActivate(Item $item, Player $player = null) : bool{
|
||||
$this->open = !$this->open;
|
||||
$this->level->setBlock($this, $this);
|
||||
$this->level->addSound(new DoorSound($this));
|
||||
$this->level->addSound($this, new DoorSound());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -60,9 +60,9 @@ class EnderPearl extends Throwable{
|
||||
//TODO: spawn endermites at origin
|
||||
|
||||
$this->level->broadcastLevelEvent($owner, LevelEventPacket::EVENT_PARTICLE_ENDERMAN_TELEPORT);
|
||||
$this->level->addSound(new EndermanTeleportSound($owner));
|
||||
$owner->teleport($event->getRayTraceResult()->getHitVector());
|
||||
$this->level->addSound(new EndermanTeleportSound($owner));
|
||||
$this->level->addSound($owner, new EndermanTeleportSound());
|
||||
$owner->teleport($target = $event->getRayTraceResult()->getHitVector());
|
||||
$this->level->addSound($target, new EndermanTeleportSound());
|
||||
|
||||
$owner->attack(new EntityDamageEvent($owner, EntityDamageEvent::CAUSE_FALL, 5));
|
||||
}
|
||||
|
@ -77,9 +77,9 @@ class ChorusFruit extends Food{
|
||||
}
|
||||
|
||||
//Sounds are broadcasted at both source and destination
|
||||
$level->addSound(new EndermanTeleportSound($consumer->asVector3()));
|
||||
$consumer->teleport(new Vector3($x + 0.5, $y + 1, $z + 0.5));
|
||||
$level->addSound(new EndermanTeleportSound($consumer->asVector3()));
|
||||
$level->addSound($consumer->asVector3(), new EndermanTeleportSound());
|
||||
$consumer->teleport($target = new Vector3($x + 0.5, $y + 1, $z + 0.5));
|
||||
$level->addSound($target, new EndermanTeleportSound());
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user