Пример #1
0
 def decode_extra(packet, bbuff):
     packet.data['entries'] = [
         [
             datautils.unpack(MC_STRING, bbuff),
             datautils.unpack(MC_VARINT, bbuff)
         ] for _ in range(datautils.unpack(MC_VARINT, bbuff))]
     return packet
Пример #2
0
    def decode(self, bbuff, proto_comp_state):
        self.data = {}
        packet_length = datautils.unpack(MC_VARINT, bbuff)
        packet_data = bbuff.recv(packet_length)
        pbuff = BoundBuffer(packet_data)
        if proto_comp_state == mcdata.PROTO_COMP_ON:
            body_length = datautils.unpack(MC_VARINT, pbuff)
            if body_length > 0:
                body_data = zlib.decompress(pbuff.flush(), zlib.MAX_WBITS)
                pbuff.write(body_data)
                pbuff.save()

        try:
            # Ident
            self.__ident[2] = datautils.unpack(MC_VARINT, pbuff)
            self.ident = tuple(self.__ident)
            self.str_ident = mcdata.packet_ident2str[self.ident]
            # Payload
            for dtype, name in mcdata.hashed_structs[self.ident]:
                self.data[name] = datautils.unpack(dtype, pbuff)
            # Extension
            if self.ident in hashed_extensions:
                hashed_extensions[self.ident].decode_extra(self, pbuff)
            if len(pbuff) > 0:
                raise PacketDecodeFailure(self, pbuff)
        except BufferUnderflowException:
            raise PacketDecodeFailure(self, pbuff, True)
        return self
Пример #3
0
    def decode(self, bbuff, proto_comp_state):
        self.data = {}
        packet_length = datautils.unpack(MC_VARINT, bbuff)
        packet_data = bbuff.recv(packet_length)
        pbuff = BoundBuffer(packet_data)
        if proto_comp_state == proto.PROTO_COMP_ON:
            body_length = datautils.unpack(MC_VARINT, pbuff)
            if body_length:
                body_data = zlib.decompress(pbuff.flush(), zlib.MAX_WBITS)
                pbuff.write(body_data)
                pbuff.save()

        try:
            # Ident
            self.__ident[2] = datautils.unpack(MC_VARINT, pbuff)
            self.ident = tuple(self.__ident)
            self.str_ident = proto.packet_ident2str[self.ident]
            # Payload
            for dtype, name in proto.hashed_structs[self.ident]:
                self.data[name] = datautils.unpack(dtype, pbuff)
            # Extension
            if self.ident in hashed_extensions:
                hashed_extensions[self.ident].decode_extra(self, pbuff)
            if pbuff:
                raise PacketDecodeFailure(self, pbuff)
        except BufferUnderflowException:
            raise PacketDecodeFailure(self, pbuff, True)
        return self
Пример #4
0
 def decode_extra(packet, bbuff):
     packet.data['blocks'] = [
         [datautils.unpack(MC_BYTE, bbuff) for j in range(3)]
         for i in range(datautils.unpack(MC_INT, bbuff))]
     packet.data['player_x'] = datautils.unpack(MC_FLOAT, bbuff)
     packet.data['player_y'] = datautils.unpack(MC_FLOAT, bbuff)
     packet.data['player_z'] = datautils.unpack(MC_FLOAT, bbuff)
     return packet
Пример #5
0
 def decode_extra(packet, bbuff):
     packet.data['blocks'] = [[
         datautils.unpack(MC_BYTE, bbuff) for j in range(3)
     ] for i in range(datautils.unpack(MC_INT, bbuff))]
     packet.data['player_x'] = datautils.unpack(MC_FLOAT, bbuff)
     packet.data['player_y'] = datautils.unpack(MC_FLOAT, bbuff)
     packet.data['player_z'] = datautils.unpack(MC_FLOAT, bbuff)
     return packet
Пример #6
0
 def decode_extra(packet, bbuff):
     act = packet.data["action"]
     if act == mcdata.TL_TITLE or act == mcdata.TL_SUBTITLE:
         packet.data["text"] = datautils.unpack(MC_CHAT, bbuff)
     if act == mcdata.TL_TIMES:
         packet.data["fade_in"] = datautils.unpack(MC_INT, bbuff)
         packet.data["stay"] = datautils.unpack(MC_INT, bbuff)
         packet.data["fade_out"] = datautils.unpack(MC_INT, bbuff)
     return packet
