Visible Entity Name (Lowered)

Discussion in 'Plugin Development' started by GamerzKing, Nov 30, 2015.

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

    GamerzKing

    Hey everyone!

    My name is GamerzKing, and I am creating an ability, that requires for me to create visible name tags for entity names. So I began by creating a new armor stand, naming it, and setting the passenger to the entity, however it still appears higher than I would like it.

    I've tried searching for a solution to this, and I have tried creating a negative slime, and setting the passenger to the slime, however this did not work, unfortunately.

    Image:
    [​IMG]

    Code:
    Code:
    package com.GamerzKing.elementals.kits.water;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.World;
    import org.bukkit.entity.ArmorStand;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Guardian;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.scheduler.BukkitRunnable;
    
    import com.GamerzKing.elementals.core.GameKits;
    import com.GamerzKing.elementals.core.Main;
    import com.GamerzKing.elementals.utils.ChatUtils;
    import com.GamerzKing.elementals.utils.CooldownUtilities;
    
    public class Water_Support implements Listener {
    
        int cooldownTime = 14;
    
        int guardianHealth = 15;
        int maxGuardianHealth = 15;
    
        int despawnTime = 8;
    
        @EventHandler
        public void onPlayerInteract(PlayerInteractEvent event) {
    
            Player player = event.getPlayer();
            Action action = event.getAction();
    
            if (GameKits.getKit(player) == GameKits.WATER && player.getInventory().getItemInHand().getType().equals(Material.IRON_AXE)) {
                if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) {
                    if (CooldownUtilities.Water_Support.containsKey(player.getName())) {
    
                        ChatUtils.sendCooldownMessage(player, CooldownUtilities.Water_Support);
    
                    } else {
    
                        CooldownUtilities.setCooldownLength(player, cooldownTime, CooldownUtilities.Water_Support);
                        CooldownUtilities.startCooldown(player, CooldownUtilities.Water_Support);
    
                        World world = Bukkit.getWorld(player.getLocation().getWorld().getName());
                        Location playerLocation = player.getLocation();
    
                        Guardian guardian1 = (Guardian) world.spawnEntity(playerLocation, EntityType.GUARDIAN);
                        ArmorStand guardian_name1 = (ArmorStand) world.spawnEntity(playerLocation, EntityType.ARMOR_STAND);
    
                        guardian_name1.setGravity(false);
                        guardian_name1.setCustomNameVisible(true);
                        guardian_name1.setSmall(true);
                        guardian_name1.setVisible(false);
                        guardian_name1.setCustomName(ChatColor.RED + player.getName() + "'s" + " Ocean Call");
    
                        guardian1.setHealth(guardianHealth);
                        guardian1.setMaxHealth(maxGuardianHealth);
                        guardian1.setPassenger(guardian_name1);
    
                        new BukkitRunnable() {
    
                            @Override
                            public void run() {
    
                                guardian1.setHealth(0);
                                guardian_name1.setHealth(0);
                            }
                        }.runTaskLater(Main.getPlugin(), despawnTime * 20);
                    }
                }
            }
        }
    }
    Thread I previously viewed:
    https://www.spigotmc.org/threads/using-armorstands-riding-entities-as-nameplates.44809/

    If anyone could help, that would be greatly appreciated, thanks! :)
     
  2. Offline

    Zombie_Striker

    @GamerzKing
    • Keep your package names lower case
    • Did you debug? How did the negative slime effect your issue? Did you do that correctly?
     
  3. Offline

    teej107

    @GamerzKing So you want to have an entity named? You can do that without armorstands.
     
  4. Offline

    CoolDude53

    @teej107 in 1.8+ custom named entities only show their name overhead when looking at them from a short distance.
    @GamerzKing I don't think you can fix this with the armorstand being a passenger of the guardian. You will have to either deal with this, or create code that manually has the armorstand follow the guardian.
     
  5. Offline

    mcdorli

    Entity#setCustomName(String s)?
     
  6. Offline

    Konato_K

    @GamerzKing I know it's possible to use an "offset" and make the entities ride an entity at a different height of the normal one, I have seen this implemented with command blocks, so I'm not sure how it can be done with craftbukkit.
     
  7. Offline

    GamerzKing

    Read @CoolDude53 's reply.
     
Thread Status:
Not open for further replies.

Share This Page