mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 14:05:35 +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
|
* Serializes the chunk for sending to players
|
||||||
*/
|
*/
|
||||||
public function networkSerialize() : string{
|
public function networkSerialize(?string $networkSerializedTiles) : string{
|
||||||
$result = "";
|
$result = "";
|
||||||
$subChunkCount = $this->getSubChunkSendCount();
|
$subChunkCount = $this->getSubChunkSendCount();
|
||||||
|
|
||||||
@ -866,6 +866,17 @@ class Chunk{
|
|||||||
$result .= chr(0); //border block array count
|
$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.
|
//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){
|
foreach($this->tiles as $tile){
|
||||||
if($tile instanceof Spawnable){
|
if($tile instanceof Spawnable){
|
||||||
$result .= $tile->getSerializedSpawnCompound();
|
$result .= $tile->getSerializedSpawnCompound();
|
||||||
|
@ -39,6 +39,7 @@ class ChunkRequestTask extends AsyncTask{
|
|||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $chunk;
|
protected $chunk;
|
||||||
|
private string $tiles;
|
||||||
/** @var int */
|
/** @var int */
|
||||||
protected $chunkX;
|
protected $chunkX;
|
||||||
/** @var int */
|
/** @var int */
|
||||||
@ -52,13 +53,15 @@ class ChunkRequestTask extends AsyncTask{
|
|||||||
$this->compressionLevel = $level->getServer()->networkCompressionLevel;
|
$this->compressionLevel = $level->getServer()->networkCompressionLevel;
|
||||||
|
|
||||||
$this->chunk = $chunk->fastSerialize();
|
$this->chunk = $chunk->fastSerialize();
|
||||||
|
$this->tiles = $chunk->networkSerializeTiles();
|
||||||
|
|
||||||
$this->chunkX = $chunkX;
|
$this->chunkX = $chunkX;
|
||||||
$this->chunkZ = $chunkZ;
|
$this->chunkZ = $chunkZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onRun(){
|
public function onRun(){
|
||||||
$chunk = Chunk::fastDeserialize($this->chunk);
|
$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 = new BatchPacket();
|
||||||
$batch->addPacket($pk);
|
$batch->addPacket($pk);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user