1.7.10 Create FakePlayer with break line on his name

Discussion in 'Spigot Plugin Development' started by tsukuuyomi, Jan 28, 2020.

  1. I want to make a FakePlayer that have a description above of his head, but it doesn't let me break lines and add more than 16 characters on his name.

    what i want to do:

    [​IMG]

    what gives:
    [​IMG]

    my code:

    Code (Text):
    public static void npcSky(Location l, Player p) {
            MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
            WorldServer nmsWorld = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
            GameProfile profile = new GameProfile(UUID.fromString("baad6231-75f2-48c9-b020-7f33891c1af5"), "test\nbreakline");
            EntityPlayer npc = new EntityPlayer(nmsServer, nmsWorld, profile, new PlayerInteractManager(nmsWorld));
            profile.getProperties().put("textures", new Property("textures", "eyJ0aW1lc3RhbXAiOjE1ODAyMzI4MzM4NjgsInByb2ZpbGVJZCI6Ijg1NWFmNjQ3OTM4NjRmZjVhYmExNjI2Yzc0MzkzMTYwIiwicHJvZmlsZU5hbWUiOiJMdWdpbkJyIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS82OWEwMWY2Y2YzMzdjM2M2OTk2NWQ5NDI0OTc5OWJhZThiNDlhYzRmMzQ4NjY2YTRjNDNmMjljZjdjYzQ4NmRlIn19fQ==",
                    "P0WF25pNkjYu8IQ1lydlT7aOyrP4M8U2N1rETHGTuZ95B19WZ3/CKEXXXmJ9KLd53C3JxraxHv01Rp4rW23EUoIIv7uzeRcJ2kTTvH0hCLmLGg+rxnVouHpGl4xBheAc6m4ndblCDmh/ISlWTErZPiJ2/5j0ByoxMU4Bh2D9h99Qv0plwCOsyFKKSOcmHgQEDcCwLrveIoUflNk/wKAg2uhWZyZQvSHjzzCEZkH9mwQCXRjLiZyynZ3KVygfhIpuCylPAC4lLZwnk+nOuX4yOsrTpI9OkW1lUcYjZqGxUcBYtdqNY82UJ+CSlenjYlu84/Su4SJ/WUDiDcbfriyWCHSdMkywlYtbs9YY4iD5s8rmdorHXzjhoqa7bvGFX7/aKMO+EbmEnSJ8f46pXZwpj0tUM6fd3Iw8PIrz8KgCBiKqgFLDiLP2R8p01Jq333j34/qi19AwskbR4U/fg8nAZaFvO9+RXjvlKAxANOVUe+XVGB1w2SCz7N4bEV1AVE6eqp0RWLf0j+EjfHImNWjMgw49MKca/wOD7uOSwkx53D12H3rsk3AZg4PPewC7qbP/ZlhIcza++UCNJ2JkB8nrhD3cV8/Caly41+4+ht0zNjVoFp3r5fFjMl9Z2uYjGekW1U2IP60KmEbaf+gDPjbd6ojz/VXh0lA9d1LWEvk6ge0="));
            npc.setLocation(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch());
            PlayerConnection connection = ((CraftPlayer) p.getPlayer()).getHandle().playerConnection;
            connection.sendPacket(PacketPlayOutPlayerInfo.addPlayer(npc));
            connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
         
        }
    please help me!!!!
     
  2. Place an invisible entity with a visible custom name over the NPC.
     
  3. what youre trying to recreate is not achieved by a line break, its another (invisible) entity, likely an armor stand.
    putting a line break in an entity's nametag is currently not possible
     
  4. how could i do this? can you help me?
     
  5. What is the game version?
    You could use an armorstand, set his position at the npc but y +0.5 and set his custom name
     
  6. i'm using a PaperSpigot for 1.7 and 1.8 on my server. i can't create armor stands, there is some way to create that without it? or some bukkit/spigot jar for 1.7 & 1.8 that permit armor stands?
     
  7. Create an entity "ent", give it a name and use the method Entity.setPassenger(ent). That should work. I used it for hiding NPC names, but i think if you give it a name it MIGHT work.
     
    #7 Ckblck, Jan 29, 2020
    Last edited: Jan 29, 2020
  8. You need at least version 1.8 for armor stands, they don't exist in 1.7
     
  9. it worked in part. the custom display name shows just when aproximate my crosshair

    [​IMG]

    [​IMG]
     
  10. yes, the "customnamevisible" option (which makes this always visible) for all mobs was added in 1.9 or later
     
    • Like Like x 1
  11. but i want to show the customnamevisible without player aproximate, like in the image before! there is no way to do that?
     
  12. at least not with spigot's API methods, as far as i know.
    maybe you can get lucky with something in protocollib or the likes, packet stuff
     
    • Agree Agree x 1