Floating text like holographicdisplays above blocks?

Discussion in 'Spigot Plugin Development' started by danablend, Mar 21, 2016.

  1. I am in need of a method to make floating text above specific blocks (chests) and I need to know how to make the armorstand and set passenger properly etc..

    EDIT: New problem - I have 2 events, in one of them I spawn multiple armorstands, in the second one, I need to remove them, I need to remove the specific armorstand, so not all armorstands at once. Should I make hashmap or something like that?
    #1 danablend, Mar 21, 2016
    Last edited: Mar 21, 2016
    • Like Like x 1
  2. Yes, I had the same problem a few months ago where I could find SOME solutions, but I can't find any answers on google currently. All solutions (that I found) are about the vanilla commands to do it.
    • Optimistic Optimistic x 1
  3. All you have to do is spawn an ArmorStand entity and make it invisible, set the custom name and make it visible. Then, you take a hashmap with the location and entityid and do what you want with the hologram by referencing the hashmap.get(block.getLocation()). I try not to spoonfeed code, but if you need help I'll help :)
    • Like Like x 1
  4. @danablend
    Holographic displays is open source, mess around with it ta little :p.
    Also, if you know what commands to use, and what the commands do, you can create it in code as well.
    • Like Like x 1
  5. What did you google?

    bukkit floating text api
    bukkit setting passanger
    bukkit how to spawn entities

    It's not THAT hard.

    Anyway, check above ^
    • Like Like x 1
  6. How should I make the armorstand as an entity?
    • Like Like x 1
  7. Can I set it as passenger on a block? Or should I just spawn it on top?

    EDIT: Nevermind, thanks y'all for helping, problem solved. My stupid thinking was the problem hehe. Got a new problem tho, below.
    #9 danablend, Mar 21, 2016
    Last edited: Mar 21, 2016
  8. Step 1: Get the world
    Step 2: Spawn it in by using the world variable and using the method spawnEntity
    Step 3: Cancel the damage event sopeople cant break the armor stand
    Code (Text):
    World w = block.getLocation().getWorld();
    ArmorStand a = (ArmorStand) w.spawnEntity(EntityType.Armor_Stand, block.getLocation());
    //Do stuff with the armor stand from here
    a.setDisplayName(ChatColor.GREEN + "Green Text");
    Also, you cant really set a passenger to a block unless it is fallingsand :)
    • Agree Agree x 1
  9. Hey thanks, but how can I remove the specific armor stands in another method? I have 2 events, I create multiple armorstands in one, and I need to remove them on another (PlayerInteractEvent)
    Specifically, I need to remove the nearest armorstand to a specific block (Which I do have the location of)
    #11 danablend, Mar 21, 2016
    Last edited: Mar 21, 2016
  10. Add their EntityID to a collection then use a loop to remove them.
    • Winner Winner x 1
  11. How would I get them to this event? I have them in a Collection with Entity UUID, but how do I retrieve them from this code?
    Code (Text):
        public void lootSpawner(PlayerInteractEvent event) {
            if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
                Player player = event.getPlayer();
                Block block = event.getClickedBlock();
                if (block.getType().equals(Material.CHEST)) {
                    if (supplyCrates.containsValue(block.getLocation())) {
                        chest = (Chest) block.getState();
                        if (supplyCrates.isEmpty()) {
                            player.sendMessage(Envoys.prefix + ChatColor.GRAY + " You have claimed the last supply crate!");
                                    Envoys.prefix + ChatColor.GREEN + " The last supply crate has been claimed by "
                                            + ChatColor.YELLOW + player.getName() + ", and the event is now over.");
                            plugin.started = false;
                        player.sendMessage(Envoys.prefix + ChatColor.GRAY + " You have claimed a supply crate!");
                                .broadcastMessage(Envoys.prefix + ChatColor.RED + " " + player.getName() + ChatColor.GREEN
                                        + " claimed a supply crate! There are " + ChatColor.YELLOW + supplyCrates.size()
                                        + ChatColor.GREEN + " left!");
    EDIT: Problem solved. I checked if there was an armorstand within a block of the chest, then removed it.
    #13 danablend, Mar 21, 2016
    Last edited: Mar 21, 2016
    • Winner Winner x 1