Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dm-earth/deferredregistries

[Fabric/Quilt Mod] Register things in ease
https://github.com/dm-earth/deferredregistries

api fabric fabricmc fabricmc-mod minecraft minecraft-mod quilt quiltmc quiltmc-mod

Last synced: about 1 month ago
JSON representation

[Fabric/Quilt Mod] Register things in ease

Awesome Lists containing this project

README

        


Deferred Registries

Deferred Registries

This Minecraft mod provides a way to register things that are not available at the time of registration, which is similar to how Minecraft Forge's `DeferredRegister` works.

### Setup

```gradle
repositories {
// [...]
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}
}

dependencies {
// [...]
modImplementation include("maven.modrinth:deferred-registries:")
}
```

### Usage

First, create a `DeferredRegistries` object, here we use `Item` as example:

```java
private static final DeferredRegistries ITEMS = DeferredRegistries.create(Registry.ITEM, "example_mod");
```

Then, register things to it:

```java
public static final DeferredObject EXAMPLE_ITEM = ITEMS.register("example_item", () -> new Item(new Item.Settings()));
public static final DeferredObject SIMPLE_ITEM = ITEMS.register("simple_item", new Item(new Item.Settings()));
```

Finally, register the DeferredRegistries object when initializing your mod:

```java
@Override
public void onInitialize() {
ITEMS.register();
}
```