diff --git a/src/pocketmine/block/BlockFactory.php b/src/pocketmine/block/BlockFactory.php index 92784bfa1..237224b41 100644 --- a/src/pocketmine/block/BlockFactory.php +++ b/src/pocketmine/block/BlockFactory.php @@ -31,8 +31,6 @@ use pocketmine\utils\MainLogger; * Manages block registration and instance creation */ class BlockFactory{ - /** @var \SplFixedArray */ - private static $list = null; /** @var \SplFixedArray */ private static $fullList = null; @@ -65,7 +63,6 @@ class BlockFactory{ * this if you need to reset the block factory back to its original defaults for whatever reason. */ public static function init() : void{ - self::$list = new \SplFixedArray(256); self::$fullList = new \SplFixedArray(4096); self::$light = new \SplFixedArray(256); @@ -327,12 +324,6 @@ class BlockFactory{ //TODO: RESERVED6 - foreach(self::$list as $id => $block){ - if($block === null){ - self::registerBlock(new UnknownBlock($id)); - } - } - /** @var mixed[] $runtimeIdMap */ $runtimeIdMap = json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "runtimeid_table.json"), true); foreach($runtimeIdMap as $obj){ @@ -360,8 +351,6 @@ class BlockFactory{ throw new \RuntimeException("Trying to overwrite an already registered block"); } - self::$list[$id] = clone $block; - for($meta = 0; $meta < 16; ++$meta){ $variant = clone $block; $variant->setDamage($meta); @@ -392,8 +381,8 @@ class BlockFactory{ } try{ - if(self::$fullList !== null){ - $block = clone self::$fullList[($id << 4) | $meta]; + if(self::$fullList !== null and self::$fullList[$idx = ($id << 4) | $meta] !== null){ + $block = clone self::$fullList[$idx]; }else{ $block = new UnknownBlock($id, $meta); } @@ -426,7 +415,7 @@ class BlockFactory{ * @return bool */ public static function isRegistered(int $id) : bool{ - $b = self::$list[$id]; + $b = self::$fullList[$id << 4]; return $b !== null and !($b instanceof UnknownBlock); }