Reactors#

A reactor is a class used by the Connection to handle incoming packets, while also forcing the read loop to wait until processing of the packet is complete.

This is useful in cases like SetCompression, in which the next packet will be compressed, and the Connection needs to know that before recieving it.

These are mostly used by the library and shouldn’t need to be overriden by you, the developer, however, you can still override their default behavior by updating REACTORS with your own Reactor.

minecraft.networking.reactors.REACTORS#

A dictionary mapping connection states to reactors. (dict[State, Reactor])

class minecraft.networking.reactors.Reactor(connection)#

Base class for all reactors.

Reactors are used to handle packets internally, though they can be overwritten to change their behavior.

They act a bit differently than handlers, in that they force the read loop to wait for processing to finish.

Variables:
  • connection (Connection) – The connection that this reactor is attached to.

  • handlers (dict[Packet, Callable]) – A dictionary of packet types to methods that handle them.

property client: Client#

The client that this reactor’s connection is attached to.

Return type:

Client

setup()#

Setup the reactor.

This method is called when the reactor is attached to a connection.

minecraft.networking.reactors.react_to(packet: type[minecraft.packets.base.Packet]) Callable[[Callable[[PACKET], None]], Callable[[PACKET], None]]#

Decorator for specifying what packets a method in a Reactor should react to.

Parameters:

packet (type[Packet]) – The packet type to react to.

Login#

class minecraft.networking.reactors.LoginReactor(connection)#

Reacts to packets sent during the login state.

async disconnect_login(packet: DisconnectLogin)#
async encryption_request(packet: EncryptionRequest)#
async login_plugin_request(packet: LoginPluginRequest)#
async login_success(packet: LoginSuccess)#
async set_compression(packet: SetCompression)#

Play#

class minecraft.networking.reactors.PlayReactor(connection)#

Reacts to packets sent during the play state.

async disconnect(packet: DisconnectPlay)#
async keep_alive(packet: KeepAliveClientbound)#
async login(packet: LoginPlay)#
async ping(packet: Ping)#
async synchronize_player_position(packet: SynchronizePlayerPosition)#