Home›Java›Mods›LibGamerule
LibGamerule
ModsJava

LibGamerule

Java mod listed for Minecraft 1.16. Downloads from the MC Java Mods app on Android.

by Martmists · on CurseForge

⬇ Download on CurseForge

The author built this one for Minecraft 1.16.1 on Fabric. On other versions it may install and then do nothing.

LibGamerule

Libgamerule allows for easily adding custom gamerules on the Fabric modloader.

Usage (for mod devs)

// Adding a boolean gamerule GameRules.RuleKey<BooleanRule> MY_GAMERULE = Gamerule.register(
​ ​ ​ ​ "myGameRule", // name in /gamerule
​ ​ ​ ​ BooleanRule.create(true) // default to true
);

// Get the gamerule data
boolean value = Gamerule.get(MY_GAMERULE);

Supported Rule types:

Libcd support (datapack/modpack devs)

Conditions (note: does not support enums)

{
​ ​ "when": [
​ ​ ​ ​ {
​ ​ ​ ​ ​ ​ "comment": "Boolean gamerule check",
​ ​ ​ ​ ​ ​ "libgamerule:gamerule_has_value": "my_gamerule"
​ ​ ​ ​ },
​ ​ ​ ​ {
​ ​ ​ ​ ​ ​ "comment": "Typed gamerule check",
​ ​ ​ ​ ​ ​ "libgamerule:gamerule_has_value": {
​ ​ ​ ​ ​ ​ ​ ​ "name": "my_gamerule_typed",
​ ​ ​ ​ ​ ​ ​ ​ "type": "int",
​ ​ ​ ​ ​ ​ ​ ​ "value": 10
​ ​ ​ ​ ​ ​ }
​ ​ ​ ​ }
​ ​ ]
}

Creating gamerules in scripts

var GameruleTweaker = libcd.require("libgamerule.GameruleTweaker");
GameruleTweaker.addGamerule("my_gamerule", "boolean", false);
GameruleTweaker.addGamerule("my_gamerule_typed", "integer", 7);

Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

File checked by MCModsHub

These come from our own check of the pack file, not from the source page.

Explore more