Per Player Skulls

Discussion in 'Spigot Plugin Development' started by _Nickk, Jul 1, 2016.

  1. Hello. I am writing a plugin where each player will see a skull block as their own. Here is my current code:

    Code (Text):
     
            BlockState state = head.getState();
            Skull skull = (Skull) state;

            PacketPlayOutTileEntityData skullPacket = ((CraftSkull)skull).getTileEntity().getUpdatePacket();
            try {
                Field nbt = skullPacket.getClass().getDeclaredField("c");
                nbt.setAccessible(true);
                NBTTagCompound comp = (NBTTagCompound) nbt.get(skullPacket);

                comp.setString("Owner", username);

                ((CraftPlayer)p).getHandle().playerConnection.sendPacket(skullPacket);
            } catch (NoSuchFieldException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
     
    This code is not working, as the skull appears as a steve head.
     
  2. With that method I'd be getting a skull item. I'm looking to make a skull that is placed in the world look like the person who is viewing it.
     
  3. Woops, sorry!
     
  4. Np, thanks though.