百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

Registrate

> 编程语言
开源

您模块的好朋友 - 让注册表对象简单且有序

187 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

您模块的好朋友 - 让注册表对象简单且有序

Registrate

A powerful wrapper for creating and registering objects in your mod.

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.

java
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.

If declared static in your @Mod class, you must create the Registrate object lazily so it is not created too early during loading. This can be done easily like so:

java
public static final NonNullSupplier REGISTRATE = NonNullSupplier.lazy(() -> Registrate.create(MOD_ID));

Next, begin adding objects.

If you have a block class such as

java
public class MyBlock extends Block {

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

then register it like so,

java
public static final RegistryEntry 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:

java
public static final RegistryEntry 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.

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 be installed in the mods folder as a typical dependency, but since it does not have a mod, it can also be pre-packaged into your mod. You can do this by making use of Forges Jar-in-Jar system.

See here for more info on Forges Jar-in-Jar system.

To get started you MUST enable the Jar-in-Jar system, you can do this by adding the following code anywhere in your build script:

gradle
jarJar.enable()

Then, make sure the jarJar artifact is reobfuscated.

groovy
reobf {
    jarJar { }
}

tasks.jarJar.finalizedBy('reobfJarJar')

Finally, the dependency itself must be added. First add Gegy's maven repository,

groovy
repositories {
    maven { // Registrate
        url "https://maven.gegy.dev/releases"
    }
}

and then the Registrate dependency to the implementation and jarJar configurations.

groovy
dependencies {
    minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" // This should alread
    
    // MC-
    implementation fg.deobf("com.tterrag.registrate:Registrate:MC26.1-1.5.0")
    // [MC,MC)
    jarJar(group: 'com.tterrag.registrate', name: 'Registrate', version: "[MC26.1,MC26.2)")
}

Additional JarJar Note

By default the jar containing your mod & registrate will have a -all suffix and the normal jar file will not contain registrate. You would want to share around this -all jar, as that contains registrate and any other libs you have pre-packaged.

You can change this though with the following code, this changes the -all jar to no longer have a suffix, and the default main jar to be given a -slim suffix. Essentially swapping the 2 jars [you now would want to share the jar with no suffix appended].

groovy
tasks.jarJar.configure {
    // remove '-all' from jarJar jar file
	classifier ''
}

jar {
    // this now conflicts with jarJar as filenames are the same
    // append a `-slim` to this jar, as this jar contains no pre-packaged libs
    classifier 'slim'
}

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Java

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言