ProtocolLib

3M Downloads

Packet elements not corresponding

MarkManFlame55 opened this issue · 0 comments

commented

Make sure you're doing the following

  • You're using the latest build for your server version -> 5.2.0-SNAPSHOT-679 latest dev build
  • This isn't an issue caused by another plugin -> ProtocolLib and my plugin are the only only on the server
  • You've checked for duplicate issues
  • You didn't use /reload

Hi, im trying to create a Packet that show ceratin player in glowing for just one player using the Server ENTITY_EFFECT packet, and using the wiki.vg i see things like 3 Integers, some booleans and more, but when I try to write those values, the server throws me errors of Indexes Out Of Bounds (things like there are only 2 integers intead of 3, or there are no booleans, which doesn´t correspond to what wiki.vg says).

Code:

ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();

    PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.ENTITY_EFFECT);

    packet.getIntegers().write(0, player.getEntityId());
    packet.getIntegers().write(1, 24);
    packet.getIntegers().write(2, 200);
    packet.getBooleans().write(0, true);

    protocolManager.sendServerPacket(player, packet);

Error:
Caused by: com.comphenix.protocol.reflect.FieldAccessException: Field index 2 is out of bounds for length 2
at com.comphenix.protocol.reflect.FieldAccessException.fromFormat(FieldAccessException.java:49) ~[?:?]
at com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:315) ~[?:?]
at net.mmf55dev.uhcclases.items.SonicBoomItem.wardenSniff(SonicBoomItem.java:117) ~[?:?]
at net.mmf55dev.uhcclases.items.SonicBoomItem.onPlayerClick(SonicBoomItem.java:88) ~[?:?]
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:580) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.20.4-R0.1-SNAPSHOT.jar:?]
... 23 more

Server on Spigot 1.20.4

Is my first time using ProtocolLib or any packet related library. Thanks for any help!