Пример #1
0
    'default:furnace_active',
    'beds:fancy_bed_top',
    'beds:fancy_bed_bottom',
    'beds:bed_top',
    'beds:bed_bottom'
]

for row in sourcecursor0.execute("SELECT `pos` FROM `blocks`"):
    pos = getIntegerAsBlock(row[0])
    if pos[0]**2 + pos[2]**2 < (160 / 16)**2 and pos[1] > (
            -60 / 16) and pos[1] < (
                128 / 16):  #just small central map part for fast demonstration
        for datarow in sourcecursor.execute(
                "SELECT `data` FROM `blocks` WHERE `pos` == ? LIMIT 1;",
            (row[0], )):
            tempA = mt_block_parser.MtBlockParser(datarow[0])
            tempA.nodeDataParse()
            tempA.nodeMetadataParse()
            tempA.nameIdMappingsParse()

            tempB = mt_block_parser.MtBlockParser(0)  #blank block

            for i in range(0, 4096):
                tempB.arrayParam0[i] = tempA.arrayParam0[m[i]]
                tempB.arrayParam1[i] = tempA.arrayParam1[m[i]]
                tempB.arrayParam2[i] = tempA.arrayParam2[m[i]]
                if tempA.arrayParam0[i] not in tempB.nameIdMappings:
                    tempB.nameIdMappings[tempA.arrayParam0[
                        i]] = tempA.nameIdMappings[tempA.arrayParam0[i]]
                if m[i] in tempA.arrayMetadataRead:
                    tempB.arrayMetadataRead[i] = tempA.arrayMetadataRead[m[i]]
Пример #2
0
useful_block_evidence = re.compile(
    "default:cobble|"+
    "protector:protect|default:chest_locked|doors:door_steel|"+
    "default:chest|default:torch|default:stonebrick|default:glass|default:obsidian_glass|"+
    "default:ladder|default:rail|default:fence_wood|"+
    "bones:bones"
    )

sourceconn = sqlite3.connect(source)
targetconn = sqlite3.connect(target)
sourcecursor = sourceconn.cursor()
targetcursor = targetconn.cursor()
targetcursor.execute("CREATE TABLE IF NOT EXISTS `blocks` (`pos` INT NOT NULL PRIMARY KEY, `data` BLOB);")

for row in sourcecursor.execute("SELECT `pos`, `data` "+" FROM `blocks`;"):
    pos=getIntegerAsBlock(row[0])
    if pos[0]**2 + pos[2]**2 < (160/16)**2 and pos[1]>(-60/16):    #160 nodes radius and 60 nodes deep
        targetcursor.execute("INSERT OR IGNORE INTO `blocks` VALUES (?, ?);", (row[0], row[1]))
    else:
        try:
            temp = mt_block_parser.MtBlockParser(row[1])
            if useful_block_evidence.search(temp.nameIdMappingsRead)!=None:
                targetcursor.execute("INSERT OR IGNORE INTO `blocks` VALUES (?, ?);", (row[0], row[1]))
        except:
            print "Block parse error:", pos[0], pos[1], pos[2]
            
targetconn.commit()

sourceconn.close()
targetconn.close()
Пример #3
0
 for row in sourcecursor.execute(" SELECT "+
                                 " CASE WHEN `X` < 2048 THEN `X` ELSE `X` - 4096 END AS X, "+
                                 " CASE WHEN `Y` < 2048 THEN `Y` ELSE `Y` - 4096 END AS Y, "+
                                 " CASE WHEN `Z` < 2048 THEN `Z` ELSE `Z` - 4096 END AS Z, "+
                                 " `pos`, "+
                                 " `data` "+
                                 " FROM ("+"SELECT "+
                                     " `pos`, "+
                                     " (`pos`) & 4095 AS X, "+
                                     " ((`pos`) & 16773120)>>12 AS Y, "+
                                     " ((`pos`) & 68702699520)>>24 AS Z, "+
                                     " `data` "+
                                     " FROM `blocks`"+
                                 ")"+
                                 " WHERE Y == 0; "):
     block = mt_block_parser.MtBlockParser(row[4])
     if useful_block_evidence.search(str(block.nameIdMappingsRead)) != None:
         if row[0] - minX < 0 or width <= row[0] - minX or height - row[2] + minZ < 0 or height <= height - row[2] + minZ:
             print("Do not fit:", row[0], row[1], row[2])
         else:
             block.nodeDataParse()
             block.nameIdMappingsParse()
             chunk_blockdict = {k: blockdict[v] for k, v in block.nameIdMappings.items() if blockdict.get(v) is not None}
             for z in range(16):
                 for x in range(16):
                     blockmap = chunk_blockdict.get(block.arrayParam0[z*256 + 2*16 + x])
                     if blockmap == 5 or blockmap == 9:
                         blockmap += block.arrayParam2[z*256 + 2*16 + x]
                     elif blockmap == 2 and block.arrayParam2[z*256 + 2*16 + x] == 0:
                         blockmap += 1
                     data[row[2]*16 + z][row[0]*16 + x] = blockmap
Пример #4
0
target = r'<Put path to output text file>'
arguments = sys.argv
if(len(arguments) > 1 ):
    source = str(arguments[1])
if(len(arguments) > 2 ):
    target = str(arguments[2])

sourceconn = sqlite3.connect(source)
sourcecursor0 = sourceconn.cursor()
sourcecursor = sourceconn.cursor()

nodelist = {}

for row in sourcecursor0.execute("SELECT `pos` FROM `blocks`"):
    for datarow in sourcecursor.execute("SELECT `data` FROM `blocks` WHERE `pos` == ? LIMIT 1;", (row[0],)):
        temp = mt_block_parser.MtBlockParser(datarow[0])

        temp.nameIdMappingsParse()
        for key,value in temp.nameIdMappings.iteritems():
            if value not in nodelist:
                nodelist[value] = 0

        #Counting all nodes takes too long
        # temp.nodeDataParse()
        # for i in range(0, 4096):
        #     tempName = temp.nameIdMappings[temp.arrayParam0[i]]
        #     nodelist[tempName]+= 1

s_nodelist = sorted(nodelist)
#s_nodelist = sorted(nodelist.items(), key=operator.itemgetter(1))