Fixed player sounds not being broadcasted to the player itself

fixes #4259
fixes #4270
This commit is contained in:
Dylan K. Taylor 2021-06-21 20:03:32 +01:00
parent 5d6146a01f
commit 60d80e173b
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -105,6 +105,7 @@ use pocketmine\world\Position;
use pocketmine\world\sound\EntityAttackNoDamageSound;
use pocketmine\world\sound\EntityAttackSound;
use pocketmine\world\sound\FireExtinguishSound;
use pocketmine\world\sound\Sound;
use pocketmine\world\World;
use Ramsey\Uuid\UuidInterface;
use function abs;
@ -2221,6 +2222,14 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
parent::broadcastAnimation($animation, $targets);
}
public function broadcastSound(Sound $sound, ?array $targets = null) : void{
if($this->spawned && $targets === null){
$targets = $this->getViewers();
$targets[] = $this;
}
parent::broadcastSound($sound, $targets);
}
/**
* TODO: remove this
*/