Interface ClientPlayContext
- All Superinterfaces:
ClientContext,ListenerContext,PlayContext
@Environment(CLIENT) public interface ClientPlayContext extends PlayContext, ClientContext
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.ClientPlayNetworkHandlergetListener()Returns the packet listener that received this packet.net.minecraft.client.network.ClientPlayerEntitygetPlayer()Returns a player associated with the current packet.Methods inherited from interface io.github.fablabsmc.fablabs.api.networking.v1.client.ClientContext
getEngineMethods 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.offThreadGameAccesssystem property can be set toPERMITfor disabling checks,WARNfor emitting an error message, andTHROWto 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:
getPlayerin interfacePlayContext- 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:
getListenerin interfaceListenerContext- Returns:
- the packet listener
-