MCFPP is a new object-oriented language that compiles into Minecraft data packs. It aims to simplify data pack creation with syntax similar to C-based languages, incorporating common programming concepts for convenience.
Note: This project is in early development. Features may change, and library functions are incomplete.
- Code optimization
- Basic library
MCSharp is a CSharp library for data pack development, now discontinued due to technical issues. MCFPP inherits some of its ideas.
JustMCF simplifies mcfunction projects, allowing both original and streamlined commands for efficiency.
func example(){
var i = @s.pos[0];
if(i > 0){
execute(as = @s) {
say("Hello Minecraft!");
}
}
}class Example{
var i as int {
get {
return field * 2;
}
set {
field = value;
}
};
constructor(i as int){
this.i = i;
}
func print(){
print(this.i);
}
}import mcfpp.math;
void example{
float i = 1.5;
float out;
out = pow(i, 2);
print(out);
}class Example<T as type>{
var i as T;
public Example(i as T){
this.i = i;
}
public func print(){
print(this.i);
}
}
func test<T as Type>(i as T){
print(i);
}var qwq = "Minecraft";
func test(){
/execute as @a run say Hello ${qwq}!
}A newline or semicolon ends a statement. An expression can continue on the next line when its operator ends the current line. If / is the first non-whitespace character on a line, that line is a vanilla Minecraft command; put a division operator on the previous line when splitting division across lines.
func calculate(){
var x = 12 /
3;
x += 2;
x *= 3;
var opposite = -x;
/say Calculation complete
}
Compound assignments +=, -=, *=, /=, and %= read the target, apply the corresponding operation, and write the result back. ++ and -- are not supported.
Set the target version in mcfpp.json, for example "version": "26.3". Each build produces one data pack for that target; change version and build again for another version. Targets 26.1, 26.2, 26.3, and the previously supported older versions are available.
#if MC >= 26.1
func greet(){
/say 26.1 or newer
}
#elif MC >= 1.21.6
func greet(){
/say 1.21.6 to 1.21.8
}
#else
func greet(){
/say older version
}
#endif
Directives may be nested and can surround imports, declarations, or function statements. A condition compares MC with a version using ==, !=, <, <=, >, or >=; logical combinations are not supported. Versions are compared component by component. Spell older versions in full, such as 1.21.6, rather than 21.6. Ordinary # comments retain their behavior.
For more syntax information, refer to the MCFPP API.
