minecraft-datapack-language 15.4.8__py3-none-any.whl → 15.4.10__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 +11 -11
- minecraft_datapack_language/cli_help.py +561 -370
- minecraft_datapack_language/cli_new.py +129 -41
- minecraft_datapack_language/mdl_errors.py +227 -139
- {minecraft_datapack_language-15.4.8.dist-info → minecraft_datapack_language-15.4.10.dist-info}/METADATA +1 -1
- {minecraft_datapack_language-15.4.8.dist-info → minecraft_datapack_language-15.4.10.dist-info}/RECORD +11 -11
- {minecraft_datapack_language-15.4.8.dist-info → minecraft_datapack_language-15.4.10.dist-info}/WHEEL +0 -0
- {minecraft_datapack_language-15.4.8.dist-info → minecraft_datapack_language-15.4.10.dist-info}/entry_points.txt +0 -0
- {minecraft_datapack_language-15.4.8.dist-info → minecraft_datapack_language-15.4.10.dist-info}/licenses/LICENSE +0 -0
- {minecraft_datapack_language-15.4.8.dist-info → minecraft_datapack_language-15.4.10.dist-info}/top_level.txt +0 -0
@@ -54,21 +54,40 @@ def create_new_project(project_name: str, pack_name: str = None, pack_format: in
|
|
54
54
|
with open(readme_file, 'w', encoding='utf-8') as f:
|
55
55
|
f.write(readme_content)
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
57
|
+
try:
|
58
|
+
from .cli_colors import color
|
59
|
+
print(f"{color.success('[OK]')} Successfully created new MDL project: {color.highlight(clean_name)}")
|
60
|
+
print(f"{color.info('[DIR]')} Project directory: {color.file_path(str(project_dir.absolute()))}")
|
61
|
+
print(f"{color.info('[FILE]')} Main file: {color.file_path(str(mdl_file))}")
|
62
|
+
print(f"{color.info('[DOC]')} Documentation: {color.file_path(str(readme_file))}")
|
63
|
+
print()
|
64
|
+
print(f"{color.section('[NEXT]')} Next steps:")
|
65
|
+
print(f" 1. cd {color.highlight(clean_name)}")
|
66
|
+
print(f" 2. Edit main.mdl with your code")
|
67
|
+
print(f" 3. mdl build --mdl main.mdl -o dist")
|
68
|
+
print(f" 4. mdl check main.mdl")
|
69
|
+
print()
|
70
|
+
print(f"{color.section('[INFO]')} Learn more:")
|
71
|
+
print(" • Language Reference: https://www.mcmdl.com/docs/language-reference")
|
72
|
+
print(" • Examples: https://www.mcmdl.com/docs/examples")
|
73
|
+
print(" • CLI Reference: https://www.mcmdl.com/docs/cli-reference")
|
74
|
+
except ImportError:
|
75
|
+
# Fallback if colors aren't available
|
76
|
+
print(f"[OK] Successfully created new MDL project: {clean_name}")
|
77
|
+
print(f"[DIR] Project directory: {project_dir.absolute()}")
|
78
|
+
print(f"[FILE] Main file: {mdl_file}")
|
79
|
+
print(f"[DOC] Documentation: {readme_file}")
|
80
|
+
print()
|
81
|
+
print("[NEXT] Next steps:")
|
82
|
+
print(f" 1. cd {clean_name}")
|
83
|
+
print(f" 2. Edit main.mdl with your code")
|
84
|
+
print(f" 3. mdl build --mdl main.mdl -o dist")
|
85
|
+
print(f" 4. mdl check main.mdl")
|
86
|
+
print()
|
87
|
+
print("[INFO] Learn more:")
|
88
|
+
print(" • Language Reference: https://www.mcmdl.com/docs/language-reference")
|
89
|
+
print(" • Examples: https://www.mcmdl.com/docs/examples")
|
90
|
+
print(" • CLI Reference: https://www.mcmdl.com/docs/cli-reference")
|
72
91
|
|
73
92
|
except Exception as e:
|
74
93
|
# Clean up on error
|
@@ -78,16 +97,79 @@ def create_new_project(project_name: str, pack_name: str = None, pack_format: in
|
|
78
97
|
|
79
98
|
|
80
99
|
def _generate_mdl_template(project_name: str, pack_name: str, pack_format: int) -> str:
|
81
|
-
"""Generate the MDL
|
82
|
-
return f'''pack "{pack_name}" "
|
83
|
-
namespace "{
|
100
|
+
"""Generate the template MDL content."""
|
101
|
+
return f'''pack "{pack_name}" "Generated by MDL CLI" {pack_format};
|
102
|
+
namespace "{pack_name}";
|
84
103
|
|
104
|
+
// Example variables
|
105
|
+
var num score = 0;
|
106
|
+
var num lives = 3;
|
107
|
+
|
108
|
+
// Main function - this runs when called
|
85
109
|
function "main" {{
|
86
|
-
say Hello
|
87
|
-
|
110
|
+
say Hello from {project_name}!;
|
111
|
+
|
112
|
+
// Set initial values
|
113
|
+
score = 10;
|
114
|
+
lives = 3;
|
115
|
+
|
116
|
+
// Display current values
|
117
|
+
say Score: $score$;
|
118
|
+
say Lives: $lives$;
|
119
|
+
|
120
|
+
// Example conditional statement
|
121
|
+
if "$score$ > 5" {{
|
122
|
+
say Great score!;
|
123
|
+
}} else {{
|
124
|
+
say Keep trying!;
|
125
|
+
}};
|
126
|
+
|
127
|
+
// Example while loop
|
128
|
+
while "$lives$ > 0" {{
|
129
|
+
say You have $lives$ lives remaining;
|
130
|
+
lives = lives - 1;
|
131
|
+
}};
|
132
|
+
|
133
|
+
say Game over!;
|
134
|
+
}}
|
135
|
+
|
136
|
+
// Init function - this runs when the datapack loads
|
137
|
+
function "init" {{
|
138
|
+
say [GAME] {pack_name} loaded successfully!;
|
139
|
+
say Type: /function {project_name}:main;
|
140
|
+
}}
|
141
|
+
|
142
|
+
// Tick function - this runs every tick (20 times per second)
|
143
|
+
function "tick" {{
|
144
|
+
// Add your tick logic here
|
145
|
+
// Be careful with performance!
|
88
146
|
}}
|
89
147
|
|
90
|
-
|
148
|
+
// Example function with parameters
|
149
|
+
function "greet_player" {{
|
150
|
+
say Welcome to {pack_name}!;
|
151
|
+
say Have fun playing!;
|
152
|
+
}}
|
153
|
+
|
154
|
+
// Raw Minecraft commands example
|
155
|
+
$!raw
|
156
|
+
# You can use raw Minecraft commands here
|
157
|
+
# These are passed through directly to the output
|
158
|
+
# Useful for complex commands or commands not yet supported by MDL
|
159
|
+
tellraw @a {{"text":"Raw command example","color":"gold"}}
|
160
|
+
raw!$
|
161
|
+
|
162
|
+
// Example recipe (optional)
|
163
|
+
// recipe "diamond_sword" "diamond_sword.json";
|
164
|
+
|
165
|
+
// Example loot table (optional)
|
166
|
+
// loot_table "chest_loot" "chest_loot.json";
|
167
|
+
|
168
|
+
// Example advancement (optional)
|
169
|
+
// advancement "first_diamond" "first_diamond.json";
|
170
|
+
|
171
|
+
// Hook the init function to run when the datapack loads
|
172
|
+
on_load "{project_name}:init";
|
91
173
|
'''
|
92
174
|
|
93
175
|
|
@@ -99,14 +181,14 @@ A Minecraft datapack created with MDL (Minecraft Datapack Language).
|
|
99
181
|
|
100
182
|
## [GAME] About
|
101
183
|
|
102
|
-
This datapack was generated using the MDL CLI tool. MDL is a simplified language for creating Minecraft datapacks with
|
184
|
+
This datapack was generated using the MDL CLI tool. MDL is a simplified language for creating Minecraft datapacks with variables, control structures, and easy syntax.
|
103
185
|
|
104
186
|
## [DIR] Project Structure
|
105
187
|
|
106
188
|
```
|
107
189
|
{project_name}/
|
108
190
|
├── README.md # This file
|
109
|
-
└── main.mdl # Main MDL source file
|
191
|
+
└── main.mdl # Main MDL source file
|
110
192
|
```
|
111
193
|
|
112
194
|
## [NEXT] Getting Started
|
@@ -120,19 +202,19 @@ This datapack was generated using the MDL CLI tool. MDL is a simplified language
|
|
120
202
|
|
121
203
|
1. **Build the project:**
|
122
204
|
```bash
|
123
|
-
mdl build --mdl
|
205
|
+
mdl build --mdl {project_name}.mdl -o dist
|
124
206
|
```
|
125
207
|
|
126
208
|
2. **Check for errors:**
|
127
209
|
```bash
|
128
|
-
mdl check
|
210
|
+
mdl check {project_name}.mdl
|
129
211
|
```
|
130
212
|
|
131
213
|
3. **Install in Minecraft:**
|
132
214
|
- Copy the `dist` folder to your world's `datapacks` directory
|
133
215
|
- Or use the `--wrapper` option to create a zip file:
|
134
216
|
```bash
|
135
|
-
mdl build --mdl
|
217
|
+
mdl build --mdl {project_name}.mdl -o dist --wrapper {project_name}
|
136
218
|
```
|
137
219
|
|
138
220
|
### Using the Datapack
|
@@ -145,31 +227,37 @@ This datapack was generated using the MDL CLI tool. MDL is a simplified language
|
|
145
227
|
|
146
228
|
### Editing the Code
|
147
229
|
|
148
|
-
Open `
|
230
|
+
Open `{project_name}.mdl` in your favorite text editor. The file contains:
|
149
231
|
|
150
232
|
- **Pack declaration** - Datapack metadata
|
151
|
-
- **
|
233
|
+
- **Variables** - Scoreboard variables for storing data
|
152
234
|
- **Functions** - The main logic of your datapack
|
153
|
-
- **
|
235
|
+
- **Control structures** - If/else statements and loops
|
236
|
+
- **Raw commands** - Direct Minecraft commands when needed
|
154
237
|
|
155
238
|
### Key Features
|
156
239
|
|
157
|
-
- **
|
158
|
-
- **
|
159
|
-
- **
|
160
|
-
- **
|
240
|
+
- **Variables**: Use `variable name = value` to create scoreboard objectives
|
241
|
+
- **Functions**: Define reusable code blocks with `function name { ... }`
|
242
|
+
- **Conditionals**: Use `if (condition) { ... } else { ... }`
|
243
|
+
- **Loops**: Use `while (condition) { ... }` for repeating actions
|
244
|
+
- **Variable substitution**: Use `$variable$` in commands to insert values
|
161
245
|
|
162
246
|
### Example Code
|
163
247
|
|
164
248
|
```mdl
|
165
|
-
//
|
166
|
-
|
167
|
-
say Hello, Minecraft!;
|
168
|
-
tellraw @a {{"text":"Welcome!","color":"green"}};
|
169
|
-
}}
|
249
|
+
// Set a variable
|
250
|
+
score = 10
|
170
251
|
|
171
|
-
//
|
172
|
-
|
252
|
+
// Use it in a command
|
253
|
+
say "Your score is: $score$"
|
254
|
+
|
255
|
+
// Conditional logic
|
256
|
+
if (score > 5) {{
|
257
|
+
say "Great job!"
|
258
|
+
}} else {{
|
259
|
+
say "Keep trying!"
|
260
|
+
}}
|
173
261
|
```
|
174
262
|
|
175
263
|
## [INFO] Resources
|
@@ -189,7 +277,7 @@ on_load "{project_name}:main";
|
|
189
277
|
- Check that the file has a `.mdl` extension
|
190
278
|
|
191
279
|
2. **Syntax errors**
|
192
|
-
- Use `mdl check
|
280
|
+
- Use `mdl check {project_name}.mdl` to find and fix errors
|
193
281
|
- Check the error messages for line numbers and suggestions
|
194
282
|
|
195
283
|
3. **Datapack not loading**
|