minecraft-datapack-language 15.1.62__py3-none-any.whl → 15.1.64__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 +68 -12
- minecraft_datapack_language/cli_utils.py +31 -13
- {minecraft_datapack_language-15.1.62.dist-info → minecraft_datapack_language-15.1.64.dist-info}/METADATA +1 -1
- {minecraft_datapack_language-15.1.62.dist-info → minecraft_datapack_language-15.1.64.dist-info}/RECORD +9 -9
- {minecraft_datapack_language-15.1.62.dist-info → minecraft_datapack_language-15.1.64.dist-info}/WHEEL +0 -0
- {minecraft_datapack_language-15.1.62.dist-info → minecraft_datapack_language-15.1.64.dist-info}/entry_points.txt +0 -0
- {minecraft_datapack_language-15.1.62.dist-info → minecraft_datapack_language-15.1.64.dist-info}/licenses/LICENSE +0 -0
- {minecraft_datapack_language-15.1.62.dist-info → minecraft_datapack_language-15.1.64.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.64'
|
32
|
+
__version_tuple__ = version_tuple = (15, 1, 64)
|
33
33
|
|
34
34
|
__commit_id__ = commit_id = None
|
@@ -193,6 +193,10 @@ def _generate_load_function(scoreboard_commands: List[str], output_dir: Path, na
|
|
193
193
|
"""Generate the load function with scoreboard setup."""
|
194
194
|
load_content = []
|
195
195
|
|
196
|
+
# Add armor stand setup for server-side operations
|
197
|
+
load_content.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}")
|
198
|
+
load_content.append("")
|
199
|
+
|
196
200
|
# Add scoreboard objectives
|
197
201
|
load_content.extend(scoreboard_commands)
|
198
202
|
|
@@ -213,15 +217,20 @@ def _process_say_command_with_variables(content: str, selector: str) -> str:
|
|
213
217
|
"""Process say command content with variable substitution, converting to tellraw with score components."""
|
214
218
|
import re
|
215
219
|
|
220
|
+
# Clean up the content - remove quotes if present
|
221
|
+
content = content.strip()
|
222
|
+
if content.startswith('"') and content.endswith('"'):
|
223
|
+
content = content[1:-1] # Remove surrounding quotes
|
224
|
+
|
216
225
|
# Find all variable references like $variable$ or $variable<selector>$
|
217
226
|
var_pattern = r'\$([^$]+)\$'
|
218
227
|
matches = re.findall(var_pattern, content)
|
219
228
|
|
220
229
|
if not matches:
|
221
230
|
# No variables, return simple tellraw
|
222
|
-
return f'tellraw @a [{{"text":{content}}}]'
|
231
|
+
return f'tellraw @a [{{"text":"{content}"}}]'
|
223
232
|
|
224
|
-
# Split content by variable references
|
233
|
+
# Split content by variable references while preserving the structure
|
225
234
|
parts = re.split(var_pattern, content)
|
226
235
|
|
227
236
|
# Build tellraw components
|
@@ -244,8 +253,8 @@ def _process_say_command_with_variables(content: str, selector: str) -> str:
|
|
244
253
|
var_selector = var_parts[1][:-1] # Remove trailing >
|
245
254
|
components.append(f'{{"score":{{"name":"{var_selector}","objective":"{base_var}"}}}}')
|
246
255
|
else:
|
247
|
-
# Simple variable: $variable$
|
248
|
-
components.append(f'{{"score":{{"name":"
|
256
|
+
# Simple variable: $variable$ - use server armor stand
|
257
|
+
components.append(f'{{"score":{{"name":"@e[type=armor_stand,tag=mdl_server,limit=1]","objective":"{var_name}"}}}}')
|
249
258
|
|
250
259
|
var_index += 1
|
251
260
|
|
@@ -292,13 +301,43 @@ def _process_statement(statement: Any, namespace: str, function_name: str, state
|
|
292
301
|
commands.append(f"scoreboard players operation {var_name} {selector} = {ref_var} {selector}")
|
293
302
|
elif hasattr(value, '__class__') and 'BinaryExpression' in str(value.__class__):
|
294
303
|
# Handle complex expressions (BinaryExpression, etc.)
|
295
|
-
#
|
296
|
-
|
304
|
+
# Convert to proper Minecraft scoreboard commands
|
305
|
+
if hasattr(value, 'left') and hasattr(value, 'right') and hasattr(value, 'operator'):
|
306
|
+
left = value.left
|
307
|
+
right = value.right
|
308
|
+
operator = value.operator
|
309
|
+
|
310
|
+
# Handle different operators
|
311
|
+
if operator == 'PLUS':
|
312
|
+
if hasattr(left, 'name') and hasattr(right, 'value'):
|
313
|
+
# counter = counter + 1
|
314
|
+
commands.append(f"scoreboard players add {var_name} {selector} {right.value}")
|
315
|
+
else:
|
316
|
+
# Complex case - use operation
|
317
|
+
commands.append(f"# Complex addition: {var_name} = {left} + {right}")
|
318
|
+
elif operator == 'MINUS':
|
319
|
+
if hasattr(left, 'name') and hasattr(right, 'value'):
|
320
|
+
# health = health - 10
|
321
|
+
commands.append(f"scoreboard players remove {var_name} {selector} {right.value}")
|
322
|
+
else:
|
323
|
+
# Complex case - use operation
|
324
|
+
commands.append(f"# Complex subtraction: {var_name} = {left} - {right}")
|
325
|
+
else:
|
326
|
+
# Other operators - use operation
|
327
|
+
commands.append(f"# Complex operation: {var_name} = {left} {operator} {right}")
|
328
|
+
else:
|
329
|
+
commands.append(f"# Complex assignment: {var_name} = {value}")
|
297
330
|
else:
|
298
|
-
#
|
331
|
+
# Handle LiteralExpression and other value types
|
299
332
|
try:
|
300
|
-
|
301
|
-
|
333
|
+
if hasattr(value, 'value'):
|
334
|
+
# LiteralExpression case
|
335
|
+
num_value = int(value.value)
|
336
|
+
commands.append(f"scoreboard players set {var_name} {selector} {num_value}")
|
337
|
+
else:
|
338
|
+
# Direct value case
|
339
|
+
num_value = int(value)
|
340
|
+
commands.append(f"scoreboard players set {var_name} {selector} {num_value}")
|
302
341
|
except (ValueError, TypeError):
|
303
342
|
# If we can't convert to int, add a placeholder
|
304
343
|
commands.append(f"# Assignment: {var_name} = {value}")
|
@@ -322,7 +361,11 @@ def _process_statement(statement: Any, namespace: str, function_name: str, state
|
|
322
361
|
|
323
362
|
# Write conditional function
|
324
363
|
if if_commands:
|
325
|
-
|
364
|
+
# Use the output directory from build context
|
365
|
+
if hasattr(build_context, 'output_dir'):
|
366
|
+
if_dir = build_context.output_dir / "data" / namespace / "function"
|
367
|
+
else:
|
368
|
+
if_dir = Path(f"data/{namespace}/function")
|
326
369
|
ensure_dir(str(if_dir))
|
327
370
|
with open(if_dir / f"{if_func_name}.mcfunction", 'w', encoding='utf-8') as f:
|
328
371
|
f.write('\n'.join(if_commands))
|
@@ -436,6 +479,11 @@ def _generate_hook_files(ast: Dict[str, Any], output_dir: Path, namespace: str,
|
|
436
479
|
if hook['hook_type'] == 'load':
|
437
480
|
load_values.append(hook['function_name'])
|
438
481
|
|
482
|
+
# Add pack-specific load function if pack name is available
|
483
|
+
if 'pack' in ast and 'name' in ast['pack']:
|
484
|
+
pack_name = ast['pack']['name']
|
485
|
+
load_values.append(f"{pack_name}:load")
|
486
|
+
|
439
487
|
load_tag_content = {
|
440
488
|
"values": load_values
|
441
489
|
}
|
@@ -534,7 +582,11 @@ def _process_while_loop_recursion(while_statement, namespace: str, function_name
|
|
534
582
|
|
535
583
|
# Write loop body function
|
536
584
|
if body_commands:
|
537
|
-
|
585
|
+
# Use the output directory from build context
|
586
|
+
if hasattr(build_context, 'output_dir'):
|
587
|
+
func_dir = build_context.output_dir / "data" / namespace / "function"
|
588
|
+
else:
|
589
|
+
func_dir = Path(f"data/{namespace}/function")
|
538
590
|
ensure_dir(str(func_dir))
|
539
591
|
with open(func_dir / f"{loop_body_func_name}.mcfunction", 'w', encoding='utf-8') as f:
|
540
592
|
f.write('\n'.join(body_commands))
|
@@ -580,7 +632,11 @@ def _process_while_loop_schedule(while_statement, namespace: str, function_name:
|
|
580
632
|
|
581
633
|
# Write loop body function
|
582
634
|
if body_commands:
|
583
|
-
|
635
|
+
# Use the output directory from build context
|
636
|
+
if hasattr(build_context, 'output_dir'):
|
637
|
+
func_dir = build_context.output_dir / "data" / namespace / "function"
|
638
|
+
else:
|
639
|
+
func_dir = Path(f"data/{namespace}/function")
|
584
640
|
ensure_dir(str(func_dir))
|
585
641
|
with open(func_dir / f"{loop_body_func_name}.mcfunction", 'w', encoding='utf-8') as f:
|
586
642
|
f.write('\n'.join(body_commands))
|
@@ -119,6 +119,24 @@ def _convert_condition_to_minecraft_syntax(condition: str, selector: str = "@s")
|
|
119
119
|
# Remove extra whitespace and normalize
|
120
120
|
condition = condition.strip()
|
121
121
|
|
122
|
+
# Handle variable substitution in conditions (e.g., "$value$ > 3")
|
123
|
+
import re
|
124
|
+
var_pattern = r'\$([^$]+)\$'
|
125
|
+
|
126
|
+
# Replace variable references with proper scoreboard syntax
|
127
|
+
def replace_var(match):
|
128
|
+
var_name = match.group(1)
|
129
|
+
# Remove scope selector if present
|
130
|
+
if '<' in var_name and var_name.endswith('>'):
|
131
|
+
var_parts = var_name.split('<', 1)
|
132
|
+
base_var = var_parts[0]
|
133
|
+
return f"@e[type=armor_stand,tag=mdl_server,limit=1] {base_var}"
|
134
|
+
else:
|
135
|
+
return f"@e[type=armor_stand,tag=mdl_server,limit=1] {var_name}"
|
136
|
+
|
137
|
+
# Apply variable substitution
|
138
|
+
condition = re.sub(var_pattern, replace_var)
|
139
|
+
|
122
140
|
# Handle common patterns
|
123
141
|
if '==' in condition:
|
124
142
|
var1, var2 = condition.split('==', 1)
|
@@ -128,10 +146,10 @@ def _convert_condition_to_minecraft_syntax(condition: str, selector: str = "@s")
|
|
128
146
|
# Check if var2 is a number
|
129
147
|
try:
|
130
148
|
value = int(var2)
|
131
|
-
return f"score {var1}
|
149
|
+
return f"score {var1} matches {value}"
|
132
150
|
except ValueError:
|
133
151
|
# Both are variables, compare them
|
134
|
-
return f"score {var1}
|
152
|
+
return f"score {var1} = {var2}"
|
135
153
|
|
136
154
|
elif '!=' in condition:
|
137
155
|
var1, var2 = condition.split('!=', 1)
|
@@ -140,9 +158,9 @@ def _convert_condition_to_minecraft_syntax(condition: str, selector: str = "@s")
|
|
140
158
|
|
141
159
|
try:
|
142
160
|
value = int(var2)
|
143
|
-
return f"score {var1}
|
161
|
+
return f"score {var1} matches ..{value-1} {value+1}.."
|
144
162
|
except ValueError:
|
145
|
-
return f"score {var1}
|
163
|
+
return f"score {var1} != {var2}"
|
146
164
|
|
147
165
|
elif '>' in condition:
|
148
166
|
var1, var2 = condition.split('>', 1)
|
@@ -151,9 +169,9 @@ def _convert_condition_to_minecraft_syntax(condition: str, selector: str = "@s")
|
|
151
169
|
|
152
170
|
try:
|
153
171
|
value = int(var2)
|
154
|
-
return f"score {var1}
|
172
|
+
return f"score {var1} matches {value+1}.."
|
155
173
|
except ValueError:
|
156
|
-
return f"score {var1}
|
174
|
+
return f"score {var1} > {var2}"
|
157
175
|
|
158
176
|
elif '<' in condition:
|
159
177
|
var1, var2 = condition.split('<', 1)
|
@@ -162,9 +180,9 @@ def _convert_condition_to_minecraft_syntax(condition: str, selector: str = "@s")
|
|
162
180
|
|
163
181
|
try:
|
164
182
|
value = int(var2)
|
165
|
-
return f"score {var1}
|
183
|
+
return f"score {var1} matches ..{value-1}"
|
166
184
|
except ValueError:
|
167
|
-
return f"score {var1}
|
185
|
+
return f"score {var1} < {var2}"
|
168
186
|
|
169
187
|
elif '>=' in condition:
|
170
188
|
var1, var2 = condition.split('>=', 1)
|
@@ -173,9 +191,9 @@ def _convert_condition_to_minecraft_syntax(condition: str, selector: str = "@s")
|
|
173
191
|
|
174
192
|
try:
|
175
193
|
value = int(var2)
|
176
|
-
return f"score {var1}
|
194
|
+
return f"score {var1} matches {value}.."
|
177
195
|
except ValueError:
|
178
|
-
return f"score {var1}
|
196
|
+
return f"score {var1} >= {var2}"
|
179
197
|
|
180
198
|
elif '<=' in condition:
|
181
199
|
var1, var2 = condition.split('<=', 1)
|
@@ -184,12 +202,12 @@ def _convert_condition_to_minecraft_syntax(condition: str, selector: str = "@s")
|
|
184
202
|
|
185
203
|
try:
|
186
204
|
value = int(var2)
|
187
|
-
return f"score {var1}
|
205
|
+
return f"score {var1} matches ..{value}"
|
188
206
|
except ValueError:
|
189
|
-
return f"score {var1}
|
207
|
+
return f"score {var1} <= {var2}"
|
190
208
|
|
191
209
|
# Default: treat as a variable that should be non-zero
|
192
|
-
return f"score {condition}
|
210
|
+
return f"score {condition} matches 1.."
|
193
211
|
|
194
212
|
|
195
213
|
def _find_mdl_files(directory: Path) -> List[Path]:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: minecraft-datapack-language
|
3
|
-
Version: 15.1.
|
3
|
+
Version: 15.1.64
|
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,12 +1,12 @@
|
|
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=DJ37ZFW0-8bmiU8fhrOkLHBwJ5JCGFDJDrTsKgcDtr4,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=hrD48HTeI4h3jOUU18UVPUx7m6sOD7CuJ1hCCU7iTZ4,39358
|
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
|
9
|
-
minecraft_datapack_language/cli_utils.py,sha256=
|
9
|
+
minecraft_datapack_language/cli_utils.py,sha256=OF64njFa_19qGJ-1EBMI8btMs8OUi-0wGoFAQo6525U,9775
|
10
10
|
minecraft_datapack_language/dir_map.py,sha256=HmxFkuvWGkzHF8o_GFb4BpuMCRc6QMw8UbmcAI8JVdY,1788
|
11
11
|
minecraft_datapack_language/expression_processor.py,sha256=GN6cuRNvgI8TrV6YnEHrA9P0X-ACTT7rCBh4WlOPjSI,20140
|
12
12
|
minecraft_datapack_language/linter.py,sha256=7UqbygC5JPCGg-BSOq65NB2xEJBu_OUOYIIgmHItO2M,16567
|
@@ -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.64.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
20
|
+
minecraft_datapack_language-15.1.64.dist-info/METADATA,sha256=Y1PLkQMTnvjgUwSwSbVwES8QhXoG3CnJjysLUspxw8w,35230
|
21
|
+
minecraft_datapack_language-15.1.64.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
22
|
+
minecraft_datapack_language-15.1.64.dist-info/entry_points.txt,sha256=c6vjBeCiyQflvPHBRyBk2nJCSfYt3Oc7Sc9V87ySi_U,108
|
23
|
+
minecraft_datapack_language-15.1.64.dist-info/top_level.txt,sha256=ADtFI476tbKLLxEAA-aJQAfg53MA3k_DOb0KTFiggfw,28
|
24
|
+
minecraft_datapack_language-15.1.64.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|