Interface PacketContext


@Deprecated
public interface PacketContext
Deprecated.
Interface defining a context used during packet processing. Allows access to additional information, such as the source/target of the player, or the correct task queue to enqueue synchronization-requiring code on.
  • Method Summary

    Modifier and Type Method Description
    net.fabricmc.api.EnvType getPacketEnvironment()
    Deprecated.
    Get the environment associated with the packet.
    net.minecraft.entity.player.PlayerEntity getPlayer()
    Deprecated.
    Get the player associated with the packet.
    net.minecraft.util.thread.ThreadExecutor getTaskQueue()
    Deprecated.
    Get the task queue for a given side.
  • Method Details

    • getPacketEnvironment

      net.fabricmc.api.EnvType getPacketEnvironment()
      Deprecated.
      Get the environment associated with the packet.
      Returns:
      EnvType.CLIENT if processing packet on the client side, EnvType.SERVER otherwise.
    • getPlayer

      net.minecraft.entity.player.PlayerEntity getPlayer()
      Deprecated.
      Get the player associated with the packet.

      On the client side, this always returns the client-side player instance. On the server side, it returns the player belonging to the client this packet was sent by.

      Returns:
      The player associated with the packet.
    • getTaskQueue

      net.minecraft.util.thread.ThreadExecutor getTaskQueue()
      Deprecated.
      Get the task queue for a given side.

      As Minecraft networking I/O is asynchronous, but a lot of its logic is not thread-safe, it is recommended to do the following:

      • read and parse the PacketByteBuf,
      • run the packet response logic through the main thread task queue via ThreadTaskQueue.execute(). The method will check if it's not already on the main thread in order to avoid unnecessary delays, so don't worry about that!
      Returns:
      The thread task queue.