minecraft-datapack-language 15.4.35__py3-none-any.whl → 15.4.36__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/mdl_compiler.py +73 -26
- {minecraft_datapack_language-15.4.35.dist-info → minecraft_datapack_language-15.4.36.dist-info}/METADATA +1 -1
- {minecraft_datapack_language-15.4.35.dist-info → minecraft_datapack_language-15.4.36.dist-info}/RECORD +8 -8
- {minecraft_datapack_language-15.4.35.dist-info → minecraft_datapack_language-15.4.36.dist-info}/WHEEL +0 -0
- {minecraft_datapack_language-15.4.35.dist-info → minecraft_datapack_language-15.4.36.dist-info}/entry_points.txt +0 -0
- {minecraft_datapack_language-15.4.35.dist-info → minecraft_datapack_language-15.4.36.dist-info}/licenses/LICENSE +0 -0
- {minecraft_datapack_language-15.4.35.dist-info → minecraft_datapack_language-15.4.36.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.36'
|
32
|
+
__version_tuple__ = version_tuple = (15, 4, 36)
|
33
33
|
|
34
34
|
__commit_id__ = commit_id = None
|
@@ -148,9 +148,9 @@ class MDLCompiler:
|
|
148
148
|
lines.append(f"# Scope: {func.scope}")
|
149
149
|
lines.append("")
|
150
150
|
|
151
|
-
#
|
152
|
-
if hasattr(self, '
|
153
|
-
self.
|
151
|
+
# Ensure a temp-command sink stack exists
|
152
|
+
if not hasattr(self, '_temp_sink_stack'):
|
153
|
+
self._temp_sink_stack = []
|
154
154
|
|
155
155
|
# Set current function context and reset per-function counters
|
156
156
|
self._current_function_name = func.name
|
@@ -158,18 +158,15 @@ class MDLCompiler:
|
|
158
158
|
self.else_counter = 0
|
159
159
|
self.while_counter = 0
|
160
160
|
|
161
|
+
# Route temp commands into this function's body by default
|
162
|
+
self._temp_sink_stack.append(lines)
|
161
163
|
# Generate commands from function body
|
162
164
|
for statement in func.body:
|
163
165
|
cmd = self._statement_to_command(statement)
|
164
166
|
if cmd:
|
165
167
|
lines.append(cmd)
|
166
|
-
|
167
|
-
|
168
|
-
if hasattr(self, 'temp_commands') and self.temp_commands:
|
169
|
-
lines.append("")
|
170
|
-
lines.append("# Temporary variable operations:")
|
171
|
-
for temp_cmd in self.temp_commands:
|
172
|
-
lines.append(temp_cmd)
|
168
|
+
# Done routing temp commands for this function body
|
169
|
+
self._temp_sink_stack.pop()
|
173
170
|
|
174
171
|
return "\n".join(lines)
|
175
172
|
|
@@ -401,6 +398,10 @@ class MDLCompiler:
|
|
401
398
|
|
402
399
|
# Generate the if body function content
|
403
400
|
if_body_lines = [f"# Function: {self.current_namespace}:{if_function_name}"]
|
401
|
+
# Route temp commands to the if-body function content
|
402
|
+
if not hasattr(self, '_temp_sink_stack'):
|
403
|
+
self._temp_sink_stack = []
|
404
|
+
self._temp_sink_stack.append(if_body_lines)
|
404
405
|
for stmt in if_stmt.then_body:
|
405
406
|
if isinstance(stmt, VariableAssignment):
|
406
407
|
cmd = self._variable_assignment_to_command(stmt)
|
@@ -419,6 +420,8 @@ class MDLCompiler:
|
|
419
420
|
elif isinstance(stmt, FunctionCall):
|
420
421
|
cmd = self._function_call_to_command(stmt)
|
421
422
|
if_body_lines.append(cmd)
|
423
|
+
# Stop routing temp commands for if-body
|
424
|
+
self._temp_sink_stack.pop()
|
422
425
|
|
423
426
|
# Handle else body if it exists
|
424
427
|
if if_stmt.else_body:
|
@@ -443,6 +446,10 @@ class MDLCompiler:
|
|
443
446
|
else:
|
444
447
|
lines.append(f"execute unless {condition} run function {self.current_namespace}:{else_function_name}")
|
445
448
|
else_body_lines = [f"# Function: {self.current_namespace}:{else_function_name}"]
|
449
|
+
# Route temp commands into the else-body
|
450
|
+
if not hasattr(self, '_temp_sink_stack'):
|
451
|
+
self._temp_sink_stack = []
|
452
|
+
self._temp_sink_stack.append(else_body_lines)
|
446
453
|
for stmt in if_stmt.else_body:
|
447
454
|
if isinstance(stmt, VariableAssignment):
|
448
455
|
cmd = self._variable_assignment_to_command(stmt)
|
@@ -461,6 +468,8 @@ class MDLCompiler:
|
|
461
468
|
elif isinstance(stmt, FunctionCall):
|
462
469
|
cmd = self._function_call_to_command(stmt)
|
463
470
|
else_body_lines.append(cmd)
|
471
|
+
# Stop routing temp commands for else-body
|
472
|
+
self._temp_sink_stack.pop()
|
464
473
|
self._store_generated_function(else_function_name, else_body_lines)
|
465
474
|
|
466
475
|
# Store the if function as its own file
|
@@ -483,6 +492,9 @@ class MDLCompiler:
|
|
483
492
|
loop_body_lines = [f"# Function: {self.current_namespace}:{loop_function_name}"]
|
484
493
|
|
485
494
|
# Add the loop body statements
|
495
|
+
if not hasattr(self, '_temp_sink_stack'):
|
496
|
+
self._temp_sink_stack = []
|
497
|
+
self._temp_sink_stack.append(loop_body_lines)
|
486
498
|
for stmt in while_loop.body:
|
487
499
|
if isinstance(stmt, VariableAssignment):
|
488
500
|
cmd = self._variable_assignment_to_command(stmt)
|
@@ -505,6 +517,8 @@ class MDLCompiler:
|
|
505
517
|
# Add the recursive call at the end to continue the loop
|
506
518
|
cond_str, _inv = self._build_condition(while_loop.condition)
|
507
519
|
loop_body_lines.append(f"execute if {cond_str} run function {self.current_namespace}:{loop_function_name}")
|
520
|
+
# Stop routing temp commands for while-body
|
521
|
+
self._temp_sink_stack.pop()
|
508
522
|
|
509
523
|
# Store the loop function as its own file
|
510
524
|
self._store_generated_function(loop_function_name, loop_body_lines)
|
@@ -680,10 +694,20 @@ class MDLCompiler:
|
|
680
694
|
if isinstance(expression.left, BinaryExpression):
|
681
695
|
self._store_temp_command(f"scoreboard players operation @s {temp_var} = @s {left_temp}")
|
682
696
|
else:
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
697
|
+
# Assign from left value (score or literal)
|
698
|
+
if isinstance(expression.left, VariableSubstitution) or (isinstance(expression.left, str) and str(left_value).startswith("score ")):
|
699
|
+
parts = str(left_value).split()
|
700
|
+
scope = parts[1]
|
701
|
+
obj = parts[2]
|
702
|
+
self._store_temp_command(f"scoreboard players operation @s {temp_var} = {scope} {obj}")
|
703
|
+
else:
|
704
|
+
self._store_temp_command(f"scoreboard players set @s {temp_var} {left_value}")
|
705
|
+
# Add right value
|
706
|
+
if isinstance(expression.right, VariableSubstitution) or (isinstance(expression.right, str) and str(right_value).startswith("score ")):
|
707
|
+
parts = str(right_value).split()
|
708
|
+
scope = parts[1]
|
709
|
+
obj = parts[2]
|
710
|
+
self._store_temp_command(f"scoreboard players operation @s {temp_var} += {scope} {obj}")
|
687
711
|
else:
|
688
712
|
self._store_temp_command(f"scoreboard players add @s {temp_var} {right_value}")
|
689
713
|
|
@@ -691,10 +715,19 @@ class MDLCompiler:
|
|
691
715
|
if isinstance(expression.left, BinaryExpression):
|
692
716
|
self._store_temp_command(f"scoreboard players operation @s {temp_var} = @s {left_temp}")
|
693
717
|
else:
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
718
|
+
if isinstance(expression.left, VariableSubstitution) or (isinstance(expression.left, str) and str(left_value).startswith("score ")):
|
719
|
+
parts = str(left_value).split()
|
720
|
+
scope = parts[1]
|
721
|
+
obj = parts[2]
|
722
|
+
self._store_temp_command(f"scoreboard players operation @s {temp_var} = {scope} {obj}")
|
723
|
+
else:
|
724
|
+
self._store_temp_command(f"scoreboard players set @s {temp_var} {left_value}")
|
725
|
+
# Subtract right value
|
726
|
+
if isinstance(expression.right, VariableSubstitution) or (isinstance(expression.right, str) and str(right_value).startswith("score ")):
|
727
|
+
parts = str(right_value).split()
|
728
|
+
scope = parts[1]
|
729
|
+
obj = parts[2]
|
730
|
+
self._store_temp_command(f"scoreboard players operation @s {temp_var} -= {scope} {obj}")
|
698
731
|
else:
|
699
732
|
self._store_temp_command(f"scoreboard players remove @s {temp_var} {right_value}")
|
700
733
|
|
@@ -702,12 +735,18 @@ class MDLCompiler:
|
|
702
735
|
if isinstance(expression.left, BinaryExpression):
|
703
736
|
self._store_temp_command(f"scoreboard players operation @s {temp_var} = @s {left_temp}")
|
704
737
|
else:
|
705
|
-
|
738
|
+
if isinstance(expression.left, VariableSubstitution) or (isinstance(expression.left, str) and str(left_value).startswith("score ")):
|
739
|
+
parts = str(left_value).split()
|
740
|
+
scope = parts[1]
|
741
|
+
obj = parts[2]
|
742
|
+
self._store_temp_command(f"scoreboard players operation @s {temp_var} = {scope} {obj}")
|
743
|
+
else:
|
744
|
+
self._store_temp_command(f"scoreboard players set @s {temp_var} {left_value}")
|
706
745
|
|
707
746
|
if isinstance(expression.right, BinaryExpression):
|
708
747
|
self._store_temp_command(f"scoreboard players operation @s {temp_var} *= @s {right_temp}")
|
709
748
|
else:
|
710
|
-
# For literal values,
|
749
|
+
# For literal values, keep explicit multiply command for compatibility
|
711
750
|
if isinstance(expression.right, LiteralExpression):
|
712
751
|
self._store_temp_command(f"scoreboard players multiply @s {temp_var} {expression.right.value}")
|
713
752
|
else:
|
@@ -717,12 +756,18 @@ class MDLCompiler:
|
|
717
756
|
if isinstance(expression.left, BinaryExpression):
|
718
757
|
self._store_temp_command(f"scoreboard players operation @s {temp_var} = @s {left_temp}")
|
719
758
|
else:
|
720
|
-
|
759
|
+
if isinstance(expression.left, VariableSubstitution) or (isinstance(expression.left, str) and str(left_value).startswith("score ")):
|
760
|
+
parts = str(left_value).split()
|
761
|
+
scope = parts[1]
|
762
|
+
obj = parts[2]
|
763
|
+
self._store_temp_command(f"scoreboard players operation @s {temp_var} = {scope} {obj}")
|
764
|
+
else:
|
765
|
+
self._store_temp_command(f"scoreboard players set @s {temp_var} {left_value}")
|
721
766
|
|
722
767
|
if isinstance(expression.right, BinaryExpression):
|
723
768
|
self._store_temp_command(f"scoreboard players operation @s {temp_var} /= @s {right_temp}")
|
724
769
|
else:
|
725
|
-
# For literal values,
|
770
|
+
# For literal values, keep explicit divide command for compatibility
|
726
771
|
if isinstance(expression.right, LiteralExpression):
|
727
772
|
self._store_temp_command(f"scoreboard players divide @s {temp_var} {expression.right.value}")
|
728
773
|
else:
|
@@ -732,10 +777,12 @@ class MDLCompiler:
|
|
732
777
|
self._store_temp_command(f"scoreboard players set @s {temp_var} 0")
|
733
778
|
|
734
779
|
def _store_temp_command(self, command: str):
|
735
|
-
"""
|
736
|
-
if
|
737
|
-
self.
|
738
|
-
|
780
|
+
"""Append a temporary command into the current output sink (function/if/while body)."""
|
781
|
+
if hasattr(self, '_temp_sink_stack') and self._temp_sink_stack:
|
782
|
+
self._temp_sink_stack[-1].append(command)
|
783
|
+
else:
|
784
|
+
# Fallback: do nothing, but keep behavior predictable
|
785
|
+
pass
|
739
786
|
|
740
787
|
def _generate_temp_variable_name(self) -> str:
|
741
788
|
"""Generate a unique temporary variable name."""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: minecraft-datapack-language
|
3
|
-
Version: 15.4.
|
3
|
+
Version: 15.4.36
|
4
4
|
Summary: Compile MDL language with explicit scoping 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,18 +1,18 @@
|
|
1
1
|
minecraft_datapack_language/__init__.py,sha256=0KVXBE4ScRaRUrf83aA2tVB-y8A_jplyaxVvtHH6Uw0,1199
|
2
|
-
minecraft_datapack_language/_version.py,sha256
|
2
|
+
minecraft_datapack_language/_version.py,sha256=-lqyDIq8xZADk9VgmkKo5oD27xSGH-vH7aUZSbeWTUQ,708
|
3
3
|
minecraft_datapack_language/ast_nodes.py,sha256=nbWrRz137MGMRpmnq8QkXNzrtlaCgyPEknytbkrS_M8,3899
|
4
4
|
minecraft_datapack_language/cli.py,sha256=-TMAL1HCCtwf0aG46x88MVBsYUswPRCVhy854li7X9c,9780
|
5
5
|
minecraft_datapack_language/dir_map.py,sha256=HmxFkuvWGkzHF8o_GFb4BpuMCRc6QMw8UbmcAI8JVdY,1788
|
6
|
-
minecraft_datapack_language/mdl_compiler.py,sha256=
|
6
|
+
minecraft_datapack_language/mdl_compiler.py,sha256=WNh1MFWyNHV0s3binx-afD_GAVGdRmG0P5id--btZxs,38393
|
7
7
|
minecraft_datapack_language/mdl_errors.py,sha256=r0Gu3KhoX1YLPAVW_iO7Q_fPgaf_Dv9tOGSOdKNSzmw,16114
|
8
8
|
minecraft_datapack_language/mdl_lexer.py,sha256=CjbEUpuuF4eU_ucA_WIhw6wSMcHGk2BchtQ0bLAGvwg,22033
|
9
9
|
minecraft_datapack_language/mdl_linter.py,sha256=z85xoAglENurCh30bR7kEHZ_JeMxcYaLDcGNRAl-RAI,17253
|
10
10
|
minecraft_datapack_language/mdl_parser.py,sha256=aQPKcmATM9BOMzO7vCXmMdxU1qjOJNLCSAKJopu5h3g,23429
|
11
11
|
minecraft_datapack_language/python_api.py,sha256=yU8SIhxRfCWsDW3qBheMQD2Ii0Y6-Tk9VMvVncEPlv4,8183
|
12
12
|
minecraft_datapack_language/utils.py,sha256=Aq0HAGlXqj9BUTEjaEilpvzEW0EtZYYMMwOqG9db6dE,684
|
13
|
-
minecraft_datapack_language-15.4.
|
14
|
-
minecraft_datapack_language-15.4.
|
15
|
-
minecraft_datapack_language-15.4.
|
16
|
-
minecraft_datapack_language-15.4.
|
17
|
-
minecraft_datapack_language-15.4.
|
18
|
-
minecraft_datapack_language-15.4.
|
13
|
+
minecraft_datapack_language-15.4.36.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
14
|
+
minecraft_datapack_language-15.4.36.dist-info/METADATA,sha256=7ZLAsFhF4cRd5kIMYe0MTK24UyL5dWzwK87_EJtulNU,8360
|
15
|
+
minecraft_datapack_language-15.4.36.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
16
|
+
minecraft_datapack_language-15.4.36.dist-info/entry_points.txt,sha256=c6vjBeCiyQflvPHBRyBk2nJCSfYt3Oc7Sc9V87ySi_U,108
|
17
|
+
minecraft_datapack_language-15.4.36.dist-info/top_level.txt,sha256=ADtFI476tbKLLxEAA-aJQAfg53MA3k_DOb0KTFiggfw,28
|
18
|
+
minecraft_datapack_language-15.4.36.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|