RuntimeBlockMapping: add a type check for decoded NBT root type

this is kinda redundant since this function can blow up in so many other ways anyway, but it makes PHPStan happy, so it'll do.
This commit is contained in:
Dylan K. Taylor 2019-12-02 08:21:42 +00:00
parent 8594cb3e74
commit abf8081ebc

View File

@ -53,6 +53,9 @@ final class RuntimeBlockMapping{
public static function init() : void{
$legacyIdMap = json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "vanilla/block_id_map.json"), true);
$tag = (new BigEndianNBTStream())->read(file_get_contents(\pocketmine\RESOURCE_PATH . "vanilla/runtime_block_states.dat"));
if(!($tag instanceof CompoundTag)){ //this is a little redundant currently, but good for auto complete and makes phpstan happy
throw new \RuntimeException("Invalid blockstates table, expected CompoundTag root");
}
$decompressed = [];