English | δΈζ
Acacia is a programming language for Minecraft Bedrock Edition command
development. Our principle is to be as simple as possible. Minecraft
commands can be complicated, long and hard to maintain. Acacia simplify
commands into Python-like code. Acacia code is finally compiled into
.mcfunction
files, and can be loaded in a Minecraft world as a datapack.
Acacia is written in Python (require 3.3 or newer), so it's easy to create a binary module using Python for Acacia code to use.
Go to this test file for an overview of Acacia.
Defining variables in Acacia: a = 1
. That's it.
No need for scoreboards.
Nested expression within 1 line of code:
a = 10
# `10 + 20` is folded into `30`
b = (10 + 20) * a - 5
Function definition:
def foo(x: int, y = True) -> int:
pass # code here...
# These are all OK:
foo(1)
z = foo(2, False)
z = foo(x=3)
Flow Control Statement:
def is_prime(x: int) -> bool:
# Test if `x` is a prime number
mod = 2
result True
while mod <= x / 2:
if x % mod == 0:
result False
mod += 1
Builtin modules:
import print
money = 10
# Send "Hello, world!" in char to everyone
print.tell("Hello world!")
# Show "Money: (Value of variable `money`)" on actionbar to everyone
print.title(print.format("Money: %0", money), mode=print.ACTIONBAR)
Acacia supports commands inserted in code:
a = 1
/tp @p 11 45 14
/*
tellraw @a {
...
}
*/ # Multi-line command!
It can even simplify commands:
player -> "@p[tag=player]" # defining macro
/tp ${player} 11 45 14
/execute at ${player} run setblock ~ ~ ~ grass
Accessing scores on scoreboard: |"player": "scoreboard"| = 10
Acacia can even do better than you in some aspects like doing math!
def sum_between(start: int, to: int, delta=1) -> int:
#* Return sum of Equidistant sequence from `start` to `to` with `delta` *#
result (start + to) * ((to - start) / delta + 1) / 2
sum_between(-5, 5, delta=2)
These commands are generated for function sum_between
:
# On initial run
scoreboard players set "acacia5" "acacia" 2
# "acacia1", "acacia2" and "acacia3" are the arguments
scoreboard players operation "acacia6" "acacia" = "acacia2" "acacia"
scoreboard players operation "acacia6" "acacia" -= "acacia1" "acacia"
scoreboard players operation "acacia6" "acacia" /= "acacia3" "acacia"
scoreboard players add "acacia6" "acacia" 1
scoreboard players operation "acacia4" "acacia" = "acacia1" "acacia"
scoreboard players operation "acacia4" "acacia" += "acacia2" "acacia"
scoreboard players operation "acacia4" "acacia" *= "acacia6" "acacia"
scoreboard players operation "acacia4" "acacia" /= "acacia5" "acacia"
The order of the operations are well-organized by Acacia compiler.
- An introduction video in Chinese
- Go to this test file for more details about Acacia!
- A simple number guessing game written in Acacia can also be found here!