@FunctionalInterface public interface PacketConsumer
| Modifier and Type | Method and Description |
|---|---|
void |
accept(PacketContext context,
net.minecraft.network.PacketByteBuf buffer)
Receive a CustomPayload-based packet.
|
void accept(PacketContext context, net.minecraft.network.PacketByteBuf buffer)
The PacketByteBuf received will be released as soon as the method exits, meaning that you have to call .retain()/.release() on it if you want to keep it around after that.
Please keep in mind that this CAN be called OUTSIDE of the main thread!
Most game operations are not thread-safe, so you should look into using
the thread task queue (PacketContext.getTaskQueue()) to split
the "reading" (which should happen within this method's execution)
and "applying" (which, unless you know what you're doing, should happen
on the main thread, after this method exits).
context - The context (receiving player, side, etc.)buffer - The byte buffer containing the received packet data.