docs v1.0

MOVED FROM CUBELIB WIKI ON GITLAB

this docs refers to v1.0

Typical read usage scheme


Bound = cubelib.bound.Client
Threshold = -1
State = cubelib.state.Handshaking
Protocol = cubelib.proto.v47

# receive new packets

Buffer += Socket.read(65535)
packets = []

Buffer = cubelib.p.readPacketsStream(Buffer, Threshold, Bound, packets)

# resolve packets into class abstraction

for packet in packets:
	packet_class = packet.resolve(State, Protocol)
	# further packet processing ///

Typical build usage scheme

For real examples see examples/ dir in gitlab repo

Exporting

cubelib.version

cubelib.supported_versions

List of supported protocol versions (not minecraft versions)

cubelib.state

Enum representing internal protocol state

cubelib.bound

Enum representing protocol role

cubelib.NextState

Enum representing protocol next state. (Used once in Handshake)

cubelib.readPacketsStream

Function for parsing stream of incoming packets.

args:

  • buff: bytes object contains 0 or more packets

  • threshold: -1 for disabled compression otherwise compression threshold sent in SetCompression

  • bound: cubelib.bound

  • packets: list that will be appended with parsed packets

return:

  • bytes object contains unparsed data

raises:

  • cubelib.errors.BadPacketException

cubelib.p.Packet.resolve

Function for resolving packets into class abstractions

args:

  • state: cubelib.state

  • v: one of protocols from cubelib.proto.v* or None if state not Play

return:

  • heir of cubelib.p.Night (abstract class)

raises:

  • cubelib.errors.DecoderException

Errors

BadPacketException

  • Raised when bad packet passed to one of read() functions

DecoderException

  • Raised when error occured in Night.destroy (Decoder)

that's all you need to know about usage

enjoy =]

find a error in the docs? - open gitlab issue!

Last updated