Solved help with DataWatcher

Discussion in 'Spigot Plugin Development' started by FavioFlashMc, Jun 20, 2021.

Thread Status:
Not open for further replies.
  1. Hello guys
    Basically, I was summoning an EntityPlayer with a skin, and I verified the value and signature of the skins are successfully retrieved.
    However, the second layer of the skin is not showing.
    code:
    Code (Java):
    public void senNpcPacket(EntityPlayer npc) {
        for (Player receiver : Bukkit.getOnlinePlayers()) {
          CraftPlayer cr = (CraftPlayer)receiver;
            EntityPlayer r = cr.getHandle();
            r.b.sendPacket((Packet<?>)new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a, new EntityPlayer[] { npc }));
            r.b.sendPacket((Packet<?>)new PacketPlayOutNamedEntitySpawn((EntityHuman)npc));
            r.b.sendPacket((Packet<?>)new PacketPlayOutEntityHeadRotation((Entity)npc, (byte)(int)(npc.getBukkitYaw() * 256.0F / 360.0F)));
            DataWatcher watcher = r.getDataWatcher();
            watcher.set(new DataWatcherObject<Byte>(16, DataWatcherRegistry.a), (byte) 0x40);
            PacketPlayOutEntityMetadata metadata = new PacketPlayOutEntityMetadata(r.getId(), watcher, true);
            r.b.sendPacket((Packet<?>)metadata);
        }
      }
    these lines crash the server:
    Code (Java):
    watcher.set(new DataWatcherObject<Byte>(16, DataWatcherRegistry.a), (byte) 0x40);
            PacketPlayOutEntityMetadata metadata = new PacketPlayOutEntityMetadata(r.getId(), watcher, true);
     
    1. Wrong entity id used in packet.
     
  2. I had the same problem. I don't know why but the index 16 changed to 'score' [ integer ].
    The index 17 has the bitmask thing.
     
    • Like Like x 1
  3. https://wiki.vg/Pre-release_protocol#Entity_Metadata

    They didn't update the main entity metadata page.
    The powder snow at index 7 shifted the rest of the indices
     
    • Like Like x 1
    • Useful Useful x 1
  4. change your code from
    watcher.set(new DataWatcherObject<Byte>(16, DataWatcherRegistry.a), (byte) 0x40);
    to
    watcher.set(new DataWatcherObject<Byte>(17, DataWatcherRegistry.a), (byte) 0x40);

    Minecraft changed the packet id in 1.17
     
Thread Status:
Not open for further replies.