minecraft-datapack-language 15.1.79__py3-none-any.whl → 15.1.81__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 +43 -66
- {minecraft_datapack_language-15.1.79.dist-info → minecraft_datapack_language-15.1.81.dist-info}/METADATA +1 -1
- {minecraft_datapack_language-15.1.79.dist-info → minecraft_datapack_language-15.1.81.dist-info}/RECORD +8 -8
- {minecraft_datapack_language-15.1.79.dist-info → minecraft_datapack_language-15.1.81.dist-info}/WHEEL +0 -0
- {minecraft_datapack_language-15.1.79.dist-info → minecraft_datapack_language-15.1.81.dist-info}/entry_points.txt +0 -0
- {minecraft_datapack_language-15.1.79.dist-info → minecraft_datapack_language-15.1.81.dist-info}/licenses/LICENSE +0 -0
- {minecraft_datapack_language-15.1.79.dist-info → minecraft_datapack_language-15.1.81.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.1.
|
32
|
-
__version_tuple__ = version_tuple = (15, 1,
|
31
|
+
__version__ = version = '15.1.81'
|
32
|
+
__version_tuple__ = version_tuple = (15, 1, 81)
|
33
33
|
|
34
34
|
__commit_id__ = commit_id = None
|
@@ -155,14 +155,16 @@ def _generate_scoreboard_objectives(ast: Dict[str, Any], output_dir: Path) -> Li
|
|
155
155
|
"""Generate scoreboard objectives for all variables."""
|
156
156
|
scoreboard_commands = []
|
157
157
|
|
158
|
-
# Collect all variable names
|
159
|
-
variables =
|
158
|
+
# Collect all variable names in order of appearance
|
159
|
+
variables = []
|
160
|
+
seen_variables = set()
|
160
161
|
|
161
|
-
# From variable declarations
|
162
|
+
# From variable declarations (preserve order)
|
162
163
|
if 'variables' in ast:
|
163
164
|
for var_decl in ast['variables']:
|
164
|
-
if 'name' in var_decl:
|
165
|
-
variables.
|
165
|
+
if 'name' in var_decl and var_decl['name'] not in seen_variables:
|
166
|
+
variables.append(var_decl['name'])
|
167
|
+
seen_variables.add(var_decl['name'])
|
166
168
|
|
167
169
|
# From functions (scan for variable usage)
|
168
170
|
if 'functions' in ast:
|
@@ -171,7 +173,9 @@ def _generate_scoreboard_objectives(ast: Dict[str, Any], output_dir: Path) -> Li
|
|
171
173
|
for statement in func['body']:
|
172
174
|
# Look for variable assignments and usage
|
173
175
|
if statement['type'] == 'variable_assignment':
|
174
|
-
|
176
|
+
if statement['name'] not in seen_variables:
|
177
|
+
variables.append(statement['name'])
|
178
|
+
seen_variables.add(statement['name'])
|
175
179
|
elif statement['type'] == 'command':
|
176
180
|
# Scan command for variable substitutions
|
177
181
|
command = statement['command']
|
@@ -180,10 +184,12 @@ def _generate_scoreboard_objectives(ast: Dict[str, Any], output_dir: Path) -> Li
|
|
180
184
|
for var_name in var_matches:
|
181
185
|
# Extract base name from scoped variables
|
182
186
|
base_name = _extract_base_variable_name(var_name)
|
183
|
-
|
187
|
+
if base_name not in seen_variables:
|
188
|
+
variables.append(base_name)
|
189
|
+
seen_variables.add(base_name)
|
184
190
|
|
185
|
-
# Create scoreboard objectives
|
186
|
-
for var_name in
|
191
|
+
# Create scoreboard objectives in the order they were found
|
192
|
+
for var_name in variables:
|
187
193
|
scoreboard_commands.append(f"scoreboard objectives add {var_name} dummy")
|
188
194
|
|
189
195
|
return scoreboard_commands
|
@@ -228,65 +234,38 @@ def _process_say_command_with_variables(content: str, selector: str) -> str:
|
|
228
234
|
matches = re.findall(var_pattern, content)
|
229
235
|
|
230
236
|
if not matches:
|
231
|
-
#
|
232
|
-
|
233
|
-
word_pattern = r'\b(counter|health|score|value|num|count|timer|level)\b'
|
234
|
-
word_matches = re.findall(word_pattern, content)
|
235
|
-
|
236
|
-
if word_matches:
|
237
|
-
# Process the content by replacing each variable with a score component
|
238
|
-
components = []
|
239
|
-
processed_content = content
|
240
|
-
|
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))
|
247
|
-
|
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}"}}')
|
268
|
-
|
269
|
-
# Combine all components
|
270
|
-
components_str = ','.join(components)
|
271
|
-
return f'tellraw @a [{components_str}]'
|
272
|
-
else:
|
273
|
-
# No variables, return simple tellraw
|
274
|
-
return f'tellraw @a [{{"text":"{content}"}}]'
|
237
|
+
# No variables, return simple tellraw
|
238
|
+
return f'tellraw @a [{{"text":"{content}"}}]'
|
275
239
|
|
276
|
-
#
|
277
|
-
|
240
|
+
# Use re.sub to replace variables with placeholders, then split by placeholders
|
241
|
+
# This avoids the issue with re.split including captured groups
|
242
|
+
placeholder_content = content
|
243
|
+
var_placeholders = []
|
244
|
+
|
245
|
+
for i, match in enumerate(matches):
|
246
|
+
placeholder = f"__VAR_{i}__"
|
247
|
+
var_placeholders.append((placeholder, match))
|
248
|
+
placeholder_content = placeholder_content.replace(f"${match}$", placeholder, 1)
|
249
|
+
|
250
|
+
# Split by placeholders to get text parts
|
251
|
+
text_parts = placeholder_content
|
252
|
+
for placeholder, var_name in var_placeholders:
|
253
|
+
text_parts = text_parts.replace(placeholder, f"|{var_name}|")
|
254
|
+
|
255
|
+
# Now split by the pipe delimiters
|
256
|
+
parts = text_parts.split('|')
|
278
257
|
|
279
258
|
# Build tellraw components
|
280
259
|
components = []
|
281
|
-
var_index = 0
|
282
260
|
|
283
261
|
for i, part in enumerate(parts):
|
284
|
-
if
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
262
|
+
if i % 2 == 0:
|
263
|
+
# Text part
|
264
|
+
if part: # Add text component if not empty
|
265
|
+
components.append(f'{{"text":"{part}"}}')
|
266
|
+
else:
|
267
|
+
# Variable part
|
268
|
+
var_name = part
|
290
269
|
|
291
270
|
# Check if variable has scope selector
|
292
271
|
if '<' in var_name and var_name.endswith('>'):
|
@@ -298,8 +277,6 @@ def _process_say_command_with_variables(content: str, selector: str) -> str:
|
|
298
277
|
else:
|
299
278
|
# Simple variable: $variable$ - use server armor stand
|
300
279
|
components.append(f'{{"score":{{"name":"@e[type=armor_stand,tag=mdl_server,limit=1]","objective":"{var_name}"}}}}')
|
301
|
-
|
302
|
-
var_index += 1
|
303
280
|
|
304
281
|
# Combine all components
|
305
282
|
components_str = ','.join(components)
|
@@ -640,8 +617,8 @@ def _process_while_loop_recursion(while_statement, namespace: str, function_name
|
|
640
617
|
body = while_statement['body']
|
641
618
|
|
642
619
|
# Generate unique function names
|
643
|
-
loop_func_name = f"{function_name}_while_{statement_index}"
|
644
|
-
loop_body_func_name = f"{function_name}
|
620
|
+
loop_func_name = f"{namespace}_{function_name}_while_{statement_index}"
|
621
|
+
loop_body_func_name = f"{namespace}_{function_name}_while_{statement_index}"
|
645
622
|
|
646
623
|
# Process loop body
|
647
624
|
body_commands = []
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: minecraft-datapack-language
|
3
|
-
Version: 15.1.
|
3
|
+
Version: 15.1.81
|
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=PouTZRlXiJiT85KKzWG-K7UwauiTv-ftV3RaLTyPh64,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=aPlyB5DKoafCpxbFl597kR5-m3eP1YGqtsKOqrQD68Y,42212
|
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.
|
20
|
-
minecraft_datapack_language-15.1.
|
21
|
-
minecraft_datapack_language-15.1.
|
22
|
-
minecraft_datapack_language-15.1.
|
23
|
-
minecraft_datapack_language-15.1.
|
24
|
-
minecraft_datapack_language-15.1.
|
19
|
+
minecraft_datapack_language-15.1.81.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
20
|
+
minecraft_datapack_language-15.1.81.dist-info/METADATA,sha256=ewdotxZ8pwgR6MIp3oHVTvZDPIORWkLlGKv5mrJfFqw,35230
|
21
|
+
minecraft_datapack_language-15.1.81.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
22
|
+
minecraft_datapack_language-15.1.81.dist-info/entry_points.txt,sha256=c6vjBeCiyQflvPHBRyBk2nJCSfYt3Oc7Sc9V87ySi_U,108
|
23
|
+
minecraft_datapack_language-15.1.81.dist-info/top_level.txt,sha256=ADtFI476tbKLLxEAA-aJQAfg53MA3k_DOb0KTFiggfw,28
|
24
|
+
minecraft_datapack_language-15.1.81.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|