Field index out of bounds
JHarris12345 opened this issue · 4 comments
- This issue is not solved in a development build
Describe the bug
When I try to create a packet container for the client custom payload, I cannot write to the byte array field.
To Reproduce
Steps to reproduce the behavior:
-
I am using the latest 5.0.0-SNAPSHOT API
-
Here is my code:
PacketContainer packetContainer = new PacketContainer(PacketType.Play.Client.CUSTOM_PAYLOAD); packetContainer.getByteArrays().write(0, bytes);
-
I get the error Field index 0 is out of bounds for length 0
Expected behavior
It should allow me to get that field
Screenshots
If applicable, add screenshots to help explain your problem.
Version Info
Provide your ProtocolLib install info with /protocol dump
through pastebin.
http://dump-2022-12-21_12.13.31.txt
Additional context
Add any other context about the problem here.
@JHarris12345 your problem is that the field type is not a byte array but a packet data serializer. You can access that field with packetContainer.getModifier().withType(ByteBuf.class)
and create a buffer from your byte array with:
ByteBuf buffer = Unpooled.copiedBuffer(<the byte array>);
Object wrappedSerializableBuffer = MinecraftReflection.getPacketDataSerializer(buffer);
container.getModifier().withType(ByteBuf.class).write(0, wrappedSerializableBuffer);
@TheCalypso your issue is that the info action field changed from a single action to an enum set of actions. Use getPlayerInfoActions()
to access that field. Note that REMOVE_PLAYER was moved to a separate packet (PacketType.Play.Server.PLAYER_INFO_REMOVE
) and you just need to write the uuid of the player into the packet to remove him.
@JHarris12345votre problème est que le type de champ n'est pas un tableau d'octets mais un sérialiseur de données par paquets. Vous pouvez accéder à ce champ avec
packetContainer.getModifier().withType(ByteBuf.class)
et créer un tampon à partir de votre tableau d'octets avec :ByteBuf buffer = Unpooled.copiedBuffer(<the byte array>); Object wrappedSerializableBuffer = MinecraftReflection.getPacketDataSerializer(buffer); container.getModifier().withType(ByteBuf.class).write(0, wrappedSerializableBuffer);@TheCalypsovotre problème est que le champ d'action d'information est passé d'une action unique à un ensemble d'actions enum. Utilisez
getPlayerInfoActions()
pour accéder à ce champ. Notez que REMOVE_PLAYER a été déplacé vers un paquet séparé (PacketType.Play.Server.PLAYER_INFO_REMOVE
) et il vous suffit d'Ă©crire l'uuid du joueur dans le paquet pour le supprimer.
Hello, thank you for your reply. Could you give me an example? Currently I use these methods so that the fakeplayer is not sent to the player in the TABlist. However I can see that PLAYER_INFO_REMOVE has been moved. But I don't see how I can use it.
Can you tell me more ?