Class RegistrationHelper

java.lang.Object
org.moddingx.libx.registration.RegistrationHelper

public final class RegistrationHelper extends Object
A small factory helper that creates BlockBehaviour.Properties and Item.Properties with the correct setId call pre-applied, and optionally tracks the created objects for bulk registration via registerAll().

Intended for manual registration classes (those that do not use @RegisterClass). Create a static instance and use it to build all property objects:

private static final RegistrationHelper REG = new RegistrationHelper(MyMod.getInstance());

public static final BlockBase myBlock = REG.block("my_block",
        props -> new BlockBase(MyMod.getInstance(), props, new Item.Properties()));

public static void init() {
    REG.registerAll();
}

For @RegisterClass classes the coremod injects ids automatically — this helper is not needed there.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends net.minecraft.world.level.block.Block>
    T
    block(String name, Function<net.minecraft.world.level.block.state.BlockBehaviour.Properties, T> factory)
     
    <T extends net.minecraft.world.level.block.Block>
    T
    block(String name, net.minecraft.world.level.block.Block base, Function<net.minecraft.world.level.block.state.BlockBehaviour.Properties, T> factory)
     
    net.minecraft.world.level.block.state.BlockBehaviour.Properties
    blockCopy(String name, net.minecraft.world.level.block.Block base)
     
    net.minecraft.world.level.block.state.BlockBehaviour.Properties
     
    <T extends net.minecraft.world.item.Item>
    T
    item(String name, Function<net.minecraft.world.item.Item.Properties, T> factory)
     
    net.minecraft.world.item.Item.Properties
    itemOf(String name)
     
    mod()
     
    void
    Registers all blocks and items created through this helper with the mods' registration system.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • mod

      public ModXRegistration mod()
    • blockOf

      public net.minecraft.world.level.block.state.BlockBehaviour.Properties blockOf(String name)
    • blockCopy

      public net.minecraft.world.level.block.state.BlockBehaviour.Properties blockCopy(String name, net.minecraft.world.level.block.Block base)
    • itemOf

      public net.minecraft.world.item.Item.Properties itemOf(String name)
    • block

      public <T extends net.minecraft.world.level.block.Block> T block(String name, Function<net.minecraft.world.level.block.state.BlockBehaviour.Properties, T> factory)
    • block

      public <T extends net.minecraft.world.level.block.Block> T block(String name, net.minecraft.world.level.block.Block base, Function<net.minecraft.world.level.block.state.BlockBehaviour.Properties, T> factory)
    • item

      public <T extends net.minecraft.world.item.Item> T item(String name, Function<net.minecraft.world.item.Item.Properties, T> factory)
    • registerAll

      public void registerAll()
      Registers all blocks and items created through this helper with the mods' registration system. Must be called before the first RegisterEvent fires — typically from the mod class constructor or another early-setup method. Do not call from FMLCommonSetupEvent or later. Calling this method clears the tracked entries, so it is safe to add more entries and call again.