Class GatherDataRegistryEntriesEvent
- All Implemented Interfaces:
IModBusEvent, DatapackRegistryGatherer, GlobalDatapackRegistryGatherer
Gathers the datapack registry entries used for data generation. This is fired for all mods to collect all registry objects, but only those added via '--mod' in the run arguments will have their contents generated.
Usage:
@SubscribeEvent
public static void gatherRegistries(GatherDataRegistryEntriesEvent event) {
// Create a bootstrap for the desired registries.
event.add(Registries.PLACED_FEATURE, context -> { /*...*/ })
// All methods are chainable and are added to the appropriate layer.
.add(Registries.PREDICATE, context -> { /*...*/ })
// Extension methods for registries with custom providers.
.advancement(output -> { /*...*/ });
// Generating entries for a different mod id.
event.gatherFor("othermod")
.add(Registries.INSTRUMENT, context -> { /*...*/ });
}
This event is not cancellable.
This event is fired on the mod-specific event bus, during data generation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final GlobalDatapackRegistryGathererprivate final ModContainer -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionadd(MultiRegistryBootstrap bootstrap) Adds a bootstrap for the requested registries to register entries for use during data generation.add(ResourceKey<? extends Registry<T>> registryKey, SingleRegistryBootstrap<T> bootstrap) Adds a bootstrap for the provided registryResourceKeyto register entries for use during data generation.Gathers the datapack registry entries for a subset of mod ids different from the caller's mod id.Returns the container of the mod.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DatapackRegistryGatherer
advancement, lootTable, recipe
-
Field Details
-
modContainer
-
delegate
-
-
Constructor Details
-
GatherDataRegistryEntriesEvent
@Internal public GatherDataRegistryEntriesEvent(ModContainer mc, GlobalDatapackRegistryGatherer delegate)
-
-
Method Details
-
getModContainer
Returns the container of the mod.- Returns:
- the container of the mod
-
gatherFor
Description copied from interface:GlobalDatapackRegistryGathererGathers the datapack registry entries for a subset of mod ids different from the caller's mod id. These entries will generate if the caller's mod id is added via '--mod' in the run arguments, not the mod ids passed into this method.
// Assume there is a mod "examplemod" public static void gatherRegistries(GlobalDatapackRegistryGatherer registries) { // Gather entries for a mod other than "examplemod" // Entries gathered here will also generate if '--mod examplemod' is included in the run arguments, // as "examplemod" added the entries (e.g., for mod interoperability) registries.gatherFor("othermod") .add(Registries.INSTRUMENT, context -> { /*...*/ }); }Entries added using this method will still be available in the global registry set for any mod to use. If trying to create a built-in datapack added via
AddPackFindersEvent, then it should be handled viaPackGenerator.createWorldRegistryObjects(RegistrySetBuilder, Set)andPackGenerator.createReloadableRegistryObjects(RegistrySetBuilder, Set), respectively.- Specified by:
gatherForin interfaceGlobalDatapackRegistryGatherer- Parameters:
modId- The first mod id to gather registry entries for.modIds- Any additional mod ids to gather the registry entries for.- Returns:
- A gatherer for the specified mod ids.
-
add
public <T> DatapackRegistryGatherer add(ResourceKey<? extends Registry<T>> registryKey, SingleRegistryBootstrap<T> bootstrap) throws IllegalArgumentException Description copied from interface:DatapackRegistryGathererAdds a bootstrap for the provided registry
ResourceKeyto register entries for use during data generation. The layer each registry belongs to is handled internally.Analogous to
RegistrySetBuilder.add(ResourceKey, SingleRegistryBootstrap).Custom datapack registries must be registered via
NewDatapackRegistryEventfirst; otherwise, an exception will be thrown.- Specified by:
addin interfaceDatapackRegistryGatherer- Type Parameters:
T- The type of the registry object.- Parameters:
registryKey- The key of the registry.bootstrap- The bootstrap used to register entries to the registry.- Returns:
- This gatherer.
- Throws:
IllegalArgumentException- If theregistryKeydoes not belong to a datapack registry.
-
add
public DatapackRegistryGatherer add(MultiRegistryBootstrap bootstrap) throws IllegalArgumentException Description copied from interface:DatapackRegistryGathererAdds a bootstrap for the requested registries to register entries for use during data generation. The layer the registries belong to is handled internally.
Analogous to
RegistrySetBuilder.add(MultiRegistryBootstrap).Custom datapack registries must be registered via
NewDatapackRegistryEventfirst. Additionally, all requested registries must be part of the same registry layer. Otherwise, an exception will be thrown.- Specified by:
addin interfaceDatapackRegistryGatherer- Parameters:
bootstrap- The bootstrap used to register entries to the requested registries.- Returns:
- This gatherer.
- Throws:
IllegalArgumentException- If not all requested registries are datapack registries in the same layer.
-