mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-10 13:35:29 +00:00
Fixed tiles not being sent with chunks
This commit is contained in:
parent
d5f81fe261
commit
baeac2eb07
@ -846,7 +846,7 @@ class Chunk{
|
||||
/**
|
||||
* Serializes the chunk for sending to players
|
||||
*/
|
||||
public function networkSerialize() : string{
|
||||
public function networkSerialize(?string $networkSerializedTiles) : string{
|
||||
$result = "";
|
||||
$subChunkCount = $this->getSubChunkSendCount();
|
||||
|
||||
@ -866,6 +866,17 @@ class Chunk{
|
||||
$result .= chr(0); //border block array count
|
||||
//Border block entry format: 1 byte (4 bits X, 4 bits Z). These are however useless since they crash the regular client.
|
||||
|
||||
$result .= $networkSerializedTiles ?? $this->networkSerializeTiles();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes all tiles in network format for chunk sending. This is necessary because fastSerialize() doesn't
|
||||
* include tiles; they have to be encoded on the main thread.
|
||||
*/
|
||||
public function networkSerializeTiles() : string{
|
||||
$result = "";
|
||||
foreach($this->tiles as $tile){
|
||||
if($tile instanceof Spawnable){
|
||||
$result .= $tile->getSerializedSpawnCompound();
|
||||
|
@ -39,6 +39,7 @@ class ChunkRequestTask extends AsyncTask{
|
||||
|
||||
/** @var string */
|
||||
protected $chunk;
|
||||
private string $tiles;
|
||||
/** @var int */
|
||||
protected $chunkX;
|
||||
/** @var int */
|
||||
@ -52,13 +53,15 @@ class ChunkRequestTask extends AsyncTask{
|
||||
$this->compressionLevel = $level->getServer()->networkCompressionLevel;
|
||||
|
||||
$this->chunk = $chunk->fastSerialize();
|
||||
$this->tiles = $chunk->networkSerializeTiles();
|
||||
|
||||
$this->chunkX = $chunkX;
|
||||
$this->chunkZ = $chunkZ;
|
||||
}
|
||||
|
||||
public function onRun(){
|
||||
$chunk = Chunk::fastDeserialize($this->chunk);
|
||||
$pk = LevelChunkPacket::withoutCache($this->chunkX, $this->chunkZ, $chunk->getSubChunkSendCount() + 4, $chunk->networkSerialize());
|
||||
$pk = LevelChunkPacket::withoutCache($this->chunkX, $this->chunkZ, $chunk->getSubChunkSendCount() + 4, $chunk->networkSerialize($this->tiles));
|
||||
|
||||
$batch = new BatchPacket();
|
||||
$batch->addPacket($pk);
|
||||
|
Loading…
x
Reference in New Issue
Block a user