ADeferredRegistryHolder¶
abstract class ADeferredRegistryHolder<T> : Map<ResourceLocation, RegistrySupplier<out T>>
A registry holder that stores every registered entry in a Map keyed by its ResourceLocation, providing O(1) lookup by id string as well as property delegation via by register(...).
This class wraps an Architectury DeferredRegister and exposes the registered suppliers through the Map interface. Use it as a base for per-registry object singletons.
Note: Always use by register(...) (delegation) rather than calling .get() eagerly, to avoid touching the registry before it is unfrozen.
Example¶
object MyItems : ADeferredRegistryHolder<Item>(MyMod.MOD, Registries.ITEM) {
val MY_ITEM by register("my_item") { Item(Item.Properties()) }
}
// In mod init:
MyItems.init()
Parameters¶
- T: The registry entry type.
Constructors¶
ADeferredRegistryHolder¶
constructor(mod: Mod, registryKey: ResourceKey<Registry<T>>)
Properties¶
entries¶
keys¶
size¶
values¶
open override val values: Collection<RegistrySupplier<out T>>
Functions¶
containsKey¶
open override fun containsKey(key: ResourceLocation): Boolean
containsValue¶
open override fun containsValue(value: RegistrySupplier<out T>): Boolean
get¶
getValue¶
Property delegate operator that unwraps a RegistrySupplier to its concrete value.
init¶
open fun init()
Registers the underlying DeferredRegister, then schedules initClient to run on the client, at the earliest point registration APIs that depend on registryKey's registry already being populated (e.g. Architectury's MenuRegistry.registerScreenFactory, or registering a renderer for a BlockEntityType this holder just registered) are safe to call - see waitForRegistry. Must be called once during mod initialization.