Solved Teleport armor stand along Y axis

Discussion in 'Spigot Plugin Development' started by DualNeXoN, Jan 28, 2020.

  1. Hi guys!

    I am trying to make a nametag with invisible armor stand for entity (above head something like current health info). The thing is that I somehow cannot modificate any axis with add or substract method. It is stuck with the current location of an entity. I cannot move it more above. Now it is colliding with nametag of the attached entity.

    This is how my location modificator looks like.
    Code (Java):
    Location location = livingEntity.getLocation(); //Getting current location
    armorStand.teleport(location.clone().add(0, 1, 0)); //Teleporting armor stand with modificated Y axis

    The question is:
    How to move the armor stand more up along Y?
  2. You‘ll need to turn off the gravity (ArmorStand#setGravity(false))
  3. I forgot to say that I already changed few properties for armor stand.

    Code (Java):
    I can't even set X or Z position. It always stick to the entity.:(


    Okay I somehow figured out what was the problem. In my constructor of the armor stand I was parsing to the spawn method exact location of the livingEntity and not the modified one.
    Code (Java):
    armorStand = (ArmorStand) entity.getWorld().spawnEntity(livingEntity.getLocation(), EntityType.ARMOR_STAND);
    But when I tried to spawn armor stand with the modified Y it suddenly works
    Code (Java):
    armorStand = (ArmorStand) entity.getWorld().spawnEntity(livingEntity.getLocation().add(0, 1, 0), EntityType.ARMOR_STAND);
    Don't know why it acts like this because this is just the constructor thing, the only tick. After the constructor I am setting every tick the modified position... So I need to set the height of armor stand in the constructor and can't do it in repeating task (weird). Nevermind, problem solved.
    #3 DualNeXoN, Jan 28, 2020
    Last edited: Jan 28, 2020