minecraft-datapack-language 15.4.22__py3-none-any.whl → 15.4.23__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- minecraft_datapack_language/_version.py +2 -2
- minecraft_datapack_language/cli_build.py +34 -25
- minecraft_datapack_language/mdl_parser_js.py +100 -3
- {minecraft_datapack_language-15.4.22.dist-info → minecraft_datapack_language-15.4.23.dist-info}/METADATA +1 -1
- {minecraft_datapack_language-15.4.22.dist-info → minecraft_datapack_language-15.4.23.dist-info}/RECORD +9 -9
- {minecraft_datapack_language-15.4.22.dist-info → minecraft_datapack_language-15.4.23.dist-info}/WHEEL +0 -0
- {minecraft_datapack_language-15.4.22.dist-info → minecraft_datapack_language-15.4.23.dist-info}/entry_points.txt +0 -0
- {minecraft_datapack_language-15.4.22.dist-info → minecraft_datapack_language-15.4.23.dist-info}/licenses/LICENSE +0 -0
- {minecraft_datapack_language-15.4.22.dist-info → minecraft_datapack_language-15.4.23.dist-info}/top_level.txt +0 -0
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
28
28
|
commit_id: COMMIT_ID
|
29
29
|
__commit_id__: COMMIT_ID
|
30
30
|
|
31
|
-
__version__ = version = '15.4.
|
32
|
-
__version_tuple__ = version_tuple = (15, 4,
|
31
|
+
__version__ = version = '15.4.23'
|
32
|
+
__version_tuple__ = version_tuple = (15, 4, 23)
|
33
33
|
|
34
34
|
__commit_id__ = commit_id = None
|
@@ -176,7 +176,7 @@ def _generate_scoreboard_objectives(ast: Dict[str, Any], output_dir: Path) -> Li
|
|
176
176
|
if 'body' in func:
|
177
177
|
for statement in func['body']:
|
178
178
|
# Look for variable assignments and usage
|
179
|
-
if statement['type']
|
179
|
+
if statement['type'] in ['variable_assignment', 'explicit_scope_assignment']:
|
180
180
|
if statement['name'] not in seen_variables:
|
181
181
|
variables.append(statement['name'])
|
182
182
|
seen_variables.add(statement['name'])
|
@@ -280,8 +280,7 @@ def _process_say_command_with_variables(content: str, selector: str, variable_sc
|
|
280
280
|
var_selector = var_parts[1][:-1] # Remove trailing >
|
281
281
|
components.append(f'{{"score":{{"name":"{var_selector}","objective":"{base_var}"}}}}')
|
282
282
|
else:
|
283
|
-
# Simple variable: $variable$ -
|
284
|
-
var_selector = "@e[type=armor_stand,tag=mdl_server,limit=1]" # Default to global
|
283
|
+
# Simple variable: $variable$ - use declared scope if available, otherwise default to current selector
|
285
284
|
if variable_scopes and var_name in variable_scopes:
|
286
285
|
declared_scope = variable_scopes[var_name]
|
287
286
|
if declared_scope == 'global':
|
@@ -290,7 +289,8 @@ def _process_say_command_with_variables(content: str, selector: str, variable_sc
|
|
290
289
|
var_selector = declared_scope
|
291
290
|
print(f"DEBUG: Variable {var_name} using declared scope {declared_scope} -> selector {var_selector}")
|
292
291
|
else:
|
293
|
-
|
292
|
+
var_selector = selector # Use current selector (@s)
|
293
|
+
print(f"DEBUG: Variable {var_name} has no declared scope, using default selector {var_selector}")
|
294
294
|
|
295
295
|
components.append(f'{{"score":{{"name":"{var_selector}","objective":"{var_name}"}}}}')
|
296
296
|
|
@@ -336,16 +336,25 @@ def _process_statement(statement: Any, namespace: str, function_name: str, state
|
|
336
336
|
var_name = statement['name']
|
337
337
|
value = statement['value']
|
338
338
|
|
339
|
-
#
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
339
|
+
# For implicit assignments, always default to @s (current entity)
|
340
|
+
# Declared scopes only affect variable substitutions, not assignments
|
341
|
+
var_selector = selector # Default to current selector (@s)
|
342
|
+
print(f"DEBUG: Variable {var_name} assignment using selector: {var_selector} (implicit scope, ignoring declared scope: {variable_scopes.get(var_name, 'none')})")
|
343
|
+
|
344
|
+
elif statement['type'] == 'explicit_scope_assignment':
|
345
|
+
var_name = statement['name']
|
346
|
+
value = statement['value']
|
347
|
+
explicit_scope = statement['scope']
|
348
348
|
|
349
|
+
# For explicit scope assignments, use the specified scope
|
350
|
+
if explicit_scope == 'global':
|
351
|
+
var_selector = "@e[type=armor_stand,tag=mdl_server,limit=1]"
|
352
|
+
else:
|
353
|
+
var_selector = explicit_scope
|
354
|
+
print(f"DEBUG: Variable {var_name} assignment using explicit selector: {var_selector}")
|
355
|
+
|
356
|
+
# Handle assignment value processing for both types
|
357
|
+
if statement['type'] in ['variable_assignment', 'explicit_scope_assignment']:
|
349
358
|
# Handle different value types
|
350
359
|
if isinstance(value, int):
|
351
360
|
commands.append(f"scoreboard players set {var_selector} {var_name} {value}")
|
@@ -841,22 +850,22 @@ def _ast_to_pack(ast: Dict[str, Any], mdl_files: List[Path]) -> Pack:
|
|
841
850
|
else:
|
842
851
|
# Simple function call without scope
|
843
852
|
function.commands.append(f"function {func_namespace}:{func_name}")
|
844
|
-
elif statement.get('type')
|
853
|
+
elif statement.get('type') in ['variable_assignment', 'explicit_scope_assignment']:
|
845
854
|
# Handle variable assignments
|
846
855
|
var_name = statement['name']
|
847
856
|
value = statement['value']
|
848
857
|
|
849
|
-
# Determine selector based on
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
858
|
+
# Determine selector based on assignment type
|
859
|
+
if statement.get('type') == 'explicit_scope_assignment':
|
860
|
+
# Explicit scope assignment - use specified scope
|
861
|
+
explicit_scope = statement['scope']
|
862
|
+
if explicit_scope == 'global':
|
863
|
+
var_selector = "@e[type=armor_stand,tag=mdl_server,limit=1]"
|
864
|
+
else:
|
865
|
+
var_selector = explicit_scope
|
866
|
+
else:
|
867
|
+
# Implicit assignment - always default to @s
|
868
|
+
var_selector = "@s"
|
860
869
|
|
861
870
|
if hasattr(value, 'value'):
|
862
871
|
# Simple literal value
|
@@ -316,10 +316,15 @@ class MDLParser:
|
|
316
316
|
suggestion="Replace 'for' with 'while' and adjust the loop structure"
|
317
317
|
)
|
318
318
|
|
319
|
-
# Check if this is a variable assignment
|
319
|
+
# Check if this is a variable assignment
|
320
|
+
# Pattern 1: identifier = (simple assignment)
|
320
321
|
if (self.current + 1 < len(self.tokens) and
|
321
322
|
self.tokens[self.current + 1].type == TokenType.ASSIGN):
|
322
323
|
return self._parse_variable_assignment()
|
324
|
+
|
325
|
+
# Pattern 2: identifier<scope> = (explicit scope assignment)
|
326
|
+
elif self._is_explicit_scope_assignment():
|
327
|
+
return self._parse_explicit_scope_assignment()
|
323
328
|
else:
|
324
329
|
# Assume it's a command
|
325
330
|
return self._parse_command()
|
@@ -386,6 +391,72 @@ class MDLParser:
|
|
386
391
|
|
387
392
|
return {"type": "variable_assignment", "name": name, "value": value}
|
388
393
|
|
394
|
+
def _is_explicit_scope_assignment(self) -> bool:
|
395
|
+
"""Check if current position is an explicit scope assignment pattern: var<scope> = value"""
|
396
|
+
if self.current >= len(self.tokens):
|
397
|
+
return False
|
398
|
+
|
399
|
+
# Look for pattern: IDENTIFIER LANGLE ... RANGLE ASSIGN
|
400
|
+
idx = self.current + 1
|
401
|
+
|
402
|
+
# Must have LANGLE after identifier
|
403
|
+
if idx >= len(self.tokens) or self.tokens[idx].type != TokenType.LANGLE:
|
404
|
+
return False
|
405
|
+
idx += 1
|
406
|
+
|
407
|
+
# Skip tokens until we find RANGLE
|
408
|
+
while idx < len(self.tokens) and self.tokens[idx].type != TokenType.RANGLE:
|
409
|
+
idx += 1
|
410
|
+
|
411
|
+
# Must find RANGLE
|
412
|
+
if idx >= len(self.tokens) or self.tokens[idx].type != TokenType.RANGLE:
|
413
|
+
return False
|
414
|
+
idx += 1
|
415
|
+
|
416
|
+
# Must have ASSIGN after RANGLE
|
417
|
+
if idx >= len(self.tokens) or self.tokens[idx].type != TokenType.ASSIGN:
|
418
|
+
return False
|
419
|
+
|
420
|
+
return True
|
421
|
+
|
422
|
+
def _parse_explicit_scope_assignment(self) -> dict:
|
423
|
+
"""Parse variable assignment with explicit scope: var<scope> = value"""
|
424
|
+
# Parse variable name
|
425
|
+
name_token = self._match(TokenType.IDENTIFIER)
|
426
|
+
name = name_token.value
|
427
|
+
|
428
|
+
# Parse scope: <scope>
|
429
|
+
self._match(TokenType.LANGLE)
|
430
|
+
|
431
|
+
# Parse scope selector content
|
432
|
+
scope_parts = []
|
433
|
+
while not self._is_at_end() and self._peek().type != TokenType.RANGLE:
|
434
|
+
scope_parts.append(self._peek().value)
|
435
|
+
self._advance()
|
436
|
+
|
437
|
+
if self._is_at_end():
|
438
|
+
raise create_parser_error(
|
439
|
+
message="Unterminated scope selector in assignment",
|
440
|
+
file_path=self.source_file,
|
441
|
+
line=self._peek().line,
|
442
|
+
column=self._peek().column,
|
443
|
+
line_content=self._peek().value,
|
444
|
+
suggestion="Add a closing '>' to terminate the scope selector"
|
445
|
+
)
|
446
|
+
|
447
|
+
self._match(TokenType.RANGLE)
|
448
|
+
scope = ''.join(scope_parts)
|
449
|
+
|
450
|
+
# Parse assignment
|
451
|
+
self._match(TokenType.ASSIGN)
|
452
|
+
|
453
|
+
# Parse the value
|
454
|
+
value = self._parse_expression()
|
455
|
+
|
456
|
+
self._match(TokenType.SEMICOLON)
|
457
|
+
|
458
|
+
return {"type": "explicit_scope_assignment", "name": name, "scope": scope, "value": value}
|
459
|
+
|
389
460
|
def _parse_if_statement(self) -> IfStatement:
|
390
461
|
"""Parse if statement."""
|
391
462
|
self._match(TokenType.IF)
|
@@ -836,8 +907,34 @@ class MDLParser:
|
|
836
907
|
identifier_name = token.value
|
837
908
|
self._advance() # consume the identifier
|
838
909
|
|
839
|
-
# Check
|
840
|
-
if
|
910
|
+
# Check for explicit scope syntax: identifier<scope>
|
911
|
+
if not self._is_at_end() and self._peek().type == TokenType.LANGLE:
|
912
|
+
self._advance() # consume <
|
913
|
+
|
914
|
+
# Parse scope selector content
|
915
|
+
scope_parts = []
|
916
|
+
while not self._is_at_end() and self._peek().type != TokenType.RANGLE:
|
917
|
+
scope_parts.append(self._peek().value)
|
918
|
+
self._advance()
|
919
|
+
|
920
|
+
if self._is_at_end():
|
921
|
+
raise create_parser_error(
|
922
|
+
message="Unterminated scope selector in expression",
|
923
|
+
file_path=self.source_file,
|
924
|
+
line=self._peek().line,
|
925
|
+
column=self._peek().column,
|
926
|
+
line_content=self._peek().value,
|
927
|
+
suggestion="Add a closing '>' to terminate the scope selector"
|
928
|
+
)
|
929
|
+
|
930
|
+
self._advance() # consume >
|
931
|
+
scope_selector = ''.join(scope_parts)
|
932
|
+
|
933
|
+
# Return variable expression with explicit scope encoded in name
|
934
|
+
return VariableExpression(f"{identifier_name}<{scope_selector}>")
|
935
|
+
|
936
|
+
# Check if the identifier contains a scope selector (legacy single-token format)
|
937
|
+
elif '<' in identifier_name and identifier_name.endswith('>'):
|
841
938
|
# Extract variable name and scope selector
|
842
939
|
parts = identifier_name.split('<', 1)
|
843
940
|
if len(parts) == 2:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: minecraft-datapack-language
|
3
|
-
Version: 15.4.
|
3
|
+
Version: 15.4.23
|
4
4
|
Summary: Compile JavaScript-style MDL language or Python API into a Minecraft datapack (1.21+ ready). Features variables, control flow, error handling, and VS Code extension.
|
5
5
|
Project-URL: Homepage, https://www.mcmdl.com
|
6
6
|
Project-URL: Documentation, https://www.mcmdl.com/docs
|
@@ -1,8 +1,8 @@
|
|
1
1
|
minecraft_datapack_language/__init__.py,sha256=i-qCchbe5b2Fshgc6yCU9mddOLs2UBt9SAcLqfUIrT0,606
|
2
|
-
minecraft_datapack_language/_version.py,sha256=
|
2
|
+
minecraft_datapack_language/_version.py,sha256=2M9DVfO2B0gW3xckA3jnSFVOsLpE1n8q1owBMbxNoIU,708
|
3
3
|
minecraft_datapack_language/ast_nodes.py,sha256=pgjI2Nlap3ixFPgWqGSkqncG9zB91h5BKgRjtcJqMew,2118
|
4
4
|
minecraft_datapack_language/cli.py,sha256=p5A_tEEXugN2NhQFbbgfwi4FxbWYD91RWeKR_A3Vuec,6263
|
5
|
-
minecraft_datapack_language/cli_build.py,sha256=
|
5
|
+
minecraft_datapack_language/cli_build.py,sha256=hid5hdIwd3NVppBoatkij_OeH9HsBjKTT1WseRdSUs0,48510
|
6
6
|
minecraft_datapack_language/cli_check.py,sha256=bPq9gHsxQ1CIiftkrAtRCifWkVAyjp5c8Oay2NNQ1qs,6277
|
7
7
|
minecraft_datapack_language/cli_colors.py,sha256=Hr8awY966bGSnVdXL3WnmRhSP1wH56vTQKGt5z-kIQM,7878
|
8
8
|
minecraft_datapack_language/cli_help.py,sha256=Rc-v9E2kctsdN_lMunqdKuZ8EZ8rcZIjBCOPrXLBQeE,21363
|
@@ -14,12 +14,12 @@ minecraft_datapack_language/linter.py,sha256=7UqbygC5JPCGg-BSOq65NB2xEJBu_OUOYII
|
|
14
14
|
minecraft_datapack_language/mdl_errors.py,sha256=mz6uyPkeBpbMHj4PiAyVecEVJ9_hdSfR45QAjG6oYf0,15690
|
15
15
|
minecraft_datapack_language/mdl_lexer_js.py,sha256=VvbhKm727khdSAABxa03hoIIA7H3hWi3RLp9BSXbhY0,28277
|
16
16
|
minecraft_datapack_language/mdl_linter.py,sha256=z85xoAglENurCh30bR7kEHZ_JeMxcYaLDcGNRAl-RAI,17253
|
17
|
-
minecraft_datapack_language/mdl_parser_js.py,sha256=
|
17
|
+
minecraft_datapack_language/mdl_parser_js.py,sha256=ttnxvZCHKwRu51IL9U0w7WIX1q19qXNJJYt0D4f4a8M,44149
|
18
18
|
minecraft_datapack_language/pack.py,sha256=nYiXQ3jgJlDfc4m-65f7C2LFhDRioaUU_XVy6Na4SJI,34625
|
19
19
|
minecraft_datapack_language/utils.py,sha256=Aq0HAGlXqj9BUTEjaEilpvzEW0EtZYYMMwOqG9db6dE,684
|
20
|
-
minecraft_datapack_language-15.4.
|
21
|
-
minecraft_datapack_language-15.4.
|
22
|
-
minecraft_datapack_language-15.4.
|
23
|
-
minecraft_datapack_language-15.4.
|
24
|
-
minecraft_datapack_language-15.4.
|
25
|
-
minecraft_datapack_language-15.4.
|
20
|
+
minecraft_datapack_language-15.4.23.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
21
|
+
minecraft_datapack_language-15.4.23.dist-info/METADATA,sha256=dnH_xWsKU808MSG335P3esNgF5C7H8ujM-O-7hs6nb4,37917
|
22
|
+
minecraft_datapack_language-15.4.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
23
|
+
minecraft_datapack_language-15.4.23.dist-info/entry_points.txt,sha256=c6vjBeCiyQflvPHBRyBk2nJCSfYt3Oc7Sc9V87ySi_U,108
|
24
|
+
minecraft_datapack_language-15.4.23.dist-info/top_level.txt,sha256=ADtFI476tbKLLxEAA-aJQAfg53MA3k_DOb0KTFiggfw,28
|
25
|
+
minecraft_datapack_language-15.4.23.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|