Let armorstand move quickly inside player

Discussion in 'Plugin Development' started by Banjer_HD, Mar 28, 2018.

Thread Status:
Not open for further replies.
  1. Offline


    I am making a plugin where an armorstand should be inside a player at all times.
    When I run a scheduleSyncRepeatingTask that teleports the armorstand to the player it isn't fast enough and the armorstand will follow the player like a trail.
    What is the best way to do this?

    Current code:
    2. Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Main.getInstance(), new BukkitRunnable() {
    4. @Override
    5. public void run() {
    6. armorstand.teleport(Bukkit.getEntity(Bukkit.getPlayer("Player").getUniqueId()));;
    7. }
    9. }, 1, 1);

    Video of what's happening currently:
  2. Offline


    Your issue here is latency. Try doing the following to help reduce the problem:
    1. Get the player's ping. This is now the amount of MS it takes for the player to move and see the armorstand.
    2. If this value is greater than 50, then the player will see the armorstand from atleast one tick earlier than what the client. If this is the case, do the following:
    3. When teleporting the armorstand, add onto it the player's walk speed multiplied by some value (which accounts for how bad the player's ping is). Now, to the server, the armorstand will appear in front of the player, but to the client it should be close enough to where they were going.
    4. If you get lag spikes, where latency can change, also set the velocity of the armorstand (you will need to enable gravity for this). Doing this will mean the armorstand will still move with the player, even if they temporarily lose connection.
    Banjer_HD likes this.
  3. Offline


    Thanks! I didn't think of latency but it makes sence!

    When a player rides something or something is riding the player, the client knows that and there shouldn't be any latency (for example a minecart).
    Is it possible to move an entity (up, down, left and right) when it is riding you?
  4. Offline


    No. Entities that are riding other entities cannot be moved by the server; They will always follow the entity they are riding.
    Banjer_HD likes this.
Thread Status:
Not open for further replies.

Share This Page