示例#1
0
    def read(stream, packet_size):
        position = StreamIO.read_position(stream)
        face = StreamIO.read_byte(stream)
        slot_data = SlotData(StreamIO.read_short(stream))
        if not slot_data.is_empty():
            slot_data.set_count(StreamIO.read_byte(stream))
            slot_data.set_damage(StreamIO.read_short(stream))
            slot_data.set_tag(NBTSerializer.read(stream))
        cursor_x = StreamIO.read_byte(stream)
        cursor_y = StreamIO.read_byte(stream)
        cursor_z = StreamIO.read_byte(stream)

        return PlayerBlockPlacementPacket(position, face, slot_data, cursor_x, cursor_y, cursor_z)
示例#2
0
    def read(stream, packet_size):
        window_id = StreamIO.read_ubyte(stream)
        slot = StreamIO.read_short(stream)
        button = StreamIO.read_byte(stream)
        transaction_id = StreamIO.read_short(stream)
        mode = StreamIO.read_byte(stream)
        slot_data = SlotData(StreamIO.read_short(stream))
        if not slot_data.is_empty():
            slot_data.set_count(StreamIO.read_byte(stream))
            slot_data.set_damage(StreamIO.read_short(stream))
            slot_data.set_tag(NBTSerializer.read(stream))

        return ClickWindowPacket(window_id, slot, button, transaction_id, mode,
                                 slot_data)
示例#3
0
    def read(stream, packet_size):
        window_id = StreamIO.read_byte(stream)
        transaction_id = StreamIO.read_short(stream)
        accepted = StreamIO.read_bool(stream)

        return ConfirmTransactionServerPacket(window_id, transaction_id,
                                              accepted)
示例#4
0
    def read(stream):
        values = []
        len = StreamIO.read_int(stream)

        for i in xrange(len):
            values.append(StreamIO.read_byte(stream))

        return NBTTagByteArray(values)
示例#5
0
    def read(stream, packet_size):
        x = StreamIO.read_double(stream)
        y = StreamIO.read_double(stream)
        z = StreamIO.read_double(stream)
        yaw = StreamIO.read_float(stream)
        pitch = StreamIO.read_float(stream)
        flags = StreamIO.read_byte(stream)

        return PlayerPositionAndLookClientPacket(x, y, z, yaw, pitch, flags)
示例#6
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)
示例#7
0
    def read(stream, packet_size):
        entity_id = StreamIO.read_int(stream)
        gamemode = StreamIO.read_ubyte(stream)
        dimension = StreamIO.read_byte(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)
示例#8
0
    def read(stream, packet_size):
        window_id = StreamIO.read_ubyte(stream)
        slots_len = StreamIO.read_short(stream)
        slots = []

        for i in xrange(slots_len):
            slot_data = SlotData(StreamIO.read_short(stream))
            if not slot_data.is_empty():
                slot_data.set_count(StreamIO.read_byte(stream))
                slot_data.set_damage(StreamIO.read_short(stream))
                slot_data.set_tag(NBTSerializer.read(stream))

            slots.append(slot_data)

        return WindowItemsPacket(window_id, slots)
示例#9
0
    def read(stream, packet_size):
        slot = StreamIO.read_byte(stream)

        return HeldItemChangeClientPacket(slot)
示例#10
0
    def read(stream, packet_size):
        chat = json.loads(StreamIO.read_string(stream).decode("utf8"))
        position = StreamIO.read_byte(stream)

        return ChatMessageClientPacket(chat, position)
示例#11
0
    def read(stream):
        value = StreamIO.read_byte(stream)

        return NBTTagByte(value)