Пример #7
0
 def decode_extra(packet, bbuff):
     if packet.data["event"] == mcdata.CE_END_COMBAT:
         packet.data["duration"] = datautils.unpack(MC_VARINT, bbuff)
         packet.data["eid"] = datautils.unpack(MC_INT, bbuff)
     if packet.data["event"] == mcdata.CE_ENTITY_DEAD:
         packet.data["player_id"] = datautils.unpack(MC_VARINT, bbuff)
         packet.data["eid"] = datautils.unpack(MC_INT, bbuff)
         packet.data["message"] = datautils.unpack(MC_STRING, bbuff)
     return packet
Пример #8
0
 def decode_extra(packet, bbuff):
     act = packet.data['action']
     if act == const.TL_TITLE or act == const.TL_SUBTITLE:
         packet.data['text'] = datautils.unpack(MC_CHAT, bbuff)
     if act == const.TL_TIMES:
         packet.data['fade_in'] = datautils.unpack(MC_INT, bbuff)
         packet.data['stay'] = datautils.unpack(MC_INT, bbuff)
         packet.data['fade_out'] = datautils.unpack(MC_INT, bbuff)
     return packet
Пример #9
0
 def decode_extra(packet, bbuff):
     act = packet.data['action']
     if act == const.TL_TITLE or act == const.TL_SUBTITLE:
         packet.data['text'] = datautils.unpack(MC_CHAT, bbuff)
     if act == const.TL_TIMES:
         packet.data['fade_in'] = datautils.unpack(MC_INT, bbuff)
         packet.data['stay'] = datautils.unpack(MC_INT, bbuff)
         packet.data['fade_out'] = datautils.unpack(MC_INT, bbuff)
     return packet
Пример #10
0
 def decode_extra(packet, bbuff):
     if packet.data['event'] == const.CE_END_COMBAT:
         packet.data['duration'] = datautils.unpack(MC_VARINT, bbuff)
         packet.data['eid'] = datautils.unpack(MC_INT, bbuff)
     if packet.data['event'] == const.CE_ENTITY_DEAD:
         packet.data['player_id'] = datautils.unpack(MC_VARINT, bbuff)
         packet.data['eid'] = datautils.unpack(MC_INT, bbuff)
         packet.data['message'] = datautils.unpack(MC_STRING, bbuff)
     return packet
Пример #11
0
 def decode_extra(packet, bbuff):
     if packet.data['event'] == const.CE_END_COMBAT:
         packet.data['duration'] = datautils.unpack(MC_VARINT, bbuff)
         packet.data['eid'] = datautils.unpack(MC_INT, bbuff)
     if packet.data['event'] == const.CE_ENTITY_DEAD:
         packet.data['player_id'] = datautils.unpack(MC_VARINT, bbuff)
         packet.data['eid'] = datautils.unpack(MC_INT, bbuff)
         packet.data['message'] = datautils.unpack(MC_STRING, bbuff)
     return packet
Пример #12
0
 def decode_extra(packet, bbuff):
     packet.data['blocks'] = []
     for i in range(datautils.unpack(MC_VARINT, bbuff)):
         data = datautils.unpack(MC_USHORT, bbuff)
         packet.data['blocks'].append({
             'y': data & 0xFF,
             'z': (data >> 8) & 0xF,
             'x': (data >> 12) & 0xF,
             'block_data': datautils.unpack(MC_VARINT, bbuff),
         })
     return packet
Пример #13
0
 def decode_extra(packet, bbuff):
     sky_light = datautils.unpack(MC_BOOL, bbuff)
     count = datautils.unpack(MC_VARINT, bbuff)
     packet.data['sky_light'] = sky_light
     packet.data['metadata'] = [
         {
             'chunk_x': datautils.unpack(MC_INT, bbuff),
             'chunk_z': datautils.unpack(MC_INT, bbuff),
             'primary_bitmap': datautils.unpack(MC_USHORT, bbuff),
         } for _ in range(count)]
     packet.data['data'] = bbuff.flush()
     return packet
