Skip to content

How it all works

Each Modloader has it's own way of handling the registration of the exact same thing, indirectly meaning to globalize the act of registering something you need to handle the registration for every loader also separately whilst creating a singular callable function for other to simply call for easy use. Which is exactly what this system does at it's core.

graph LR
  Registery --> Modloader{Present Modloader ?};
  Modloader -->|Forge| RegisterA[Register For Forge];
  Modloader -->|NeoForge| RegisterB[Register For NeoForge];
  Modloader -->|Fabric| RegisterC[Register For Fabric];
  Modloader -->|Quilt| RegisterD[Register For Quilt];
  RegisterA --> ReturnObject[Return Data as Java Object];
  RegisterB --> ReturnObject[Return Data as Java Object];
  RegisterC --> ReturnObject[Return Data as Java Object];
  RegisterD --> ReturnObject[Return Data as Java Object];
  ReturnObject -->|Parsable To Mc Safe Type| Convert[Convert To Minecraft Object];

When a Modloader is initialized with it is also a set of callback's created customized for how the Modloader wants things Handled, each call back is assigned an UUID (1). This created callbacks is what we refer to as Registries. These Callbacks are what gets called to handle a registration request.

  1. img
Example

How the Item Registry Call back's look like in 1.20.4

1
2
3
4
5
6
7
ICallBack Itemcallback = new ICallBack() {
    @Override
    public Object accept(Object... args) {
        return ITEM_REGISTRY.register(args[0].toString(), (Supplier<? extends Item>) args[1]);
    }
};
Registry.initRegistry(Itemcallback, RegistryTypes.ITEM, modid);
1
2
3
4
5
6
7
ICallBack Itemcallback = new ICallBack() {
    @Override
    public Object accept(Object... args) {
        return net.minecraft.registry.Registry.register(Registries.ITEM, new Identifier(modid, args[0].toString()), ((Supplier<Item>)args[1]).get());
    }
};
Registry.initRegistry(Itemcallback, RegistryTypes.ITEM, modid);

Programing Registration Handlers

initRegistry(ICallBack _registery, IRegistryType _currentRegistryTypes, String modid)

1.0.0

Initializes a Modloader's registry to be used for loading objects.

Parameters:

  • _registery: The registry callback.
  • _currentRegistryTypes: The type of registry.
  • modid: The Mod ID.

initRegistry(ICallBack _registery, UUID _currentRegistryTypes, String modid)

1.0.0

Initializes a Modloader's registry to be used for loading objects.

Info

Using this function is highly discouraged unless you have a deep understanding of its inner workings.

Parameters:

  • _registery: The registry callback.
  • _currentRegistryTypes: The type of registry.
  • modid: The Mod ID.

Registering Data

SimpleRegister(IRegistryType type, String Modid, Object... args)

1.0.0

Sends data to the modloader to register an object for Minecraft.

Parameters:

  • type: The type of registration.
  • Modid: The Mod ID of the registrar.
  • args: The arguments needed to register the object.

Returns: The registered data.

SimpleRegister(UUID type, String Modid, Object... args)

1.0.0

Sends data to the modloader to register an object for Minecraft.

Info

Using this function is highly discouraged unless you have a deep understanding of its inner workings.

Parameters:

  • type: The type of registration.
  • Modid: The Mod ID of the registrar.
  • args: The arguments needed to register the object.

Returns: The registered data.