BlockFactory: split up static ID mapping registration from other things

this is actually HUGELY WASTEFUL on memory. An average of 3 MB is wasted per AsyncWorker on this.
This commit is contained in:
Dylan K. Taylor 2018-06-01 10:28:53 +01:00
parent 515e4aabc4
commit d535fe20a3
2 changed files with 9 additions and 6 deletions

View File

@ -1633,6 +1633,7 @@ class Server{
Entity::init(); Entity::init();
Tile::init(); Tile::init();
BlockFactory::init(); BlockFactory::init();
BlockFactory::registerStaticRuntimeIdMappings();
Enchantment::init(); Enchantment::init();
ItemFactory::init(); ItemFactory::init();
Item::initCreativeItems(); Item::initCreativeItems();

View File

@ -323,12 +323,6 @@ class BlockFactory{
//TODO: STRUCTURE_BLOCK //TODO: STRUCTURE_BLOCK
//TODO: RESERVED6 //TODO: RESERVED6
/** @var mixed[] $runtimeIdMap */
$runtimeIdMap = json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "runtimeid_table.json"), true);
foreach($runtimeIdMap as $obj){
self::registerMapping($obj["runtimeID"], $obj["id"], $obj["data"]);
}
} }
/** /**
@ -419,6 +413,14 @@ class BlockFactory{
return $b !== null and !($b instanceof UnknownBlock); return $b !== null and !($b instanceof UnknownBlock);
} }
public static function registerStaticRuntimeIdMappings() : void{
/** @var mixed[] $runtimeIdMap */
$runtimeIdMap = json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "runtimeid_table.json"), true);
foreach($runtimeIdMap as $obj){
self::registerMapping($obj["runtimeID"], $obj["id"], $obj["data"]);
}
}
/** /**
* @internal * @internal
* *