Minecraft 26.1 and above

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')"]

Minecraft 1.20.1 and 1.21.1

Simple legacy rules can be written directly in the rules config option. Datapack rulesets are useful when a modpack or mod wants to ship reusable named rulesets that players can enable with the rulesets config option.

Legacy ruleset files are placed under:

data/<ruleset_namespace>/unbreakables/<ruleset_path>.json

The <ruleset_namespace>:<ruleset_path> part is the id used in the config. For example, data/example/unbreakables/protected_spawner.json can be enabled with:

rulesets = ["example:protected_spawner"]

Legacy ruleset files contain a rules array using the 1.20.1/1.21.1 rule format:

{
  "rules": [
    "[is_block(minecraft:spawner)] refuse(You cannot break this block.)"
  ]
}

Waystones 1.20.1 and 1.21.1 ship with the following ruleset that can be enabled in Unbreakables:

{
  "rules": [
    "[is_tag(waystones:waystones), is_not_state(origin, player)] refuse($chat.waystones.cannot_break_waystone)"
  ]
}

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

rulesets = ["waystones:generated_waystones"]