-
Notifications
You must be signed in to change notification settings - Fork 5
Registrar System
From Fzzy Config 0.5.9, there is a simple registration system built into the PlatformApi
for cross-platform registration to built-in or modded Registry
objects.
The system is built out of two basic parts
The registration manager object for a particular Registry
. Game objects are registered into this, much like a DeferredRegister
from a (Neo)Forge modding context.
The output object of a Registrar
, this supplier performs all of the basic registry-reference actions you should need
RegistrySupplier
provides:
-
get()
- The registered object; it is aSupplier<T>
of the object type. -
getKey()
- TheRegistryKey
the object is registered with. -
getId()
- TheIdentifier
the object is registered with. -
getEntry()
- TheRegistryEntry
that stores the object in the registry.
Create a new Registrar using the PlatformApi
accessed through the ConfigApi
.
val myItemRegistrar: Registrar<Item> = ConfigApi.platform().createRegistrar(MOD_ID, Registries.ITEM)
Registrar<Item> myItemRegistrar = ConfigApiJava.platform().createRegistrar(MOD_ID, Registries.ITEM);
Once you have a registrar, there are two primary activities you need to do with it.
-
register()
objects to it -
init()
the registrar to link it to the modloading system
val myItemRegistrar: Registrar<Item> = ConfigApi.platform().createRegistrar(MOD_ID, Registries.ITEM)
val ITEM_1: RegistrySupplier<Item> = myItemRegistrar.register("item_1", Supplier { Item1() })
//mod initializer, in your mod entrypoint or related initializer
fun myCommonInit() {
myItemRegistrar.init()
}
Registrar<Item> myItemRegistrar = ConfigApiJava.platform().createRegistrar(MOD_ID, Registries.ITEM);
public RegistrySupplier<Item> ITEM_1 = myItemRegistrar.register("item_1", () -> new Item1());
//mod initializer, in your mod entrypoint or related initializer
public void myCommonInit() {
myItemRegistrar.init();
}
Fzzy Config doesn't currently have the ability to strictly work with load orders, so keep this in mind if you need to register in a certain order relative to another mod. On Fabric, load orders aren't even a concept.