Пример #14
0
 def decode_extra(packet, bbuff):
     packet.data['blocks'] = []
     for i in range(datautils.unpack(MC_VARINT, bbuff)):
         data = datautils.unpack(MC_USHORT, bbuff)
         packet.data['blocks'].append({
             'y':
             data & 0xFF,
             'z': (data >> 8) & 0xF,
             'x': (data >> 12) & 0xF,
             'block_data':
             datautils.unpack(MC_VARINT, bbuff),
         })
     return packet
Пример #15
0
 def decode_extra(packet, bbuff):
     packet.data["blocks"] = []
     for i in range(datautils.unpack(MC_VARINT, bbuff)):
         data = datautils.unpack(MC_USHORT, bbuff)
         packet.data["blocks"].append(
             {
                 "y": data & 0xFF,
                 "z": (data >> 8) & 0xF,
                 "x": (data >> 12) & 0xF,
                 "block_data": datautils.unpack(MC_VARINT, bbuff),
             }
         )
     return packet
Пример #16
0
 def decode_extra(packet, bbuff):
     sky_light = datautils.unpack(MC_BOOL, bbuff)
     count = datautils.unpack(MC_VARINT, bbuff)
     packet.data["sky_light"] = sky_light
     packet.data["metadata"] = [
         {
             "chunk_x": datautils.unpack(MC_INT, bbuff),
             "chunk_z": datautils.unpack(MC_INT, bbuff),
             "primary_bitmap": datautils.unpack(MC_USHORT, bbuff),
         }
         for _ in range(count)
     ]
     packet.data["data"] = bbuff.flush()
     return packet
Пример #17
0
 def decode_extra(packet, bbuff):
     sky_light = datautils.unpack(MC_BOOL, bbuff)
     count = datautils.unpack(MC_VARINT, bbuff)
     packet.data['sky_light'] = sky_light
     packet.data['metadata'] = [{
         'chunk_x':
         datautils.unpack(MC_INT, bbuff),
         'chunk_z':
         datautils.unpack(MC_INT, bbuff),
         'primary_bitmap':
         datautils.unpack(MC_USHORT, bbuff),
     } for _ in range(count)]
     packet.data['data'] = bbuff.flush()
     return packet
Пример #18
0
 def decode_extra(packet, bbuff):
     tag_type = datautils.unpack(MC_BYTE, bbuff)
     if tag_type == nbt.TAG_COMPOUND:
         name = nbt.TagString(buffer=bbuff).value
         nbt_data = nbt.TagCompound(buffer=bbuff)
         nbt_data.name = name
         packet.data['nbt'] = nbt_data
     else:
         assert (tag_type == nbt.TAG_END)
         packet.data['nbt'] = None
     return packet
Пример #19
0
 def decode_extra(packet, bbuff):
     tag_type = datautils.unpack(MC_BYTE, bbuff)
     if tag_type == nbt.TAG_COMPOUND:
         name = nbt.TagString(buffer=bbuff).value
         nbt_data = nbt.TagCompound(buffer=bbuff)
         nbt_data.name = name
         packet.data['nbt'] = nbt_data
     else:
         assert (tag_type == nbt.TAG_END)
         packet.data['nbt'] = None
     return packet
Пример #20
0
 def decode_extra(packet, bbuff):
     act = packet.data["action"]
     if act in [mcdata.TE_CREATE_TEAM, mcdata.TE_UPDATE_TEAM]:
         packet.data["display_name"] = datautils.unpack(MC_STRING, bbuff)
         packet.data["team_prefix"] = datautils.unpack(MC_STRING, bbuff)
         packet.data["team_suffix"] = datautils.unpack(MC_STRING, bbuff)
         packet.data["friendly_fire"] = datautils.unpack(MC_BYTE, bbuff)
         packet.data["name_visibility"] = datautils.unpack(MC_STRING, bbuff)
         packet.data["color"] = datautils.unpack(MC_BYTE, bbuff)
     if act in [mcdata.TE_CREATE_TEAM, mcdata.TE_ADDPLY_TEAM, mcdata.TE_REMPLY_TEAM]:
         packet.data["players"] = [
             datautils.unpack(MC_STRING, bbuff) for _ in range(datautils.unpack(MC_VARINT, bbuff))
         ]
     return packet
