Solved Packet player heads

Discussion in 'Spigot Plugin Development' started by AgentLV, Jul 27, 2015.

  1. Hello, I am having problems with spawning a player head with packets. A playerhead is spawned, but never the actuall skin of the players head is shown. Yes I have to do this with packets.

    My code
    Code (Java):
    EntityArmorStand as = new EntityArmorStand(((CraftWorld) loc.getWorld()).getHandle());
                as.setInvisible(true);
                as.setCustomName(p.getName());
                as.setCustomNameVisible(true);
                as.setSmall(true);
                as.setGravity(false);
                as.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
               
                ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (byte) SkullType.PLAYER.ordinal());
                SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
                skullMeta.setOwner(p.getName());
                skull.setItemMeta(skullMeta);
               
                EntityNMSItem item = new EntityNMSItem(((CraftWorld) loc.getWorld()).getHandle());
                item.setLockTick(true);
                item.setItemStackNMS(skull);
                item.setLocationNMS(loc.getX(), loc.getY() + 1.5, loc.getZ());
                item.allowPickup(false);
               
                PacketPlayOutSpawnEntityLiving armorStandPacket = new PacketPlayOutSpawnEntityLiving(as);
                ((CraftPlayer) p).getHandle().playerConnection.sendPacket(armorStandPacket);
               
                PacketPlayOutSpawnEntity itemPacket = new PacketPlayOutSpawnEntity(item, 2, 0);
                ((CraftPlayer) p).getHandle().playerConnection.sendPacket(itemPacket);
               
                PacketPlayOutEntityMetadata itemMetaDataPacket = new PacketPlayOutEntityMetadata(item.getId(), item.getDataWatcher(), true);
                ((CraftPlayer) p).getHandle().playerConnection.sendPacket(itemMetaDataPacket);
               
                PacketPlayOutAttachEntity attachEntityPacket = new PacketPlayOutAttachEntity(0, item, as);
                ((CraftPlayer) p).getHandle().playerConnection.sendPacket(attachEntityPacket);
     
  2. This fixes it! :)