Class ModXRegistration

java.lang.Object
org.moddingx.libx.mod.ModX
org.moddingx.libx.mod.ModXRegistration

public abstract class ModXRegistration extends ModX
You need to extend this instead of ModX if you want to use the LibX registration system. This works like this: You define your objects for registration in classes like ModItems. Create some static methods there that register all the items. To register something you need to call register(ResourceKey, String, Object). Then in the constructor of your mod class, you call addRegistrationHandler(Runnable) for every registration method with a method reference to it. (Example: addRegistrationHandler(ModItems::init). The handlers will get called in the order you added them. This system has several advantages over the one recommended by forge:
  • An object can have dependencies that are automatically registered with it. This is done with the Registerable interface. For example BlockBE registers a block, an item for the block and a block entity type. You could even go further with it and automatically register slabs, stairs, walls and doors for all of your decorative blocks.
  • You don't need the .get() when you want to access a registration object
The system allows to create holders. However, this will only work for vanilla registries that support holder creation prior to registering the item.
  • Constructor Details

    • ModXRegistration

      protected ModXRegistration()
      Subclasses should provide a public no-arg constructor that calls this with the values needed.
  • Method Details

    • initRegistration

      protected void initRegistration(RegistrationBuilder builder)
      Initialises the registration system. See RegistrationBuilder for more information.
    • addRegistrationHandler

      public final void addRegistrationHandler(Runnable handler)
      Adds a registration handler that runs during the registry phase.
    • register

      public final <T> void register(@Nullable net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> registry, String id, T value)
      Registers an object to a given registry using a given name as the path part of the objects id. The registry parameter may be null to allow registering registerables that shouldn't go into any specific registry.