Пример #21
0
 def decode_extra(packet, bbuff):
     packet.data['icons'] = []
     for i in range(datautils.unpack(MC_VARINT, bbuff)):
         byte = datautils.unpack(MC_UBYTE, bbuff)
         packet.data['icons'].append({
             'direction': byte >> 8,
             'type': byte & 0x0F,
             'x': datautils.unpack(MC_BYTE, bbuff),
             'y': datautils.unpack(MC_BYTE, bbuff),
         })
     packet.data['columns'] = datautils.unpack(MC_BYTE, bbuff)
     if packet.data['columns']:
         packet.data['rows'] = datautils.unpack(MC_BYTE, bbuff)
         packet.data['x'] = datautils.unpack(MC_BYTE, bbuff)
         packet.data['y'] = datautils.unpack(MC_BYTE, bbuff)
         packet.data['data'] = bbuff.recv(datautils.unpack(
             MC_VARINT, bbuff))
     return packet
Пример #22
0
 def decode_extra(packet, bbuff):
     packet.data['icons'] = []
     for i in range(datautils.unpack(MC_VARINT, bbuff)):
         byte = datautils.unpack(MC_UBYTE, bbuff)
         packet.data['icons'].append({
             'direction': byte >> 8,
             'type': byte & 0x0F,
             'x': datautils.unpack(MC_BYTE, bbuff),
             'y': datautils.unpack(MC_BYTE, bbuff),
         })
     packet.data['columns'] = datautils.unpack(MC_BYTE, bbuff)
     if packet.data['columns']:
         packet.data['rows'] = datautils.unpack(MC_BYTE, bbuff)
         packet.data['x'] = datautils.unpack(MC_BYTE, bbuff)
         packet.data['y'] = datautils.unpack(MC_BYTE, bbuff)
         packet.data['data'] = bbuff.recv(
             datautils.unpack(MC_VARINT, bbuff))
     return packet
Пример #23
0
 def decode_extra(packet, bbuff):
     act = packet.data['action']
     if act == const.WB_SET_SIZE:
         packet.data['radius'] = datautils.unpack(MC_VARINT, bbuff)
     if act == const.WB_SET_CENTER or act == const.WB_INITIALIZE:
         packet.data['x'] = datautils.unpack(MC_DOUBLE, bbuff)
         packet.data['z'] = datautils.unpack(MC_DOUBLE, bbuff)
     if act == const.WB_LERP_SIZE or act == const.WB_INITIALIZE:
         packet.data['old_radius'] = datautils.unpack(MC_DOUBLE, bbuff)
         packet.data['new_radius'] = datautils.unpack(MC_DOUBLE, bbuff)
         packet.data['speed'] = datautils.unpack(MC_VARLONG, bbuff)
     if act == const.WB_INITIALIZE:
         packet.data['port_tele_bound'] = datautils.unpack(MC_VARINT, bbuff)
     if act == const.WB_SET_WARN_TIME or act == const.WB_INITIALIZE:
         packet.data['warn_time'] = datautils.unpack(MC_VARINT, bbuff)
     if act == const.WB_SET_WARN_BLOCKS or act == const.WB_INITIALIZE:
         packet.data['warn_blocks'] = datautils.unpack(MC_VARINT, bbuff)
     return packet
Пример #24
0
 def decode_extra(packet, bbuff):
     act = packet.data["action"]
     if act == mcdata.WB_SET_SIZE:
         packet.data["radius"] = datautils.unpack(MC_VARINT, bbuff)
     if act == mcdata.WB_SET_CENTER or act == mcdata.WB_INITIALIZE:
         packet.data["x"] = datautils.unpack(MC_DOUBLE, bbuff)
         packet.data["z"] = datautils.unpack(MC_DOUBLE, bbuff)
     if act == mcdata.WB_LERP_SIZE or act == mcdata.WB_INITIALIZE:
         packet.data["old_radius"] = datautils.unpack(MC_DOUBLE, bbuff)
         packet.data["new_radius"] = datautils.unpack(MC_DOUBLE, bbuff)
         packet.data["speed"] = datautils.unpack(MC_VARLONG, bbuff)
     if act == mcdata.WB_INITIALIZE:
         packet.data["port_tele_bound"] = datautils.unpack(MC_VARINT, bbuff)
     if act == mcdata.WB_SET_WARN_TIME or act == mcdata.WB_INITIALIZE:
         packet.data["warn_time"] = datautils.unpack(MC_VARINT, bbuff)
     if act == mcdata.WB_SET_WARN_BLOCKS or act == mcdata.WB_INITIALIZE:
         packet.data["warn_blocks"] = datautils.unpack(MC_VARINT, bbuff)
     return packet
