Skip to content

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

open override val entries: Set<Map.Entry<ResourceLocation, RegistrySupplier<out T>>>

keys

open override val keys: Set<ResourceLocation>

size

open override val size: Int

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

open operator override fun get(key: ResourceLocation): RegistrySupplier<out T>?
operator fun get(id: String): RegistrySupplier<out T>?

getValue

operator fun <R : T> RegistrySupplier<R>.getValue(any: Any?, property: KProperty<*>): R

init

fun init()

isEmpty

open override fun isEmpty(): Boolean