Download Unruled API — Minecraft Mods — MetaMods
Unruled API

Unruled API

Active

Downloads

0

Last update

1 month ago

Versions

1.18 — 1.21.8
Server
Fabric
Forge
Neoforge
Quilt
Game mechanics
Libraries
Utils

Unruled API

Mod icon

This mod opens up new possibilities for creating game rules that go beyond standard integer and boolean values. Developers can now easily create rules with floating points, long numbers, strings, text, enumerations, entity selection, and even registry elements.

Game Rules Registration

Usage example:

import mc.recraftors.unruled_api.UnruledApi;

public class MyClass {
    private static final int STRING_RULE_MAX_LENGTH = 24;

    public void gamerulesRegistration() {
        var myFloatingRule = UnruledApi.floatRuleBuilder(1.5) // takes initial value
                .register("my_gamerule", category); // registration requires rule name and category
        var myStringRule = new StringRule.Builder("initial value", STRING_RULE_MAX_LENGTH)
                .register("my_other_gamerule", category);
    }
}

Quick registration methods for convenience:

import mc.reraftors.unruled_api.UnruledApi;

public static void quickGamerulesRegistration() {
    var myLongRule = UnruledApi.registerLongRule("my_long_rule", category, 25L);
    var myEnumRule = UnruledApi.registerEnumRule("my_enum_rule", category, MyEnum.class, MyEnum.FIRST);
}

enum MyEnum {
    FIRST,
    SECOND,
    THIRD
}

Standard rule type registration:

import mc.recraftors.unruled_api.UnruledApi;

public static void registerBasicRules() {
    UnruledApi.registerInt("my_int_rule", category, 5);
    UnruledApi.registerBoolean("my_bool_rule", category, false);
}

Retrieving rule values:

public long getMyLongGamerules(ServerWorld dimension) {
    return UnruledApi.getLong(dimension.getGameRules(), myLongGamerule);
}

public Block getMyBlockRule(ServerWorld dimension) {
    return UnruledApi.getRegistryEntry(dimension.getGameRules(), myBlockRegistryEntryRule);
}

Per-Dimension Rule Overrides

The system allows setting individual rule settings for each dimension through the gamerule-override command.

Available commands:

  • gamerule-override - shows override list in current dimension
  • gamerule-override <dimension id> - shows overrides in specified dimension
  • gamerule-override get <rule name> - checks override for rule in current dimension
  • gamerule-override set <rule name> <value> - sets override
  • gamerule-override unset <rule name> - removes override
  • Commands with in <dimension id> work similarly for specified dimension

Override data is stored in the gamerules.dat file in the dimension folder.

Usage in Your Project

Add Modrinth Maven repository:

repositories {
    maven {
        name = "Modrinth"
        url = "https://api.modrinth.com/maven"
    }
}

For Loom:

dependencies {
    modApi "maven.modrinth:unruled-api:${project.unruled_version}"
}

For ForgeGradle:

dependencies {
    implementation "maven.modrinth:unruled-api:${project.unruled_version}"
}

The mod should not be included in other projects via JiJ, shadow, or similar methods.