minecraft-datapack-language 16.0.14__py3-none-any.whl → 16.0.16__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 +67 -33
- {minecraft_datapack_language-16.0.14.dist-info → minecraft_datapack_language-16.0.16.dist-info}/METADATA +1 -1
- {minecraft_datapack_language-16.0.14.dist-info → minecraft_datapack_language-16.0.16.dist-info}/RECORD +8 -8
- {minecraft_datapack_language-16.0.14.dist-info → minecraft_datapack_language-16.0.16.dist-info}/WHEEL +0 -0
- {minecraft_datapack_language-16.0.14.dist-info → minecraft_datapack_language-16.0.16.dist-info}/entry_points.txt +0 -0
- {minecraft_datapack_language-16.0.14.dist-info → minecraft_datapack_language-16.0.16.dist-info}/licenses/LICENSE +0 -0
- {minecraft_datapack_language-16.0.14.dist-info → minecraft_datapack_language-16.0.16.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 = '16.0.
|
32
|
-
__version_tuple__ = version_tuple = (16, 0,
|
31
|
+
__version__ = version = '16.0.16'
|
32
|
+
__version_tuple__ = version_tuple = (16, 0, 16)
|
33
33
|
|
34
34
|
__commit_id__ = commit_id = None
|
@@ -819,12 +819,58 @@ class MDLCompiler:
|
|
819
819
|
else:
|
820
820
|
return str(expression)
|
821
821
|
|
822
|
+
def _normalize_operator(self, op_in: Any) -> Optional[str]:
|
823
|
+
"""Normalize operator tokens/strings to Minecraft execute/scoreboard symbols.
|
824
|
+
Returns one of: '>', '>=', '<', '<=', '==', '!=' or None if unknown.
|
825
|
+
"""
|
826
|
+
# Direct symbol passthrough
|
827
|
+
if op_in in ('>', '>=', '<', '<=', '==', '!='):
|
828
|
+
return op_in
|
829
|
+
# TokenType instances
|
830
|
+
try:
|
831
|
+
if op_in == TokenType.GREATER:
|
832
|
+
return '>'
|
833
|
+
if op_in == TokenType.GREATER_EQUAL:
|
834
|
+
return '>='
|
835
|
+
if op_in == TokenType.LESS:
|
836
|
+
return '<'
|
837
|
+
if op_in == TokenType.LESS_EQUAL:
|
838
|
+
return '<='
|
839
|
+
if op_in == TokenType.EQUAL:
|
840
|
+
return '=='
|
841
|
+
if op_in == TokenType.NOT_EQUAL:
|
842
|
+
return '!='
|
843
|
+
except Exception:
|
844
|
+
pass
|
845
|
+
# String names from bindings or parser
|
846
|
+
if isinstance(op_in, str):
|
847
|
+
upper = op_in.upper()
|
848
|
+
if upper == 'GREATER':
|
849
|
+
return '>'
|
850
|
+
if upper == 'GREATER_EQUAL':
|
851
|
+
return '>='
|
852
|
+
if upper == 'LESS':
|
853
|
+
return '<'
|
854
|
+
if upper == 'LESS_EQUAL':
|
855
|
+
return '<='
|
856
|
+
if upper == 'EQUAL' or upper == 'EQ':
|
857
|
+
return '=='
|
858
|
+
if upper == 'NOT_EQUAL' or upper == 'NE':
|
859
|
+
return '!='
|
860
|
+
return None
|
861
|
+
|
822
862
|
def _expression_to_condition(self, expression: Any) -> str:
|
823
863
|
"""Legacy: Convert expression to a naive condition string (internal use)."""
|
824
864
|
if isinstance(expression, BinaryExpression):
|
825
865
|
left = self._expression_to_value(expression.left)
|
826
866
|
right = self._expression_to_value(expression.right)
|
827
|
-
|
867
|
+
op_sym = self._normalize_operator(expression.operator)
|
868
|
+
# Minecraft scoreboard uses '=' instead of '=='
|
869
|
+
if op_sym == '==':
|
870
|
+
op_text = '='
|
871
|
+
else:
|
872
|
+
op_text = op_sym if op_sym is not None else str(expression.operator)
|
873
|
+
return f"{left} {op_text} {right}"
|
828
874
|
else:
|
829
875
|
return self._expression_to_value(expression)
|
830
876
|
|
@@ -841,41 +887,10 @@ class MDLCompiler:
|
|
841
887
|
e = e.expression
|
842
888
|
return e
|
843
889
|
|
844
|
-
def norm_op(op_in: Any) -> Optional[str]:
|
845
|
-
# Return one of: '>', '>=', '<', '<=', '==', '!=' or None
|
846
|
-
if op_in == TokenType.GREATER or op_in == ">":
|
847
|
-
return ">"
|
848
|
-
if op_in == TokenType.GREATER_EQUAL or op_in == ">=":
|
849
|
-
return ">="
|
850
|
-
if op_in == TokenType.LESS or op_in == "<":
|
851
|
-
return "<"
|
852
|
-
if op_in == TokenType.LESS_EQUAL or op_in == "<=":
|
853
|
-
return "<="
|
854
|
-
if op_in == TokenType.EQUAL or op_in == "==" or op_in == "EQUAL":
|
855
|
-
return "=="
|
856
|
-
if op_in == TokenType.NOT_EQUAL or op_in == "!=" or op_in == "NOT_EQUAL":
|
857
|
-
return "!="
|
858
|
-
# Accept python bindings string names as well
|
859
|
-
if isinstance(op_in, str):
|
860
|
-
upper = op_in.upper()
|
861
|
-
if upper == "GREATER":
|
862
|
-
return ">"
|
863
|
-
if upper == "GREATER_EQUAL":
|
864
|
-
return ">="
|
865
|
-
if upper == "LESS":
|
866
|
-
return "<"
|
867
|
-
if upper == "LESS_EQUAL":
|
868
|
-
return "<="
|
869
|
-
if upper == "EQUAL":
|
870
|
-
return "=="
|
871
|
-
if upper == "NOT_EQUAL":
|
872
|
-
return "!="
|
873
|
-
return None
|
874
|
-
|
875
890
|
if isinstance(expression, BinaryExpression):
|
876
891
|
left = unwrap(expression.left)
|
877
892
|
right = unwrap(expression.right)
|
878
|
-
op_sym =
|
893
|
+
op_sym = self._normalize_operator(expression.operator)
|
879
894
|
# Variable vs literal
|
880
895
|
if op_sym and isinstance(left, VariableSubstitution) and isinstance(right, LiteralExpression) and isinstance(right.value, (int, float)):
|
881
896
|
objective = self.variables.get(left.name, left.name)
|
@@ -930,6 +945,25 @@ class MDLCompiler:
|
|
930
945
|
if op_sym == "!=":
|
931
946
|
# Use equals with inversion
|
932
947
|
return (f"score {lscope} {lobj} = {rscope} {robj}", True)
|
948
|
+
|
949
|
+
# General scoreboard vs scoreboard (covers temps produced by BinaryExpression)
|
950
|
+
if op_sym:
|
951
|
+
try:
|
952
|
+
left_val = self._expression_to_value(left)
|
953
|
+
right_val = self._expression_to_value(right)
|
954
|
+
except Exception:
|
955
|
+
left_val = None
|
956
|
+
right_val = None
|
957
|
+
if isinstance(left_val, str) and left_val.startswith("score ") and isinstance(right_val, str) and right_val.startswith("score "):
|
958
|
+
lparts = left_val.split()
|
959
|
+
rparts = right_val.split()
|
960
|
+
if len(lparts) >= 3 and len(rparts) >= 3:
|
961
|
+
lscope, lobj = lparts[1], lparts[2]
|
962
|
+
rscope, robj = rparts[1], rparts[2]
|
963
|
+
if op_sym == "!=":
|
964
|
+
return (f"score {lscope} {lobj} = {rscope} {robj}", True)
|
965
|
+
comp = op_sym if op_sym != "==" else "="
|
966
|
+
return (f"score {lscope} {lobj} {comp} {rscope} {robj}", False)
|
933
967
|
|
934
968
|
# Fallback: treat as generic condition string
|
935
969
|
return (self._expression_to_condition(expression), False)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: minecraft-datapack-language
|
3
|
-
Version: 16.0.
|
3
|
+
Version: 16.0.16
|
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=d04fOD3hne3CIblJtZJsJY9-QzwsZ1sOB7PzgWLaDWM,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=
|
6
|
+
minecraft_datapack_language/mdl_compiler.py,sha256=5lBvLpBbB90SVg1i10oAkeRVYhVDfeBvbJXONoSgAUE,55612
|
7
7
|
minecraft_datapack_language/mdl_errors.py,sha256=r0Gu3KhoX1YLPAVW_iO7Q_fPgaf_Dv9tOGSOdKNSzmw,16114
|
8
8
|
minecraft_datapack_language/mdl_lexer.py,sha256=bDzAj39-kfnX0uVlYQg1oQ7YDb-JO9UZx8jbODQqg6E,23902
|
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.
|
14
|
-
minecraft_datapack_language-16.0.
|
15
|
-
minecraft_datapack_language-16.0.
|
16
|
-
minecraft_datapack_language-16.0.
|
17
|
-
minecraft_datapack_language-16.0.
|
18
|
-
minecraft_datapack_language-16.0.
|
13
|
+
minecraft_datapack_language-16.0.16.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
14
|
+
minecraft_datapack_language-16.0.16.dist-info/METADATA,sha256=LLHp-JLyIvV2l7sVIhwgKk_i4NX1S9PRxR-trcER4Zc,8344
|
15
|
+
minecraft_datapack_language-16.0.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
16
|
+
minecraft_datapack_language-16.0.16.dist-info/entry_points.txt,sha256=c6vjBeCiyQflvPHBRyBk2nJCSfYt3Oc7Sc9V87ySi_U,108
|
17
|
+
minecraft_datapack_language-16.0.16.dist-info/top_level.txt,sha256=ADtFI476tbKLLxEAA-aJQAfg53MA3k_DOb0KTFiggfw,28
|
18
|
+
minecraft_datapack_language-16.0.16.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|