Packet handling
The event of receiving or sending a packet.
This event allows you to trigger code when a packet is received (Client -> Server) or sent (Server -> Client).
on packet:on packet %packet name%:
The event can be canceled. In this case, the packet will not be received or sent (respectively).
This event has built-in expressions.
event-packet- to receive the packetevent-player- to get a player
event-packet can be replaced with set event-packet to %packet%, provided that no execution delay was used.
Getting a buffer from a packet
After receiving the buffer from the packet, we can read the fields indicated on The Minecraft Wiki
buffer (of|from) %packet%%packet%'s bufferReading the buffer
To get values from the buffer, the following expressions exist, similar to writing to the buffer
read bool[ean] from %bytebuf%
read uuid from %bytebuf%
read string from %bytebuf%
read position from %bytebuf%
read [unsigned] byte from %bytebuf%
read [unsigned] short from %bytebuf%
read float from %bytebuf%
read double from %bytebuf%
read int[eger] from %bytebuf%
read long from %bytebuf%
read angle from %bytebuf%
read var[iable][ ]int[eger] from %bytebuf%
read var[iable][ ]long from %bytebuf%
read utf[(-| )]8 [with [len[gth]]] %number% from %bytebuf%To read utf-8 you must also specify the length of the text in bytes
Reading occurs in the same order as writing a packet, provided that the packet was not created by you.
If you created a packet and want to read it, then move its reader index to position zero.
Reader index
Each reading of the buffer shifts its Reader index, this is the number of bytes read inside the buffer.Reader index you can find out or change it using the following expression:
reader index of %bytebuf%%bytebuf%'s reader indexDisabling or enabling packet handling
You can enable or disable handling of incoming or outgoing packets per player using the following expression.
[(handl(e|ing))|(listen[ing] [of])] (in|out)coming packets of %player%%player%'s [(handl(e|ing))|(listen[ing] [of])] (in|out)coming packets