LibGamerule

Mods
84 Downloads Last Updated: Feb 24, 2020 Game Version: 1.15.2

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:

  • BooleanRule
  • DoubleRule (+min/max)
  • IntRule (+min/max)
  • EnumRule (Any Enum)
  • StringRule (greedy strings)

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);

Comments

Posts Quoted: