Package net.minecraftforge.common
Class ForgeTagHandler
java.lang.Object
net.minecraftforge.common.ForgeTagHandler
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Helper storage class for keeping track of various data for all custom tag types in the NetworkTagReader to make the code easier to read. -
Field Summary
Modifier and TypeFieldDescriptionprivate static Set<ResourceLocation>
private static Map<ResourceLocation,
ITagCollection<?>> private static final org.apache.logging.log4j.Logger
private static boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Map<ResourceLocation,
TagCollectionReader<?>> 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.getCustomTagTypeReloadResults
(IResourceManager resourceManager, Executor backgroundExecutor, Map<ResourceLocation, TagCollectionReader<?>> readers) Gets the completable future containing the reload results for all custom tag types.static Map<ResourceLocation,
ITagCollection<?>> Gets a map of registry name to tag collection for all custom tag types.private static <T extends IForgeRegistryEntry<T>>
TagRegistry<T>getTagRegistry
(IForgeRegistry<T> registry) static <T extends IForgeRegistryEntry<T>>
ITag.INamedTag<T>makeWrapperTag
(ResourceLocation registryName, ResourceLocation name) Helper method for creating named tags for custom forge registries.static <T extends IForgeRegistryEntry<T>>
ITag.INamedTag<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 ITagCollectionSupplier
populateTagCollectionManager
(ITagCollection<Block> blockTags, ITagCollection<Item> itemTags, ITagCollection<Fluid> fluidTags, ITagCollection<EntityType<?>> entityTypeTags) Used to ensure that all custom tag types have a defaulted collection when vanilla is initializing a defaulted TagCollectionManagerstatic void
Add all the missing optional tags back into the custom tag types tag collectionsstatic void
resetCachedTagCollections
(boolean makeEmpty, boolean withOptional) Resets the cached collections for the various custom tag types.static void
setCustomTagTypes
(Set<ResourceLocation> customTagTypes) Sets the set containing the resource locations representing the registry name of each forge registry that supports custom tag types.static void
updateCustomTagTypes
(List<ForgeTagHandler.TagCollectionReaderInfo> tagCollectionReaders) Updates the custom tag types' tags from reloading via NetworkTagManagerstatic void
Updates the custom tag types' tags from packetprivate static void
validateRegistrySupportsTags
(IForgeRegistry<?> registry) static ITagCollectionSupplier
withNoCustom
(ITagCollectionSupplier tagCollectionSupplier) Gets anITagCollectionSupplier
with empty custom tag type collections to allow for checking if the client is requiring any tags of custom tag types.static ITagCollectionSupplier
withSpecificCustom
(ITagCollectionSupplier tagCollectionSupplier, Map<ResourceLocation, ITagCollection<?>> customTagTypes) Gets anITagCollectionSupplier
with specific custom tag types for testing if any tags are missing.
-
Field Details
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER -
customTagTypes
-
customTagTypeNames
-
tagTypesSet
private static boolean tagTypesSet
-
-
Constructor Details
-
ForgeTagHandler
public ForgeTagHandler()
-
-
Method Details
-
getTagRegistry
@Nullable private static <T extends IForgeRegistryEntry<T>> TagRegistry<T> getTagRegistry(IForgeRegistry<T> registry) -
validateRegistrySupportsTags
-
makeWrapperTag
public static <T extends IForgeRegistryEntry<T>> ITag.INamedTag<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>> ITag.INamedTag<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. -
getCustomTagTypes
Gets a map of registry name to tag collection for all 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 -
resetCachedTagCollections
public static void resetCachedTagCollections(boolean makeEmpty, boolean withOptional) Resets the cached collections for the various custom tag types. -
populateTagCollectionManager
public static ITagCollectionSupplier populateTagCollectionManager(ITagCollection<Block> blockTags, ITagCollection<Item> itemTags, ITagCollection<Fluid> fluidTags, ITagCollection<EntityType<?>> entityTypeTags) Used to ensure that all custom tag types have a defaulted collection when vanilla is initializing a defaulted TagCollectionManager -
updateCustomTagTypes
public static void updateCustomTagTypes(List<ForgeTagHandler.TagCollectionReaderInfo> tagCollectionReaders) Updates the custom tag types' tags from reloading via NetworkTagManager -
updateCustomTagTypes
Updates the custom tag types' tags from packet -
getCustomTagTypeReloadResults
public static CompletableFuture<List<ForgeTagHandler.TagCollectionReaderInfo>> getCustomTagTypeReloadResults(IResourceManager resourceManager, Executor backgroundExecutor, Map<ResourceLocation, TagCollectionReader<?>> readers) Gets the completable future containing the reload results for all custom tag types. -
reinjectOptionalTagsCustomTypes
public static void reinjectOptionalTagsCustomTypes()Add all the missing optional tags back into the custom tag types tag collections -
withNoCustom
Gets anITagCollectionSupplier
with empty custom tag type collections to allow for checking if the client is requiring any tags of custom tag types. -
withSpecificCustom
public static ITagCollectionSupplier withSpecificCustom(ITagCollectionSupplier tagCollectionSupplier, Map<ResourceLocation, ITagCollection<?>> customTagTypes) Gets anITagCollectionSupplier
with specific custom tag types for testing if any tags are missing.
-