Пример #25
0
 def decode_extra(packet, bbuff):
     act = packet.data['action']
     if act == const.WB_SET_SIZE:
         packet.data['radius'] = datautils.unpack(MC_VARINT, bbuff)
     if act == const.WB_SET_CENTER or act == const.WB_INITIALIZE:
         packet.data['x'] = datautils.unpack(MC_DOUBLE, bbuff)
         packet.data['z'] = datautils.unpack(MC_DOUBLE, bbuff)
     if act == const.WB_LERP_SIZE or act == const.WB_INITIALIZE:
         packet.data['old_radius'] = datautils.unpack(MC_DOUBLE, bbuff)
         packet.data['new_radius'] = datautils.unpack(MC_DOUBLE, bbuff)
         packet.data['speed'] = datautils.unpack(MC_VARLONG, bbuff)
     if act == const.WB_INITIALIZE:
         packet.data['port_tele_bound'] = datautils.unpack(MC_VARINT, bbuff)
     if act == const.WB_SET_WARN_TIME or act == const.WB_INITIALIZE:
         packet.data['warn_time'] = datautils.unpack(MC_VARINT, bbuff)
     if act == const.WB_SET_WARN_BLOCKS or act == const.WB_INITIALIZE:
         packet.data['warn_blocks'] = datautils.unpack(MC_VARINT, bbuff)
     return packet
Пример #26
0
 def decode_extra(packet, bbuff):
     act = packet.data['action']
     if act in [const.TE_CREATE_TEAM, const.TE_UPDATE_TEAM]:
         packet.data['display_name'] = datautils.unpack(MC_STRING, bbuff)
         packet.data['team_prefix'] = datautils.unpack(MC_STRING, bbuff)
         packet.data['team_suffix'] = datautils.unpack(MC_STRING, bbuff)
         packet.data['friendly_fire'] = datautils.unpack(MC_BYTE, bbuff)
         packet.data['name_visibility'] = datautils.unpack(MC_STRING, bbuff)
         packet.data['color'] = datautils.unpack(MC_BYTE, bbuff)
     if act in [const.TE_CREATE_TEAM, const.TE_ADDPLY_TEAM,
                const.TE_REMPLY_TEAM]:
         packet.data['players'] = [
             datautils.unpack(MC_STRING, bbuff)
             for _ in range(datautils.unpack(MC_VARINT, bbuff))]
     return packet
Пример #27
0
 def decode_extra(packet, bbuff):
     packet.data["icons"] = []
     for i in range(datautils.unpack(MC_VARINT, bbuff)):
         byte = datautils.unpack(MC_UBYTE, bbuff)
         packet.data["icons"].append(
             {
                 "direction": byte >> 8,
                 "type": byte & 0x0F,
                 "x": datautils.unpack(MC_BYTE, bbuff),
                 "y": datautils.unpack(MC_BYTE, bbuff),
             }
         )
     packet.data["columns"] = datautils.unpack(MC_BYTE, bbuff)
     if packet.data["columns"]:
         packet.data["rows"] = datautils.unpack(MC_BYTE, bbuff)
         packet.data["x"] = datautils.unpack(MC_BYTE, bbuff)
         packet.data["y"] = datautils.unpack(MC_BYTE, bbuff)
         packet.data["data"] = bbuff.recv(datautils.unpack(MC_VARINT, bbuff))
     return packet
