Exemplo n.º 1
0
    def write(stream, packet):
        StreamIO.write_ubyte(stream, packet.get_window_id())
        StreamIO.write_short(stream, len(packet.get_slots()))

        for slot_data in packet.get_slots():
            StreamIO.write_short(stream, slot_data.get_id())
            if not slot_data.is_empty():
                StreamIO.write_byte(stream, slot_data.get_count())
                StreamIO.write_short(stream, slot_data.get_damage())
                NBTSerializer.write(stream, slot_data.get_tag())
Exemplo n.º 2
0
 def write(stream, packet):
     StreamIO.write_ubyte(stream, packet.get_window_id())
     StreamIO.write_short(stream, packet.get_slot())
     StreamIO.write_byte(stream, packet.get_button())
     StreamIO.write_short(stream, packet.get_transaction_id())
     StreamIO.write_byte(stream, packet.get_mode())
     StreamIO.write_short(stream, packet.get_slot_data().get_id())
     if not packet.get_slot_data().is_empty():
         StreamIO.write_byte(stream, packet.get_slot_data().get_count())
         StreamIO.write_short(stream, packet.get_slot_data().get_damage())
         NBTSerializer.write(stream, packet.get_slot_data().get_tag())
Exemplo n.º 3
0
 def write(stream, packet):
     StreamIO.write_position(stream, packet.get_position())
     StreamIO.write_byte(stream, packet.get_face())
     StreamIO.write_short(stream, packet.get_slot_data().get_id())
     if not packet.get_slot_data().is_empty():
         StreamIO.write_byte(stream, packet.get_slot_data().get_count())
         StreamIO.write_short(stream, packet.get_slot_data().get_damage())
         NBTSerializer.write(stream, packet.get_slot_data().get_tag())
     StreamIO.write_byte(stream, packet.get_cursor_x())
     StreamIO.write_byte(stream, packet.get_cursor_y())
     StreamIO.write_byte(stream, packet.get_cursor_z())
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 6
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)