Skip to content

Fabricators-of-Create/Registrate-Refabricated

 
 

Repository files navigation

Registrate Refabricated License Minecraft Version

A powerful wrapper for creating and registering objects in your mod. Now ported to Fabric/Quilt.

This is an unofficial port. Please do not report issues to the Forge version.

Having trouble? Open an issue, or join us in the Create Discord's #devchat.

Why Registrate?

  • Allows you to organize your mod content however you like, rather than having pieces of each object defined in scattered places
  • Simple fluent API
  • Open to extension, build and register custom objects and data
  • Automatic data generation with sane defaults
  • Shadeable, contains no mod, only code

How to Use

First, create a Registrate object which will be used across your entire project.

public static final Registrate REGISTRATE = Registrate.create(MOD_ID);

Using a constant field is not necessary, it can be passed around and thrown away after registration is setup.

Next, begin adding objects.

If you have a block class such as

public class MyBlock extends Block {

    public MyBlock(Block.Properties properties) {
        super(properties);
    }
    
    ...
}

then register it like so,

public static final RegistryEntry<MyBlock> MY_BLOCK = REGISTRATE.block("my_block", MyBlock::new).register();

Registrate will create a block, with a default simple blockstate, model, loot table, and lang entry. However, all of these facets can be configured easily to use whatever custom data you may want. Example:

public static final RegistryEntry<MyStairsBlock> MY_STAIRS = REGISTRATE.block("my_block", MyStairsBlock::new)
            .defaultItem()
            .tag(BlockTags.STAIRS)
            .blockstate(ctx -> ctx.getProvider()
                .stairsBlock(ctx.getEntry(), ctx.getProvider().modLoc(ctx.getName())))
            .lang("Special Stairs")
            .register();

This customized version will create a BlockItem (with its own default model and lang entry), add the block to a tag, configure the blockstate for stair properties, and add a custom localization.

Finally, when you're done with registration, you must call REGISTRATE.register(); to finalize everything.

public class MyMod implements ModInitializer {
	public static final Registrate REGISTRATE = Registrate.create(MOD_ID);
	
	public void onInitialize() {
        MyModBlocks.init();
        ...
        REGISTRATE.register();
    }
}

For data generation, Your mod must have a DataGeneratorEntrypoint. From here, create an ExistingFileHelper and call REGISTRATE.setupDatagen(generator, helper);.

public class MyModDatagen implements DataGeneratorEntrypoint {
	@Override
	public void onInitializeDataGenerator(FabricDataGenerator generator) {
		ExistingFileHelper helper = ExistingFileHelper.standard();
		MyMod.REGISTRATE.setupDatagen(generator, helper);
	}
}

To get an overview of the different APIs and methods, check out the Javadocs. For more advanced usage, read the wiki (WIP).

Project Setup

Registrate can easily be depended on like any other Fabric mod. You should include Registrate in your mod, so it doesn't need to be downloaded manually.

repositories {
    // Registrate Refabricated is hosted on this maven.
    maven { url = "https://mvn.devos.one/snapshots/" }
}

...

dependencies {
    // depend on and include Registrate.
    modImplementation(include("com.tterrag.registrate_fabric:Registrate:${project.registrate_version}"))
}

About

Your mod's best friend - keep your registry objects simple and organized

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%