From 4221b40b65561d11684db306083708db44d7e029 Mon Sep 17 00:00:00 2001 From: Stoupy51 Date: Thu, 17 Sep 2026 21:10:58 +0200 Subject: [PATCH] fix: update loot, predicate and advancement JSON to the 26.3 formats 26.3 dispatches loot conditions and functions on "type", holds a single condition where a list used to be accepted, and replaced value_check with int_value_check whose "range" field became "test". The versioning plugin injects version checks in the new shape too, so the built packs stay valid. Pack versions are untouched. --- .../impl/vanilla/bed/clicked_bed.json | 92 +++++++--------- .../impl/vanilla/bed/slept_in_bed.json | 16 ++- .../container/clicked_lockable_block.json | 55 ++++----- .../predicate/impl/is_day.json | 95 ++++++++-------- .../advancement/technical/enter_gui.json | 18 ++- .../item_modifier/impl/remove_one.json | 2 +- .../impl/set_count_from_score.json | 31 +++--- .../loot_table/blocks/table.json | 8 +- .../predicate/block/table/invalid_items.json | 104 ++++++++++++------ .../block/table/special_clear/buckets.json | 71 ++++++------ .../impl/technical/place_custom_block.json | 12 +- smithed_libraries/plugins/versioning/load.py | 44 +++++--- 12 files changed, 294 insertions(+), 254 deletions(-) diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/bed/clicked_bed.json b/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/bed/clicked_bed.json index 11c7e9f7..2f7fc234 100644 --- a/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/bed/clicked_bed.json +++ b/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/bed/clicked_bed.json @@ -3,71 +3,63 @@ "unoccupied": { "trigger": "minecraft:any_block_use", "conditions": { - "player": [ - { - "condition": "minecraft:inverted", - "term": { - "condition": "minecraft:value_check", - "value": { - "type": "minecraft:score", - "target": "this", - "score": "smithed.actionbar.sneaking" - }, - "range": { - "min": 1 - } + "player": { + "type": "minecraft:inverted", + "term": { + "type": "minecraft:int_value_check", + "value": { + "type": "minecraft:score", + "target": "this", + "score": "smithed.actionbar.sneaking" + }, + "test": { + "min": 1 } } - ], - "location": [ - { - "condition": "minecraft:location_check", - "predicate": { - "dimension": "minecraft:overworld", - "block": { - "blocks": "#minecraft:beds", - "state": { - "occupied": "false" - } + }, + "location": { + "type": "minecraft:location_check", + "predicate": { + "dimension": "minecraft:overworld", + "block": { + "blocks": "#minecraft:beds", + "state": { + "occupied": "false" } } } - ] + } } }, "occupied": { "trigger": "minecraft:any_block_use", "conditions": { - "player": [ - { - "condition": "minecraft:inverted", - "term": { - "condition": "minecraft:value_check", - "value": { - "type": "minecraft:score", - "target": "this", - "score": "smithed.actionbar.sneaking" - }, - "range": { - "min": 1 - } + "player": { + "type": "minecraft:inverted", + "term": { + "type": "minecraft:int_value_check", + "value": { + "type": "minecraft:score", + "target": "this", + "score": "smithed.actionbar.sneaking" + }, + "test": { + "min": 1 } } - ], - "location": [ - { - "condition": "minecraft:location_check", - "predicate": { - "dimension": "minecraft:overworld", - "block": { - "blocks": "#minecraft:beds", - "state": { - "occupied": "true" - } + }, + "location": { + "type": "minecraft:location_check", + "predicate": { + "dimension": "minecraft:overworld", + "block": { + "blocks": "#minecraft:beds", + "state": { + "occupied": "true" } } } - ] + } } } }, diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/bed/slept_in_bed.json b/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/bed/slept_in_bed.json index 3e4aacc5..827c27a4 100644 --- a/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/bed/slept_in_bed.json +++ b/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/bed/slept_in_bed.json @@ -3,17 +3,15 @@ "requirement": { "trigger": "minecraft:slept_in_bed", "conditions": { - "player": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "minecraft:location": { - "dimension": "minecraft:overworld" - } + "player": { + "type": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "minecraft:location": { + "dimension": "minecraft:overworld" } } - ] + } } } } diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/container/clicked_lockable_block.json b/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/container/clicked_lockable_block.json index 6f083c8b..80e520b8 100644 --- a/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/container/clicked_lockable_block.json +++ b/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/container/clicked_lockable_block.json @@ -3,48 +3,41 @@ "click_no_sneak": { "trigger": "minecraft:any_block_use", "conditions": { - "player": [ - { - "condition": "minecraft:inverted", - "term": { - "condition": "minecraft:value_check", - "value": { - "type": "minecraft:score", - "target": "this", - "score": "smithed.actionbar.sneaking" - }, - "range": { - "min": 1 - } + "player": { + "type": "minecraft:inverted", + "term": { + "type": "minecraft:int_value_check", + "value": { + "type": "minecraft:score", + "target": "this", + "score": "smithed.actionbar.sneaking" + }, + "test": { + "min": 1 } } - ], - "location": [ - { - "condition": "minecraft:location_check", - "predicate": { - "block": { - "blocks": "#smithed.actionbar:impl/lockable" - } + }, + "location": { + "type": "minecraft:location_check", + "predicate": { + "block": { + "blocks": "#smithed.actionbar:impl/lockable" } } - ] + } } }, "click_empty": { "trigger": "minecraft:default_block_use", "conditions": { - "player": [], - "location": [ - { - "condition": "minecraft:location_check", - "predicate": { - "block": { - "blocks": "#smithed.actionbar:impl/lockable" - } + "location": { + "type": "minecraft:location_check", + "predicate": { + "block": { + "blocks": "#smithed.actionbar:impl/lockable" } } - ] + } } } }, diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/predicate/impl/is_day.json b/smithed_libraries/packs/actionbar/data/smithed.actionbar/predicate/impl/is_day.json index 586071c3..b65ed4f2 100644 --- a/smithed_libraries/packs/actionbar/data/smithed.actionbar/predicate/impl/is_day.json +++ b/smithed_libraries/packs/actionbar/data/smithed.actionbar/predicate/impl/is_day.json @@ -1,48 +1,51 @@ -[ - { - "condition": "minecraft:weather_check", - "thundering": false - }, - { - "condition": "minecraft:any_of", - "terms": [ - { - "condition": "minecraft:weather_check", - "raining": true - }, - { - "condition": "minecraft:inverted", - "term": { - "condition": "minecraft:time_check", - "clock": "minecraft:overworld", - "value": { - "min": 12542, - "max": 23459 - }, - "period": 24000 +{ + "type": "minecraft:all_of", + "terms": [ + { + "type": "minecraft:weather_check", + "thundering": false + }, + { + "type": "minecraft:any_of", + "terms": [ + { + "type": "minecraft:weather_check", + "raining": true + }, + { + "type": "minecraft:inverted", + "term": { + "type": "minecraft:time_check", + "clock": "minecraft:overworld", + "value": { + "min": 12542, + "max": 23459 + }, + "period": 24000 + } } - } - ] - }, - { - "condition": "minecraft:any_of", - "terms": [ - { - "condition": "minecraft:weather_check", - "raining": false - }, - { - "condition": "minecraft:inverted", - "term": { - "condition": "minecraft:time_check", - "clock": "minecraft:overworld", - "value": { - "min": 12010, - "max": 23991 - }, - "period": 24000 + ] + }, + { + "type": "minecraft:any_of", + "terms": [ + { + "type": "minecraft:weather_check", + "raining": false + }, + { + "type": "minecraft:inverted", + "term": { + "type": "minecraft:time_check", + "clock": "minecraft:overworld", + "value": { + "min": 12010, + "max": 23991 + }, + "period": 24000 + } } - } - ] - } -] + ] + } + ] +} diff --git a/smithed_libraries/packs/crafter/data/smithed.crafter/advancement/technical/enter_gui.json b/smithed_libraries/packs/crafter/data/smithed.crafter/advancement/technical/enter_gui.json index 13319fa1..c7bab78e 100644 --- a/smithed_libraries/packs/crafter/data/smithed.crafter/advancement/technical/enter_gui.json +++ b/smithed_libraries/packs/crafter/data/smithed.crafter/advancement/technical/enter_gui.json @@ -3,18 +3,16 @@ "click_paleontology_table": { "trigger": "minecraft:default_block_use", "conditions": { - "location": [ - { - "condition": "minecraft:location_check", - "predicate": { - "block": { - "blocks": [ - "minecraft:barrel" - ] - } + "location": { + "type": "minecraft:location_check", + "predicate": { + "block": { + "blocks": [ + "minecraft:barrel" + ] } } - ] + } } } }, diff --git a/smithed_libraries/packs/crafter/data/smithed.crafter/item_modifier/impl/remove_one.json b/smithed_libraries/packs/crafter/data/smithed.crafter/item_modifier/impl/remove_one.json index c76cd967..de64cfb5 100644 --- a/smithed_libraries/packs/crafter/data/smithed.crafter/item_modifier/impl/remove_one.json +++ b/smithed_libraries/packs/crafter/data/smithed.crafter/item_modifier/impl/remove_one.json @@ -1,5 +1,5 @@ { - "function": "minecraft:set_count", + "type": "minecraft:set_count", "count": -1, "add": true } \ No newline at end of file diff --git a/smithed_libraries/packs/crafter/data/smithed.crafter/item_modifier/impl/set_count_from_score.json b/smithed_libraries/packs/crafter/data/smithed.crafter/item_modifier/impl/set_count_from_score.json index e68ee17f..fdf1417c 100644 --- a/smithed_libraries/packs/crafter/data/smithed.crafter/item_modifier/impl/set_count_from_score.json +++ b/smithed_libraries/packs/crafter/data/smithed.crafter/item_modifier/impl/set_count_from_score.json @@ -1,15 +1,18 @@ -[ - { - "function": "minecraft:set_count", - "count": { - "type": "minecraft:score", - "target": { - "type": "minecraft:fixed", - "name": "$temp2" +{ + "type": "minecraft:sequence", + "functions": [ + { + "type": "minecraft:set_count", + "count": { + "type": "minecraft:score", + "target": { + "type": "minecraft:fixed", + "name": "$temp2" + }, + "score": "smithed.data", + "scale": -1 }, - "score": "smithed.data", - "scale": -1 - }, - "add": true - } -] + "add": true + } + ] +} diff --git a/smithed_libraries/packs/crafter/data/smithed.crafter/loot_table/blocks/table.json b/smithed_libraries/packs/crafter/data/smithed.crafter/loot_table/blocks/table.json index 322bbd0f..afddb4f0 100644 --- a/smithed_libraries/packs/crafter/data/smithed.crafter/loot_table/blocks/table.json +++ b/smithed_libraries/packs/crafter/data/smithed.crafter/loot_table/blocks/table.json @@ -6,13 +6,13 @@ { "type": "minecraft:item", "name": "minecraft:furnace", - "functions": [ + "modifier": [ { - "function": "minecraft:set_components", + "type": "minecraft:set_components", "components": { "minecraft:item_name": { - "translate":"block.smithed.crafter", - "italic":false + "translate": "block.smithed.crafter", + "italic": false }, "minecraft:item_model": "smithed.crafter:table", "minecraft:container": [ diff --git a/smithed_libraries/packs/crafter/data/smithed.crafter/predicate/block/table/invalid_items.json b/smithed_libraries/packs/crafter/data/smithed.crafter/predicate/block/table/invalid_items.json index 35db232e..1f7666d9 100644 --- a/smithed_libraries/packs/crafter/data/smithed.crafter/predicate/block/table/invalid_items.json +++ b/smithed_libraries/packs/crafter/data/smithed.crafter/predicate/block/table/invalid_items.json @@ -1,155 +1,189 @@ { - "condition": "minecraft:any_of", + "type": "minecraft:any_of", "terms": [ { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:0b}]}" } } }, { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:1b}]}" } } }, { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:5b}]}" } } }, { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:6b}]}" } } }, { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:7b}]}" } } }, { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:8b}]}" } } }, { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:9b}]}" } } }, { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:10b}]}" } } }, { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:14b}]}" } } }, { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:15b}]}" } } }, { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:17b}]}" } } }, { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:18b}]}" } } }, { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:19b}]}" } } }, { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:23b}]}" } } }, { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:24b}]}" } } }, { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:25b}]}" } } }, { - "condition": "minecraft:location_check", + "type": "minecraft:location_check", "predicate": { "block": { - "blocks": ["minecraft:barrel"], + "blocks": [ + "minecraft:barrel" + ], "nbt": "{Items:[{Slot:26b}]}" } } diff --git a/smithed_libraries/packs/crafter/data/smithed.crafter/predicate/block/table/special_clear/buckets.json b/smithed_libraries/packs/crafter/data/smithed.crafter/predicate/block/table/special_clear/buckets.json index 8f0acad0..9e0615a5 100644 --- a/smithed_libraries/packs/crafter/data/smithed.crafter/predicate/block/table/special_clear/buckets.json +++ b/smithed_libraries/packs/crafter/data/smithed.crafter/predicate/block/table/special_clear/buckets.json @@ -1,43 +1,46 @@ -[ - { - "condition": "minecraft:inverted", - "term": { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "equipment": { - "mainhand": { - "components": { - "minecraft:custom_data": { - "smithed":{ - "not_bucket":1 +{ + "type": "minecraft:all_of", + "terms": [ + { + "type": "minecraft:inverted", + "term": { + "type": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "equipment": { + "mainhand": { + "components": { + "minecraft:custom_data": { + "smithed": { + "not_bucket": 1 + } } } } } } } - } - }, - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "equipment": { - "mainhand": { - "items": [ - "minecraft:water_bucket", - "minecraft:lava_bucket", - "minecraft:milk_bucket", - "minecraft:tropical_fish_bucket", - "minecraft:cod_bucket", - "minecraft:salmon_bucket", - "minecraft:axolotl_bucket", - "minecraft:pufferfish_bucket", - "minecraft:powder_snow_bucket" - ] + }, + { + "type": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "equipment": { + "mainhand": { + "items": [ + "minecraft:water_bucket", + "minecraft:lava_bucket", + "minecraft:milk_bucket", + "minecraft:tropical_fish_bucket", + "minecraft:cod_bucket", + "minecraft:salmon_bucket", + "minecraft:axolotl_bucket", + "minecraft:pufferfish_bucket", + "minecraft:powder_snow_bucket" + ] + } } } } - } -] + ] +} diff --git a/smithed_libraries/packs/custom-block/data/smithed.custom_block/advancement/impl/technical/place_custom_block.json b/smithed_libraries/packs/custom-block/data/smithed.custom_block/advancement/impl/technical/place_custom_block.json index a5b726b4..95f74c70 100644 --- a/smithed_libraries/packs/custom-block/data/smithed.custom_block/advancement/impl/technical/place_custom_block.json +++ b/smithed_libraries/packs/custom-block/data/smithed.custom_block/advancement/impl/technical/place_custom_block.json @@ -3,17 +3,15 @@ "requirement": { "trigger": "minecraft:placed_block", "conditions": { - "location": [ - { - "condition": "minecraft:location_check", - "predicate": { - "block": { + "location": { + "type": "minecraft:location_check", + "predicate": { + "block": { "blocks": "#smithed.custom_block:placeable", "nbt": "{Items:[{components:{\"minecraft:custom_data\":{smithed:{block:{}}}}}]}" - } } } - ] + } } } }, diff --git a/smithed_libraries/plugins/versioning/load.py b/smithed_libraries/plugins/versioning/load.py index ac283ce5..4c639769 100644 --- a/smithed_libraries/plugins/versioning/load.py +++ b/smithed_libraries/plugins/versioning/load.py @@ -85,6 +85,30 @@ def resolve_advancements(ctx: Context, opts: VersioningOptions): resolve_advancement(advancement, opts) +def as_terms(player): + """The conditions already on a trigger field, which 26.3 stores as a single condition + + A dict without a "type" is a raw entity predicate rather than a condition, + so it keeps being wrapped the way it always was. + """ + + if player is None: + return [] + if isinstance(player, list): + return player + if "type" not in player: + return [{"type": "minecraft:entity_properties", "entity": "this", "predicate": player}] + if player["type"] == "minecraft:all_of": + return list(player["terms"]) + return [player] + + +def one_condition(terms): + """A trigger field holds one condition, so several of them become an all_of""" + + return terms[0] if len(terms) == 1 else {"type": "minecraft:all_of", "terms": terms} + + def resolve_advancement(advancement: Advancement, opts: VersioningOptions): """Adds version checking to advancement conditions @@ -96,20 +120,12 @@ def resolve_advancement(advancement: Advancement, opts: VersioningOptions): criteria = advancement.data["criteria"] for requirement in criteria.values(): conditions = requirement.setdefault("conditions", {}) - player_conditions = conditions.setdefault("player", []) - - if isinstance(player_conditions, dict): - player_conditions = [{ - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": player_conditions - }] - conditions["player"] = player_conditions + player_conditions = as_terms(conditions.get("player")) for name, number in opts.version.named_parts(): scoreholder_part = f"{opts.scoreholder}.{name}" version_check = { - "condition": "minecraft:value_check", + "type": "minecraft:int_value_check", "value": { "type": "minecraft:score", "target": { @@ -118,21 +134,23 @@ def resolve_advancement(advancement: Advancement, opts: VersioningOptions): }, "score": "load.status", }, - "range": number, + "test": number, } for cond in player_conditions: with suppress(KeyError, TypeError): if ( - cond["condition"] == "minecraft:value_check" + cond["type"] == "minecraft:int_value_check" and cond["value"]["target"]["name"] == scoreholder_part ): - cond["range"] = number + cond["test"] = number break else: # only when there's no break player_conditions.append(version_check) + conditions["player"] = one_condition(player_conditions) + def enumerate_func(ctx: Context, opts: VersioningOptions) -> str: """The enumeration function which sets the best version