Interface ClientPlayContext

All Superinterfaces:
ClientContext, ListenerContext, PlayContext

@Environment(CLIENT)
public interface ClientPlayContext
extends PlayContext, ClientContext
Represents the context for ClientNetworking.getPlayReceiver(), in which a server to client custom payload packet is received.
See Also:
ClientNetworking.getPlayReceiver()
  • Method Summary

    Modifier and Type Method Description
    net.minecraft.client.network.ClientPlayNetworkHandler getListener()
    Returns the packet listener that received this packet.
    net.minecraft.client.network.ClientPlayerEntity getPlayer()
    Returns a player associated with the current packet.

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

    getEngine

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

    getPacketSender
  • Method Details

    • getPlayer

      net.minecraft.client.network.ClientPlayerEntity 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.

      In the client play context, the player is always the client's own player. It is the same as MinecraftClient.getInstance().player, but this player is guaranteed to be non-null.

      Specified by:
      getPlayer in interface PlayContext
      Returns:
      the client's own player
    • getListener

      net.minecraft.client.network.ClientPlayNetworkHandler getListener()
      Returns the packet listener that received this packet.

      The packet listener offers access to the connection.

      In the client play context, the packet listener is always a ClientPlayNetworkHandler, which exposes a few useful properties, including the client world, the tag manager, the advancement manager, etc.

      Specified by:
      getListener in interface ListenerContext
      Returns:
      the packet listener