From 39cc4624f555874808c629000c260c2feefbb5b4 Mon Sep 17 00:00:00 2001 From: Valentin Berlier Date: Mon, 25 Jul 2022 20:52:27 +0200 Subject: [PATCH] fix: enable interpolation for uuid --- bolt/helpers.py | 1 + bolt/parse.py | 1 + examples/bolt_basic/src/data/demo/functions/foo.mcfunction | 3 +++ tests/snapshots/examples__build_bolt_basic__0.pack.md | 1 + 4 files changed, 6 insertions(+) diff --git a/bolt/helpers.py b/bolt/helpers.py index 73a6b4a..fb1b9a7 100644 --- a/bolt/helpers.py +++ b/bolt/helpers.py @@ -79,6 +79,7 @@ def get_bolt_helpers() -> Dict[str, Any]: "interpolate_range": converter(AstRange.from_value), "interpolate_resource_location": converter(AstResourceLocation.from_value), "interpolate_item_slot": converter(AstItemSlot.from_value), + "interpolate_uuid": converter(AstUUID.from_value), "interpolate_objective": converter(AstObjective.from_value), "interpolate_objective_criteria": converter(AstObjectiveCriteria.from_value), "interpolate_scoreboard_slot": converter(AstScoreboardSlot.from_value), diff --git a/bolt/parse.py b/bolt/parse.py index 553eac8..4e3de71 100644 --- a/bolt/parse.py +++ b/bolt/parse.py @@ -406,6 +406,7 @@ def get_bolt_parsers( "item_slot": InterpolationParser( "item_slot", parsers["item_slot"], fallback=True ), + "uuid": InterpolationParser("uuid", parsers["uuid"]), "objective": InterpolationParser("objective", parsers["objective"]), "objective_criteria": InterpolationParser( "objective_criteria", parsers["objective_criteria"] diff --git a/examples/bolt_basic/src/data/demo/functions/foo.mcfunction b/examples/bolt_basic/src/data/demo/functions/foo.mcfunction index 54f61cd..6bdf2f6 100644 --- a/examples/bolt_basic/src/data/demo/functions/foo.mcfunction +++ b/examples/bolt_basic/src/data/demo/functions/foo.mcfunction @@ -662,3 +662,6 @@ rd = Random() rd.seed(42) random_id = UUID(int=rd.getrandbits(128)) whitelist add random_id + +other_id = UUID(int=rd.getrandbits(128)) +attribute @s minecraft:generic.attack_speed modifier add other_id "double" 0.5 multiply diff --git a/tests/snapshots/examples__build_bolt_basic__0.pack.md b/tests/snapshots/examples__build_bolt_basic__0.pack.md index 2357b90..d08b671 100644 --- a/tests/snapshots/examples__build_bolt_basic__0.pack.md +++ b/tests/snapshots/examples__build_bolt_basic__0.pack.md @@ -270,6 +270,7 @@ say AstCommand(identifier='tellraw:targets:message', arguments=AstChildren((AstS say tellraw @p "hello" execute as 00000001-0002-0003-0405-000000000006 run function test:test whitelist add bdd640fb-0667-1ad1-1c80-317fa3b1799d +attribute @s minecraft:generic.attack_speed modifier add 23b8c1e9-3924-56de-3eb1-3b9046685257 double 0.5 multiply ``` `@function demo:import_a`