NetworkUtil - Lemonszz/LKLib GitHub Wiki

NetworkUtil contains methods to help with sending packets to clients.

serverSendToNearby

This method will send the given Identifier packet with the given PacketByteBuf to all players within 32 blocks of the given x, y and z.
Packet will only be send to players in the same world.

PacketByteBuf data = PacketByteBufs.create();
//write data to bytebuf...

NetworkUtil.sendToNearby(world, ModNetwork.SERVER_SEND_CRAFT_EFFECT, data, x, y, z);

serverSendTracking

This method will send a packet to all players tracking a given BlockPos.

PacketByteBuf data = PacketByteBufs.create();
//write data to bytebuf...

NetworkUtil.sendToNearby(world, pos, ModNetwork.SERVER_SEND_CRAFT_EFFECT, data);