This shows you the differences between two versions of the page.
wiki:api:registry [2022/09/12 11:47] – created shedaniel | wiki:api:registry [2022/09/16 13:56] (current) – Deleted shedaniel | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Registry ====== | ||
- | |||
- | ===== Why is registering content so complicated? | ||
- | |||
- | Forge **disallows** you to use vanilla '' | ||
- | |||
- | ===== Submitting your mod event bus in Forge to Architectury API ===== | ||
- | |||
- | We will need to pass your mod event bus to Architectury API to allow Architectury API to listen to the registry events on Forge. Each mod's '' | ||
- | |||
- | Now, we will expose our mod event bus to Architectury. In your forge mod constructor, | ||
- | |||
- | **NOTE: The following tutorial only applies to mods using the '' | ||
- | |||
- | <code java> | ||
- | EventBuses.registerModEventBus(MOD_ID, | ||
- | </ | ||
- | |||
- | ===== Registering our content through Architectury' | ||
- | |||
- | ==== Via Registrar ==== | ||
- | |||
- | **NOTE: The following tutorial is shown in mojmap** | ||
- | |||
- | We will create a lazy registries object, this is to prevent crashes due to static load orders. | ||
- | |||
- | <code java> | ||
- | public static final Supplier< | ||
- | </ | ||
- | |||
- | During your mods' initialization, | ||
- | |||
- | <code java> | ||
- | Registrar< | ||
- | </ | ||
- | |||
- | Notice that the value returned is a '' | ||
- | |||
- | ==== Via DeferredRegister ==== | ||
- | |||
- | We will create a deferred register, we will then use this to register our entries. | ||
- | |||
- | <code java> | ||
- | public static final DeferredRegister< | ||
- | </ | ||
- | |||
- | After statically defining our deferred register, we can add entries to it, please note that the entries are not registered at this point, so we must refrain from accessing them until we actually register them. | ||
- | |||
- | <code java> | ||
- | public static final RegistrySupplier< | ||
- | </ | ||
- | |||
- | We can now submit our registry entries to the registry themselves, we will do this in our initialization block, please make sure that this is called only after we pass our mod event bus to architectury: | ||
- | |||
- | <code java> | ||
- | ITEMS.register(); | ||
- | </ | ||