將實體傳送到另一個實體

Entity entity;     //The entity you want to teleport
Entity teleportTo; //The entity where you want <entity> to be teleported to

boolean success = entity.teleport(teleportTo);   //Attempting to teleport.

if(success) {
//Teleport was successful
}else {
//Teleport wasn't successful
}

你還可以為你的傳送新增原因,以便你可以自定義外掛或其他人對你的原因的處理方式:

Entity entity;     //The entity you want to teleport
Entity teleportTo; //The entity where you want <entity> to be teleported to
PlayerTeleportEvent.TeleportCause cause;    //The cause you want the teleport to be of

boolean success = entity.teleport(teleportTo, cause);   //Attempting to teleport.

if(success) {
//Teleport was successful
}else {
//Teleport wasn't successful
}