minecraft-datapack-language 15.1.75__py3-none-any.whl → 15.1.77__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 = '15.1.75'
32
- __version_tuple__ = version_tuple = (15, 1, 75)
31
+ __version__ = version = '15.1.77'
32
+ __version_tuple__ = version_tuple = (15, 1, 77)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -234,29 +234,37 @@ def _process_say_command_with_variables(content: str, selector: str) -> str:
234
234
  word_matches = re.findall(word_pattern, content)
235
235
 
236
236
  if word_matches:
237
- # Found potential variables, convert to score components
237
+ # Process the content by replacing each variable with a score component
238
238
  components = []
239
- remaining_content = content
239
+ processed_content = content
240
240
 
241
- for var_name in word_matches:
242
- # Find the position of this variable in the remaining content
243
- var_pos = remaining_content.find(var_name)
244
- if var_pos >= 0:
245
- # Add text before variable
246
- if var_pos > 0:
247
- text_before = remaining_content[:var_pos]
248
- if text_before:
249
- components.append(f'{{"text":"{text_before}"}}')
250
-
251
- # Add score component for variable
252
- components.append(f'{{"score":{{"name":"@e[type=armor_stand,tag=mdl_server,limit=1]","objective":"{var_name}"}}}}')
253
-
254
- # Continue with remaining content after this variable
255
- remaining_content = remaining_content[var_pos + len(var_name):]
241
+ # Sort variables by their position in the content to process them in order
242
+ var_positions = []
243
+ for var_name in set(word_matches): # Remove duplicates
244
+ pos = processed_content.find(var_name)
245
+ if pos >= 0:
246
+ var_positions.append((pos, var_name))
256
247
 
257
- # Add remaining text
258
- if remaining_content:
259
- components.append(f'{{"text":"{remaining_content}"}}')
248
+ var_positions.sort() # Sort by position
249
+
250
+ last_pos = 0
251
+ for pos, var_name in var_positions:
252
+ # Add text before this variable
253
+ if pos > last_pos:
254
+ text_before = processed_content[last_pos:pos]
255
+ if text_before:
256
+ components.append(f'{{"text":"{text_before}"}}')
257
+
258
+ # Add score component for variable
259
+ components.append(f'{{"score":{{"name":"@e[type=armor_stand,tag=mdl_server,limit=1]","objective":"{var_name}"}}}}')
260
+
261
+ last_pos = pos + len(var_name)
262
+
263
+ # Add remaining text after last variable
264
+ if last_pos < len(processed_content):
265
+ remaining_text = processed_content[last_pos:]
266
+ if remaining_text:
267
+ components.append(f'{{"text":"{remaining_text}"}}')
260
268
 
261
269
  # Combine all components
262
270
  components_str = ','.join(components)
