Hiding NPC name

Discussion in 'Plugin Development' started by davidclue, Feb 11, 2021.

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


    So pretty self explanatory I can't make npc's without nametags and I've used scoreboards and it doesn't work and I used NMS scoreboard team packets and when I changed the field for "g" it threw me an error for trying to modify the field.
    public DeathMessages(Main plugin) {
            plugin.getServer().getPluginManager().registerEvents(this, plugin);
            ScoreboardManager manager = Bukkit.getScoreboardManager();
            Scoreboard board = manager.getNewScoreboard();
            this.team = board.registerNewTeam("frozenplayers");
            team.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
        public void spawnFakePlayer(Player player, String displayname, World tempW) {
            MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
            WorldServer world = ((CraftWorld) tempW).getHandle();
            Player target = Bukkit.getServer().getPlayer(displayname);
            EntityPlayer npc;
            if (target != null) {
                npc = new EntityPlayer(server, world, new GameProfile(target.getUniqueId(), target.getName()), new PlayerInteractManager(world));
            } else {
                OfflinePlayer op = Bukkit.getServer().getOfflinePlayer(displayname);
                npc = new EntityPlayer(server, world, new GameProfile(op.getUniqueId(), ChatColor.translateAlternateColorCodes('&', displayname)), new PlayerInteractManager(world));
            Location loc = player.getLocation();
            npc.setLocation(loc.getBlockX()+0.5, loc.getBlockY(), loc.getBlockZ()+0.5, loc.getYaw(), loc.getPitch());
            PacketPlayOutEntityHeadRotation rotation = new PacketPlayOutEntityHeadRotation(npc, (byte) ((loc.getYaw() * 256.0F) / 360.0F));
            for (Player all : Bukkit.getOnlinePlayers()) {
                PlayerConnection connection = ((CraftPlayer)all).getHandle().playerConnection;
                connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
                connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
Thread Status:
Not open for further replies.

Share This Page