Too Many Attributes
» Entity actions » Swap

Swap

too-many-attributes:swapbi-entity action

The actor and the target trade places. It works across dimensions.

FieldTypeDefaultDescription
x, y, zDouble0Where the actor lands, as an offset from the target's position. The target always lands where the actor stood.
landing_block_conditionBlock conditionoptionalChecked on the block under the actor's landing spot. If false, nobody moves.
landing_conditionEntity conditionoptionalChecked on the actor as if it already stood at the landing spot. If false, nobody moves. Skipped when the swap crosses dimensions.
loaded_chunks_onlyBooleantrueIf the actor's landing spot is in an unloaded chunk, nobody moves.
success_actionBi-entity actionoptionalRuns after the swap, with the same actor and target.
fail_actionBi-entity actionoptionalRuns when a check stops the swap.
  • Both keep the way they're facing.
  • A mob that changes dimension becomes a new copy of itself there. success_action gets the copy.
  • From Overgrown's Apoli: the fields match Overgrown's swap, except space. The offset is always in world directions. Overgrown's teleport_to isn't in TMA.

Example: "Switcheroo". Hitting an entity swaps places with it and plays the enderman teleport sound, once every 5 seconds.

json
{
  "type": "origins:action_on_hit",
  "bientity_action": {
    "type": "too-many-attributes:swap",
    "success_action": {
      "type": "origins:actor_action",
      "action": {
        "type": "too-many-attributes:play_sound",
        "sound": "minecraft:entity.enderman.teleport"
      }
    }
  },
  "cooldown": 100
}