Unruled API
Allows to create new form of gamerules, beyond the restrictive vanilla integers and booleans.
Albeit not registering them automatically, this mod allows you to easily create and register new
floating, long, double, string, text, entity selector and enum-driven gamerules,
using the generative static methods of the mc.recraftors.unruled_api.UnruledApi
class,
alongside the vanilla integer and boolean gamerules.
For consistency, methods have also been created to allow instantiating vanilla gamerules.
Example:
public void gamerulesRegistration() {
myGameRule = registerGamerule("my_gamerule", category, UnruledApi.createFloat(1.5));
myOtherGameRule = registerGamerule("my_other_gamerule", category, UnruledApi.createString("some text"));
myLastGameRule = registerGamerule("my_last_gamerule", category, UnruledApi.createBoolean(false, (server, rule) -> {
onLastRuleChange(server, rule);
}));
}
Now, for your very own convenience (since 0.4), with additional creation and registration method!
public void registerCustomGamerules() {
MY_BOOLEAN_RULE = UnruledApi.register("gamerule_name", someCategory, UnruledApi.createBoolean(false));
MY_FLOAT_RULE = UnruledApi.registerFloat("other_gamerule_name", sameOrOtherCategory, 0.5);
MY_ENUM_RULE = UnruledApi.registerEnum("yet_another_gamerule_name", yetAgainACategory, MyEnumClass.class, MyEnumClass.SOME_VALUE);
}
Each rule can also be easily consulted using the IGameRulesProvider
interface.
Example:
String value = ((IGameRulesProvider)gamerules).unruled_getString(myStringGameRule);
float aFloat = ((IGameRulesProvider)gamerules).unruled_getFloat(myFloatGameRule);
How to use in your project
You can implement this mod in your project using the Modrinth maven. Don't hesitate to read the official documentation.
Add the Modrinth maven repository
repositories {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
Import the mod
loom example:
dependencies {
// using modApi allows your project's dependents to also import dependencies by default
modApi "maven.modrinth:unruled-api:${project.unruled_version}"
}
forgeGradle example:
dependencies {
implementation "maven.modrinth:unruled-api:${project.unruled_version}"
}
For copyright reasons, we require you to not include (JiJ, jar-in-a-jar, shadow, etc) this mod inside of your own. Thank you for your comprehension.
90% of ad revenue goes to creators
Support creators and Modrinth ad-free with Modrinth+