Interface ITagManager<V>
- All Known Implementing Classes:
ForgeRegistryTagManager
A tag manager holds information about all tags currently bound to a forge registry.
This should be preferred to any
Holder
-related methods.-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds defaults to an existing tag key.createOptionalTagKey
(@NotNull ResourceLocation location, @NotNull Set<? extends Supplier<V>> defaults) Creates a tag key that will use the set of defaults if the tag is not loaded from any datapacks.createTagKey
(@NotNull ResourceLocation location) Creates a tag key based on the location and the forge registry linked to this tag manager.@NotNull Optional<IReverseTag<V>>
getReverseTag
(V value) Queries a reverse tag for a given value from the forge registry linked to this tag manager.Queries this tag manager for a tag with the given tag key.boolean
isKnownTagName
(@NotNull TagKey<V> name) Checks whether the given tag key exists in this tag manager and is bound.stream()
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
getTag
Queries this tag manager for a tag with the given tag key. If it does not exist, this will create an empty tag and return it.- See Also:
-
getReverseTag
Queries a reverse tag for a given value from the forge registry linked to this tag manager. A reverse tag stores all tags that the givenvalue
is contained in.- Parameters:
value
- A value currently registered to the forge registry linked to this tag manager- Returns:
- A reverse tag for the given value, or an empty optional if the value is not registered
-
isKnownTagName
Checks whether the given tag key exists in this tag manager and is bound. UnlikegetTag(TagKey)
, this method will not create the tag if it does not exist.- See Also:
-
stream
- Returns:
- A stream of all tags stored in this tag manager, bound or unbound.
-
getTagNames
- Returns:
- A stream of all tag keys stored in this tag manager, bound or unbound.
-
createTagKey
Creates a tag key based on the location and the forge registry linked to this tag manager. Custom registries can useDeferredRegister.createTagKey(ResourceLocation)
to create tag keys before the tag manager is created. -
createOptionalTagKey
@NotNull @NotNull TagKey<V> createOptionalTagKey(@NotNull @NotNull ResourceLocation location, @NotNull @NotNull Set<? extends Supplier<V>> defaults) Creates a tag key that will use the set of defaults if the tag is not loaded from any datapacks. Useful on the client side when a server may not provide a specific tag. Custom registries can useDeferredRegister.addOptionalTagDefaults(TagKey, Set)
to create tag keys before the tag manager is created. -
addOptionalTagDefaults
void addOptionalTagDefaults(@NotNull @NotNull TagKey<V> name, @NotNull @NotNull Set<? extends Supplier<V>> defaults) Adds defaults to an existing tag key. The set of defaults will be bound to the tag if the tag is not loaded from any datapacks. Useful on the client side when a server may not provide a specific tag. Custom registries can useDeferredRegister.addOptionalTagDefaults(TagKey, Set)
to add defaults before the tag manager is created.
-