create a new function readBox in anticipation of better box specifiers
This commit is contained in:
parent
11048d9d74
commit
00509546b3
50
mce.py
50
mce.py
@ -6,6 +6,7 @@ from box import BoundingBox
|
|||||||
from numpy import zeros, bincount
|
from numpy import zeros, bincount
|
||||||
import logging
|
import logging
|
||||||
import itertools
|
import itertools
|
||||||
|
import traceback
|
||||||
|
|
||||||
class UsageError(RuntimeError): pass
|
class UsageError(RuntimeError): pass
|
||||||
class BlockMatchError(RuntimeError): pass
|
class BlockMatchError(RuntimeError): pass
|
||||||
@ -111,6 +112,12 @@ class mce(object):
|
|||||||
debug = False
|
debug = False
|
||||||
needsSave = False;
|
needsSave = False;
|
||||||
|
|
||||||
|
def readBox(self, command):
|
||||||
|
sourcePoint = self.readPoint(command)
|
||||||
|
sourceSize = self.readPoint(command, isPoint = False)
|
||||||
|
box = BoundingBox(sourcePoint, sourceSize)
|
||||||
|
return box
|
||||||
|
|
||||||
def readPoint(self, command, isPoint = True):
|
def readPoint(self, command, isPoint = True):
|
||||||
try:
|
try:
|
||||||
word = command.pop(0)
|
word = command.pop(0)
|
||||||
@ -228,15 +235,14 @@ class mce(object):
|
|||||||
self.printUsage("clone")
|
self.printUsage("clone")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sourcePoint = self.readPoint(command)
|
box = self.readBox(command);
|
||||||
sourceSize = self.readPoint(command, isPoint = False)
|
|
||||||
destPoint = self.readPoint(command)
|
destPoint = self.readPoint(command)
|
||||||
|
|
||||||
destPoint = map(int, destPoint)
|
destPoint = map(int, destPoint)
|
||||||
|
|
||||||
box = BoundingBox(sourcePoint, sourceSize)
|
|
||||||
tempSchematic = self.level.extractSchematic(box);
|
tempSchematic = self.level.extractSchematic(box);
|
||||||
self.level.copyBlocksFrom(tempSchematic, BoundingBox((0,0,0), sourceSize), destPoint);
|
self.level.copyBlocksFrom(tempSchematic, BoundingBox((0,0,0), box.origin), destPoint);
|
||||||
|
|
||||||
self.needsSave = True;
|
self.needsSave = True;
|
||||||
print "Cloned 0 blocks."
|
print "Cloned 0 blocks."
|
||||||
@ -258,10 +264,7 @@ class mce(object):
|
|||||||
assert blockType >=0 and blockType < 256
|
assert blockType >=0 and blockType < 256
|
||||||
|
|
||||||
if len(command):
|
if len(command):
|
||||||
destPoint = self.readPoint(command);
|
box = self.readBox(command)
|
||||||
destSize = self.readPoint(command, isPoint = False);
|
|
||||||
box = BoundingBox(destPoint, destSize)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
box = None
|
box = None
|
||||||
|
|
||||||
@ -295,10 +298,7 @@ class mce(object):
|
|||||||
assert newBlockType >=0 and newBlockType < 256
|
assert newBlockType >=0 and newBlockType < 256
|
||||||
|
|
||||||
if len(command):
|
if len(command):
|
||||||
destPoint = self.readPoint(command);
|
box = self.readBox(command)
|
||||||
destSize = self.readPoint(command, isPoint = False);
|
|
||||||
box = BoundingBox(destPoint, destSize)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
box = None
|
box = None
|
||||||
|
|
||||||
@ -345,11 +345,8 @@ class mce(object):
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
filename = command.pop(0)
|
filename = command.pop(0)
|
||||||
sourcePoint = self.readPoint(command)
|
box = self.readBox(command)
|
||||||
sourceSize = self.readPoint(command, isPoint = False)
|
|
||||||
|
|
||||||
|
|
||||||
box = BoundingBox(sourcePoint, sourceSize)
|
|
||||||
tempSchematic = self.level.extractSchematic(box);
|
tempSchematic = self.level.extractSchematic(box);
|
||||||
|
|
||||||
tempSchematic.saveToFile(filename)
|
tempSchematic.saveToFile(filename)
|
||||||
@ -560,10 +557,7 @@ class mce(object):
|
|||||||
self.printUsage("createchunks")
|
self.printUsage("createchunks")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
point = self.readPoint(command)
|
box = self.readBox(command)
|
||||||
size = self.readPoint(command, isPoint = False)
|
|
||||||
|
|
||||||
box = BoundingBox(point, size)
|
|
||||||
|
|
||||||
oldChunkCount = len(self.level.presentChunks)
|
oldChunkCount = len(self.level.presentChunks)
|
||||||
self.level.createChunksInBox(box)
|
self.level.createChunksInBox(box)
|
||||||
@ -583,10 +577,7 @@ class mce(object):
|
|||||||
self.printUsage("deletechunks")
|
self.printUsage("deletechunks")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
point = self.readPoint(command)
|
box = self.readBox(command)
|
||||||
size = self.readPoint(command, isPoint = False)
|
|
||||||
|
|
||||||
box = BoundingBox(point, size)
|
|
||||||
|
|
||||||
oldChunkCount = len(self.level.presentChunks)
|
oldChunkCount = len(self.level.presentChunks)
|
||||||
self.level.deleteChunksInBox(box)
|
self.level.deleteChunksInBox(box)
|
||||||
@ -604,10 +595,7 @@ class mce(object):
|
|||||||
self.printUsage("prune")
|
self.printUsage("prune")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
point = self.readPoint(command)
|
box = self.readBox(command)
|
||||||
size = self.readPoint(command, isPoint = False)
|
|
||||||
|
|
||||||
box = BoundingBox(point, size)
|
|
||||||
|
|
||||||
oldChunkCount = len(self.level.presentChunks)
|
oldChunkCount = len(self.level.presentChunks)
|
||||||
|
|
||||||
@ -626,14 +614,12 @@ class mce(object):
|
|||||||
recalculates the entire world.
|
recalculates the entire world.
|
||||||
"""
|
"""
|
||||||
if len(command):
|
if len(command):
|
||||||
point = self.readPoint(command)
|
box = self.readBox(command)
|
||||||
size = self.readPoint(command, isPoint = False)
|
|
||||||
|
|
||||||
box = BoundingBox(point, size)
|
|
||||||
chunks = itertools.product(range(box.mincx, box.maxcx),range(box.mincz, box.maxcz))
|
chunks = itertools.product(range(box.mincx, box.maxcx),range(box.mincz, box.maxcz))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
chunks = self.level.presentChunks
|
chunks = self.level.presentChunks
|
||||||
|
|
||||||
self.level.generateLights(chunks)
|
self.level.generateLights(chunks)
|
||||||
|
|
||||||
print "Relit 0 chunks."
|
print "Relit 0 chunks."
|
||||||
|
Reference in New Issue
Block a user