-
Notifications
You must be signed in to change notification settings - Fork 6
Language reference: vocabulary
The point of the language vocabulary is to give you every command that exists.
Table of contents:
- Vanilla commands
A vanilla command is a command that is executable in Minecraft
run: [command]
example: run: setblock 1 2 3 minecraft:stone
Variables hold numerical values to be used for later on. In Minecraft, these varibles are represented by scoreboard values.
Note: Since there is no way of knowing how the datapack will work, it can't do any variable checks (e.g. if it was declared or not)
var: [name] = [value]
example: var: foo = 42
var: [name1] [operation] [name2]
name1
: the name of the first operand
name2
: the name of the second operand
operation
: one of the following operations:
-
=
: assignment; assigns the value of the second opereand to the value of the first operand -
+=
: addition; adds the value of the second operand to the value of the first operand -
-=
: subtraction; subtracts the value of the second operand from the value of the first operand -
*=
: multiplication; multiplies the value of the first operand with the value of the second operand -
/=
: division; divides the value of the first operand by the value of the second operand -
%=
: modulus; divides the value of the first operand by the value of the second operand and assigns the remainder to the first operand -
>
: greater than; assigns the value of the second operand if - and only if - the value of the first operand is the greater one -
<
: less than; assigns the value of the second operand if - and only if - the value of the first operand is the smaller one -
><
value flip; assigns the value of one operand to the other
example: var: foo += bar
Note: performing operations with numbers are currently not possible. To work around this issue, you can do something like this (the variable foo was already created):
var: const = 42
var: foo *= const
Functions are the core element of datapacks. They are a file with a list of commands that are all executed in one tick
fnc: [namespace]->[name]
namespace
: The namespace the function is in (can be in a different datapack as well)
name
: The name of the function
example: fnc: foo->bar
fnc: [namespace]?[alias]
namespace
: The namespace the alias is in
alias
: the json file holding all the function names
example: fnc: foo?bar
Block variables are used to hold coordinates of a position representing a block in minecraft.
Note: block variables are only accessible in the function they were declared in.
blk: [name] = [x],[y],[z]
name
: the name of the variable (can already be declared)
x/y/z
: the coordinates
example: blk: foo = 420, 69, 42
blk: [name].type=§[blockID]§[state]{nbt}
name
: the name of the variable
blockID
: a valid block id (just the id, no prefix. will be fixed in the next update)
state
: a blockstate (1)
nbt
: the nbt data of the block (1)(2)
(1) can be omitted
(2) has to be in json format (keys in quotes)
example 1: blk: foo.type = §furnace§[facing=north]{"BurnTime":42}
example 2: blk: foo.type = $stone§
blk: [name][path][operation][value]
name
: The block variable
path
: The nbt path
operation
: One of these options
-
->
: Appends a value -
<-
: Prepend a value
value
: The value to append
example 1: blk: foo.bar -> 42
example 2: blk: foo.bar[0].arr <- {"hello":"world"}
Note: If the appended value is in nbt/json format, keys must be written in quoutes as well.
blk: [name][path][index]+=[value]
name
: The block variable
path
: The path to the array
index
: The index to insert into
value
: The value to append
example: blk: foo.arr[2] += 42
Note 1: If the appended value is in nbt/json format, keys must be written in quoutes as well.
Note 2: Inserting means that 1 is added to all indices at the given index and all following ones and then the value is inserted into the index
If/Unless statements are control structures that execute the corresponding instructions if/unless, and only if/unless, the given condition is met. An If statements executes its instructions when the condition is true, an unless statement executes its instructions when the condition is false
if/unless([variable1][operation][value/variable2]
variable1
: the left side of the condition
operation
: One of the given options
-
=
: equality; is true when the given values are equal -
>=
: greater than or equal; is true when the left side is greater than or equal to the right value -
<=
: less than or equal; is true when the left side is less than or equal to the right value -
<
: less than; is true when the left side is less than the right side -
>
: greater than; is true when the left side is greater than the right side
variable2
: the left side of the condition
value
: a numerical value
Example: if(foo = 42)
Note: all statements that need to execute when the if/unless condition is met need to be in curley bracets:
if(foo = 42)
{
var: foo = 69
blk: a = 2, 4, 6
}