Пример #28
0
 def decode_extra(packet, bbuff):
     act = packet.data['action']
     if act in [const.TE_CREATE_TEAM, const.TE_UPDATE_TEAM]:
         packet.data['display_name'] = datautils.unpack(MC_STRING, bbuff)
         packet.data['team_prefix'] = datautils.unpack(MC_STRING, bbuff)
         packet.data['team_suffix'] = datautils.unpack(MC_STRING, bbuff)
         packet.data['friendly_fire'] = datautils.unpack(MC_BYTE, bbuff)
         packet.data['name_visibility'] = datautils.unpack(MC_STRING, bbuff)
         packet.data['color'] = datautils.unpack(MC_BYTE, bbuff)
     if act in [
             const.TE_CREATE_TEAM, const.TE_ADDPLY_TEAM,
             const.TE_REMPLY_TEAM
     ]:
         packet.data['players'] = [
             datautils.unpack(MC_STRING, bbuff)
             for _ in range(datautils.unpack(MC_VARINT, bbuff))
         ]
     return packet
Пример #29
0
 def decode_extra(packet, bbuff):
     packet.data['properties'] = []
     for i in range(datautils.unpack(MC_INT, bbuff)):
         prop = {
             'key': datautils.unpack(MC_STRING, bbuff),
             'value': datautils.unpack(MC_DOUBLE, bbuff),
             'modifiers': [],
         }
         for j in range(datautils.unpack(MC_VARINT, bbuff)):
             prop['modifiers'].append({
                 'uuid': datautils.unpack(MC_UUID, bbuff),
                 'amount': datautils.unpack(MC_DOUBLE, bbuff),
                 'operation': datautils.unpack(MC_BYTE, bbuff),
             })
         packet.data['properties'].append(prop)
     return packet
Пример #30
0
 def decode_extra(packet, bbuff):
     packet.data["properties"] = []
     for i in range(datautils.unpack(MC_INT, bbuff)):
         prop = {
             "key": datautils.unpack(MC_STRING, bbuff),
             "value": datautils.unpack(MC_DOUBLE, bbuff),
             "modifiers": [],
         }
         for j in range(datautils.unpack(MC_VARINT, bbuff)):
             prop["modifiers"].append(
                 {
                     "uuid": datautils.unpack(MC_UUID, bbuff),
                     "amount": datautils.unpack(MC_DOUBLE, bbuff),
                     "operation": datautils.unpack(MC_BYTE, bbuff),
                 }
             )
         packet.data["properties"].append(prop)
     return packet
Пример #31
0
 def decode_extra(packet, bbuff):
     packet.data['properties'] = []
     for i in range(datautils.unpack(MC_INT, bbuff)):
         prop = {
             'key': datautils.unpack(MC_STRING, bbuff),
             'value': datautils.unpack(MC_DOUBLE, bbuff),
             'modifiers': [],
         }
         for j in range(datautils.unpack(MC_VARINT, bbuff)):
             prop['modifiers'].append({
                 'uuid':
                 datautils.unpack(MC_UUID, bbuff),
                 'amount':
                 datautils.unpack(MC_DOUBLE, bbuff),
                 'operation':
                 datautils.unpack(MC_BYTE, bbuff),
             })
         packet.data['properties'].append(prop)
     return packet
Пример #32
0
 def decode_extra(packet, bbuff):
     act = packet.data['action']
     if act in [const.SO_CREATE_BOARD, const.SO_UPDATE_BOARD]:
         packet.data['obj_val'] = datautils.unpack(MC_STRING, bbuff)
         packet.data['type'] = datautils.unpack(MC_STRING, bbuff)
     return packet
Пример #33
0
 def decode_extra(packet, bbuff):
     packet.data['matches'] = [
         datautils.unpack(MC_STRING, bbuff)
         for i in range(datautils.unpack(MC_VARINT, bbuff))
     ]
     return packet
