Swap (Bi-Entity Action Type)

Swaps the positions of the actor and the target.

Swaps the positions of the actor and the target: each ends up where the other one was, across dimensions if they were in different ones.

Type ID: apoli:swap

This is apoli:teleport_to with swap already on, and it takes every field that one does — the offset, the landing conditions and the success and fail actions all work the same way.

Fields

FieldTypeDefaultDescription
swapBooleantrueSetting this to false turns the action back into a plain apoli:teleport_to. Alias: swap_position.
x, y, zFloat or Expression0An offset applied to where the actor lands. The target still lands exactly where the actor was.
spaceSpaceworldWhich axes the offset is measured along.
landing_block_conditionBlock Condition TypeoptionalIf specified, the swap only happens when the block below the actor’s destination fulfills this condition.
landing_conditionEntity Condition TypeoptionalIf specified, the swap only happens when the actor would fulfill this condition at the destination.
loaded_chunks_onlyBooleantrueWhether the swap is refused when the destination chunk is not loaded.
success_actionBi-Entity Action TypeoptionalRuns with the same pair once both have arrived.
fail_actionBi-Entity Action TypeoptionalRuns when the swap is refused.

Examples

{
    "type": "apoli:action_on_hit",
    "cooldown": 100,
    "bientity_action": {
        "type": "apoli:swap"
    }
}

Hitting something trades places with it.

{
    "type": "apoli:fire_projectile",
    "texture_location": "minecraft:textures/item/ender_eye.png",
    "cooldown": 60,
    "speed": 2.0,
    "owner_target_bientity_action_on_hit": {
        "type": "apoli:swap",
        "success_action": {
            "type": "apoli:invert",
            "action": {
                "type": "apoli:actor_action",
                "action": {
                    "type": "apoli:apply_effect",
                    "effect": { "effect": "minecraft:nausea", "duration": 100 }
                }
            }
        }
    }
}

A thrown eye that changes places with whoever it hits and leaves them dizzy.

If apoli:prevent_teleport stops the actor, nothing moves at all. If it stops only the target, the actor still arrives and the target stays put — a one-way trip rather than a swap.