45 private static function make() :
self{
46 $map = json_decode(Filesystem::fileGetContents(BedrockDataFiles::ITEM_TAGS_JSON),
true, flags: JSON_THROW_ON_ERROR);
51 foreach(Utils::promoteKeys($map) as $tagName => $ids){
52 if(!is_string($tagName)){
61 throw new AssumptionFailedError(
"Invalid item tag $tagName, expected string as ID, got " . gettype($id));
65 $cleanMap[$tagName] = $cleanIds;
68 return new self($cleanMap);
75 private array $tagToIdsMap = [];
84 foreach(Utils::stringifyKeys($tagToIds) as $tag => $ids){
86 $this->tagToIdsMap[$tag][$id] =
true;
96 return array_keys($this->tagToIdsMap[$tag] ?? []);
99 public function tagContainsId(
string $tag,
string $id) : bool{
100 return isset($this->tagToIdsMap[$tag][$id]);
103 public function addIdToTag(
string $tag,
string $id) : void{
104 $this->tagToIdsMap[$tag][$id] = true;