Пример #34
0
 def decode_extra(packet, bbuff):
     act = packet.data['action']
     packet.data['player_list'] = []
     for i in range(datautils.unpack(MC_VARINT, bbuff)):
         item = {'uuid': datautils.unpack(MC_UUID, bbuff)}
         if act == const.PL_ADD_PLAYER:
             item['name'] = datautils.unpack(MC_STRING, bbuff)
             item['properties'] = []
             for i in range(datautils.unpack(MC_VARINT, bbuff)):
                 prop = {
                     'name': datautils.unpack(MC_STRING, bbuff),
                     'value': datautils.unpack(MC_STRING, bbuff),
                     'signed': datautils.unpack(MC_BOOL, bbuff),
                 }
                 if prop['signed']:
                     prop['signature'] = datautils.unpack(MC_STRING, bbuff)
                 item['properties'].append(prop)
         if act in [const.PL_ADD_PLAYER, const.PL_UPDATE_GAMEMODE]:
             item['gamemode'] = datautils.unpack(MC_VARINT, bbuff)
         if act in [const.PL_ADD_PLAYER, const.PL_UPDATE_LATENCY]:
             item['ping'] = datautils.unpack(MC_VARINT, bbuff)
         if act in [const.PL_ADD_PLAYER, const.PL_UPDATE_DISPLAY]:
             item['has_display'] = datautils.unpack(MC_BOOL, bbuff)
             if item['has_display']:
                 item['display_name'] = datautils.unpack(MC_CHAT, bbuff)
         packet.data['player_list'].append(item)
Пример #35
0
 def decode_extra(packet, bbuff):
     packet.data['entries'] = [[
         datautils.unpack(MC_STRING, bbuff),
         datautils.unpack(MC_VARINT, bbuff)
     ] for _ in range(datautils.unpack(MC_VARINT, bbuff))]
     return packet
Пример #36
0
 def decode_extra(packet, bbuff):
     packet.data['matches'] = [
         datautils.unpack(MC_STRING, bbuff)
         for i in range(datautils.unpack(MC_VARINT, bbuff))]
     return packet
Пример #37
0
 def decode_extra(packet, bbuff):
     packet.data['slots'] = [
         datautils.unpack(MC_SLOT, bbuff)
         for i in range(datautils.unpack(MC_SHORT, bbuff))]
     return packet
Пример #38
0
 def decode_extra(packet, bbuff):
     if packet.data['inv_type'] == 'EntityHorse':
         packet.data['eid'] = datautils.unpack(MC_INT, bbuff)
     return packet
Пример #39
0
 def decode_extra(packet, bbuff):
     length = datautils.unpack(MC_VARINT, bbuff)
     packet.data['public_key'] = bbuff.recv(length)
     length = datautils.unpack(MC_VARINT, bbuff)
     packet.data['verify_token'] = bbuff.recv(length)
     return packet
Пример #40
0
 def decode_extra(packet, bbuff):
     if packet.data['action'] == const.US_UPDATE_SCORE:
         packet.data['value'] = datautils.unpack(MC_VARINT, bbuff)
     return packet
Пример #41
0
 def decode_extra(packet, bbuff):
     packet.data['data'] = [
         datautils.unpack(MC_VARINT, bbuff)
         for i in range(proto.particles[packet.data['id']][1])
     ]
     return packet
Пример #42
0
 def decode_extra(packet, bbuff):
     if packet.data['action'] == const.INTERACT_ENTITY_AT:
         packet.data['target_x'] = datautils.unpack(MC_FLOAT, bbuff)
         packet.data['target_y'] = datautils.unpack(MC_FLOAT, bbuff)
         packet.data['target_z'] = datautils.unpack(MC_FLOAT, bbuff)
     return packet
Пример #43
0
 def decode_extra(packet, bbuff):
     if packet.data['has_position']:
         packet.data['block_loc'] = datautils.unpack(MC_POSITION, bbuff)
     return packet
Пример #44
0
 def decode_extra(packet, bbuff):
     packet.data['data'] = bbuff.recv(datautils.unpack(MC_VARINT, bbuff))
     return packet
Пример #45
0
 def decode_extra(packet, bbuff):
     length = datautils.unpack(MC_VARINT, bbuff)
     packet.data['shared_secret'] = bbuff.recv(length)
     length = datautils.unpack(MC_VARINT, bbuff)
     packet.data['verify_token'] = bbuff.recv(length)
     return packet
Пример #46
0
 def decode_extra(packet, bbuff):
     packet.data['slots'] = [
         datautils.unpack(MC_SLOT, bbuff)
         for i in range(datautils.unpack(MC_SHORT, bbuff))
     ]
     return packet
Пример #47
0
 def decode_extra(packet, bbuff):
     if packet.data['action'] == const.US_UPDATE_SCORE:
         packet.data['value'] = datautils.unpack(MC_VARINT, bbuff)
     return packet
