#! /usr/bin/env python import os from logging import warn, error, info, debug from numpy import fromstring import nbt from mclevelbase import * import mclevel from indev import * from infiniteworld import * from java import * from level import * from schematic import * import threading import time class modifierThread(threading.Thread): def __init__(self, workerid): threading.Thread.__init__(self); self.chunkQueue = []; self.alive = True self.done = False self.id=workerid def run(self): while self.alive: while len(self.chunkQueue)>0: chunk = self.chunkQueue.pop(); for x in range(0,16): for z in range(0,16): for y in range(50,128): blockid = chunk.Blocks[x,z,y]; if changeBlocksHash[blockid]: chunk.Blocks[x,z,y]=changeBlocks[int(random.random()*len(changeBlocks))]; chunk.chunkChanged(); #print "worker %s fu" time.sleep(.01); if not self.alive and len(self.chunkQueue)==0: self.done = True changeBlocks = [1,2,3,4,5,7,12,13,14,15,16,17,18,19,20,21,22,23,24,25,29,30,33,35,41,42,43,44,45,46,47,48,49,52,53,54,55,56,57,58,60,61,63,67,73,74,79,80,81,82,83,84,85,86,87,88,89,90,91,95,97,98,101,102,103,107,108,109] changeBlocksHash = [] for i in range(0,257): changeBlocksHash.append(False) for i in changeBlocks: changeBlocksHash[i]=True world = mclevel.fromFile("/tmp/ramdisk/Waterfarm/"); workers = [modifierThread(0), modifierThread(1), modifierThread(2), modifierThread(3), modifierThread(4), modifierThread(5), modifierThread(6), modifierThread(7)] for thread in workers: thread.start(); chunklist = list(world.allChunks); counttotal = len(chunklist); countprocessed = 0 while countprocessed