McShell - A programming language compiles to Minecraft mcfunction files

Overview

MCSH

MCSH语言是一个语法类似Rust的编译型编程语言,其编译目标是mcfunction文件,以在Minecraft中运行。

MCSH有内存条,可实现函数递归操作。

编译

您需要先安装Rust 然后在您的控制台运行

git clone https://github.com/Fancyflame/mcsh.git
cd mcsh
cargo r

在此期间,请保证您的网络通畅,因为rust编译需要通过网络下载许多必要的依赖。

使用

在编译完成后,将该行为包安装到Minecraft里。游戏中加载该行为包后,在第一次使用前必须先运行

/function mcsh_init

然后再调用导出的函数

/function print_some
/function your_custom_function

如果您运行mcsh_init后再次调用,则会将所有静态变量重置为初始值。您可以利用这一点来重置环境。

CLI

MCSH编译器是一个命令行工具,您可以使用./mcsh --help查看帮助文档。在rust中,cargo r也是运行程序的命令(如果没有程序或代码变动则编译)。下面给出一些常用的示例命令。

在MCSH CLI中,所有相对路径都被视为基于当前工作目录。 你可以利用--help选项探索更多功能。

在虚拟仿真运行

模拟运行本仓库里的print.mcsh示例文件的print_some函数。

cd mcsh
cargo r examples/print.mcsh simulate print_some

编译

将本仓库里的print.mcsh示例文件编译到C:\Users\Alice\Desktop\mcsh_out目录下(没有生成额外文件夹,请保证该文件夹是空的!),并使用交互式输入(-m)生成manifest.json

cd mcsh
cargo r examples/print.mcsh b -o "C:\Users\Alice\Desktop\mcsh_out" -m

输出文件夹结构如下所示。可以观察到,mcsh额外生成了一个mcsh_init.mcfunction文件用于初始化环境。

