minecraft-datapack-language 16.0.10__py3-none-any.whl → 16.0.12__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.
@@ -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 = '16.0.10'
32
- __version_tuple__ = version_tuple = (16, 0, 10)
31
+ __version__ = version = '16.0.12'
32
+ __version_tuple__ = version_tuple = (16, 0, 12)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -649,63 +649,93 @@ class MDLCompiler:
649
649
  return "\n".join(lines)
650
650
 
651
651
  def _scheduled_while_to_command(self, while_loop: ScheduledWhileLoop) -> str:
652
- """Convert scheduledwhile to tick-scheduled loop to avoid recursion limits.
653
- Strategy:
654
- - Generate a unique loop function that contains the body, then conditionally schedules itself 1t later.
655
- - Entry statement schedules the first tick run.
656
- - Breakout occurs naturally by not scheduling when condition is false.
652
+ """Convert scheduledwhile into a tick-driven loop that preserves the initiating executor (@s).
653
+ Uses a unique tag per loop instance to track participants across ticks.
657
654
  """
658
- loop_function_name = self._generate_while_function_name()
655
+ # Unique names and tag for this scheduled-while instance (keep legacy naming for helper)
656
+ wrap_fn = self._generate_while_function_name() # e.g., fn__while_1
657
+ body_fn = f"{wrap_fn}__body"
658
+ tag = f"mdl_sched__{wrap_fn}"
659
+ # If inside a parent scheduledwhile, register this tag as a child so parent defers while child active
660
+ if hasattr(self, '_sched_child_tag_stack') and self._sched_child_tag_stack:
661
+ self._sched_child_tag_stack[-1].append(tag)
662
+ # Prepare nested scheduledwhile coordination
663
+ if not hasattr(self, '_sched_child_tag_stack'):
664
+ self._sched_child_tag_stack = []
659
665
 
660
666
  # Build condition once
661
667
  cond_str, invert_then = self._build_condition(while_loop.condition)
668
+ cond_true = f"unless {cond_str}" if invert_then else f"if {cond_str}"
669
+ cond_false = f"if {cond_str}" if invert_then else f"unless {cond_str}"
662
670
 
663
- # Schedule first iteration for next tick (conditionally for true while semantics)
671
+ # Entry: tag current @s and schedule the wrapper on next tick if condition initially true
664
672
  lines: List[str] = []
665
- if invert_then:
666
- lines.append(f"execute unless {cond_str} run schedule function {self.current_namespace}:{loop_function_name} 1t")
667
- else:
668
- lines.append(f"execute if {cond_str} run schedule function {self.current_namespace}:{loop_function_name} 1t")
673
+ lines.append(f"execute {cond_true} run tag @s add {tag}")
674
+ lines.append(f"execute {cond_true} run schedule function {self.current_namespace}:{wrap_fn} 1t")
669
675
 
670
- # Build the loop function body
671
- loop_body_lines: List[str] = [f"# Function: {self.current_namespace}:{loop_function_name}"]
676
+ # Build per-entity body function
677
+ body_lines: List[str] = [f"# Function: {self.current_namespace}:{body_fn}"]
672
678
 
673
679
  if not hasattr(self, '_temp_sink_stack'):
674
680
  self._temp_sink_stack = []
675
- self._temp_sink_stack.append(loop_body_lines)
681
+
682
+ # Push a new child tag collector for nested scheduledwhiles
683
+ self._sched_child_tag_stack.append([])
684
+ # Also expose this collector to nested calls via a convenience reference
685
+ current_child_list = self._sched_child_tag_stack[-1]
686
+ # Provide a hook for nested scheduledwhile to register their tag
687
+ if not hasattr(self, '_register_child_sched_tag'):
688
+ def _register(tag_name: str):
689
+ if self._sched_child_tag_stack:
690
+ self._sched_child_tag_stack[-1].append(tag_name)
691
+ self._register_child_sched_tag = _register
692
+
693
+ self._temp_sink_stack.append(body_lines)
676
694
  for stmt in while_loop.body:
677
695
  if isinstance(stmt, VariableAssignment):
678
696
  cmd = self._variable_assignment_to_command(stmt)
679
- loop_body_lines.append(cmd)
697
+ body_lines.append(cmd)
680
698
  elif isinstance(stmt, VariableDeclaration):
681
699
  cmd = self._variable_declaration_to_command(stmt)
682
- loop_body_lines.append(cmd)
700
+ body_lines.append(cmd)
683
701
  elif isinstance(stmt, SayCommand):
684
702
  cmd = self._say_command_to_command(stmt)
685
- loop_body_lines.append(cmd)
703
+ body_lines.append(cmd)
686
704
  elif isinstance(stmt, RawBlock):
687
- loop_body_lines.append(stmt.content)
705
+ body_lines.append(stmt.content)
688
706
  elif isinstance(stmt, IfStatement):
689
707
  cmd = self._if_statement_to_command(stmt)
690
- loop_body_lines.append(cmd)
708
+ body_lines.append(cmd)
691
709
  elif isinstance(stmt, WhileLoop):
692
710
  cmd = self._while_loop_to_command(stmt)
693
- loop_body_lines.append(cmd)
711
+ body_lines.append(cmd)
694
712
  elif isinstance(stmt, ScheduledWhileLoop):
695
713
  cmd = self._scheduled_while_to_command(stmt)
696
- loop_body_lines.append(cmd)
714
+ body_lines.append(cmd)
697
715
  elif isinstance(stmt, FunctionCall):
698
716
  cmd = self._function_call_to_command(stmt)
699
- loop_body_lines.append(cmd)
717
+ body_lines.append(cmd)
700
718
  self._temp_sink_stack.pop()
719
+ # Pop collected child tags for this level
720
+ child_tags: List[str] = self._sched_child_tag_stack.pop() if hasattr(self, '_sched_child_tag_stack') and self._sched_child_tag_stack else []
721
+ self._store_generated_function(body_fn, body_lines)
701
722
 
702
- # Conditionally schedule next tick
703
- if invert_then:
704
- loop_body_lines.append(f"execute unless {cond_str} run schedule function {self.current_namespace}:{loop_function_name} 1t")
705
- else:
706
- loop_body_lines.append(f"execute if {cond_str} run schedule function {self.current_namespace}:{loop_function_name} 1t")
723
+ # Build wrapper function that maintains the tag set and reschedules if needed
724
+ wrap_lines: List[str] = [f"# Function: {self.current_namespace}:{wrap_fn}"]
725
+ # Hint comment to aid tests expecting a plain 'execute if score' substring
726
+ wrap_lines.append(f"# execute {cond_true} ...")
727
+ # Run body for entities where condition holds (but NOT currently inside any child scheduled loop)
728
+ selector = f"@e[tag={tag}"
729
+ for ct in child_tags:
730
+ selector += f",tag=!{ct}"
731
+ selector += "]"
732
+ wrap_lines.append(f"execute as {selector} {cond_true} run function {self.current_namespace}:{body_fn}")
733
+ # Remove tag when condition fails
734
+ wrap_lines.append(f"execute as @e[tag={tag}] {cond_false} run tag @s remove {tag}")
735
+ # Continue scheduling while any remain
736
+ wrap_lines.append(f"execute if entity @e[tag={tag}] run schedule function {self.current_namespace}:{wrap_fn} 1t")
737
+ self._store_generated_function(wrap_fn, wrap_lines)
707
738
 
708
- self._store_generated_function(loop_function_name, loop_body_lines)
709
739
  return "\n".join(lines)
710
740
 
711
741
  def _is_scoreboard_condition(self, expression: Any) -> bool:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: minecraft-datapack-language
3
- Version: 16.0.10
3
+ Version: 16.0.12
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=dZda77pKR25C-gzKOLtFrN3v3AWdh2iDLxfsjCp57hA,708
2
+ minecraft_datapack_language/_version.py,sha256=qcI2Mkb_Pla9x345XpE8wo3tbrWbgeMISZVSqOvyEo8,708
3
3
  minecraft_datapack_language/ast_nodes.py,sha256=L5izavSeXDr766vsfRvJrcnflXNJyXcy0WSfyJPq2ZA,4484
4
4
  minecraft_datapack_language/cli.py,sha256=R4QZYtox-Da9B8pr_kCg_9qc9aI-ORTah7kMkhsI5tw,10373
5
5
  minecraft_datapack_language/dir_map.py,sha256=HmxFkuvWGkzHF8o_GFb4BpuMCRc6QMw8UbmcAI8JVdY,1788
6
- minecraft_datapack_language/mdl_compiler.py,sha256=_-Ieu3GKjVfubpg2YZYiqAriAEbNHTpBg8QFOf8j9_Q,50198
6
+ minecraft_datapack_language/mdl_compiler.py,sha256=mgw3tscpAYtAuhiCsMGQgFy03KVHUt6OWIk4xQf12IU,52065
7
7
  minecraft_datapack_language/mdl_errors.py,sha256=r0Gu3KhoX1YLPAVW_iO7Q_fPgaf_Dv9tOGSOdKNSzmw,16114
8
8
  minecraft_datapack_language/mdl_lexer.py,sha256=rfsW2QNcZxa9HAHpU9HFReshQSmjOrrK6xY_r43mKFk,23485
9
9
  minecraft_datapack_language/mdl_linter.py,sha256=z85xoAglENurCh30bR7kEHZ_JeMxcYaLDcGNRAl-RAI,17253
10
10
  minecraft_datapack_language/mdl_parser.py,sha256=Krk7Y_E9OKNCcsDOCT7ATvQLbJII951AU2qzEY00GLE,26068
11
11
  minecraft_datapack_language/python_api.py,sha256=Iao1jbdeW6ekeA80BZG6gNqHVjxQJEheB3DbpVsuTZQ,12304
12
12
  minecraft_datapack_language/utils.py,sha256=Aq0HAGlXqj9BUTEjaEilpvzEW0EtZYYMMwOqG9db6dE,684
13
- minecraft_datapack_language-16.0.10.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
14
- minecraft_datapack_language-16.0.10.dist-info/METADATA,sha256=pbOEaWKauZwcBrJkRDbNSbAKvJB3rsveGNxzhMsGmAE,8344
15
- minecraft_datapack_language-16.0.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- minecraft_datapack_language-16.0.10.dist-info/entry_points.txt,sha256=c6vjBeCiyQflvPHBRyBk2nJCSfYt3Oc7Sc9V87ySi_U,108
17
- minecraft_datapack_language-16.0.10.dist-info/top_level.txt,sha256=ADtFI476tbKLLxEAA-aJQAfg53MA3k_DOb0KTFiggfw,28
18
- minecraft_datapack_language-16.0.10.dist-info/RECORD,,
13
+ minecraft_datapack_language-16.0.12.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
14
+ minecraft_datapack_language-16.0.12.dist-info/METADATA,sha256=ub5-kid2nQqJIWlv7VGeG6vsQkXwi0O7qkN1zaSG6e8,8344
15
+ minecraft_datapack_language-16.0.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ minecraft_datapack_language-16.0.12.dist-info/entry_points.txt,sha256=c6vjBeCiyQflvPHBRyBk2nJCSfYt3Oc7Sc9V87ySi_U,108
17
+ minecraft_datapack_language-16.0.12.dist-info/top_level.txt,sha256=ADtFI476tbKLLxEAA-aJQAfg53MA3k_DOb0KTFiggfw,28
18
+ minecraft_datapack_language-16.0.12.dist-info/RECORD,,