GlowstoneMC / Glowstone

A fast, customizable and compatible open source server for Minecraft: Java Edition
https://glowstone.net
Other
1.88k stars 271 forks source link

Entity Teleportation Not Syncing to Client #1006

Open Dev296 opened 5 years ago

Dev296 commented 5 years ago

Title: Entity Teleportation Not Syncing to Client Glowstone Version: 2018.9.0.e83d836

I was trying to develop a plugin that involves moving an entity by teleporting it a lot. I was running my teleportation code in a BukkitRunnable.

To reproduce the problem put the following code as your onCommand:

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        getLogger().info("onCommand has been invoked!");
        if (cmd.getName().equalsIgnoreCase("test")) {
            World world = Bukkit.getServer().getWorld("world");
            Entity e = world.spawnEntity(new Location(world, 0.0, 256.0, 0.0), ARMOR_STAND);
            new BukkitRunnable() {
                @Override
                public void run() {
                    e.teleport(new Location(world, 10.0, 256.0, 10.0, e.getLocation().getYaw(), e.getLocation().getPitch()));
                }

            }.runTaskLater(this, 20);

        }
        return false;
    }

Then compile the plugin, start the glowstone server and fly to 0, 256, 0. Then run /test. An armor stand appears at 0,256,0 as intended however, it when it teleports to to 10, 256, 10 it does not move client side. Reloging fixes this issue.

Potentially related to #993.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/68923166-entity-teleportation-not-syncing-to-client?utm_campaign=plugin&utm_content=tracker%2F14691067&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F14691067&utm_medium=issues&utm_source=github).
aramperes commented 5 years ago

Does the issue occur without using the BukkitRunnable? (like calling the teleport method directly after spawning, or after a second command is called, etc)

Dev296 commented 5 years ago

It works directly after spawning, but a BukkitRunnable is how you would add a delay. Just sleeping would hang the main thread.