Solved Setting Name tags to appear at all times

Discussion in 'Plugin Development' started by n1ghtk1n9, Jul 13, 2014.

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

    n1ghtk1n9

    I'm currently trying to create a hologram type display(YES I know there are other plugins, but if you just use someone else's work, you don't really learn anything(I've also tried decompiling the code and didn't learn much out of that)) Currently I've made it so there's a custom-entity chicken(I could might be able to do a lot of this without making a custom entity but it's just quicker this way anyways b/c I'm just testing) that's damageEntity method has been overridden like this:
    Code:java
    1. @Override
    2. public boolean damageEntity(DamageSource source, float f) {
    3. return false;
    4. }

    I've gotten that entity to work, but my problem is that the only time you see the name tag is when you're looking directly at the entity. Is there a way to set it so the name tag appears at all times?

    TL;DR: How can I get a name-tag of an entity to appear without having to make the player look at the entity, and without using external plugins or an API
     
  2. Offline

    xTigerRebornx

  3. Offline

    n1ghtk1n9

    No I don't believe it does, when I actually implement it into my plugin I won't be using NMS, I really just did it for practice with NMS(I'm not that experienced with it, so I'd like to get better everyway possible)

    EDIT: Also, when that method is called and the argument is set to true, it just makes it so that it's visible, not that it's visible even when you're not looking at the entity(like how player name tags are handled)
     
  4. Offline

    xTigerRebornx

    n1ghtk1n9
    Did you even test it? If you did, then look for an alternate method, or research the horse glitch that holograms are made with.
     
  5. Offline

    n1ghtk1n9

    Yes I did, let me check again

    EDIT: That worked! My live-debugging didn't insert the current code(has been happening pretty often lately, but I turned off the notification for it cause it was getting annoying)
    Thanks!

    Also, do you know how to add multiple lines in a name tag? I tried \n which would work with normal strings in Java but it makes a weird box on the name tag now

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  6. Offline

    xTigerRebornx

    n1ghtk1n9 AFAIK, you can't. They are one line. You should really look at how the holograms work if you want to make your own version (they use a glitch involving negative values for a horse's age that distorts their model, I believe)
     
  7. Offline

    n1ghtk1n9

    Oh darn, that ruins my plan then. Oh well! I will look into that, sounds kinda funky though
     
  8. Offline

    xTigerRebornx

    n1ghtk1n9 likes this.
  9. Offline

    n1ghtk1n9

    I watched the video, and he basically said it's a horse riding a witherskull(so it doesn't move I figure), with a very long negative age value so it glitches out, then he adds create multiple nametags on top of each other. The video was very informative, but really the only reason he did the negative age value was so the horse was practically invisible, and it riding the witherskull is only so it doesn't move. He leaves out the multiple name-tag part, which I need. Thanks anyways
     
  10. Offline

    xTigerRebornx

    n1ghtk1n9 Multiple name tag is basically the horses spawned with slight differences in Y values (you'd have to do testing to find this)
     
  11. Offline

    n1ghtk1n9

    Do you mean there's multiple horses with each different Y values(like 5.0, 5.1, etc)?
     
  12. Offline

    xTigerRebornx

    n1ghtk1n9 I believe so, as a Name-tag is only 1 line, it'd make sense.
    Edit: unless there is something else, could look into the redstone logic his stuff does.
     
  13. Offline

    n1ghtk1n9

    Will try it and get back to you

    Got any ideas how to make the Witherskull immobile? I set the velocity to just 0 and it still moves. I'm gonna try to use the default NMS EntityWitherSkull and will see if that works

    EDIT: I used NMS Entities:
    Code:java
    1. EntityWitherSkull witherskull = new EntityWitherSkull(((CraftWorld) world).getHandle());
    2. witherskull.setLocation(1782, 6, -233, 0, 0);
    3. ((CraftWorld) world).getHandle().addEntity(witherskull);
    4.  
    5. EntityHorse entityhorse = new EntityHorse(((CraftWorld) world).getHandle());
    6. entityhorse.setLocation(1782, 6, -233, 0f, 0f);
    7. entityhorse.setAge(1); //will set this to like -1700000 or so(like in the video)
    8. entityhorse.setPassengerOf(witherskull);
    9. entityhorse.setCustomName("Name");
    10. entityhorse.setCustomNameVisible(true);
    11.  
    12. ((CraftWorld) world).getHandle().addEntity(entityhorse);

    I think I'd just have to keep repeating this over and over

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  14. Offline

    xTigerRebornx

    n1ghtk1n9 Probably have to use NMS, or do what HoloAPI does (I believe they send packets to the client for the spawning and setting the horse to ride the skull)
     
  15. Offline

    n1ghtk1n9

    I set the age to a negative number and it flipped out on me(not the way it's supposed to glitch out), didn't even make it invisible or whatever, and also when I do it the nametag doesn't appear
     
  16. Offline

    xTigerRebornx

    n1ghtk1n9 Defined "flipped out", and what is the age you put? Also, mind posting some code so I can get an idea of what you are doing in terms of spawning it and what happens?
     
  17. Offline

    n1ghtk1n9

    The code above is what I have currently. The ages I've done
    -17,000 : Normal young horse
    -170,000 : Horse is spawned in pieces, is graphically floating in the air, but the nametag is in the ground and in-game it's in the ground too, b/c it's suffocating(getting damaged and is darkened)
    -1,700,000 : Horse is nowhere to be found, nametag doesn't appear
    -17,000,000 : Same as above, also the same occurrence with increasing numbers

    xTigerRebornx I kinda of figured it out. I looked into the source code of this plugin: http://dev.bukkit.org/bukkit-plugins/holographic/files/8-holographic-v0-3-2/ (Hologram_v1_7_R2 class), and what they do is they spawn the Horse with an age of -1700000 , then with the desired Y, add 55 to it. What I can't figure out is how they make the name tags flush with eachother. When I look from above(when I have multiple horses & name tags) the name tags overlay.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
Thread Status:
Not open for further replies.

Share This Page