Teleport (Entity Action Type)

Teleports the entity to a set of coordinates, optionally in another dimension.

Teleports the entity to a set of coordinates, optionally in another dimension. This is /teleport in power form: the coordinates can be absolute or relative, and the teleport can be refused unless the destination passes a condition.

Type ID: apoli:teleport

Also answers to apoli:teleport_to.

Fields

FieldTypeDefaultDescription
x, y, zFloat or Expression0The destination. Read as an offset from the entity’s current position unless relative is false.
relativeBooleantrueWhether x/y/z are an offset from the entity (true) or world coordinates (false). Alias: relative_to_position.
spaceSpaceworldWhich axes a relative offset is measured along. local turns with the entity, so z: 5 is five blocks in front of them. Ignored when relative is false.
dimensionIdentifieroptionalThe dimension to teleport into. Defaults to the one the entity is already in.
yaw, pitchFloat or ExpressionoptionalThe rotation to arrive with. Left alone if not given.
landing_block_conditionBlock Condition TypeoptionalIf specified, the teleport only happens when the block below the destination fulfills this condition.
landing_conditionEntity Condition TypeoptionalIf specified, the teleport only happens when the entity would fulfill this condition at the destination — it is tested as though the entity were already standing there. Skipped when the destination is in another dimension.
loaded_chunks_onlyBooleantrueWhether the teleport is refused when the destination chunk is not loaded. Keep this on unless you know the chunk is loaded — teleporting into unloaded terrain forces a chunk generation on the server thread.
success_actionEntity Action TypeoptionalRuns on the entity once it has arrived.
fail_actionEntity Action TypeoptionalRuns on the entity when the teleport is refused — by a condition, by an unloaded chunk, by a missing dimension, or by apoli:prevent_teleport.

Examples

"entity_action": {
    "type": "apoli:teleport",
    "space": "local",
    "z": 5
}

A short blink: five blocks in the direction the entity is facing.

"entity_action": {
    "type": "apoli:teleport",
    "y": 5,
    "landing_condition": {
        "type": "apoli:and",
        "conditions": [
            {
                "type": "apoli:in_block",
                "block_condition": { "type": "apoli:block", "block": "minecraft:air" }
            },
            {
                "type": "apoli:in_block",
                "block_condition": {
                    "type": "apoli:offset",
                    "y": 1,
                    "condition": { "type": "apoli:block", "block": "minecraft:air" }
                }
            }
        ]
    },
    "fail_action": {
        "type": "apoli:play_sound",
        "sound": "minecraft:block.note_block.bass"
    }
}

Teleports five blocks straight up, but only if both blocks the entity would occupy there are air. Otherwise nothing moves and a note plays.

"entity_action": {
    "type": "apoli:teleport",
    "relative": false,
    "x": 0,
    "y": 64,
    "z": 0,
    "dimension": "minecraft:the_nether",
    "yaw": 180
}

Drops the entity at the Nether’s origin, facing north.

The coordinates are Expressions, so they can read the entity: "y": "y + 3" is three blocks up in absolute terms, and "x": "resource('example:anchor_x')" reads a resource. See Expressions.