@@ -424,10 +432,12 @@ def _process_statement(statement: Any, namespace: str, function_name: str, state
424
432
 
425
433
  # Add the conditional execution command
426
434
  if else_body:
427
- commands.append(f"execute {minecraft_condition} run function {namespace}:{if_func_name}")
435
+ commands.append(f"execute if {minecraft_condition} run function {namespace}:{if_func_name}")
428
436
  commands.append(f"execute unless {minecraft_condition} run function {namespace}:{else_func_name}")
437
+ # Add if_end function call for cleanup
438
+ commands.append(f"function {namespace}:{function_name}_if_end_{statement_index}")
429
439
  else:
430
- commands.append(f"execute {minecraft_condition} run function {namespace}:{if_func_name}")
440
+ commands.append(f"execute if {minecraft_condition} run function {namespace}:{if_func_name}")
431
441
 
432
442
  elif statement['type'] == 'while_loop' or statement['type'] == 'while_statement':
433
443
  # Handle while loops using recursion
@@ -488,9 +498,15 @@ def _generate_function_file(ast: Dict[str, Any], output_dir: Path, namespace: st
488
498
 
489
499
  # Write function file
490
500
  if function_commands:
491
- # Add armor stand setup to the beginning of each function
501
+ # Only add armor stand setup to main functions that need it
502
+ # Don't add to helper functions or functions in the "other" namespace
503
+ should_add_armor_stand = (namespace != "other" and
504
+ func_name in ["main", "init", "load"] or
505
+ any(cmd for cmd in function_commands if "scoreboard" in cmd or "tellraw" in cmd))
506
+
492
507
  final_commands = []
493
- final_commands.append("execute unless entity @e[type=armor_stand,tag=mdl_server,limit=1] run summon armor_stand ~ 320 ~ {Tags:[\"mdl_server\"],Invisible:1b,Marker:1b,NoGravity:1b,Invulnerable:1b}")
508
+ if should_add_armor_stand:
509
+ final_commands.append("execute unless entity @e[type=armor_stand,tag=mdl_server,limit=1] run summon armor_stand ~ 320 ~ {Tags:[\"mdl_server\"],Invisible:1b,Marker:1b,NoGravity:1b,Invulnerable:1b}")
494
510
  final_commands.extend(function_commands)
495
511
 
496
512
  if verbose:
@@ -646,16 +662,16 @@ def _process_while_loop_recursion(while_statement, namespace: str, function_name
646
662
  # Create the main loop function
647
663
  minecraft_condition = _convert_condition_to_minecraft_syntax(condition, selector)
648
664
  loop_commands = [
649
- f"execute {minecraft_condition} run function {namespace}:{loop_body_func_name}",
650
- f"execute {minecraft_condition} run function {namespace}:{loop_func_name}"
665
+ f"execute if {minecraft_condition} run function {namespace}:{loop_body_func_name}",
666
+ f"execute if {minecraft_condition} run function {namespace}:{loop_func_name}"
651
667
  ]
652
668
 
653
669
  # Write loop function
654
670
  with open(func_dir / f"{loop_func_name}.mcfunction", 'w', encoding='utf-8') as f:
655
671
  f.write('\n'.join(loop_commands))
656
672
 
657
- # Return the command to start the loop
658
- return [f"function {namespace}:{loop_func_name}"]
673
+ # Return the command to start the loop with conditional execution
674
+ return [f"execute if {minecraft_condition} run function {namespace}:{loop_func_name}"]
659
675
 
660
676
 
661
677
  def _process_while_loop_schedule(while_statement, namespace: str, function_name: str, statement_index: int, is_tag_function: bool = False, selector: str = "@s", variable_scopes: Dict[str, str] = None, build_context: BuildContext = None) -> List[str]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: minecraft-datapack-language
3
- Version: 15.1.75
3
+ Version: 15.1.77
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=bukgiJaLfd44bN73uBPz3hCzin-QTY3ff3p-wP0h-iU,708
2
+ minecraft_datapack_language/_version.py,sha256=MX48oNCAEJyrqB8cvh5XZc3fKpHeRjMav0PQLztoKfo,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=KA6tW7Zzdeh3DGwwi05AcKDc3mKn9sAbEn1Nr42DxYE,42285
5
+ minecraft_datapack_language/cli_build.py,sha256=s90ZjY4jItiYYKtcpM7KrrHiJA7xurvqgCmrOcqsvl4,43188
6
6
  minecraft_datapack_language/cli_check.py,sha256=bPq9gHsxQ1CIiftkrAtRCifWkVAyjp5c8Oay2NNQ1qs,6277
7
7
  minecraft_datapack_language/cli_help.py,sha256=jUTHUQBONAZKVTdQK9tNPXq4c_6xpsafNOvHDjkEldg,12243
8
8
  minecraft_datapack_language/cli_new.py,sha256=uaKH0VBC43XBt_Hztc35-BfC9bYlsDdLbAfe_42rrtI,8235
@@ -16,9 +16,9 @@ minecraft_datapack_language/mdl_linter.py,sha256=z85xoAglENurCh30bR7kEHZ_JeMxcYa
16
16
  minecraft_datapack_language/mdl_parser_js.py,sha256=4VMWx6O7A10afTzjGnnwL_Sh52osIO84ObqHp8KoDZw,38677
17
17
  minecraft_datapack_language/pack.py,sha256=nYiXQ3jgJlDfc4m-65f7C2LFhDRioaUU_XVy6Na4SJI,34625
18
18
  minecraft_datapack_language/utils.py,sha256=Aq0HAGlXqj9BUTEjaEilpvzEW0EtZYYMMwOqG9db6dE,684
19
- minecraft_datapack_language-15.1.75.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
20
- minecraft_datapack_language-15.1.75.dist-info/METADATA,sha256=c50ZFTMwtTzQN9fccyHDjRxMejtQJ2ytAzW49EEhr8Q,35230
21
- minecraft_datapack_language-15.1.75.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
- minecraft_datapack_language-15.1.75.dist-info/entry_points.txt,sha256=c6vjBeCiyQflvPHBRyBk2nJCSfYt3Oc7Sc9V87ySi_U,108
23
- minecraft_datapack_language-15.1.75.dist-info/top_level.txt,sha256=ADtFI476tbKLLxEAA-aJQAfg53MA3k_DOb0KTFiggfw,28
24
- minecraft_datapack_language-15.1.75.dist-info/RECORD,,
19
+ minecraft_datapack_language-15.1.77.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
20
+ minecraft_datapack_language-15.1.77.dist-info/METADATA,sha256=uK2ZkCkYfQGenqR7J362qUSKpmnVS78e5JIgOZL1XPI,35230
21
+ minecraft_datapack_language-15.1.77.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
+ minecraft_datapack_language-15.1.77.dist-info/entry_points.txt,sha256=c6vjBeCiyQflvPHBRyBk2nJCSfYt3Oc7Sc9V87ySi_U,108
23
+ minecraft_datapack_language-15.1.77.dist-info/top_level.txt,sha256=ADtFI476tbKLLxEAA-aJQAfg53MA3k_DOb0KTFiggfw,28
24
+ minecraft_datapack_language-15.1.77.dist-info/RECORD,,