Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/mecha/examples/basic_list/beet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


data_pack:
load: .


pipeline:
- mecha

meta:
mecha:
multiline: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
item modify entity @s armor.feet [{function:"minecraft:set_components",components:{"minecraft:equippable":{slot:"feet",asset_id:"minecraft:netherite"}}}]


execute if predicate [{condition:"minecraft:all_of",terms:[{condition:"minecraft:random_chance",chance:5},{condition:"minecraft:value_check",value:0,range:0}]},{condition:"minecraft:reference",name:"test:l"}] run say aaa



execute if predicate [
{
condition:"minecraft:value_check",
name:"test:l",
value:0,
range:{min:0,max:2}
},
[
{condition:"minecraft:value_check",name:"test:l",value:0,range:{min:1,max:2}}
]
] run say bb


18 changes: 16 additions & 2 deletions packages/mecha/src/mecha/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"JsonObjectParser",
"NbtParser",
"NbtCompoundParser",
"NbtListParser",
"AdjacentConstraint",
"ResourceLocationParser",
"NoTagConstraint",
Expand Down Expand Up @@ -226,6 +227,7 @@ def get_default_parsers() -> Dict[str, Parser]:
"nbt_compound_entry": nbt_parser.parse_compound_entry,
"nbt_list_or_array_element": delegate("nbt"),
"nbt_compound": NbtCompoundParser(delegate("nbt")),
"nbt_list": NbtListParser(delegate("nbt")),
"adjacent_nbt_compound": AdjacentConstraint(delegate("nbt_compound"), r"\{"),
"nbt_path": NbtPathParser(
integer_parser=delegate("integer"),
Expand All @@ -238,6 +240,9 @@ def get_default_parsers() -> Dict[str, Parser]:
"resource_location_or_nbt": AlternativeParser(
[delegate("resource_location"), delegate("nbt_compound")]
),
"resource_location_or_nbt_list": AlternativeParser(
[delegate("resource_location_or_nbt"), delegate("nbt_list")]
),
"uuid": parse_uuid,
"objective": BasicLiteralParser(AstObjective),
"objective_criteria": BasicLiteralParser(AstObjectiveCriteria),
Expand Down Expand Up @@ -513,10 +518,10 @@ def get_default_parsers() -> Dict[str, Parser]:
delegate("resource_location_or_nbt")
),
"command:argument:minecraft:loot_predicate": MultilineParser(
delegate("resource_location_or_nbt")
delegate("resource_location_or_nbt_list")
),
"command:argument:minecraft:loot_modifier": MultilineParser(
delegate("resource_location_or_nbt")
delegate("resource_location_or_nbt_list")
),
"command:argument:minecraft:game_profile": delegate("game_profile"),
"command:argument:minecraft:gamemode": delegate("gamemode"),
Expand Down Expand Up @@ -1322,6 +1327,15 @@ class NbtCompoundParser(TypeConstraint):
message: str = "Expected nbt compound."


@dataclass
class NbtListParser(TypeConstraint):
Comment thread
edayot marked this conversation as resolved.
"""Parser for nbt list."""

parser: Parser = field(default_factory=NbtParser)
type: Union[Type[Any], Tuple[Type[Any], ...]] = AstNbtList
message: str = "Expected nbt list."


@dataclass
class AdjacentConstraint:
"""Constraint that ensures that there are no whitespace separators."""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Lectern snapshot

## Data pack

`@data_pack pack.mcmeta`

```json
{
"pack": {
"min_format": [
94,
1
],
"max_format": [
94,
1
],
"description": ""
}
}
```

### test

`@function test:test`

```mcfunction
item modify entity @s armor.feet [{function: "minecraft:set_components", components: {"minecraft:equippable": {slot: "feet", asset_id: "minecraft:netherite"}}}]
execute if predicate [{condition: "minecraft:all_of", terms: [{condition: "minecraft:random_chance", chance: 5}, {condition: "minecraft:value_check", value: 0, range: 0}]}, {condition: "minecraft:reference", name: "test:l"}] run say aaa
execute if predicate [{condition: "minecraft:value_check", name: "test:l", value: 0, range: {min: 0, max: 2}}, [{condition: "minecraft:value_check", name: "test:l", value: 0, range: {min: 1, max: 2}}]] run say bb
```