Compatibility
Minecraft: Java Edition
Platforms
Supported environments
Links
Tags
Creators
Details
Registrar
A registry helper for Minecraft modding
Adding Registrar To Your Project
First, fork or download this repository and publish it to your mavenLocal (sorry, I don't have a maven (yet)).
Then, adding the following to your repositories block:
mavenLocal()
If you're using deobfuscated Minecraft:
api("survivalblock.atmosphere:registrar:${project.registrar_version}") // or implementation
include("survivalblock.atmosphere:registrar:${project.registrar_version}")
If you're using obfuscated Minecraft:
modApi("survivalblock.atmosphere:registrar:${project.registrar_version}") // or modImplementation
include("survivalblock.atmosphere:registrar:${project.registrar_version}")
Normal Registrants
To start, create a Registrant instance of the type you need, like so:
private static final BlockRegistrant BLOCK_REGISTRANT = new BlockRegistrant(ExampleMod.MOD_ID);
If a registrant of the required type does not exist, you can create one!
private static final Registrant RECIPE_SERIALIZER_REGISTRANT = new Registrant(ExampleMod.MOD_ID, BuiltinRegistries.RECIPE_SERIALIZER);
Feel free to open an issue to notify me if there is a need to add other common registrants.
To register an object, simply call Registrant#register.
REGISTRANT.register("name", THING);
Note that some registrant classes have special register methods.
For example, ItemRegistrant has a register method that takes three parameters.
ITEM_REGISTRANT.register("name", Item::new, new Item.Properties());
ItemRegistrant is also capable of registering BlockItems via separate register overloads.
Delayed Registrants
All normal registrants have a delayed counterpart, which can be found in the delayed package.
Delayed registrants are identical to normal registrants, with one exception:
DelayedRegistrant#consumeAll must be called to actually register the objects.
public static void init() {
REGISTRANT.consumeAll();
}
Dynamic Registrants
Dynamic registrants are registrants for dynamic registries.
Currently, only registrants for DamageTypes and Enchantments exist in the base library.
See these links for examples of registering damage types and enchantments.
To add the registrants for datagen, override buildRegistry in your mod's DataGeneratorEntrypoint like so:
@Override
public void buildRegistry(RegistrySetBuilder registryBuilder) {
DYNAMIC_REGISTRANT.bootstrap(registryBuilder);
}
where bootstrap is a shorthand for registryBuilder.addRegistry(REGISTRY_KEY, DYNAMIC_REGISTRANT::bootstrap);


