Get time_getsetblocks working again.
setBlocks accepts single values for Blocks/Data
This commit is contained in:
parent
ff1a08519d
commit
2dfe908bbd
@ -283,6 +283,10 @@ def setBlocks(dimension, x, y, z,
|
||||
Blocks = [Blocks]
|
||||
_Blocks = []
|
||||
_Data = []
|
||||
if isinstance(Blocks, int):
|
||||
Blocks = [Blocks]
|
||||
if isinstance(Data, int):
|
||||
Data = [Data]
|
||||
|
||||
for block in Blocks:
|
||||
if isinstance(block, basestring):
|
||||
|
@ -3,44 +3,33 @@ from templevel import TempLevel
|
||||
from mceditlib.selection import BoundingBox
|
||||
|
||||
level = TempLevel("AnvilWorld")
|
||||
box = BoundingBox(level.bounds.origin, (64, 32, 64))
|
||||
dim = level.getDimension()
|
||||
box = BoundingBox(dim.bounds.origin, (64, 32, 64))
|
||||
|
||||
def timeGetBlocksOld():
|
||||
for x, y, z in box.positions:
|
||||
level.getBlockID(x, y, z)
|
||||
level.getBlockData(x, y, z)
|
||||
|
||||
|
||||
|
||||
def timeGetBlocksFast():
|
||||
|
||||
x, y, z = numpy.mgrid[
|
||||
box.minx:box.maxx,
|
||||
box.miny:box.maxy,
|
||||
box.minz:box.maxz,
|
||||
]
|
||||
|
||||
x, y, z = [numpy.ravel(a) for a in x, y, z]
|
||||
|
||||
print "Coords", [x, y, z], "maxz", z.max()
|
||||
print "Length", level.getBlocks(x, y, z, return_Data=True).Blocks.shape
|
||||
|
||||
def timeGetBlocks():
|
||||
|
||||
x, y, z = numpy.transpose(list(box.positions))
|
||||
|
||||
print "Coords", [x, y, z], "maxz", z.max()
|
||||
print "Length", level.getBlocks(x, y, z, return_Data=True).Blocks.shape
|
||||
|
||||
dim.getBlockID(x, y, z)
|
||||
dim.getBlockData(x, y, z)
|
||||
|
||||
def timeSetBlocksOld():
|
||||
for x, y, z in box.positions:
|
||||
level.setBlockID(x, y, z, 1)
|
||||
level.setBlockData(x, y, z, 1)
|
||||
dim.setBlockID(x, y, z, 1)
|
||||
dim.setBlockData(x, y, z, 1)
|
||||
|
||||
|
||||
def timeGetBlocksGrid():
|
||||
x, y, z = numpy.mgrid[
|
||||
box.minx:box.maxx,
|
||||
box.miny:box.maxy,
|
||||
box.minz:box.maxz,
|
||||
]
|
||||
|
||||
def timeSetBlocksFast():
|
||||
x, y, z = [numpy.ravel(a) for a in x, y, z]
|
||||
result = dim.getBlocks(x, y, z, return_Data=True)
|
||||
#print "Coords", [x, y, z], "maxz", z.max()
|
||||
#print "Length", result.Blocks.shape
|
||||
|
||||
def timeSetBlocksGrid():
|
||||
x, y, z = numpy.mgrid[
|
||||
box.minx:box.maxx,
|
||||
box.miny:box.maxy,
|
||||
@ -49,21 +38,28 @@ def timeSetBlocksFast():
|
||||
|
||||
x, y, z = [numpy.ravel(a) for a in x, y, z]
|
||||
|
||||
print "Coords", [x, y, z], "maxz", z.max()
|
||||
level.setBlocks(x, y, z, Blocks=1, Data=1)
|
||||
#print "Coords", [x, y, z], "maxz", z.max()
|
||||
dim.setBlocks(x, y, z, Blocks=1, Data=1)
|
||||
|
||||
|
||||
def timeGetBlocks():
|
||||
x, y, z = numpy.transpose(list(box.positions))
|
||||
result = dim.getBlocks(x, y, z, return_Data=True)
|
||||
#print "Coords", [x, y, z], "maxz", z.max()
|
||||
#print "Length", result.Blocks.shape
|
||||
|
||||
|
||||
def timeSetBlocks():
|
||||
x, y, z = numpy.transpose(list(box.positions))
|
||||
|
||||
print "Coords", [x, y, z], "maxz", z.max()
|
||||
level.setBlocks(x, y, z, Blocks=1, Data=1)
|
||||
#print "Coords", [x, y, z], "maxz", z.max()
|
||||
dim.setBlocks(x, y, z, Blocks=1, Data=1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import timeit
|
||||
print "GetFast: %.03f" % (timeit.timeit(timeGetBlocksFast, number=1))
|
||||
print "SetFast: %.03f" % (timeit.timeit(timeSetBlocksFast, number=1))
|
||||
print "GetFast: %.03f" % (timeit.timeit(timeGetBlocksGrid, number=1))
|
||||
print "SetFast: %.03f" % (timeit.timeit(timeSetBlocksGrid, number=1))
|
||||
print "GetNew: %.03f" % (timeit.timeit(timeGetBlocks, number=1))
|
||||
print "SetNew: %.03f" % (timeit.timeit(timeSetBlocks, number=1))
|
||||
print "GetOld: %.03f" % (timeit.timeit(timeGetBlocksOld, number=1))
|
||||
|
Reference in New Issue
Block a user