def read(stream, packet_size): window_id = StreamIO.read_ubyte(stream) window_type = StreamIO.read_string(stream).decode("utf8") window_title = json.loads(StreamIO.read_string(stream).decode("utf8")) slots_number = StreamIO.read_ubyte(stream) entity_id = None if window_type == "EntityHorse": entity_id = StreamIO.read_int(stream) return OpenWindowPacket(window_id, window_type, window_title, slots_number, entity_id)
def read(stream, packet_size): protocol = StreamIO.read_varint(stream) hostname = StreamIO.read_string(stream).decode("utf8") port = StreamIO.read_ushort(stream) next_state = StreamIO.read_varint(stream) return HandshakePacket(protocol, hostname, port, next_state)
def read(stream, packet_size): locale = StreamIO.read_string(stream) view_distance = StreamIO.read_byte(stream) chat_mode = StreamIO.read_varint(stream) chat_colors = StreamIO.read_bool(stream) skin_parts = StreamIO.read_ubyte(stream) return ClientSettingsPacket(locale, view_distance, chat_mode, chat_colors, skin_parts)
def read(stream, packet_size): entity_id = StreamIO.read_int(stream) gamemode = StreamIO.read_ubyte(stream) dimension = StreamIO.read_int(stream) difficulty = StreamIO.read_ubyte(stream) max_players = StreamIO.read_ubyte(stream) level_type = StreamIO.read_string(stream).decode("utf8") debug_info = StreamIO.read_bool(stream) return JoinGamePacket(entity_id, gamemode, dimension, difficulty, max_players, level_type, debug_info)
def read(stream, packet_size): chat = json.loads(StreamIO.read_string(stream).decode("utf8")) position = StreamIO.read_byte(stream) return ChatMessageClientPacket(chat, position)
def read(stream, packet_size): shared_secret = StreamIO.read_string(stream) verify_token = StreamIO.read_string(stream) return EncryptionResponsePacket(shared_secret, verify_token)
def read(stream, packet_size): message = StreamIO.read_string(stream).decode("utf8") return ChatMessageServerPacket(message)
def read(stream, packet_size): description = json.loads(StreamIO.read_string(stream).decode("utf8")) return ResponsePacket(description)
def read(stream, packet_size): uuid = StreamIO.read_string(stream).decode("utf8") username = StreamIO.read_string(stream).decode("utf8") return LoginSuccessPacket(uuid, username)
def read(stream, packet_size): reason = json.loads(StreamIO.read_string(stream).decode("utf8")) return DisconnectPacket(reason)
def read(stream, packet_size): server_id = StreamIO.read_string(stream).decode("utf8") public_key = StreamIO.read_string(stream) verify_token = StreamIO.read_string(stream) return EncryptionRequestPacket(server_id, public_key, verify_token)