juliarn / npc-lib

Asynchronous, high-performance Minecraft NPC library for 1.8-1.21 servers.
MIT License
303 stars 51 forks source link

Outer skin layer #55

Closed lbirkert closed 2 years ago

lbirkert commented 2 years ago

Can i enable the outer layer of my npc? (PacketPlayOutEntityMetadata)

lbirkert commented 2 years ago

I actually got it through trial and error:

MetadataModifier mmodifier = npc.metadata();
mmodifier.queue(MetadataModifier.EntityMetadata.SKIN_LAYERS, true);
mmodifier.send(player);

can i enable different parts of the skin with a byte too?

juliarn commented 2 years ago

Hey, this is currently only possible if you create an own instance of EntityMetadata.

It would look similar to this already existing entity metadata:

public static final EntityMetadata<Boolean, Byte> SKIN_LAYERS = new EntityMetadata<>(
    10,
    Byte.class,
    Arrays.asList(9, 9, 10, 14, 14, 15, 17),
    input -> (byte) (input ? 0xff : 0));

You would have to change the input type from boolean to an array of skin layers for example. In the lambda function you see at the bottom, you would have to compute the bitmask out of the selected skin layers, contained in the array.

But I already wanted to add this feature to the library itself as it would be pretty useful, so maybe I will implement it directly.