You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Martmists 849a245322 Working build 3 months ago
gradle/wrapper initial commit 3 months ago
src/main Working build 3 months ago
versions Catch NPE 3 months ago
.gitignore initial commit 3 months ago
LICENSE initial commit 3 months ago
README.md Fix exception message, add libcd docs 3 months ago
build.gradle Catch NPE 3 months ago
gradle.properties Working build 3 months ago
gradlew initial commit 3 months ago
gradlew.bat initial commit 3 months ago
settings.gradle Catch NPE 3 months ago

README.md

LibGamerule

Libgamerule allows for easily adding custom gamerules.

Usage

// 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

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