Packets#

Every packet in the Minecraft protocol is implemented here.

All packets inherit from one base class, Packet.

Packet#

class minecraft.packets.Packet#

Represents a Minecraft packet.

packet_id = The packet's ID#
state = The state the packet is used in#
bound_to = The direction the packet is sent in#
classmethod from_bytes(data: BytesIO) Self#

Converts a packet’s data into a packet object.

Parameters:

data (io.BytesIO) – The packet’s data.

Returns:

The packet object.

Return type:

Packet

minecraft.packets.get_packet(data: bytes, *, state: State, bound: Literal['client', 'server'] = 'client') Packet#

Convert a packet’s data into its respective packet object.

Parameters#

data: bytes

The packet’s data.

state: State

The state the connection was in when the packet arrived.

bound: str

The destination of the packet. Can be either “client” or “server”.

Returns#

Packet

The packet object.

Raises#

ValueError

The bound was invalid.