def testCreate(self): # log.info("Schematic from indev") size = (64, 64, 64) temp = mktemp("testcreate.schematic") editor = createSchematic(shape=size, blocktypes='Classic') editor.filename = temp dim = editor.getDimension() level = self.schematicLevel dim.importSchematic(level, (0, 0, 0)) assert((schematic.Blocks[0:64, 0:64, 0:64] == level.adapter.Blocks[0:64, 0:64, 0:64]).all()) dim.importSchematic(level, (-32, -32, -32)) assert((schematic.Blocks[0:32, 0:32, 0:32] == level.adapter.Blocks[32:64, 32:64, 32:64]).all()) schematic.saveChanges() schem = WorldEditor("test_files/Station.schematic") tempEditor = createSchematic(shape=(1, 1, 3)) tempDim = tempEditor.getDimension() tempDim.copyBlocks(schem, BoundingBox((0, 0, 0), (1, 1, 3)), (0, 0, 0)) level = self.pc_world for cx, cz in itertools.product(xrange(0, 4), xrange(0, 4)): try: level.createChunk(cx, cz) except ValueError: pass dim.copyBlocks(level.getDimension(), BoundingBox((0, 0, 0), (64, 64, 64,)), (0, 0, 0)) os.remove(temp)
def testCreate(self): # log.info("Schematic from indev") size = (64, 64, 64) temp = mktemp("testcreate.schematic") editor = createSchematic(shape=size, blocktypes='Classic') editor.filename = temp dim = editor.getDimension() level = self.schematicLevel dim.importSchematic(level, (0, 0, 0)) assert((schematic.Blocks[0:64, 0:64, 0:64] == level.adapter.Blocks[0:64, 0:64, 0:64]).all()) dim.importSchematic(level, (-32, -32, -32)) assert((schematic.Blocks[0:32, 0:32, 0:32] == level.adapter.Blocks[32:64, 32:64, 32:64]).all()) schematic.saveChanges() schem = WorldEditor("test_files/Station.schematic") tempEditor = createSchematic(shape=(1, 1, 3)) tempDim = tempEditor.getDimension() tempDim.copyBlocks(schem, BoundingBox((0, 0, 0), (1, 1, 3)), (0, 0, 0)) level = self.anvilLevel for cx, cz in itertools.product(xrange(0, 4), xrange(0, 4)): try: level.createChunk(cx, cz) except ValueError: pass dim.copyBlocks(level.getDimension(), BoundingBox((0, 0, 0), (64, 64, 64,)), (0, 0, 0)) os.remove(temp)
def extractSchematicFromIter(sourceDim, box, *a, **kw): editor = createSchematic(shape=box.size, blocktypes=sourceDim.blocktypes) dim = editor.getDimension() for i in copyBlocksIter(dim, sourceDim, box, (0, 0, 0), *a, **kw): yield i yield editor
def generate(self, bounds, blocktypes): # self.systemsBox.value() schematic = createSchematic(bounds.size, blocktypes) dim = schematic.getDimension() system = koch.Snowflake(dim.bounds, blocktype=self.blocktypeButton.block) symbol_list = [system] max_iterations = self.iterationsSlider.value() def process(_symbol_list): for iteration, _symbol_list in applyReplacementsIterated(_symbol_list, max_iterations): yield iteration, max_iterations yield _symbol_list symbol_list = showProgress("Generating...", process(symbol_list), cancel=True) if symbol_list is False: return import pprint pprint.pprint(symbol_list) rendering = renderBlocks(symbol_list) print("Rendering %d blocks" % len(rendering)) for x, y, z, blockType in rendering: dim.setBlock(x, y, z, blockType) return schematic
def main(): blockWidth = 64 blockCount = 256 * 16 width = blockWidth * 3 + 1 rows = blockCount // blockWidth + 1 length = rows * 3 + 1 height = 3 world = createSchematic((width, height, length)) dim = world.getDimension() allBlocks = [world.blocktypes[a, b] for a in range(256) for b in range(16)] w, l = numpy.indices((width, length)) dim.setBlocks(w, 1, l, "minecraft:stone") for i, block in enumerate(allBlocks): col = (i % blockWidth) * 3 + 1 row = (i // blockWidth) * 3 dim.setBlocks([col, col + 1, col, col + 1], 2, [row, row, row + 1, row + 1], block) world.saveToFile("testbed.schematic") displaySchematic(dim)
def exportSchematicIter(self, selection): schematic = createSchematic(shape=selection.size, blocktypes=self.blocktypes) return itertools.chain( copyBlocksIter(schematic.getDimension(), self, selection, (0, 0, 0)), [schematic])
def testCopyOffsets(pc_world): dimension = pc_world.getDimension() schematic = createSchematic((13, 8, 5)) schematicDim = schematic.getDimension() x, y, z = dimension.bounds.origin + [p/2 for p in dimension.bounds.size] for dx in range(16): for dz in range(16): dimension.copyBlocks(schematicDim, schematicDim.bounds, (x+dx, y, z+dz), biomes=True)
def updateView(self): if None in (self.block, self.editorSession): return editor = createSchematic((1, 1, 1), blocktypes=self.editorSession.worldEditor.blocktypes) dim = editor.getDimension() dim.setBlocks(0, 0, 0, self.block) self.worldView = IsoWorldView(dim, self.editorSession.textureAtlas, sharedGLWidget=self.editorSession.editorTab.miniMap) self.setLayout(Row(self.worldView))
def testCopyOffsets(self): editor = TempLevel("AnvilWorld") dimension = editor.getDimension() schematic = createSchematic((13, 8, 5)) schematicDim = schematic.getDimension() x, y, z = dimension.bounds.origin + [p/2 for p in dimension.bounds.size] for dx in range(16): for dz in range(16): dimension.copyBlocks(schematicDim, schematicDim.bounds, (x+dx, y, z+dz), biomes=True)
def testCopyOffsets(pc_world): dimension = pc_world.getDimension() schematic = createSchematic((13, 8, 5)) schematicDim = schematic.getDimension() x, y, z = dimension.bounds.origin + [p / 2 for p in dimension.bounds.size] for dx in range(16): for dz in range(16): dimension.copyBlocks(schematicDim, schematicDim.bounds, (x + dx, y, z + dz), biomes=True)
def test_schematic_extended_ids(tmpdir): filename = tmpdir.join("schematic_extended_ids.schematic").strpath s = createSchematic(shape=(1, 1, 5)) s.adapter.Blocks[0, 0, 0] = 2048 s.saveToFile(filename) del s s = WorldEditor(filename) assert s.adapter.Blocks[0, 0, 0] == 2048
def test_schematic_extended_ids(tmpdir): filename = tmpdir.join("schematic_extended_ids.schematic").strpath s = createSchematic(shape=(1, 1, 5)) s.adapter.Blocks[0,0,0] = 2048 s.saveToFile(filename) del s s = WorldEditor(filename) assert s.adapter.Blocks[0,0,0] == 2048
def extractSchematicFromIter(sourceDim, box, entities=True): p = adjustExtractionParameters(sourceDim, box) if p is None: yield None return newbox, destPoint = p editor = createSchematic(shape=box.size, blocktypes=sourceDim.blocktypes) dim = editor.getDimension() for i in copyBlocksIter(dim, sourceDim, newbox, destPoint, entities=entities, biomes=True): yield i yield editor
def generate(self, bounds, blocktypes): """ The main entry point of the GeneratePlugin. Given the bounding box chosen by the user and the BlockTypeSet for the currently edited world, return a world (usually a Schematic file) suitable for importing into the edited world. :param bounds: Bounding box chosen by the user :type bounds: BoundingBox :param blocktypes: BlockTypeSet of currently edited world :type blocktypes: BlockTypeSet :return: Generated Schematic :rtype: WorldEditor """ schematic = createSchematic(bounds.size, blocktypes) dim = schematic.getDimension() self.generateInSchematic(dim, bounds) return schematic
def generate(self, bounds, blocktypes): schematic = createSchematic(bounds.size, blocktypes) dim = schematic.getDimension() trunkX = int(bounds.width / 2) trunkZ = int(bounds.length / 2) crownBottom = int(bounds.height * 2 / 3) wood = blocktypes["log[axis=y,variant=birch]"] leaves = blocktypes[ "leaves[check_decay=false,decayable=true,variant=birch]"] dim.setBlocks(range(0, bounds.width), [range(crownBottom, bounds.height)], [[range(0, bounds.length)]], leaves) dim.setBlocks(trunkX, range(0, bounds.height), trunkZ, wood) return schematic
def exportSchematicIter(self, selection): schematic = createSchematic(shape=selection.size, blocktypes=self.blocktypes) return itertools.chain(copyBlocksIter(schematic.getDimension(), self, selection, (0, 0, 0)), [schematic])