ProtocolLib

3M Downloads

FieldAccessException: Field index 1 is out of bounds for length 1 in 1.19.3

Opened this issue ยท 1 comments

commented
  • This issue is not solved in a development build

Describe the bug
I am trying make my plugin support the Minecraft versions from 1.16.5 to 1.19.3 but I am getting an error when trying to write to a PacketContainer in 1.19.3 (no errors on 1.16.5).

It worked fine with the latest release but it won't work now because I am getting the following error: https://pastebin.com/k925nh6q

To Reproduce
Have the following code (it is executed when a player joins the server):

private PacketContainer newPacket(int mode) {
    PacketContainer container = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_TEAM, true);
    
    // All variables exist
    container.getStrings().write(0, name).write(1, "always");
    container.getChatComponents().write(0, emptyWrappedChatComponent).write(1, WrappedChatComponent.fromText(prefix)).write(2, WrappedChatComponent.fromText(suffix));
    container.getIntegers().write(0, mode);

    return container;
}

Version Info
https://pastebin.com/11TrJ7fw

commented

The underlying packet has changed since 1.16. The flags such as nametag visibility have been moved to another class ClientboundSetPlayerTeamPacket.Parameters. Unfortunately, I do not see any option on how to easily access this with ProtocolLib at the moment. You might want to use NMS for now if that's suitable for you. The corresponding NMS class is ClientboundSetPlayerTeamPacket.