Execute
execute is the most important command in any datapack. It modifies the context a command runs in (who runs it, where, facing which way), branches on world state, and stores a command's result. Almost all runtime logic flows through it - see Runtime Logic for the bigger picture, and the Minecraft Wiki for the vanilla command semantics.
In Kore you build an execute chain with the execute { } builder. Each call inside the block appends one subcommand, in order, and the final run clause is the command that actually runs:
This generates execute as @a at @s run say Hello!.
Context subcommands
These change who, where, and how the chained command runs. They can be combined freely and apply left to right.
| Subcommand | Effect |
|---|---|
align(axes, offset?) |
Floors the position onto the block grid on the given axes |
anchored(anchor) |
Sets EYES/FEET anchor for ^ ^ ^ and facing |
asTarget(target) |
Runs as each matched entity, changing @s and the executor |
at(target) |
Sets position, rotation, and dimension to the target's |
facing(vec3) / facingEntity(target, anchor) |
Rotates to face a point or an entity |
inDimension(dimension) |
Switches the execution dimension |
on(relation) |
Moves to a related entity (OWNER, VEHICLE, TARGET, PASSENGERS, ...) |
positioned(vec3) / positionedAs(target) |
Sets the position absolutely or from a target |
positionedOver(heightMap) |
Sets Y to the top block of a heightmap at the current X/Z |
rotated(rotation) / rotatedAs(target) |
Sets the rotation absolutely or from a target |
summon(entityType) |
Summons a new entity and runs as/at it |
Conditions: if / unless
ifCondition and unlessCondition gate the rest of the chain. A block can hold several checks - they are ANDed together.
Available checks inside the condition block:
| Check | Meaning |
|---|---|
biome(pos, biome) |
The biome at pos matches a biome or biome tag |
block(pos, block) |
The block at pos matches a block or block tag |
blocks(start, end, dest, mode) |
A region matches another region (ALL / MASKED) |
data(target, path) |
The data target has something at the NBT path |
dimension(dimension) |
The execution is in the given dimension |
entity(target) |
The selector matches at least one entity |
function(function) |
A function returns a non-zero value |
items(source, slots, predicate) |
Items in a container's slots match a predicate |
loaded(pos) |
The chunk at pos is fully loaded |
predicate(...) |
A predicate passes (by id, name, or inline block) |
score(target, obj, range) |
A score matches an int range |
score(target, obj, src, srcObj, relation) |
Two scores compare with a relation |
stopwatch(id, range) |
A stopwatch has elapsed within a range (ms) |
Comparing scores fluently
Inside a condition block, score(target, objective) returns a handle with the full set of infix comparison operators:
| Kotlin DSL | Generated syntax |
|---|---|
score(self(), "points") equalTo 10 |
if score @s points matches 10 |
score(self(), "points") greaterThan 10 |
if score @s points > 10 |
score(self(), "points") greaterThanOrEqualTo 10 |
if score @s points >= 10 |
score(self(), "points") lessThan 10 |
if score @s points < 10 |
score(self(), "points") lessThanOrEqualTo 10 |
if score @s points <= 10 |
score(self(), "points") matches 1..5 |
if score @s points matches 1..5 |
score(self(), "a") equalTo score(self(), "b") |
if score @s a = @s b |
The relation operators also accept another score handle to compare two scores directly:
Referencing predicates directly
If you already have a Predicate, pass it straight to ifCondition:
You can also write a one-off inline predicate without registering a file:
Stores: capturing the result
storeResult writes the chained command's numeric return value; storeSuccess writes 1/0 for whether it succeeded. Both can target a score, storage, entity NBT, block NBT, or a boss bar.
Store destinations:
| Destination | Builder call |
|---|---|
| Score | score(target, objective) |
| Storage | storage(target, path, type, scale) |
| Entity NBT | entity(target, path, type, scale) |
| Block NBT | block(pos, path, type, scale) |
| Boss bar | bossBarValue(id) / bossBarMax(id) |
The type is a DataType (BYTE, SHORT, INT, LONG, FLOAT, DOUBLE) and scale is a multiplier applied before writing.
The run clause
run is always last. It accepts three forms:
If you omit run entirely, Kore emits the bare execute ... chain (useful when the last subcommand, like summon, already has an effect).
Ordering matters
Subcommands apply in the order you call them, exactly like vanilla. asTarget then at is different from at then asTarget. Keep run last - anything after a run in the same block replaces the previous run.
See also
- Runtime Logic - why execute is the backbone of in-game logic
- Predicates - reusable conditions for
ifCondition - Commands - the full command reference
