Cleaned up Level->addSound() and Level->addParticle()

This commit is contained in:
Dylan K. Taylor 2017-08-27 19:09:05 +01:00
parent 0b2b9126a2
commit a982344b96

View File

@ -409,49 +409,31 @@ class Level implements ChunkManager, Metadatable{
public function addSound(Sound $sound, array $players = null){
$pk = $sound->encode();
if(!is_array($pk)){
$pk = [$pk];
}
if($players === null){
if($pk !== null){
if(!is_array($pk)){
$this->addChunkPacket($sound->x >> 4, $sound->z >> 4, $pk);
}else{
foreach($pk as $e){
$this->addChunkPacket($sound->x >> 4, $sound->z >> 4, $e);
}
}
foreach($pk as $e){
$this->addChunkPacket($sound->x >> 4, $sound->z >> 4, $e);
}
}else{
if($pk !== null){
if(!is_array($pk)){
$this->server->broadcastPacket($players, $pk);
}else{
$this->server->batchPackets($players, $pk, false);
}
}
$this->server->batchPackets($players, $pk, false);
}
}
public function addParticle(Particle $particle, array $players = null){
$pk = $particle->encode();
if(!is_array($pk)){
$pk = [$pk];
}
if($players === null){
if($pk !== null){
if(!is_array($pk)){
$this->addChunkPacket($particle->x >> 4, $particle->z >> 4, $pk);
}else{
foreach($pk as $e){
$this->addChunkPacket($particle->x >> 4, $particle->z >> 4, $e);
}
}
foreach($pk as $e){
$this->addChunkPacket($particle->x >> 4, $particle->z >> 4, $e);
}
}else{
if($pk !== null){
if(!is_array($pk)){
$this->server->broadcastPacket($players, $pk);
}else{
$this->server->batchPackets($players, $pk, false);
}
}
$this->server->batchPackets($players, $pk, false);
}
}