ProtocolLib tries to set a final field
TheBasicBit opened this issue ยท 1 comments
Hello everyone, I think I found a bug.
Versions:
ProtocolLib v5.0.0-SNAPSHOT-b614
Spigot 1.19.3-R0.1-SNAPSHOT (latest build)
Exception:
java.lang.IllegalStateException: Unable to set value of field private final java.util.EnumSet net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket.a
at com.comphenix.protocol.reflect.accessors.DefaultFieldAccessor.set(DefaultFieldAccessor.java:42) ~[?:?]
at com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:359) ~[?:?]
at com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:322) ~[?:?]
at de.basicbit.system.modules.npc.NpcModule$1.onPacketSending(NpcModule.java:83) ~[?:?]
Code:
var packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
packet.getPlayerInfoActions().write(0, Collections.singleton(PlayerInfoAction.ADD_PLAYER));
var profile = new WrappedGameProfile(uuid, "NPC");
profile.getProperties().put("textures", new WrappedSignedProperty("textures", skin.texture, skin.signature));
var playerInfoData = new PlayerInfoData(profile, 1, NativeGameMode.SURVIVAL, WrappedChatComponent.fromText("NPC"));
packet.getPlayerInfoDataLists().write(0, Collections.singletonList(playerInfoData)); // Error: line 83
protocolManager.sendServerPacket(player, packet);
Same issue: #2037
It works! ๐