Class BaseMappedRegistry<T>

java.lang.Object
net.neoforged.neoforge.registries.BaseMappedRegistry<T>
All Implemented Interfaces:
com.mojang.serialization.Keyable, Iterable<T>, IdMap<T>, Registry<T>, IRegistryExtension<T>
Direct Known Subclasses:
MappedRegistry

@Internal public abstract class BaseMappedRegistry<T> extends Object implements Registry<T>
  • Field Details

  • Constructor Details

    • BaseMappedRegistry

      public BaseMappedRegistry()
  • Method Details

    • setSync

      void setSync(boolean sync)
    • doesSync

      public boolean doesSync()
      Description copied from interface: IRegistryExtension
      Returns whether this registry should be synced to clients.
      Specified by:
      doesSync in interface IRegistryExtension<T>
      Returns:
      whether this registry should be synced to clients
    • setMaxId

      void setMaxId(int maxId)
    • getMaxId

      public int getMaxId()
      Description copied from interface: IRegistryExtension
      Returns the highest id that an entry in this registry is allowed to use. For the size of this registry, see IdMap.size().
      Specified by:
      getMaxId in interface IRegistryExtension<T>
      Returns:
      the highest id that an entry in this registry is allowed to use
    • addCallback

      public void addCallback(RegistryCallback<T> callback)
      Description copied from interface: IRegistryExtension
      Adds a callback to this registry.

      Depending on the interfaces implemented by the object, the callback will be called when the registry is added to, baked, and/or cleared.

      Specified by:
      addCallback in interface IRegistryExtension<T>
      Parameters:
      callback - the callback to add
    • addAlias

      public void addAlias(ResourceLocation from, ResourceLocation to)
      Description copied from interface: IRegistryExtension
      Adds an alias that maps from the name specified by from to the name specified by to.

      Any registry lookups that target the first name will resolve as the second name, if the first name is not present.

      Specified by:
      addAlias in interface IRegistryExtension<T>
      Parameters:
      from - the source registry name to alias from
      to - the target registry name to alias to
    • resolve

      public ResourceLocation resolve(ResourceLocation name)
      Description copied from interface: IRegistryExtension
      Resolves a registry name of a potential object in this registry. The original name will be returned if it is contained in this registry. If not, the alias map will be checked for entries. Resolving supports alias chains (A -> B -> C) and will terminate when an alias has an entry or the last alias in the chain is reached.
      Specified by:
      resolve in interface IRegistryExtension<T>
      Parameters:
      name - the input registry name of a potential object in this registry
      Returns:
      the resolved registry name
    • resolve

      public ResourceKey<T> resolve(ResourceKey<T> key)
      Description copied from interface: IRegistryExtension
      Resolves a registry key of a potential object in this registry. The original key will be returned if it is contained in this registry. If not, the alias map will be checked for entries. Resolving supports alias chains (A -> B -> C) and will terminate when an alias has an entry or the last alias in the chain is reached.
      Specified by:
      resolve in interface IRegistryExtension<T>
      Parameters:
      key - the input registry key of a potential object in this registry
      Returns:
      the resolved registry key
    • getId

      public int getId(ResourceKey<T> key)
      Description copied from interface: IRegistryExtension
      Gets the integer id linked to the given key. If the key is not present in the registry, the default entry's integer id is returned if the registry is defaulted or -1 if the registry is not defaulted
      Specified by:
      getId in interface IRegistryExtension<T>
      Parameters:
      key - the resource key to lookup
      Returns:
      the integer id linked to the given key
    • getId

      public int getId(ResourceLocation name)
      Description copied from interface: IRegistryExtension
      Gets the integer id linked to the given name. If the name is not present in the registry, the default entry's integer id is returned if the registry is defaulted or -1 if the registry is not defaulted
      Specified by:
      getId in interface IRegistryExtension<T>
      Parameters:
      name - the resource name to lookup
      Returns:
      the integer id linked to the given name
    • clear

      protected void clear(boolean full)
    • registerIdMapping

      protected abstract void registerIdMapping(ResourceKey<T> key, int id)
      Register a key invalid input: '<'-> ID mapping. The IDs must be registered in increasing order.
    • unfreeze

      protected abstract void unfreeze()
    • getData

      @Nullable public <A> A getData(DataMapType<T,A> type, ResourceKey<T> key)
      Description copied from interface: IRegistryExtension
      Returns the data map value attached with the object with the key, or null if there's no attached value.
      Specified by:
      getData in interface IRegistryExtension<T>
      Type Parameters:
      A - the data type
      Parameters:
      type - the type of the data map
      key - the object to get the value for
      Returns:
      the data map value attached with the object with the key, or null if there's no attached value
    • getDataMap

      public <A> Map<ResourceKey<T>,A> getDataMap(DataMapType<T,A> type)
      Description copied from interface: IRegistryExtension
      Returns the data map of the given type.
      Specified by:
      getDataMap in interface IRegistryExtension<T>
      Type Parameters:
      A - the data type
      Returns:
      the data map of the given type