MCFPP syntax overview
Start with Create a project to build a datapack in IDEA or a terminal.
mcfpp
data Reward {
var amount: int = 10
}
func doubled(value: int): int {
return value * 2
}
func main() {
var reward = Reward()
var transform: (int) -> int = { it + 5 }
print(doubled(transform(reward.amount)))
}This example combines a data template, functions, variables, a function type, and a lambda. It prints 30.
Common syntax
| Purpose | Form |
|---|---|
| Mutable value | var score: int = 0 |
| One assignment | const limit = 10 |
| Runtime storage | external score: int = 0 |
| Function result | func add(a: int, b: int): int |
| Type parameter | func identity<T>(value: T): T |
| Type alias | typealias int as Score |
| Function type | (int) -> int |
| Lambda | { value -> value + 1 } |
| Data template | data Reward { var amount: int } |
| Shared object | object data Settings { var limit: int = 10 } |
| Abstract template | abstract data Readable { abstract func read(): int } |
| Ordinary comment | // explanation |
| Documentation comment | /// Markdown documentation |
Newlines separate ordinary statements. Semicolons separate statements on one line. Update integers with += and -=.
Development topics
- Develop in IDEA: save formatting, diagnostics, and tasks.
- Project configuration: TOML, directories, and target versions.
- MNI introduction: Kotlin macros and tests.
- Address references: score and NBT access.
- Build output and IR: datapacks and compiler records.