Skip to main content

Swap (Bi-Entity Action Type)

Swaps the positions of the actor and the target, so 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. swap_position is accepted as an alias.
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 TypeoptionalThe swap only happens when the block below the actor's destination passes this condition.
landing_conditionEntity Condition TypeoptionalThe swap only happens when the actor would pass this condition at the destination.
loaded_chunks_onlyBooleantrueWhether the swap is refused when the destination chunk isn't 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.

note

If apoli:prevent_teleport stops the actor, nothing moves at all. If it only stops the target, the actor still arrives and the target stays put, which makes it a one-way trip instead of a swap.