コード例 #1
0
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: mcpacket.py プロジェクト: gamingrobot/SpockBot
    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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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
ファイル: extensions.py プロジェクト: BILLPC2684/SpockBot
 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