Package net.minecraftforge.common
Class ForgeTagHandler
java.lang.Object
net.minecraftforge.common.ForgeTagHandler
-
Field Summary
Modifier and TypeFieldDescriptionprivate static Set<ResourceLocation>
private static org.apache.logging.log4j.Logger
private static boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Map<ResourceLocation,TagLoader<?>>
Creates a map for custom tag type to tag readerstatic <T extends IForgeRegistryEntry<T>>
Tags.IOptionalNamedTag<T>createOptionalTag(ResourceLocation registryName, ResourceLocation name)
Helper method for creating optional tags for custom forge registries.static <T extends IForgeRegistryEntry<T>>
Tags.IOptionalNamedTag<T>createOptionalTag(ResourceLocation registryName, ResourceLocation name, Set<Supplier<T>> defaults)
Helper method for creating optional tags for custom forge registries.static <T extends IForgeRegistryEntry<T>>
Tags.IOptionalNamedTag<T>createOptionalTag(IForgeRegistry<T> registry, ResourceLocation name)
Helper method that creates an optional tag for a forge registry, erroring if the registry doesn't support custom tag types.static <T extends IForgeRegistryEntry<T>>
Tags.IOptionalNamedTag<T>createOptionalTag(IForgeRegistry<T> registry, ResourceLocation name, Set<Supplier<T>> defaults)
Helper method that creates an optional tag for a forge registry, erroring if the registry doesn't support custom tag types.static Set<ResourceLocation>
Gets the all the registry names of registries that support custom tag types.private static <T extends IForgeRegistryEntry<T>>
StaticTagHelper<T>getTagHelper(IForgeRegistry<T> registry)
getWrapperRegistry(ResourceKey<? extends Registry<T>> key, Optional<? extends Registry<T>> vanillaReg)
Wraps the forge registry if it supports tags into the internal registry for use in serializationstatic <T extends IForgeRegistryEntry<T>>
Tag.Named<T>makeWrapperTag(ResourceLocation registryName, ResourceLocation name)
Helper method for creating named tags for custom forge registries.static <T extends IForgeRegistryEntry<T>>
Tag.Named<T>makeWrapperTag(IForgeRegistry<T> registry, ResourceLocation name)
Helper method that creates a named tag for a forge registry, erroring if the registry doesn't support custom tag types.static TagContainer
reinjectOptionalTags(TagContainer tagCollectionSupplier)
Helper to reinject missing optional tags.static void
setCustomTagTypes(Set<ResourceLocation> customTagTypesNames)
Sets the set containing the resource locations representing the registry name of each forge registry that supports custom tag types.private static void
validateRegistrySupportsTags(IForgeRegistry<?> registry)
-
Field Details
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER -
customTagTypeNames
-
tagTypesSet
private static boolean tagTypesSet
-
-
Constructor Details
-
ForgeTagHandler
public ForgeTagHandler()
-
-
Method Details
-
getTagHelper
@Nullable private static <T extends IForgeRegistryEntry<T>> StaticTagHelper<T> getTagHelper(IForgeRegistry<T> registry) -
validateRegistrySupportsTags
-
makeWrapperTag
public static <T extends IForgeRegistryEntry<T>> Tag.Named<T> makeWrapperTag(IForgeRegistry<T> registry, ResourceLocation name)Helper method that creates a named tag for a forge registry, erroring if the registry doesn't support custom tag types. If the custom tag types have not been set yet, this method falls back and creates the tag reference delaying adding it to the tag registry to allow for statically initializing and referencing the tag.- Type Parameters:
T
- Type of the registry- Parameters:
registry
- Registry the tag is forname
- Name of the tag- Returns:
- A named tag
-
createOptionalTag
public static <T extends IForgeRegistryEntry<T>> Tags.IOptionalNamedTag<T> createOptionalTag(IForgeRegistry<T> registry, ResourceLocation name)Helper method that creates an optional tag for a forge registry, erroring if the registry doesn't support custom tag types. If the custom tag types have not been set yet, this method falls back and creates the tag reference delaying adding it to the tag registry to allow for statically initializing and referencing the tag.- Type Parameters:
T
- Type of the registry- Parameters:
registry
- Registry the tag is forname
- Name of the tag- Returns:
- An optional tag
-
createOptionalTag
public static <T extends IForgeRegistryEntry<T>> Tags.IOptionalNamedTag<T> createOptionalTag(IForgeRegistry<T> registry, ResourceLocation name, @Nullable Set<Supplier<T>> defaults)Helper method that creates an optional tag for a forge registry, erroring if the registry doesn't support custom tag types. If the custom tag types have not been set yet, this method falls back and creates the tag reference delaying adding it to the tag registry to allow for statically initializing and referencing the tag.- Type Parameters:
T
- Type of the registry- Parameters:
registry
- Registry the tag is forname
- Name of the tagdefaults
- Default values for the optional tag- Returns:
- An optional tag
-
makeWrapperTag
public static <T extends IForgeRegistryEntry<T>> Tag.Named<T> makeWrapperTag(ResourceLocation registryName, ResourceLocation name)Helper method for creating named tags for custom forge registries. If the custom tag types have not been set yet, this method falls back and creates the tag reference delaying adding it to the tag registry to allow for statically initializing and referencing the tag.- Type Parameters:
T
- Type of the registry- Parameters:
registryName
- Name of the registry the tag is forname
- Name of the tag- Returns:
- A named tag
-
createOptionalTag
public static <T extends IForgeRegistryEntry<T>> Tags.IOptionalNamedTag<T> createOptionalTag(ResourceLocation registryName, ResourceLocation name)Helper method for creating optional tags for custom forge registries. If the custom tag types have not been set yet, this method falls back and creates the tag reference delaying adding it to the tag registry to allow for statically initializing and referencing the tag.- Type Parameters:
T
- Type of the registry- Parameters:
registryName
- Name of the registry the tag is forname
- Name of the tag- Returns:
- An optional tag
-
createOptionalTag
public static <T extends IForgeRegistryEntry<T>> Tags.IOptionalNamedTag<T> createOptionalTag(ResourceLocation registryName, ResourceLocation name, @Nullable Set<Supplier<T>> defaults)Helper method for creating optional tags for custom forge registries. If the custom tag types have not been set yet, this method falls back and creates the tag reference delaying adding it to the tag registry to allow for statically initializing and referencing the tag.- Type Parameters:
T
- Type of the registry- Parameters:
registryName
- Name of the registry the tag is forname
- Name of the tagdefaults
- Default values for the optional tag- Returns:
- An optional tag
-
getCustomTagTypeNames
Gets the all the registry names of registries that support custom tag types. -
setCustomTagTypes
Sets the set containing the resource locations representing the registry name of each forge registry that supports custom tag types. -
createCustomTagTypeReaders
Creates a map for custom tag type to tag reader -
getWrapperRegistry
public static <T> Optional<? extends Registry<T>> getWrapperRegistry(ResourceKey<? extends Registry<T>> key, Optional<? extends Registry<T>> vanillaReg)Wraps the forge registry if it supports tags into the internal registry for use in serialization -
reinjectOptionalTags
Helper to reinject missing optional tags.
-