Solved Spawn block under player and trace player

Discussion in 'Spigot Plugin Development' started by djuitietr, Jul 6, 2018.

Thread Status:
Not open for further replies.
  1. I need spawn block under player and trace player i tried with passenger but i couldn't change armorstand location. When i change armorstand location its teleports to location and leaving from passenger status. Here is what i tried:

    Code (Java):
            ArmorStand armorstand = (ArmorStand) player.getWorld().spawnEntity(player.getLocation().subtract(0.0, 1.80, 0.0), EntityType.ARMOR_STAND);
            armorstand.setHelmet(new ItemStack(Material.WOOL));
            armorstand.teleport(player.getLocation().subtract(0.0, 1.80, 0.0));
    I also tried spawn an armorstand and teleport to player when player move but this method is not so fast tracing player.

    So any suggestions for this?
    #1 djuitietr, Jul 6, 2018
    Last edited: Jul 6, 2018
  2. I think you should ask your question here: Spigot Plugin Development
    Or a moderator can move this question if they happen to see this.
  3. For the block under you can use this:

    Code (Java):
    Block block = player.getLocation().getBlock();
    Block blockBelow = block.getRelative(BlockFace.DOWN);
  4. That wasn't my problem
  5. What do you mean by tracing?

  6. Like this circle under player.
  7. Have a bukkitrunnable teleport the armorstand to the player every tick (this can be optimized but you get the gist of it)
  8. if i remember right you can do this with an armorstand set as a marker & set as a passenger.

    Note that teleporting will make entities unmount a player.
  9. Indeed an even better solution
  10. Like i said i can't teleport passenger to under the player.

    I tried that but it traces player so slowly.
  11. To have the armorstand following the player you might just want to use the PlayerMoveEvent and listen to x-,y-,z-changes and apply the velocity / movement to the armorstand.
  12. Dont teleport them to under the player. The passenger is above the player.

    There is no way you can get movements that smooth and precise by teleporting or setting a velocity over an internet connection. This means the client is the one rendering it in real time, meaning it is bound to the player one way or another (most probably a passenger on the player's head).

    What you see in your video is a custom resource pack that uses a custom model thats at the lower bounding limits so that it appears to be underneath the player.
  13. Something you could try experimenting with is instead of teleporting you could try to override the velocity & to copy exactly the player and allowing a certain level of distance (I'd say 0.5 blocks) in case the server somehow messed it up in a bizarre way.

    But still, mounting it as en entity is the only effective way. You wont find something more stable. You can try to use packets to emulate it being mounted.
  14. So you are saying i can do this with resource pack? If so how can i do that? (I mean circle under player not circle texture)
    • Like Like x 1
  15. That circle is most likely not a simple texture, but a flat 3D model. 3D models can have an offset from their origin point, and that's the case with this model too. It simply has a ~2 block offset down, making it appear to be on the ground
    • Like Like x 1
  16. Thanks everyone i'll try 3D model.
Thread Status:
Not open for further replies.