public function sendChunk($x, $z, $payload, $ordering = FullChunkDataPacket::ORDER_COLUMNS)
{
if ($this->connected === false) {
return;
}
$this->usedChunks[Level::chunkHash($x, $z)] = true;
$this->chunkLoadCount++;
if ($payload instanceof DataPacket) {
$this->dataPacket($payload);
} else {
$pk = new FullChunkDataPacket();
$pk->chunkX = $x;
$pk->chunkZ = $z;
$pk->order = $ordering;
$pk->data = $payload;
$this->batchDataPacket($pk);
}
if ($this->spawned) {
foreach ($this->level->getChunkEntities($x, $z) as $entity) {
if ($entity !== $this and !$entity->closed and $entity->isAlive()) {
$entity->spawnTo($this);
}
}
}
}