Paper
Paper copied to clipboard
Teleporting a player at the right moment can mess upp vanilla teleportation
Expected behavior
The vanilla teleportation behavior should either:
- Send the player to a different dimension, and to the right location, as if the player teleported from the location that triggered this event.
- Not trigger at all, as the player nolonger is at the original location
Observed/Actual behavior
In some cases the player teleports monodimensionally (Race condition?), also generating a destination portal, if necessary.
Steps/models to reproduce
Monodimensionall travel can be reproduced with this minimal(ish) reproducible script:
@EventHandler
void onPlayerMove(PlayerMoveEvent event) {
Location to = event.getTo();
Location from = event.getFrom();
if (from.getBlockX() == to.getBlockX() &&
from.getBlockY() == to.getBlockY() &&
from.getBlockZ() == to.getBlockZ()) {
return;
}
Material toType = to.getBlock().getType();
if (!Tag.PORTALS.isTagged(toType) || toType == Material.END_GATEWAY) {
return;
}
World originWorld = to.getWorld();
World targetWorld = switch (originWorld.getName()) {
case "world" -> {
if (toType == Material.END_PORTAL) {
yield Bukkit.getWorld("world_the_end");
}
yield Bukkit.getWorld("world_nether");
}
default -> Bukkit.getWorld("world");
};
Bukkit.getScheduler().runTask(this, () -> {
event.getPlayer().teleport(new Location(targetWorld, to.getBlockX(), to.getBlockX(), to.getBlockZ()));
});
}
To reproduce
- Start a new server with default world names with a plugin that contains the given script
- Make a nether portal
- Go through the nether portal in creative mode (not flying)
Plugin and Datapack List
Only testplugin
Paper version
This server is running Paper version 1.21-9-master@4ea696f (2024-06-19T04:26:57Z) (Implementing API version 1.21-R0.1-SNAPSHOT) You are running the latest version Previous version: 1.21-DEV-c1aefee (MC: 1.21)
Other
Probably reproducible for entities as well. Can probably also be reproducible with end portals