Record Class DatapackRegistryGathererImpl

java.lang.Object
java.lang.Record
net.neoforged.neoforge.data.loading.DatapackRegistryGathererImpl
Record Components:
global - The gather of the global registry set, null if this is the global registry set.
id - The id of the gatherer, either 'Global' for the global registry set, or the mod id specifying the set of mod ids to generate for.
builder - The RegistrySetBuilders to register the datapack registry objects to, depending on their registry's layer.
modIds - The set of mod ids to generate the registry elements of.
hasEntries - A helper for keeping track of whether any entries were registered to the RegistrySetBuilders.
All Implemented Interfaces:
DatapackRegistryGatherer

record DatapackRegistryGathererImpl(@Nullable DatapackRegistryGatherer global, String id, DatapackRegistrySets<RegistrySetBuilder> builder, Set<String> modIds, DatapackRegistrySets<org.apache.commons.lang3.mutable.MutableBoolean> hasEntries) extends Record implements DatapackRegistryGatherer
An internal implementation of DatapackRegistryGatherer.
  • Field Details

  • Constructor Details

    • DatapackRegistryGathererImpl

      DatapackRegistryGathererImpl(DatapackRegistryGatherer global, String id, Set<String> modIds)
      Used to construct the registry gatherer for a subset of mod ids.
      Parameters:
      global - The global registry gatherer.
      id - The mod id specifying the subset of mod ids to generate for.
      modIds - The set of mod ids to generate the registry elements of.
    • DatapackRegistryGathererImpl

      DatapackRegistryGathererImpl(Set<String> modIds)
      Used to construct the global registry gatherer.
      Parameters:
      modIds - The set of mod ids to generate the registry elements of.
    • DatapackRegistryGathererImpl

      DatapackRegistryGathererImpl(@Nullable DatapackRegistryGatherer global, String id, DatapackRegistrySets<RegistrySetBuilder> builder, Set<String> modIds, DatapackRegistrySets<org.apache.commons.lang3.mutable.MutableBoolean> hasEntries)
      Creates an instance of a DatapackRegistryGathererImpl record class.
      Parameters:
      global - the value for the global record component
      id - the value for the id record component
      builder - the value for the builder record component
      modIds - the value for the modIds record component
      hasEntries - the value for the hasEntries record component
  • Method Details

    • add

      public <T> DatapackRegistryGatherer add(ResourceKey<? extends Registry<T>> registryKey, SingleRegistryBootstrap<T> bootstrap) throws IllegalArgumentException
      Description copied from interface: DatapackRegistryGatherer

      Adds a bootstrap for the provided registry ResourceKey to 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 NewDatapackRegistryEvent first; otherwise, an exception will be thrown.

      Specified by:
      add in interface DatapackRegistryGatherer
      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 the registryKey does not belong to a datapack registry.
    • add

      Description copied from interface: DatapackRegistryGatherer

      Adds 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 NewDatapackRegistryEvent first. Additionally, all requested registries must be part of the same registry layer. Otherwise, an exception will be thrown.

      Specified by:
      add in interface DatapackRegistryGatherer
      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.
    • isWorldOrDimensionRegistry

      private static boolean isWorldOrDimensionRegistry(ResourceKey<? extends Registry<?>> registryKey)
      Returns whether the provided ResourceKey belongs to a datapack registry in the dimension or world layer.
      Parameters:
      registryKey - The ResourceKey of the registry to check.
      Returns:
      whether the provided ResourceKey belongs to a datapack registry in the dimension or world layer
    • createGlobal

      An internal method used to create the global registry set used for generation.
      Parameters:
      worldRegistries - The vanilla world registries.
      Returns:
      The registry set containing the modded registries for each layer.
    • createSub

      void createSub(DataGenerator generator, DatapackRegistrySets<CompletableFuture<HolderLookup.Provider>> registrySets, int index)
      An internal method used to add the data providers for any mod id subset, if any entries were added.
      Parameters:
      generator - The data generator.
      registrySets - The global registries for each layer.
      index - A unique identifier to prevent name collisions.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • global

      Returns the value of the global record component.
      Returns:
      the value of the global record component
    • id

      public String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • builder

      Returns the value of the builder record component.
      Returns:
      the value of the builder record component
    • modIds

      public Set<String> modIds()
      Returns the value of the modIds record component.
      Returns:
      the value of the modIds record component
    • hasEntries

      public DatapackRegistrySets<org.apache.commons.lang3.mutable.MutableBoolean> hasEntries()
      Returns the value of the hasEntries record component.
      Returns:
      the value of the hasEntries record component