Interface ServerPlayContext

All Superinterfaces:
ListenerContext, PlayContext, ServerContext

public interface ServerPlayContext
extends ServerContext, PlayContext
Represents the context for ServerNetworking.getPlayReceiver(), in which a client to server custom payload packet is received.
See Also:
ServerNetworking.getPlayReceiver()
  • Method Summary

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

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

    getPacketSender

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

    getEngine
  • Method Details

    • getPlayer

      net.minecraft.server.network.ServerPlayerEntity 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 server play context, the player is always a server player associated with the network handler.

      Specified by:
      getPlayer in interface PlayContext
      Returns:
      a server player
    • getListener

      net.minecraft.server.network.ServerPlayNetworkHandler 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 ServerPlayNetworkHandler.

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