Пример #48
0
 def decode_extra(packet, bbuff):
     length = datautils.unpack(MC_VARINT, bbuff)
     packet.data['shared_secret'] = bbuff.recv(length)
     length = datautils.unpack(MC_VARINT, bbuff)
     packet.data['verify_token'] = bbuff.recv(length)
     return packet
Пример #49
0
 def decode_extra(packet, bbuff):
     act = packet.data['action']
     packet.data['player_list'] = []
     for i in range(datautils.unpack(MC_VARINT, bbuff)):
         item = {'uuid': datautils.unpack(MC_UUID, bbuff)}
         if act == const.PL_ADD_PLAYER:
             item['name'] = datautils.unpack(MC_STRING, bbuff)
             item['properties'] = []
             for i in range(datautils.unpack(MC_VARINT, bbuff)):
                 prop = {
                     'name': datautils.unpack(MC_STRING, bbuff),
                     'value': datautils.unpack(MC_STRING, bbuff),
                     'signed': datautils.unpack(MC_BOOL, bbuff),
                 }
                 if prop['signed']:
                     prop['signature'] = datautils.unpack(MC_STRING, bbuff)
                 item['properties'].append(prop)
         if act in [const.PL_ADD_PLAYER, const.PL_UPDATE_GAMEMODE]:
             item['gamemode'] = datautils.unpack(MC_VARINT, bbuff)
         if act in [const.PL_ADD_PLAYER, const.PL_UPDATE_LATENCY]:
             item['ping'] = datautils.unpack(MC_VARINT, bbuff)
         if act in [const.PL_ADD_PLAYER, const.PL_UPDATE_DISPLAY]:
             item['has_display'] = datautils.unpack(MC_BOOL, bbuff)
             if item['has_display']:
                 item['display_name'] = datautils.unpack(MC_CHAT, bbuff)
         packet.data['player_list'].append(item)
Пример #50
0
 def decode_extra(packet, bbuff):
     act = packet.data['action']
     if act in [const.SO_CREATE_BOARD, const.SO_UPDATE_BOARD]:
         packet.data['obj_val'] = datautils.unpack(MC_STRING, bbuff)
         packet.data['type'] = datautils.unpack(MC_STRING, bbuff)
     return packet
Пример #51
0
 def decode_extra(packet, bbuff):
     count = datautils.unpack(MC_VARINT, bbuff)
     packet.data['eids'] = [
         datautils.unpack(MC_VARINT, bbuff) for i in range(count)
         ]
     return packet
Пример #52
0
 def decode_extra(packet, bbuff):
     if packet.data['has_position']:
         packet.data['block_loc'] = datautils.unpack(MC_POSITION, bbuff)
     return packet
Пример #53
0
 def decode_extra(packet, bbuff):
     if packet.data['obj_data']:
         packet.data['speed_x'] = datautils.unpack(MC_SHORT, bbuff)
         packet.data['speed_y'] = datautils.unpack(MC_SHORT, bbuff)
         packet.data['speed_z'] = datautils.unpack(MC_SHORT, bbuff)
     return packet
Пример #54
0
 def decode_extra(packet, bbuff):
     if packet.data['action'] == const.INTERACT_ENTITY_AT:
         packet.data['target_x'] = datautils.unpack(MC_FLOAT, bbuff)
         packet.data['target_y'] = datautils.unpack(MC_FLOAT, bbuff)
         packet.data['target_z'] = datautils.unpack(MC_FLOAT, bbuff)
     return packet
Пример #55
0
 def decode_extra(packet, bbuff):
     count = datautils.unpack(MC_VARINT, bbuff)
     packet.data['eids'] = [
         datautils.unpack(MC_VARINT, bbuff) for i in range(count)
     ]
     return packet
Пример #56
0
 def decode_extra(packet, bbuff):
     if packet.data['obj_data']:
         packet.data['speed_x'] = datautils.unpack(MC_SHORT, bbuff)
         packet.data['speed_y'] = datautils.unpack(MC_SHORT, bbuff)
         packet.data['speed_z'] = datautils.unpack(MC_SHORT, bbuff)
     return packet