Package net.minecraft.util.registry
Class DynamicRegistryManager
java.lang.Object
net.minecraft.util.registry.DynamicRegistryManager
- Direct Known Subclasses:
DynamicRegistryManager.Impl
public abstract class DynamicRegistryManager extends Object
A manager of dynamic registries. It allows users to access non-hardcoded
registries reliably.
Each minecraft server has a dynamic registry manager for file-loaded registries, while each client play network handler has a dynamic registry manager for server-sent dynamic registries.
The DynamicRegistryManager.Impl
class serves as an immutable implementation of any particular collection
or configuration of dynamic registries.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DynamicRegistryManager.Impl
An immutable implementation of the dynamic registry manager, representing a specialized configuration of registries.(package private) static class
DynamicRegistryManager.Info<E>
Represents the serialization behavior of the registries, including the id of the registry, the codec for its elements, and whether the registry should be sent to the client. -
Field Summary
Fields Modifier and Type Field Description private static DynamicRegistryManager.Impl
BUILTIN
private static Map<RegistryKey<? extends Registry<?>>,DynamicRegistryManager.Info<?>>
INFOS
private static Logger
LOGGER
-
Constructor Summary
Constructors Constructor Description DynamicRegistryManager()
-
Method Summary
Modifier and Type Method Description private static <E> void
addBuiltinEntries(DynamicRegistryManager.Impl manager, Registry<E> registry)
Add all entries of theregistry
to the corresponding registry within this manager.private static <R extends Registry<?>>
voidcopyFromBuiltin(DynamicRegistryManager.Impl manager, RegistryKey<R> registryRef)
Add all entries of the registry referred byregistryRef
to the corresponding registry within this manager.static DynamicRegistryManager.Impl
create()
Creates a default dynamic registry manager.<E> MutableRegistry<E>
get(RegistryKey<? extends Registry<E>> key)
Retrieves a registry from this manager, or throws an exception when the registry does not exist.Registry<DimensionType>
getDimensionTypes()
abstract <E> Optional<MutableRegistry<E>>
getOptional(RegistryKey<? extends Registry<E>> key)
Retrieves a registry optionally from this manager.private static <E> void
load(RegistryOps<?> ops, DynamicRegistryManager.Impl manager, DynamicRegistryManager.Info<E> info)
Loads elements from theops
into the registry specified byinfo
within themanager
.static void
load(DynamicRegistryManager.Impl impl, RegistryOps<?> registryOps)
Loads a dynamic registry manager from the resource manager's data files.private static <E> void
method_31141(DynamicRegistryManager.Impl impl, RegistryOps.EntryLoader.Impl impl2, DynamicRegistryManager.Info<E> info)
private static <E> void
register(ImmutableMap.Builder<RegistryKey<? extends Registry<?>>,DynamicRegistryManager.Info<?>> infosBuilder, RegistryKey<? extends Registry<E>> registryRef, com.mojang.serialization.Codec<E> entryCodec)
private static <E> void
register(ImmutableMap.Builder<RegistryKey<? extends Registry<?>>,DynamicRegistryManager.Info<?>> infosBuilder, RegistryKey<? extends Registry<E>> registryRef, com.mojang.serialization.Codec<E> entryCodec, com.mojang.serialization.Codec<E> networkEntryCodec)
-
Field Details
-
LOGGER
-
INFOS
-
BUILTIN
-
-
Constructor Details
-
DynamicRegistryManager
public DynamicRegistryManager()
-
-
Method Details
-
getOptional
public abstract <E> Optional<MutableRegistry<E>> getOptional(RegistryKey<? extends Registry<E>> key)Retrieves a registry optionally from this manager. -
get
Retrieves a registry from this manager, or throws an exception when the registry does not exist.- Throws:
IllegalStateException
- if the registry does not exist
-
getDimensionTypes
-
register
private static <E> void register(ImmutableMap.Builder<RegistryKey<? extends Registry<?>>,DynamicRegistryManager.Info<?>> infosBuilder, RegistryKey<? extends Registry<E>> registryRef, com.mojang.serialization.Codec<E> entryCodec) -
register
private static <E> void register(ImmutableMap.Builder<RegistryKey<? extends Registry<?>>,DynamicRegistryManager.Info<?>> infosBuilder, RegistryKey<? extends Registry<E>> registryRef, com.mojang.serialization.Codec<E> entryCodec, com.mojang.serialization.Codec<E> networkEntryCodec) -
create
Creates a default dynamic registry manager. -
method_31141
private static <E> void method_31141(DynamicRegistryManager.Impl impl, RegistryOps.EntryLoader.Impl impl2, DynamicRegistryManager.Info<E> info) -
copyFromBuiltin
private static <R extends Registry<?>> void copyFromBuiltin(DynamicRegistryManager.Impl manager, RegistryKey<R> registryRef)Add all entries of the registry referred byregistryRef
to the corresponding registry within this manager. -
addBuiltinEntries
private static <E> void addBuiltinEntries(DynamicRegistryManager.Impl manager, Registry<E> registry)Add all entries of theregistry
to the corresponding registry within this manager. -
load
Loads a dynamic registry manager from the resource manager's data files. -
load
private static <E> void load(RegistryOps<?> ops, DynamicRegistryManager.Impl manager, DynamicRegistryManager.Info<E> info)Loads elements from theops
into the registry specified byinfo
within themanager
. Note that the resource manager instance is kept within theops
.
-