From d535fe20a39456b88780d763756916cfec9f6d5d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 1 Jun 2018 10:28:53 +0100 Subject: [PATCH] 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. --- src/pocketmine/Server.php | 1 + src/pocketmine/block/BlockFactory.php | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index f90556ee1..10b471595 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -1633,6 +1633,7 @@ class Server{ Entity::init(); Tile::init(); BlockFactory::init(); + BlockFactory::registerStaticRuntimeIdMappings(); Enchantment::init(); ItemFactory::init(); Item::initCreativeItems(); diff --git a/src/pocketmine/block/BlockFactory.php b/src/pocketmine/block/BlockFactory.php index 237224b41..0cc88463e 100644 --- a/src/pocketmine/block/BlockFactory.php +++ b/src/pocketmine/block/BlockFactory.php @@ -323,12 +323,6 @@ class BlockFactory{ //TODO: STRUCTURE_BLOCK //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); } + 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 *