mixson

Inline Registration

Note for Quilt Users

Out of all mod loaders, Quilt is the slowest to run its mod main entrypoint. Because of this, Mixson events are not guaranteed to be registered in time for the beginning of resource processing. Mixson provides an entrypoint exclusive to the quilted version which runs at the proper time: MixsonEntrypoint. To declare the entrypoint, add the class to a mixson list in the entrypoints section of the quilt.mod.json.

{
"quilt_loader": {
...
"entrypoints": {
"mixson": "path.to.the.Class"
},
...
}

The interface MixsonEntrypoint can then be used as an early loading spot for inline Mixson event registration. Below is an example entrypoint:

public class TestModInitializer implements MixsonInitializer {
@Override
public void onInitialize(ModContainer mod) {
// Register events here
}
}

Registering an Event

There are three methods for registering simple events:

UUID registerEvent(int priority, String resourceId, String eventName, MixsonEvent event, ResourceReference... references)
UUID registerEvent(int priority, String resourceId, String eventName, MixsonEvent event, boolean silentlyFail, ResourceReference... references)
UUID registerEvent(int priority, Function<Identifier, Boolean> resourceLocator, String eventName, MixsonEvent event, boolean silentlyFail, ResourceReference... references)

The resourceId is the resource the event will be operating on. This supports wildcard modifiers. The resourceId can also be replaced with a Resource Locator.

The registration methods return a UUID which is the internal identifier for the event. This id can be used for removing the event if desired.

Example

Below is an example event that changes the texture on the diamond chestplate to that of the netherite chestplate:

Mixson.registerEvent(
"models/item/diamond_chestplate",
"test event",
(context) -> {
JsonElement elem = context.getFile();
JsonObject textures = elem.getAsJsonObject().getAsJsonObject("textures");
textures.addProperty("layer0", "minecraft:item/netherite_chestplate");
}
);

Removing an Event

To remove a declared event, use the following method:

boolean removeEvent(UUID uuid);

The method takes in the uuid assigned to the event during registration and returns a boolean. The returned boolean, if true, means the event was found and removed or could not be found if false.