'How can I set the second layer of an NPC visible using PacketPlayOutEntityMetadata in 1_18_R1 (without Mojang Mapping)?

I'm trying to code a Minecraft Spigot Plugin using NMS. I want to create and spawn an NPC. The code I wrote for creating the EntityPlayer, GameProfile and for sending the packets works fine, but I can't figure out how to set the EntityPlayer metadata in 1.18.1. I've tried doing the same thing in 1.15 and it worked perfectly.

md_5 remapped a lot of methods. For example, to get the DataWatcher of an EntityPlayer, I used to do npc.getDataWatcher();, but now I have to use npc.ai();. I can't seem to find a solution on the internet that works in 1.18.1 without any other APIs such as Citizens.

I think I figured out all the methods counterparts, but it still doesn't work.

So, how did the way you set Metadata of an EntityPlayer change in 1.18.1?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source