示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
    def read(stream, packet_size):
        chat = json.loads(StreamIO.read_string(stream).decode("utf8"))
        position = StreamIO.read_byte(stream)

        return ChatMessageClientPacket(chat, position)
示例#6
0
    def read(stream, packet_size):
        shared_secret = StreamIO.read_string(stream)
        verify_token = StreamIO.read_string(stream)

        return EncryptionResponsePacket(shared_secret, verify_token)
示例#7
0
    def read(stream, packet_size):
        message = StreamIO.read_string(stream).decode("utf8")

        return ChatMessageServerPacket(message)
示例#8
0
    def read(stream, packet_size):
        description = json.loads(StreamIO.read_string(stream).decode("utf8"))

        return ResponsePacket(description)
示例#9
0
    def read(stream, packet_size):
        uuid = StreamIO.read_string(stream).decode("utf8")
        username = StreamIO.read_string(stream).decode("utf8")

        return LoginSuccessPacket(uuid, username)
示例#10
0
    def read(stream, packet_size):
        reason = json.loads(StreamIO.read_string(stream).decode("utf8"))

        return DisconnectPacket(reason)
示例#11
0
    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)