Interface PlayPacketSender
- All Superinterfaces:
ChannelAware,PacketSender
public interface PlayPacketSender extends PacketSender, ChannelAware
Supports sending packets to channels in the play network handlers.
Compared to a simple packet sender, the play packet sender is informed
if its connected recipient may accept packets
in certain channels. When the networking-api-v1-draft.warnUnregisteredPackets
system property is absent or set to true and the recipient did not
declare its ability to receive packets in a channel a packet was sent in, a
warning is logged.
-
Method Summary
Modifier and Type Method Description Collection<net.minecraft.util.Identifier>getChannels()Returns the ids of all channels the recipient side of this sender has declared ability to receive.booleanhasChannel(net.minecraft.util.Identifier channel)Returns if the recipient side of this sender has declared its ability to receive in a certain channel.voidsendPacket(net.minecraft.util.Identifier channel, net.minecraft.network.PacketByteBuf buf)Sends a packet to a channel.voidsendPacket(net.minecraft.util.Identifier channel, net.minecraft.network.PacketByteBuf buf, GenericFutureListener<? extends Future<? super Void>> callback)Sends a packet to a channel.
-
Method Details
-
sendPacket
void sendPacket(net.minecraft.util.Identifier channel, net.minecraft.network.PacketByteBuf buf)Sends a packet to a channel.When the
networking-api-v1-draft.warnUnregisteredPacketssystem property is absent or set totrueand thechannelis not registered, a warning will be logged.- Specified by:
sendPacketin interfacePacketSender- Parameters:
channel- the id of the channelbuf- the content of the packet
-
sendPacket
void sendPacket(net.minecraft.util.Identifier channel, net.minecraft.network.PacketByteBuf buf, GenericFutureListener<? extends Future<? super Void>> callback)Sends a packet to a channel.When the
networking-api-v1-draft.warnUnregisteredPacketssystem property is absent or set totrueand thechannelis not registered, a warning will be logged.- Specified by:
sendPacketin interfacePacketSender- Parameters:
channel- the id of the channelbuf- the content of the packetcallback- an optional callback to execute after the packet is sent, may benull
-
getChannels
Collection<net.minecraft.util.Identifier> getChannels()Returns the ids of all channels the recipient side of this sender has declared ability to receive.This collection does not contain duplicate channels.
- Specified by:
getChannelsin interfaceChannelAware- Returns:
- a collection of channels
-
hasChannel
boolean hasChannel(net.minecraft.util.Identifier channel)Returns if the recipient side of this sender has declared its ability to receive in a certain channel.- Specified by:
hasChannelin interfaceChannelAware- Parameters:
channel- the id of the channel to check- Returns:
- whether the recipient declares it can receive in that channel
-