def decode_extra(packet, bbuff):
     assert (datautils.unpack(MC_BYTE, bbuff) == nbt.TAG_COMPOUND)
     name = nbt.TAG_String(buffer=bbuff)
     nbt_data = nbt.TAG_Compound(buffer=bbuff)
     nbt_data.name = name
     packet.data['nbt'] = nbt_data
     return packet
예제 #2
0
 def decode_extra(packet, bbuff):
     data = bbuff.recv(datautils.unpack(MC_SHORT, bbuff))
     data = utils.BoundBuffer(zlib.decompress(data, 16+zlib.MAX_WBITS))
     assert(datautils.unpack(MC_BYTE, data) == nbt.TAG_COMPOUND)
     name = nbt.TAG_String(buffer = data)
     nbt_data = nbt.TAG_Compound(buffer = data)
     nbt_data.name = name
     packet.data['nbt'] = nbt_data
     return packet
예제 #3
0
 def decode_extra(packet, bbuff):
     tag_type = datautils.unpack(MC_BYTE, bbuff)
     if tag_type == nbt.TAG_COMPOUND:
         name = nbt.TAG_String(buffer=bbuff).value
         nbt_data = nbt.TAG_Compound(buffer=bbuff)
         nbt_data.name = name
         packet.data['nbt'] = nbt_data
     else:
         assert (tag_type == nbt.TAG_END)
         packet.data['nbt'] = None
     return packet
예제 #4
0
def unpack_slot(bbuff):
    slot = {}
    slot['id'] = unpack(MC_SHORT, bbuff)
    if slot['id'] != -1:
        slot['amount'] = unpack(MC_BYTE, bbuff)
        slot['damage'] = unpack(MC_SHORT, bbuff)
        nbt_start = unpack(MC_BYTE, bbuff)
        if nbt_start > 0:
            assert (nbt_start == nbt.TAG_COMPOUND)
            name = nbt.TAG_String(buffer=bbuff)
            ench = nbt.TAG_Compound(buffer=bbuff)
            ench.name = name
            slot['enchants'] = ench
    return slot
예제 #5
0
def unpack_slot(bbuff):
    slot = {}
    slot['id'] = unpack(MC_SHORT, bbuff)
    if slot['id'] != -1:
        slot['amount'] = unpack(MC_BYTE, bbuff)
        slot['damage'] = unpack(MC_SHORT, bbuff)
        length = unpack(MC_SHORT, bbuff)
        if length > 0:
            data = bbuff.recv(length)
            try:
                ench_bbuff = utils.BoundBuffer(
                    #Adding 16 to the window bits field tells zlib
                    #to take care of the gzip headers for us
                    zlib.decompress(data, 16 + zlib.MAX_WBITS))
                assert (unpack(MC_BYTE, ench_bbuff) == nbt.TAG_COMPOUND)
                name = nbt.TAG_String(buffer=ench_bbuff)
                ench = nbt.TAG_Compound(buffer=ench_bbuff)
                ench.name = name
                slot['enchants'] = ench
            except:
                slot['enchant_data'] = data
    return slot