From 6bcfb0eb78a0b8d8aadf14e2aba0b5323cb55b87 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Fri, 15 Oct 2010 18:55:30 -1000 Subject: [PATCH] Added noair and nowater options for clone and import. --- mce.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/mce.py b/mce.py index 633e35f..5159317 100755 --- a/mce.py +++ b/mce.py @@ -203,7 +203,18 @@ class mce(object): raise BlockMatchError return blockType - + + def readBlocksToCopy(self, command): + blocksToCopy = range(256); + while len(command): + word = command.pop(); + if word == "noair": + blocksToCopy.remove(0); + if word == "nowater": + blocksToCopy.remove(8); + blocksToCopy.remove(9); + + return blocksToCopy def _debug(self, command): self.debug = not self.debug print "Debug", ("disabled", "enabled")[self.debug] @@ -225,11 +236,11 @@ class mce(object): def _clone(self, command): """ - clone + clone [noair] [nowater] Clone blocks in a cuboid starting at sourcePoint and extending for sourceSize blocks in each direction. Blocks and entities in the area - are cloned at destPoint + are cloned at destPoint. """ if len(command) == 0: self.printUsage("clone") @@ -238,11 +249,12 @@ class mce(object): box = self.readBox(command); destPoint = self.readPoint(command) - + destPoint = map(int, destPoint) + blocksToCopy = self.readBlocksToCopy(command); tempSchematic = self.level.extractSchematic(box); - self.level.copyBlocksFrom(tempSchematic, BoundingBox((0,0,0), box.origin), destPoint); + self.level.copyBlocksFrom(tempSchematic, BoundingBox((0,0,0), box.origin), destPoint, blocksToCopy); self.needsSave = True; print "Cloned 0 blocks." @@ -355,7 +367,7 @@ class mce(object): def _import(self, command): """ - import + import [noair] [nowater] Imports a level or schematic into this world, beginning at destPoint. Supported formats include @@ -371,9 +383,10 @@ class mce(object): filename = command.pop(0) destPoint = self.readPoint(command) - + blocksToCopy = self.readBlocksToCopy(command) + importLevel = mclevel.fromFile(filename, last_played=self.last_played, random_seed=self.random_seed) - self.level.copyBlocksFrom(importLevel, importLevel.getWorldBounds(), destPoint); + self.level.copyBlocksFrom(importLevel, importLevel.getWorldBounds(), destPoint, blocksToCopy); self.needsSave = True;