The MobCode Compiler is a tool designed to compile custom scripting language into Minecraft function files. It supports namespaces, classes, functions, and macros for efficient and modular scripting.
- Namespaces: Organize your code into logical groups.
- Classes: Encapsulate related functions and commands.
- Functions: Define reusable blocks of commands.
- Macros: Simplify repetitive tasks with parameterized templates.
- Real-time Watching: Automatically rebuilds files on changes.
- Conditional Logic: Use
if
statements for dynamic behavior. - Loops: Repeat commands with
times
.
- NCalc - A mathematical expression evaluator.
- Newtonsoft.Json - JSON parsing and serialization.
- Clone the repository or download the source code.
- Ensure you have the required dependencies installed.
- Build the project using .NET 9.0 or higher.
Run the compiler with the following commands:
Compile all .mc
files in the current directory:
MobCode.exe build
Automatically rebuild files when changes are detected:
MobCode.exe watch
Download and install macros from a list of URLs:
MobCode.exe install <url1> <url2> ...
Group related functions and classes:
namespace myNamespace {
function myFunction {
say Hello, World!;
}
}
Encapsulate related functions:
namespace myNamespace {
class myClass {
function myFunction {
say This is a class function!;
}
}
}
Define reusable blocks of commands:
namespace myNamespace {
function greet {
say Hello, Player!;
}
}
Use macros to simplify repetitive tasks:
namespace myNamespace {
function giveItem {
Item.Give(@p, diamond_sword, 1, {});
}
}
Execute commands conditionally:
namespace myNamespace {
function checkCondition {
if (1 == 1) {
say Condition is true!;
}
}
}
Repeat commands a specified number of times:
namespace myNamespace {
function repeatExample {
times (5) {
say This will repeat 5 times!;
}
}
}
Here is a complete example:
namespace example {
function main {
say Starting script...;
if (2 > 1) {
say Condition met!;
}
times (3) {
say Repeating this message!;
}
Item.Give(@p, diamond, 1, {});
}
}
The above example will generate a .mcfunction
file with the following content:
say Starting script...
say Condition met!
say Repeating this message!
say Repeating this message!
say Repeating this message!
give @p diamond 1
Generated by artificial intelligence