Holograms and armourstands

Discussion in 'Spigot Plugin Development' started by iSoda, May 31, 2017.

  1. Im trying to make floating damage holograms once an entity is hit (ie: if the damage is 7, then spawn a hologram saying "7" above the entity).
    I can do that by creating invisible armourstands and setting their names to whatever the damage is, however I need to be able to hit the entity constantly, and the armourstands have a hitbox which the player may hit instead of the entity. Is there any other way of creating holograms that will be affected by gravity AND wont haev hitbox that the player can hit?
     
  2. ScarabCoder

    ScarabCoder Retired Resource Staff
    Retired

    ArmorStands have a vanilla tag called "Marker". It makes it so they have no hitbox (or atleast, one that you can't hit). You can set this with ArmorStand.setMarker(true);
    It will make the custom name appear right above the nameplate, so remember to offset it for that too.
     
    • Like Like x 1
    • Informative Informative x 1
  3. You can use setMarker like the above poster suggests, but keep in mind you can't really combine that with gravity.

    Well, you can, I should say- but the armor stand will fall right through the ground, which maybe works for your purposes but something to keep in mind.
     
    • Like Like x 1
  4. uhhh.... entity#setGravity?
     
    • Like Like x 1
    • Agree Agree x 1
  5. Uhhh ... read the OP? :)

     
    • Like Like x 1
  6. ScarabCoder

    ScarabCoder Retired Resource Staff
    Retired

    Oh, right, last line. For a damage indicator, what's the reason for having gravity? Is it for the effect of it "floating" down?
    A better alternative is to set a repeating scheduler for moving the armorstand up a bit every tick, then after 1-3 seconds remove it.
     
    • Like Like x 1
  7. I was wondering that too... and came to the same conclusion as you, maybe they want it to drift slowly down as an effect. If that's the case then maybe it's fine if it falls through the ground, assuming it's going to get removed after a few seconds anyway.

    I agree with you though that moving them via code without gravity would be a better approach, at the very least it'd give you much more control over exactly how they animate.
     
    • Like Like x 1
  8. Adding onto @NathanWolf and @ScarabCoder points you could make it check the level of the ground through two ways. Either getting the players location and taking the one height block away (Y) or just check for the nearest block directly below the armour stand.

    This way you could prevent it falling through the floor by setting gravity at that coordinate.

    Yes I know about the whole gravity thing but its still a point to think about.
     
    • Like Like x 1
  9. Thank you all, set marker does suit the purpose as world interaction dont matter (the entity will be cleaned 20 ticks after spawned.), for those who wonder - Ive set the armourstand velocity in random direction so its kind of "pops"out of the damaged entity.
     
  10. Mark as resolved! ;)