[SPIGOT-7785] Teleporting a player at the right moment can mess up vanilla teleportation Created: 19/Jun/24  Updated: 25/Dec/24  Resolved: 22/Jun/24

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Hjalmar Gunnarsson Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Environment:

Running on windows 10, Java 21 (jbr_jcef-21.0.3-windows-x64-b465).

Only running with test plugin.


Version: This server is running CraftBukkit version 4223-Spigot-146439e-d01c70e (MC: 1.21) (Implementing API version 1.21-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

Expected behavior

The vanilla teleportation behavior should either:

  1. Send the player to a different dimension, and to the right location, as if the player teleported from the location that triggered this event.
  2. 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

  1. Start a new server with default world names with a plugin that contains the given script
  2. Make a nether portal
  3. Go through the nether portal in creative mode (not flying)

 

 

Other

Probably reproducible for entities as well. Can probably also be reproducible with end portals


Generated at Sat Dec 13 11:52:00 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.