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 to true and the channel is not registered, a warning will be logged.

      Specified by:
      sendPacket in interface PacketSender
      Parameters:
      channel - the id of the channel
      buf - 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 to true and the channel is not registered, a warning will be logged.

      Specified by:
      sendPacket in interface PacketSender
      Parameters:
      channel - the id of the channel
      buf - the content of the packet
      callback - an optional callback to execute after the packet is sent, may be null
    • 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 interface ChannelAware
      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 interface ChannelAware
      Parameters:
      channel - the id of the channel to check
      Returns:
      whether the recipient declares it can receive in that channel