Providing rules through datapacks

Simple rules can be written directly in the rules config option. Datapack rules are useful when a modpack or mod wants to ship reusable named rules that players can enable with use('namespace:path').

Unbreakables uses the Shogi scope unbreakables:rules. Datapack rule files for this scope are placed under:

data/<rule_namespace>/unbreakables/rules/<rule_path>.json

The <rule_namespace>:<rule_path> part is the id used in the config. For example, data/example/unbreakables/rules/protected_spawner.json can be imported with:

rules = ["use('example:protected_spawner')"]

Waystones ships with the following rule that can be enabled in Unbreakables:

{
  "type": "shogi:if",
  "condition": {
    "type": "shogi:and",
    "conditions": [
      {
        "type": "shogi:is_block",
        "block": "#waystones:waystones"
      },
      {
        "type": "shogi:not",
        "condition": {
          "type": "shogi:is_block_state_property",
          "property": "origin",
          "value": "player"
        }
      }
    ]
  },
  "then": {
    "type": "shogi:refuse",
    "message": {
      "translate": "chat.waystones.cannot_break_waystone"
    }
  }
}

Players enable that packaged rule by adding this to config/unbreakables-common.toml:

rules = ["use('waystones:generated_waystones')"]