New, more efficient blockstate table format

this reduces the file size by ~90%.
This commit is contained in:
Dylan K. Taylor 2019-04-25 17:28:22 +01:00
parent 898009a91b
commit 2bdbb9794c
2 changed files with 15 additions and 2 deletions

View File

@ -50,7 +50,20 @@ final class RuntimeBlockMapping{
public static function init() : void{
$legacyIdMap = json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "legacy_id_map.json"), true);
self::$bedrockKnownStates = self::randomizeTable(json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "runtimeid_table.json"), true));
$compressedTable = json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "runtimeid_table.json"), true);
$decompressed = [];
foreach($compressedTable as $prefix => $entries){
foreach($entries as $shortStringId => $states){
foreach($states as $state){
$decompressed[] = [
"name" => "$prefix:$shortStringId",
"data" => $state
];
}
}
}
self::$bedrockKnownStates = self::randomizeTable($decompressed);
foreach(self::$bedrockKnownStates as $k => $obj){
//this has to use the json offset to make sure the mapping is consistent with what we send over network, even though we aren't using all the entries

File diff suppressed because one or more lines are too long