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.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.void
sendPacket(net.minecraft.util.Identifier channel, net.minecraft.network.PacketByteBuf buf)
Sends a packet to a channel.void
sendPacket(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.warnUnregisteredPackets
system property is absent or set totrue
and thechannel
is not registered, a warning will be logged.- Specified by:
sendPacket
in 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.warnUnregisteredPackets
system property is absent or set totrue
and thechannel
is not registered, a warning will be logged.- Specified by:
sendPacket
in 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:
getChannels
in 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:
hasChannel
in interfaceChannelAware
- Parameters:
channel
- the id of the channel to check- Returns:
- whether the recipient declares it can receive in that channel
-