ProtocolLib icon indicating copy to clipboard operation
ProtocolLib copied to clipboard

How can I read a Enum/Varint

Open Nerd10000 opened this issue 1 year ago • 4 comments

kép

Nerd10000 avatar Mar 24 '24 06:03 Nerd10000

I want to read the Type field

Nerd10000 avatar Mar 24 '24 06:03 Nerd10000

Hello, For exemple from my function :

public static PacketContainer createPacketNES(UUID uuid, int entityID, Location location) {
    PacketContainer nesPacket = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY);
    nesPacket.getModifier().writeDefaults();
    var spawnPacketModifier = nesPacket.getModifier(); // to get Values uses .getValues()

    spawnPacketModifier.write(0, entityID);
    spawnPacketModifier.write(1, uuid);
    spawnPacketModifier.write(2, 122); // ID for player
    spawnPacketModifier.write(3, location.getX());
    spawnPacketModifier.write(4, location.getY());
    spawnPacketModifier.write(5, location.getZ());
    spawnPacketModifier.write(6, getCompressedAngle(location.getYaw()));
    spawnPacketModifier.write(7, getCompressedAngle(location.getPitch()));

    return nesPacket;
}

TheCalypso avatar Mar 25 '24 09:03 TheCalypso

Okay is there a website where I can read the Entity IDs?

Nerd10000 avatar Mar 26 '24 16:03 Nerd10000

From my issue #2856

By following the documentation that you can find here: https://wiki.vg/Protocol#Spawn_Entity it seems that index 2 is now a VarInt corresponding to https://wiki.vg/Entity_metadata#Player.

TheCalypso avatar Apr 02 '24 16:04 TheCalypso