First pass ext-encoding support (high-level network I/O and read-only data) (#6799)

This implements ext-encoding only in high-level network I/O (only BedrockProtocol and stuff implemented in PM) and read-only data.
This should net a significant performance advantage while being low-risk in the case of critical issues with the extension. Any problems affecting protocol won't do permanent damage while being fairly easy to debug.

Next passes will integrate ext-encoding versions of RakLib, RakLibIpc and NBT, as well as generally using ext-encoding for writeable data.
This commit is contained in:
Dylan T.
2025-09-25 17:32:38 +01:00
committed by GitHub
parent 6fede8a67f
commit 3336cda34a
18 changed files with 177 additions and 156 deletions

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\network\mcpe\cache;
use pmmp\encoding\BE;
use pocketmine\crafting\CraftingManager;
use pocketmine\crafting\FurnaceType;
use pocketmine\crafting\ShapedRecipe;
@@ -41,7 +42,6 @@ use pocketmine\network\mcpe\protocol\types\recipe\ShapedRecipe as ProtocolShaped
use pocketmine\network\mcpe\protocol\types\recipe\ShapelessRecipe as ProtocolShapelessRecipe;
use pocketmine\timings\Timings;
use pocketmine\utils\AssumptionFailedError;
use pocketmine\utils\Binary;
use pocketmine\utils\SingletonTrait;
use Ramsey\Uuid\Uuid;
use function array_map;
@@ -99,7 +99,7 @@ final class CraftingDataCache{
};
$recipesWithTypeIds[] = new ProtocolShapelessRecipe(
CraftingDataPacket::ENTRY_SHAPELESS,
Binary::writeInt($recipeNetId),
BE::packUnsignedInt($recipeNetId), //TODO: this should probably be changed to something human-readable
array_map($converter->coreRecipeIngredientToNet(...), $recipe->getIngredientList()),
array_map($converter->coreItemStackToNet(...), $recipe->getResults()),
$nullUUID,
@@ -118,7 +118,7 @@ final class CraftingDataCache{
}
$recipesWithTypeIds[] = $r = new ProtocolShapedRecipe(
CraftingDataPacket::ENTRY_SHAPED,
Binary::writeInt($recipeNetId),
BE::packUnsignedInt($recipeNetId), //TODO: this should probably be changed to something human-readable
$inputs,
array_map($converter->coreItemStackToNet(...), $recipe->getResults()),
$nullUUID,