Class ClientTags
Tags are loaded by the server, either the internal server in singleplayer or the connected server and synced to the client. This can be a pain point for interoperability, as a tag that does not exist on the server because it is part of a mod only present on the client will no longer be available to the client that may wish to query it.
Client Tags resolve that issue by lazily reading the tag json files within the mods on the side of the caller,
directly, allowing for mods to query tags such as ConventionalBlockTags
even when connected to a vanilla server.
Note that locally read client tags don't currently support Fabric's tag aliases. The aliasing system is only implemented on servers.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Set<Identifier> getOrCreateLocalTag(TagKey<?> tagKey) Loads a tag into the cache, recursively loading any contained tags along with it.static <T> booleanisInLocal(TagKey<T> tagKey, RegistryKey<T> registryKey) Checks if an entry is in a tag provided by the available mods.static <T> booleanisInWithLocalFallback(TagKey<T> tagKey, RegistryEntry<T> registryEntry) Checks if an entry is in a tag, for use with entries from a dynamic registry, such asBiomes.static <T> booleanisInWithLocalFallback(TagKey<T> tagKey, T entry) Checks if an entry is in a tag.
-
Method Details
-
getOrCreateLocalTag
Loads a tag into the cache, recursively loading any contained tags along with it.- Parameters:
tagKey- theTagKeyto load- Returns:
- a set of
Identifiers this tag contains
-
isInWithLocalFallback
Checks if an entry is in a tag.If the synced tag does exist, it is queried. If it does not exist, the tag populated from the available mods is checked, recursively checking the synced tags and entries contained within.
- Parameters:
tagKey- theTagKeyto being checkedentry- the entry to check- Returns:
- if the entry is in the given tag
-
isInWithLocalFallback
Checks if an entry is in a tag, for use with entries from a dynamic registry, such asBiomes.If the synced tag does exist, it is queried. If it does not exist, the tag populated from the available mods is checked, recursively checking the synced tags and entries contained within.
- Parameters:
tagKey- theTagKeyto be checkedregistryEntry- the entry to check- Returns:
- if the entry is in the given tag
-
isInLocal
Checks if an entry is in a tag provided by the available mods.- Parameters:
tagKey- theTagKeyto being checkedregistryKey- the entry to check- Returns:
- if the entry is in the given tag
-