Skip to content

A programming language which is compiled to Minecraft datapack

License

Notifications You must be signed in to change notification settings

Nervonment/mcscript

Repository files navigation

MCScript

简体中文 | English

MCScript is a simple programming language. Its target language is Minecraft Command (.mcfunction). Through MCScript, you can easily port logic written in other high-level programming languages to Minecraft datapacks.

MCScript is not suitable for developing large projects, but it is very useful for rapidly writing small auxiliary tools.

Examples

  • The MCScript code below generates a 10-block-high column of alternating yellow and black concrete above your head.
fn generate_column() {
    let y = 2;
    while y < 12 {
        if y % 2 {
            run_command!("setblock ~ ~{} ~ yellow_concrete", y);
        } else {
            run_command!("setblock ~ ~{} ~ black_concrete", y);
        }
        y += 1;
    }
}

generating a column

generating a maze

snake

Usage

For more details, see here.

MCScript supports exporting datapacks for Minecraft Java Edition 1.21 (with datapack version 48). The following command specifies the input file as my_datapack.mcs, and exports a datapack named my_datapack (containing the functions in the input file).

mcsc my_datapack.mcs -o my_datapack

Multiple input files can be specified:

mcsc namespace_1.mcs namespace_2.mcs -o my_datapack

Additionally, the compiler outputs a datapack named mcscript which contains some common functions.

After copying the two datapacks to .minecraft/saves/<save name>/datapacks/, enter the game. The first time you use the datapack generated by mcscript, you need to run the command /function mcscript:init to initialize it. To call the function named func in file_name.mcs in the game, enter the following command:

/function file_name:func

Quick Start

See Here.

Running Tests

See Here.

Plan

  • Objects & tuples.
  • Methods for getting data from entities and block entities.
  • IR design & optimization.
  • Compile-time constants.
  • References.

About

A programming language which is compiled to Minecraft datapack

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages