/teleport
原文:Commands/teleport;源修订:3867604。
本页介绍自 Java 版 1.13(17w45a)起的现行命令,旧版命令参见 /tp(Java 版 1.13 之前)。别名为 /tp。权限等级:Java 版为 2,基岩版为 1;基岩版需要开启作弊。
传送实体,包括玩家、生物等。
虽然多数命令只能影响已生成的区块,但 /teleport 可以把实体传送至尚未生成的区块。游戏会在传送前立刻生成目标区块。
语法
Java 版
teleport <destination>
teleport <targets> <destination>
将执行者或指定实体传送至某实体的位置,并使旋转朝向与该实体相同。
teleport <location>
将执行者传送至特定位置,并将其旋转朝向更改为命令执行时的朝向。
teleport <targets> <location>
将实体传送至特定位置,不更改旋转朝向。
teleport <targets> <location> <rotation>
teleport <targets> <location> facing <facingLocation>
teleport <targets> <location> facing entity <facingEntity> [<facingAnchor>]
将实体传送至特定位置,并把旋转朝向更改为指定朝向。
基岩版
teleport <destination: target>
teleport <victim: target> <destination: target> [checkForBlocks: Boolean]
将执行者或指定实体传送至某实体的位置,使其水平面向前方,并使水平旋转角与指定实体相同。
teleport <destination: x y z> [checkForBlocks: Boolean]
teleport <victim: target> <destination: x y z> [checkForBlocks: Boolean]
将执行者或指定实体传送至特定位置,不更改旋转朝向。
teleport <destination: x y z> [yRot: value] [xRot: value] [checkForBlocks: Boolean]
teleport <destination: x y z> facing <lookAtPosition: x y z> [checkForBlocks: Boolean]
teleport <destination: x y z> facing <lookAtEntity: target> [checkForBlocks: Boolean]
teleport <victim: target> <destination: x y z> [yRot: value] [xRot: value] [checkForBlocks: Boolean]
teleport <victim: target> <destination: x y z> facing <lookAtPosition: x y z> [checkForBlocks: Boolean]
teleport <victim: target> <destination: x y z> facing <lookAtEntity: target> [checkForBlocks: Boolean]
将执行者或指定实体传送至特定位置,并把旋转朝向更改为指定朝向。
参数
targets(entity)或 victim: target(CommandSelector<Actor>):指定要传送的实体,可以选择多个实体;省略时默认为执行者。
location(vec3)或 destination: x y z(CommandPositionFloat):指定目标实体要传送至的坐标。
destination(entity)或 destination: target(CommandSelector<Actor>):指定目标实体要传送至的那个实体,必须解析为单个实体。
Java 版的 rotation(rotation),或基岩版的 yRot: value、xRot: value(RelativeFloat):指定旋转朝向。
facingLocation(vec3)或 lookAtPosition: x y z(CommandPositionFloat):指定目标实体要面向的坐标。
facingEntity(entity)或 lookAtEntity: target(CommandSelector<Actor>):指定目标实体要面向的实体。
Java 版的 facingAnchor(entity_anchor):指定面向实体的眼部还是脚部;省略时默认为脚部。Java 版中,目标实体自身使用的锚点可通过 /execute anchored 更改。基岩版中,总是从目标的脚部朝向另一实体的脚部。
基岩版的 checkForBlocks: Boolean:布尔值。为 true 时,只有目标不会与其不能容身的方块发生碰撞才传送;因此可以传送至花丛中或半空中。为 false 或省略时,采用默认行为,不检查而直接传送。
详细参数类型规则见参数类型。
结果
命令不完整或任意参数指定不正确时无法解析。
目标未解析为一个或多个实体时失败;按名称指定的玩家必须在线。destination、facingEntity、destination: target 或 lookAtEntity: target 未解析为单个实体时失败。
Java 版中,目标位置 X、Z 超出 [-30000000, 30000000),或 Y 超出 [-20000000, 20000000) 时失败;源结果表将该情况在基岩版中列为成功。基岩版 checkForBlocks 为 true 且指定位置被阻挡时失败。其他情况成功。
输出
Java 版失败时成功次数、success、result 均为 0;成功时成功次数和 success 均为 1,result 为指定实体数。
基岩版失败时成功次数为 0,成功时如下:
| 命令形式 | 成功次数 |
|---|---|
/teleport <destination: x y z> ... |
1 |
/teleport <victim: target> <destination: x y z> ... |
目标被传送实体数。 |
/teleport <destination: target> ... |
2 |
/teleport <victim: target> <destination: target> ... |
被传送实体数加 1。 |
示例
把执行玩家传送至 Alice:
teleport Alice
把所有玩家传送至执行玩家:
teleport @a @s
把执行玩家传送至 X=100、Z=100,且比当前位置高 3 格:
teleport 100 ~3 100
把执行玩家向前传送 1 格:
teleport ^ ^ ^1
不更改最近玩家位置,只使其向右旋转 10 度:
execute as @p at @s run teleport @s ~ ~ ~ ~10 ~
与 /execute 配合使用时,可以在主世界、下界和末地之间传送。
把执行玩家传送至下界的相同坐标:
execute in minecraft:the_nether run teleport ~ ~ ~
以上为 Java 版。基岩版为:
execute in nether run teleport ~ ~ ~
把所有玩家传送至末地的 (84,57,79):
execute as @a in minecraft:the_end run teleport 84 57 79
基岩版为:
execute as @a in the_end run teleport 84 57 79
把 Alex 传送至主世界的 (251,64,-160):
execute as Alex in minecraft:overworld run teleport 251 64 -160
基岩版为:
execute as Alex in overworld run teleport 251 64 -160
外部链接
Microsoft Learn:/teleport 命令(2023 年 10 月 11 日)。
来源为 Minecraft Wiki;本中文翻译/改编按 CC BY-NC-SA 3.0 共享。