diff --git a/mecha/parse.py b/mecha/parse.py index ad7e7dfb..a5e7744f 100644 --- a/mecha/parse.py +++ b/mecha/parse.py @@ -232,6 +232,9 @@ def get_default_parsers() -> Dict[str, Parser]: "integer_range": IntegerRangeConstraint(delegate("range")), "resource_location_or_tag": CommentDisambiguation(ResourceLocationParser()), "resource_location": NoTagConstraint(delegate("resource_location_or_tag")), + "resource_location_or_nbt": AlternativeParser( + [delegate("resource_location"), delegate("nbt_compound")] + ), "uuid": parse_uuid, "objective": BasicLiteralParser(AstObjective), "objective_criteria": BasicLiteralParser(AstObjectiveCriteria), @@ -488,9 +491,13 @@ def get_default_parsers() -> Dict[str, Parser]: "command:argument:minecraft:template_mirror": delegate("template_mirror"), "command:argument:minecraft:float_range": delegate("range"), "command:argument:minecraft:function": delegate("resource_location_or_tag"), - "command:argument:minecraft:loot_table": delegate("resource_location"), - "command:argument:minecraft:loot_predicate": delegate("resource_location"), - "command:argument:minecraft:loot_modifier": delegate("resource_location"), + "command:argument:minecraft:loot_table": delegate("resource_location_or_nbt"), + "command:argument:minecraft:loot_predicate": delegate( + "resource_location_or_nbt" + ), + "command:argument:minecraft:loot_modifier": delegate( + "resource_location_or_nbt" + ), "command:argument:minecraft:game_profile": delegate("game_profile"), "command:argument:minecraft:gamemode": delegate("gamemode"), "command:argument:minecraft:heightmap": delegate("heightmap"), diff --git a/tests/resources/argument_examples.json b/tests/resources/argument_examples.json index a52b7c1b..dc453d98 100644 --- a/tests/resources/argument_examples.json +++ b/tests/resources/argument_examples.json @@ -252,6 +252,14 @@ "examples": ["foo", "foo:bar", "#foo"] } ], + "minecraft:loot_predicate": [ + { + "examples": [ + "demo:my_predicate", + "{condition:weather_check, raining:true}" + ] + } + ], "minecraft:game_profile": [ { "examples": [ diff --git a/tests/snapshots/parse__argument_examples_minecraft_loot_predicate_0_0__0.txt b/tests/snapshots/parse__argument_examples_minecraft_loot_predicate_0_0__0.txt new file mode 100644 index 00000000..92ef4f19 --- /dev/null +++ b/tests/snapshots/parse__argument_examples_minecraft_loot_predicate_0_0__0.txt @@ -0,0 +1,14 @@ +minecraft:loot_predicate 0 0 +--- +{} +--- +demo:my_predicate +--- +demo:my_predicate +--- + + location: SourceLocation(pos=0, lineno=1, colno=1) + end_location: SourceLocation(pos=17, lineno=1, colno=18) + is_tag: False + namespace: 'demo' + path: 'my_predicate' \ No newline at end of file diff --git a/tests/snapshots/parse__argument_examples_minecraft_loot_predicate_0_1__0.txt b/tests/snapshots/parse__argument_examples_minecraft_loot_predicate_0_1__0.txt new file mode 100644 index 00000000..34bb6115 --- /dev/null +++ b/tests/snapshots/parse__argument_examples_minecraft_loot_predicate_0_1__0.txt @@ -0,0 +1,38 @@ +minecraft:loot_predicate 0 1 +--- +{} +--- +{condition:weather_check, raining:true} +--- +{condition: "weather_check", raining: 1b} +--- + + location: SourceLocation(pos=0, lineno=1, colno=1) + end_location: SourceLocation(pos=39, lineno=1, colno=40) + entries: + + location: SourceLocation(pos=1, lineno=1, colno=2) + end_location: SourceLocation(pos=24, lineno=1, colno=25) + key: + + location: SourceLocation(pos=1, lineno=1, colno=2) + end_location: SourceLocation(pos=10, lineno=1, colno=11) + value: 'condition' + value: + + location: SourceLocation(pos=11, lineno=1, colno=12) + end_location: SourceLocation(pos=24, lineno=1, colno=25) + value: String('weather_check') + + location: SourceLocation(pos=26, lineno=1, colno=27) + end_location: SourceLocation(pos=38, lineno=1, colno=39) + key: + + location: SourceLocation(pos=26, lineno=1, colno=27) + end_location: SourceLocation(pos=33, lineno=1, colno=34) + value: 'raining' + value: + + location: SourceLocation(pos=34, lineno=1, colno=35) + end_location: SourceLocation(pos=38, lineno=1, colno=39) + value: Byte(1) \ No newline at end of file