$states */ public function __construct( private array $states ){ $this->lookupCache = new BlockStateLookupCache($this->states); } public function getDataFromStateId(int $networkRuntimeId) : ?BlockStateData{ return $this->states[$networkRuntimeId] ?? null; } /** * Searches for the appropriate state ID which matches the given blockstate NBT. * Returns null if there were no matches. */ public function lookupStateIdFromData(BlockStateData $data) : ?int{ return $this->lookupCache->lookupStateId($data); } /** * Returns an array mapping runtime ID => blockstate data. * @return BlockStateData[] * @phpstan-return array */ public function getStates() : array{ return $this->states; } public static function loadFromString(string $contents) : self{ return new self(array_map( fn(TreeRoot $root) => BlockStateData::fromNbt($root->mustGetCompoundTag()), (new NetworkNbtSerializer())->readMultiple($contents) )); } }