Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Data Pack Resources

Top-level datapack.* declarations generate tags, predicates, advancements, loot tables, recipes, item modifiers, and dialogs as JSON files in the 26.x folder layout. Resource IDs must use lowercase namespace:path syntax or lowercase relative paths. Cobble reports uppercase characters, invalid path separators, and common namespace/path mistakes with focused diagnostics.

from stdlib import datapack

datapack.function_tag("utility", ["mypack:setup"])
datapack.function_tag("minecraft:load", ["mypack:setup"])
datapack.block_tag("solid_blocks", ["minecraft:stone"])
datapack.item_tag("reward_items", [
    "minecraft:diamond",
    {"id": "minecraft:netherite_ingot", "required": False}
])
datapack.entity_type_tag("targets", ["minecraft:zombie"])

datapack.predicate("is_sneaking", {
    "type": "minecraft:entity_properties",
    "entity": "this",
    "predicate": {
        "flags": {
            "is_sneaking": True
        }
    }
})

datapack.dialog("notice", {
    "type": "minecraft:notice",
    "title": {"text": "Notice"}
})
# Adds a button for the dialog to the pause screen.
datapack.dialog_tag("minecraft:pause_screen_additions", ["mypack:notice"])

Supported resource declarations:

  • datapack.function_tag(name, values, replace=False?)
  • datapack.block_tag(name, values, replace=False?)
  • datapack.item_tag(name, values, replace=False?)
  • datapack.entity_type_tag(name, values, replace=False?)
  • datapack.dialog_tag(name, values, replace=False?)
  • datapack.predicate(name, json)
  • datapack.advancement(name, json)
  • datapack.loot_table(name, json)
  • datapack.recipe(name, json)
  • datapack.item_modifier(name, json)
  • datapack.dialog(name, json)

Typed tag declarations with the same ID are merged, deduplicated, and sorted. Tag values may be string resource IDs or object entries with id and optional required. Object entries with required: true are equivalent to strings; required: false entries remain optional Minecraft tag entries. Pass an optional third literal boolean argument to emit tag replace; when multiple declarations are merged, True wins over False. Pass-through JSON declarations with identical JSON are accepted once; different JSON for the same ID is a compile error. Resource names may use nested paths and explicit namespaces, such as other_pack:checks/is_ready. Predicate, advancement, loot table, recipe, item modifier, and dialog declarations require object JSON values.

JSON resources are written as given, in Minecraft 26.3’s formats. Because a server whose packs fail to load refuses to start, Cobble reports the common pre-26.3 shapes as datapack-resource-format errors:

  • predicates use type (formerly condition), including inside all_of, any_of, and inverted terms;
  • item modifiers use type (formerly function) and a single condition (formerly a conditions list);
  • loot tables use modifier (formerly functions) and a single condition (formerly conditions) on tables, pools, and entries, and a minecraft:tag entry names its tag in items ("#minecraft:logs");
  • a root advancement with display sets display.background;
  • cooking recipes set cookingtime.

Minecraft silently ignores lists such as conditions and functions, so Cobble reports them too.

Item component helpers build the component JSON for minecraft:set_components item modifiers:

from stdlib import datapack, item_component, text

datapack.item_modifier("items/reward_components", {
    "type": "minecraft:set_components",
    "components": item_component.components(
        item_component.custom_name(text.colored("Cobble Reward", "gold")),
        item_component.lore([text.plain("Generated by Cobble")]),
        item_component.unbreakable()
    )
})

item_component.* helpers return JSON component objects for resource declarations and emit no commands when used by themselves.

Checking The Output

Generated resources are listed in the build manifest and the source map, included in ZIP output, and reported by cobble inspect --json:

cobble check --json
cobble build --validate --zip
cobble inspect output --json