Skip to content

Repository files navigation

Introduction

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.

Quick Start

MCFPP API

  • Code optimization
  • Basic library

Related Projects

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.

Features

Basic Logic Statements

func example(){
  var i = @s.pos[0];
  if(i > 0){
    execute(as = @s) {
      say("Hello Minecraft!");
    }
  }
}

Object-Oriented Programming

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);
  }
}

Library Calls

import mcfpp.math;

void example{
    float i = 1.5;
    float out;
    out = pow(i, 2);
    print(out);
}

Generics

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);
}

Direct Use of Minecraft Commands

var qwq = "Minecraft";

func test(){
  /execute as @a run say Hello ${qwq}!
}

Line breaks and arithmetic expressions

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.

Compile for a Minecraft version

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.

About

MCFPP is a brand new objected-oriented language that can be compiled into Minecraft Datapack.

Topics

Resources

Stars

281 stars

Watchers

8 watching

Forks

Releases

Packages

Used by

Contributors

Languages