Random Teleport (Entity Action Type)

Teleports the entity to a random location within the specified area.

Teleports the entity to a random location within the specified area.

Type ID: apoli:random_teleport

!!! note

The actual width and height of the available teleportation area is double the respective provided value, +1 for the block the player stands on in the very center.

Fields

FieldTypeDefaultDescription
area_widthFloat8.0Determines the width of the area.
area_heightFloat8.0Determines the height of the area.
heightmapHeightmap TypeoptionalIf specified, the location will be anchored above the highest Y level of the world determined by this heightmap type.
attemptsIntegeroptionalDetermines how many attempts the entity should be teleported to a random location. Defaults to area_width 2 + area_height 2.
landing_block_conditionBlock Condition TypeoptionalIf specified, the entity will only be teleported on top of a block that fulfills this block condition. Otherwise, the entity will only be teleported on blocks that blocks movement/have solid collision.
landing_conditionEntity Condition TypeoptionalIf specified, the entity will only be teleported to a location if the entity fulfills this entity condition. Otherwise, the entity will only be teleported to a location that is empty (e.g: no blocks and fluids.)
landing_offsetVector{"x": 0, "y": 0, "z": 0}Determines the offset of the location of where the entity will be teleported. If the X and Z offsets are specified, the X and Z coordinates of the location will be divided (floored) before applying the offset.
loaded_chunks_onlyBooleantrueDetermines whether the entity should only be teleported in loaded chunks. It is recommended to keep this set to true for performance reasons.
success_actionEntity Action TypeoptionalIf specified, this entity action will be executed on the entity after it’s been successfully teleported to a random location.
fail_actionEntity Action TypeoptionalIf specified, this entity action will be executed on the entity upon failing to be teleported on a random location.

Examples

"entity_action": {
	"type": "apoli:random_teleport",
	"area_width": 8,
	"area_height": 8,
	"success_action": {
		"type": "apoli:spawn_particles",
		"particle": "minecraft:poof",
		"count": 8
	},
	"fail_action": {
		"type": "apoli:execute_command",
		"command": "title @s actionbar {\"text\": \"Cannot teleport!\", \"color\": \"red\"}"
	}
}

This example will teleport the entity to a random location within a 17x17x17 area. If the entity has been successfully teleported to a random location, the entity will emit a poof particle, otherwise, a message will pop-up that indicates the entity cannot be teleported.

"entity_action": {
	"type": "apoli:random_teleport",
	"area_width": 4,
	"area_height": 8,
	"landing_block_condition": {
		"type": "apoli:in_tag",
		"tag": "minecraft:wool"
	},
	"landing_offset": {
		"x": 0.5,
		"z": 0.5
	}
}

This example will teleport the entity on top of the center of a random block included in the minecraft:wools block tag within a 9x17x9 area.