Interface PlayContext

All Superinterfaces:
ListenerContext
All Known Subinterfaces:
ClientPlayContext, ServerPlayContext

public interface PlayContext
extends ListenerContext
Represents a context for packet reception in play stage of the game in a channel.

Compared to the basic listener context, the play context offers more access to the game.

  • Method Summary

    Modifier and Type Method Description
    PlayPacketSender getPacketSender()
    Returns the packet sender corresponding this context.
    net.minecraft.entity.player.PlayerEntity getPlayer()
    Returns a player associated with the current packet.

    Methods inherited from interface io.github.fablabsmc.fablabs.api.networking.v1.ListenerContext

    getEngine, getListener
  • Method Details

    • getPacketSender

      PlayPacketSender getPacketSender()
      Returns the packet sender corresponding this context.

      This packet sender may be useful for responding after receiving the packet.

      Returns:
      the packet sender
    • getPlayer

      net.minecraft.entity.player.PlayerEntity getPlayer()
      Returns a player associated with the current packet.

      For security concerns, this method should be called on game engine threads in order to prevent inadvertent asynchronous modifications to the game.

      networking-api-v1-draft.offThreadGameAccess system property can be set to PERMIT for disabling checks, WARN for emitting an error message, and THROW to throw an exception. The values are case insensitive.

      Returns:
      the player associated with the current packet
      Throws:
      IllegalArgumentException - if this method is called outside of the corresponding engine threads