From baeac2eb07f60c1917d9bb3effb9fdf51690afe4 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 30 Nov 2021 22:19:28 +0000 Subject: [PATCH 1/6] Fixed tiles not being sent with chunks --- src/pocketmine/level/format/Chunk.php | 13 ++++++++++++- src/pocketmine/level/format/io/ChunkRequestTask.php | 5 ++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/level/format/Chunk.php b/src/pocketmine/level/format/Chunk.php index 2055862c6..d20f08725 100644 --- a/src/pocketmine/level/format/Chunk.php +++ b/src/pocketmine/level/format/Chunk.php @@ -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(); diff --git a/src/pocketmine/level/format/io/ChunkRequestTask.php b/src/pocketmine/level/format/io/ChunkRequestTask.php index 9cf66ce2b..1d54a2454 100644 --- a/src/pocketmine/level/format/io/ChunkRequestTask.php +++ b/src/pocketmine/level/format/io/ChunkRequestTask.php @@ -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); From 6b7d0307afb36a7faca2dd65734e15000baf17ba Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 30 Nov 2021 22:27:42 +0000 Subject: [PATCH 2/6] Release 3.26.1 --- changelogs/3.26.md | 3 +++ src/pocketmine/VersionInfo.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/changelogs/3.26.md b/changelogs/3.26.md index 9ee4332c0..323c49c74 100644 --- a/changelogs/3.26.md +++ b/changelogs/3.26.md @@ -9,3 +9,6 @@ Plugin developers should **only** update their required API to this version if y # 3.26.0 - Added support for Minecraft: Bedrock Edition 1.18.0. - Removed compatibility with earlier versions. + +# 3.26.1 +- Fixed a bug in chunk sending that caused double chests to not be paired, signs to be blank, and various other issues. diff --git a/src/pocketmine/VersionInfo.php b/src/pocketmine/VersionInfo.php index d044a9e13..2473b68b4 100644 --- a/src/pocketmine/VersionInfo.php +++ b/src/pocketmine/VersionInfo.php @@ -34,5 +34,5 @@ const _VERSION_INFO_INCLUDED = true; const NAME = "PocketMine-MP"; const BASE_VERSION = "3.26.1"; -const IS_DEVELOPMENT_BUILD = true; +const IS_DEVELOPMENT_BUILD = false; const BUILD_CHANNEL = "stable"; From 20d6b698139e740545f15584aa5a1fef09c2b4c6 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 30 Nov 2021 22:27:42 +0000 Subject: [PATCH 3/6] 3.26.2 is next --- src/pocketmine/VersionInfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/VersionInfo.php b/src/pocketmine/VersionInfo.php index 2473b68b4..8699310ef 100644 --- a/src/pocketmine/VersionInfo.php +++ b/src/pocketmine/VersionInfo.php @@ -33,6 +33,6 @@ if(defined('pocketmine\_VERSION_INFO_INCLUDED')){ const _VERSION_INFO_INCLUDED = true; const NAME = "PocketMine-MP"; -const BASE_VERSION = "3.26.1"; -const IS_DEVELOPMENT_BUILD = false; +const BASE_VERSION = "3.26.2"; +const IS_DEVELOPMENT_BUILD = true; const BUILD_CHANNEL = "stable"; From 7665f4f443447b8c1584df794768948eb2804a51 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 30 Nov 2021 23:43:17 +0000 Subject: [PATCH 4/6] start.sh: remove 7 --- start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start.sh b/start.sh index fe4d95a8e..087b53db8 100755 --- a/start.sh +++ b/start.sh @@ -26,7 +26,7 @@ if [ "$PHP_BINARY" == "" ]; then elif [[ ! -z $(type php) ]]; then PHP_BINARY=$(type -p php) else - echo "Couldn't find a working PHP 7 binary, please use the installer." + echo "Couldn't find a working PHP binary, please use the installer." exit 1 fi fi From d535f020968db99fc4424f4123ab0642c7512fa1 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 30 Nov 2021 23:45:25 +0000 Subject: [PATCH 5/6] Make nicer errors for PHP binary not being found --- start.cmd | 17 +++++++++++++++-- start.ps1 | 7 ++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/start.cmd b/start.cmd index 929e5f7bb..747716ff8 100644 --- a/start.cmd +++ b/start.cmd @@ -2,11 +2,24 @@ TITLE PocketMine-MP server software for Minecraft: Bedrock Edition cd /d %~dp0 +set PHP_BINARY= + +where /q php.exe +if %ERRORLEVEL%==0 ( + set PHP_BINARY=php +) + if exist bin\php\php.exe ( + rem always use the local PHP binary if it exists set PHPRC="" set PHP_BINARY=bin\php\php.exe -) else ( - set PHP_BINARY=php +) + +if "%PHP_BINARY%"=="" ( + echo Couldn't find a PHP binary in system PATH or %~dp0\bin\php + echo Please refer to the installation instructions at https://doc.pmmp.io/en/rtfd/installation.html + pause + exit 1 ) if exist PocketMine-MP.phar ( diff --git a/start.ps1 b/start.ps1 index 2528dd691..19b2a6158 100644 --- a/start.ps1 +++ b/start.ps1 @@ -11,8 +11,13 @@ if($php -ne ""){ }elseif(Test-Path "bin\php\php.exe"){ $env:PHPRC = "" $binary = "bin\php\php.exe" -}else{ +}elseif((Get-Command php -ErrorAction SilentlyContinue)){ $binary = "php" +}else{ + echo "Couldn't find a PHP binary in system PATH or $pwd\bin\php" + echo "Please refer to the installation instructions at https://doc.pmmp.io/en/rtfd/installation.html" + pause + exit 1 } if($file -eq ""){ From cb0af44ccbdf948d54854fa783766c5771b5b1f8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 30 Nov 2021 23:51:35 +0000 Subject: [PATCH 6/6] start.sh: improve errors when PHP isn't found --- start.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/start.sh b/start.sh index 087b53db8..63a9a273b 100755 --- a/start.sh +++ b/start.sh @@ -23,10 +23,11 @@ if [ "$PHP_BINARY" == "" ]; then if [ -f ./bin/php7/bin/php ]; then export PHPRC="" PHP_BINARY="./bin/php7/bin/php" - elif [[ ! -z $(type php) ]]; then + elif [[ ! -z $(type php 2> /dev/null) ]]; then PHP_BINARY=$(type -p php) else - echo "Couldn't find a working PHP binary, please use the installer." + echo "Couldn't find a PHP binary in system PATH or $PWD/bin/php7/bin" + echo "Please refer to the installation instructions at https://doc.pmmp.io/en/rtfd/installation.html" exit 1 fi fi