.
|-- functions
|   |-- MCSH
|   |   |-- __MCSH_Private_AnonymousLabel_0.mcfunction
|   |   |-- __MCSH_Private_AnonymousLabel_1.mcfunction
|   |   |-- __MCSH_Private_AnonymousLabel_2.mcfunction
|   |   |-- __MCSH_Private_AnonymousLabel_3.mcfunction
|   |   |-- __MCSH_Private_AnonymousLabel_4.mcfunction
|   |   |-- __MCSH_Private_AnonymousLabel_5.mcfunction
|   |   |-- __MCSH_Private_AnonymousLabel_6.mcfunction
|   |   |-- __MCSH_Private_AnonymousLabel_7.mcfunction
|   |   |-- __MCSH_Private_MemoryLoad_Chunks1
|   |   |   |-- Branch0_1.mcfunction
|   |   |   |-- Branch0_15.mcfunction
|   |   |   |-- Branch0_3.mcfunction
|   |   |   |
|   |   |   |   ... many files ...
|   |   |   |
|   |   |   |-- Leaf8.mcfunction
|   |   |   `-- Leaf9.mcfunction
|   |   |-- __MCSH_Private_MemoryLoad_Chunks1.mcfunction
|   |   |-- __MCSH_Private_MemoryStore_Chunks1
|   |   |   |-- Branch0_1.mcfunction
|   |   |   |-- Branch0_15.mcfunction
|   |   |   |-- Branch0_3.mcfunction
|   |   |   |
|   |   |   |   ... many files ...
|   |   |   |
|   |   |   |-- Leaf8.mcfunction
|   |   |   `-- Leaf9.mcfunction
|   |   `-- __MCSH_Private_MemoryStore_Chunks1.mcfunction
|   |-- mcsh_init.mcfunction
|   `-- print_some.mcfunction
`-- manifest.json

语法

转到SYNTAX.md阅读语法

其中,格式化文本可使用的样式有

标准名称 别名
black
dark_blue
dark_green
dark_aqua
dark_red
dark_purple
gold
gray
dark_gray
blue
green
aqua
red
light_purple magenta
yellow
white
minecoin_gold dark_yellow
material_quartz quartz
material_iron iron
material_netherite netherite
obfuscated rand_char
bold
material_redstone redstone
material_copper copper
italic
material_gold dark_gold
material_emerald emerald
reset
material_diamond diamond
material_lapis laps
material_amethyst amethyst

标准库

标准库请转到STD.md

You might also like...
A simple Minecraft written in Rust with the Piston game engine
A simple Minecraft written in Rust with the Piston game engine

hematite A simple Minecraft written in Rust with the Piston game engine How To Open a World This method is only for personal use. Never distribute cop

A simple, very minimal Minecraft server implementation in Rust.
A simple, very minimal Minecraft server implementation in Rust.

A simple, very minimal Minecraft server implementation in Rust. For a simple Minecraft server that isn't supposed to do much (for example, a limbo ser

Like minecraft, but crispier!

crispycraft Like minecraft, but crispier! Links Library documentation WebGPU: https://docs.rs/wgpu/0.12.0/wgpu/ building_blocks: https://docs.rs/build

Brine is my attempt at writing a Minecraft client in Rust using the Bevy game engine.
Brine is my attempt at writing a Minecraft client in Rust using the Bevy game engine.

Brine Brine is my attempt at writing a Minecraft client in Rust using the Bevy game engine. It's EXTREMELY work-in-progress. The thing that makes Brin

Morphosis is a work-in-progress set of tools to deal with Minecraft metadata, mainly for use with PolyMC.

Morphosis Morphosis is a work-in-progress set of tools to deal with Minecraft metadata, mainly for use with PolyMC. It consists of a library (metamorp

ULE - Minecraft's server core written in Rust

ULE - Minecraft's server core written in Rust This's server core fully written in Rust-Lang and using more custom code for best perfomance and control

Libium is the backend of Ferium. It helps manage Minecraft mods from Modrinth, CurseForge, and Github Releases

Libium Libium is the backend of Ferium. It helps manage Minecraft mods from Modrinth, CurseForge, and Github Releases There are 3 main components in L

A data compatibility project for Minecraft's assets

Data Compat MC Data tool for the Falcon MC project. Description DataCompatMC is a cli tool designed to help deal with the many different versions of M

A data compatibility project for Minecraft's assets

Data Compat MC Data tool for the Falcon MC project. Description DataCompatMC is a cli tool designed to help deal with the many different versions of M

Owner
FancyFlame
Programming is an art of how to combine cats, toasts and butter
FancyFlame
A programming language designed for the DiamondFire Minecraft server.

Blackstone Blackstone is a programming language designed to help create plots on the MCDiamondFire Minecraft server. Community Links Discord: https://

Blackstone 5 May 1, 2023
A Rust library for reading asset files and resource packs for any version of Minecraft

minecraft-assets A Rust library for reading asset files and resource packs for any version of Minecraft. Example use minecraft_assets::api::AssetPack;

Ben Reeves 7 Aug 14, 2022
Rust-based replacement for the default Minecraft renderer

wgpu-mc ?? A blazing fast alternative renderer for Minecraft Intro WebGPU is a new web specification designed to provide modern graphics and compute c

Birb 1 Jun 28, 2022
Rustcraft is a simple Minecraft engine written in rust using wgpu.

Rustcraft is a simple Minecraft engine written in rust using wgpu.

Raphael Van Hoffelen 110 Dec 22, 2022
A Minecraft Java Edition to Bedrock Edition resource pack convertor in Rust

j2be A Minecraft Java Edition to Bedrock Edition resource pack convertor in Rust How to use Note: This project is still in development Run cargo build

Cqdet 11 Sep 15, 2021
Minecraft Protocol Library

Protocol Minecraft Protocol Library This branch is dedicated to the Minecraft Bedrock Edition Protocol. If you have any concerns or questions you can

Netrex 5 Mar 19, 2022
💤 Put your Minecraft server to rest when idle.

?? Put your Minecraft server to rest when idle.

Tim Visée 285 Jan 4, 2023
Minecraft-esque voxel engine prototype made with the bevy game engine. Pending bevy 0.6 release to undergo a full rewrite.

vx_bevy A voxel engine prototype made using the Bevy game engine. Goals and features Very basic worldgen Animated chunk loading (ala cube world) Optim

Lucas Arriesse 125 Dec 31, 2022
Provision Mammoth-ready Minecraft clusters with ease!

Minecraft Server Provisioner Provision Mammoth-ready Minecraft clusters with ease! Overview Provisioner is a tool designed to make the creation of Mam

null 19 Sep 29, 2022
Easily update your minecraft mods with 1 file (guess I'm back to rust again)

Mod Updater This program updates all your mods to a newer/later version. To use: Create a file named config.toml Create a folder named mods; Add the f

sussyimpostor 2 Sep 18, 2022