Contains additional options for teleporting an entity.
import { system, DimensionLocation } from "@minecraft/server";import { MinecraftEntityTypes } from "@minecraft/vanilla-data";function teleport(targetLocation: DimensionLocation) { const cow = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Cow, targetLocation); system.runTimeout(() => { cow.teleport( { x: targetLocation.x + 2, y: targetLocation.y + 2, z: targetLocation.z + 2 }, { facingLocation: targetLocation, } ); }, 20);} Copy
import { system, DimensionLocation } from "@minecraft/server";import { MinecraftEntityTypes } from "@minecraft/vanilla-data";function teleport(targetLocation: DimensionLocation) { const cow = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Cow, targetLocation); system.runTimeout(() => { cow.teleport( { x: targetLocation.x + 2, y: targetLocation.y + 2, z: targetLocation.z + 2 }, { facingLocation: targetLocation, } ); }, 20);}
import { system, DimensionLocation } from "@minecraft/server";import { MinecraftEntityTypes } from "@minecraft/vanilla-data";function teleportMovement(targetLocation: DimensionLocation) { const pig = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Pig, targetLocation); let inc = 1; const runId = system.runInterval(() => { pig.teleport( { x: targetLocation.x + inc / 4, y: targetLocation.y + inc / 4, z: targetLocation.z + inc / 4 }, { facingLocation: targetLocation, } ); if (inc > 100) { system.clearRun(runId); } inc++; }, 4);} Copy
import { system, DimensionLocation } from "@minecraft/server";import { MinecraftEntityTypes } from "@minecraft/vanilla-data";function teleportMovement(targetLocation: DimensionLocation) { const pig = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Pig, targetLocation); let inc = 1; const runId = system.runInterval(() => { pig.teleport( { x: targetLocation.x + inc / 4, y: targetLocation.y + inc / 4, z: targetLocation.z + inc / 4 }, { facingLocation: targetLocation, } ); if (inc > 100) { system.clearRun(runId); } inc++; }, 4);}
Optional
Whether to check whether blocks will block the entity after teleport.
Dimension to potentially move the entity to. If not specified, the entity is teleported within the dimension that they reside.
Location that the entity should be facing after teleport.
Whether to retain the entities velocity after teleport.
Rotation of the entity after teleport.
Contains additional options for teleporting an entity.
Example: teleport.ts
Example: teleportMovement.ts