Cleanup
This commit is contained in:
parent
89f865d850
commit
c8c69bbb10
@ -27,6 +27,7 @@ log = getLogger(__name__)
|
|||||||
|
|
||||||
blocktypeClassesByName = {"Alpha": PCBlockTypeSet}
|
blocktypeClassesByName = {"Alpha": PCBlockTypeSet}
|
||||||
|
|
||||||
|
|
||||||
def createSchematic(shape, blocktypes='Alpha'):
|
def createSchematic(shape, blocktypes='Alpha'):
|
||||||
"""
|
"""
|
||||||
Create a new .schematic of the given shape and blocktypes and return a WorldEditor.
|
Create a new .schematic of the given shape and blocktypes and return a WorldEditor.
|
||||||
@ -46,6 +47,7 @@ def createSchematic(shape, blocktypes='Alpha'):
|
|||||||
editor = WorldEditor(adapter=adapter)
|
editor = WorldEditor(adapter=adapter)
|
||||||
return editor
|
return editor
|
||||||
|
|
||||||
|
|
||||||
def blockIDMapping(blocktypes):
|
def blockIDMapping(blocktypes):
|
||||||
mapping = nbt.TAG_Compound()
|
mapping = nbt.TAG_Compound()
|
||||||
for name, ID in blocktypes.IDsByName.iteritems():
|
for name, ID in blocktypes.IDsByName.iteritems():
|
||||||
@ -53,12 +55,14 @@ def blockIDMapping(blocktypes):
|
|||||||
|
|
||||||
return mapping
|
return mapping
|
||||||
|
|
||||||
|
|
||||||
def itemIDMapping(blocktypes):
|
def itemIDMapping(blocktypes):
|
||||||
mapping = nbt.TAG_Compound()
|
mapping = nbt.TAG_Compound()
|
||||||
for name, ID in blocktypes.itemTypes.IDsByInternalName.iteritems():
|
for name, ID in blocktypes.itemTypes.IDsByInternalName.iteritems():
|
||||||
mapping[str(ID)] = nbt.TAG_String(name)
|
mapping[str(ID)] = nbt.TAG_String(name)
|
||||||
return mapping
|
return mapping
|
||||||
|
|
||||||
|
|
||||||
class SchematicChunkData(FakeChunkData):
|
class SchematicChunkData(FakeChunkData):
|
||||||
def addEntity(self, entity):
|
def addEntity(self, entity):
|
||||||
self.dimension.addEntity(entity)
|
self.dimension.addEntity(entity)
|
||||||
@ -66,6 +70,7 @@ class SchematicChunkData(FakeChunkData):
|
|||||||
def addTileEntity(self, tileEntity):
|
def addTileEntity(self, tileEntity):
|
||||||
self.dimension.addTileEntity(tileEntity)
|
self.dimension.addTileEntity(tileEntity)
|
||||||
|
|
||||||
|
|
||||||
class SchematicFileAdapter(FakeChunkedLevelAdapter):
|
class SchematicFileAdapter(FakeChunkedLevelAdapter):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -180,7 +185,6 @@ class SchematicFileAdapter(FakeChunkedLevelAdapter):
|
|||||||
# the type of its `id` tag. If no itemStacks are found, the
|
# the type of its `id` tag. If no itemStacks are found, the
|
||||||
# version defaults to 1.8 which does not need an ItemIDs tag.
|
# version defaults to 1.8 which does not need an ItemIDs tag.
|
||||||
|
|
||||||
|
|
||||||
if "itemStackVersion" in self.rootTag:
|
if "itemStackVersion" in self.rootTag:
|
||||||
itemStackVersion = self.rootTag["itemStackVersion"].value
|
itemStackVersion = self.rootTag["itemStackVersion"].value
|
||||||
if itemStackVersion not in (VERSION_1_7, VERSION_1_8):
|
if itemStackVersion not in (VERSION_1_7, VERSION_1_8):
|
||||||
@ -194,7 +198,6 @@ class SchematicFileAdapter(FakeChunkedLevelAdapter):
|
|||||||
else:
|
else:
|
||||||
self.blocktypes.itemStackVersion = self.getItemStackVersionFromEntities()
|
self.blocktypes.itemStackVersion = self.getItemStackVersionFromEntities()
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
rootTag = nbt.TAG_Compound(name="Schematic")
|
rootTag = nbt.TAG_Compound(name="Schematic")
|
||||||
rootTag["Height"] = nbt.TAG_Short(shape[1])
|
rootTag["Height"] = nbt.TAG_Short(shape[1])
|
||||||
@ -261,7 +264,6 @@ class SchematicFileAdapter(FakeChunkedLevelAdapter):
|
|||||||
# be added to the root tag.
|
# be added to the root tag.
|
||||||
return VERSION_1_8
|
return VERSION_1_8
|
||||||
|
|
||||||
|
|
||||||
def fakeEntitiesForChunk(self, cx, cz):
|
def fakeEntitiesForChunk(self, cx, cz):
|
||||||
return self.entitiesByChunk[cx, cz], self.tileEntitiesByChunk[cx, cz]
|
return self.entitiesByChunk[cx, cz], self.tileEntitiesByChunk[cx, cz]
|
||||||
|
|
||||||
@ -330,7 +332,6 @@ class SchematicFileAdapter(FakeChunkedLevelAdapter):
|
|||||||
del self.rootTag["Blocks"]
|
del self.rootTag["Blocks"]
|
||||||
self.rootTag.pop("AddBlocks", None)
|
self.rootTag.pop("AddBlocks", None)
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return u"SchematicFileAdapter(shape={0}, blocktypes={2}, filename=\"{1}\")".format(self.size, self.filename or u"", self.Materials)
|
return u"SchematicFileAdapter(shape={0}, blocktypes={2}, filename=\"{1}\")".format(self.size, self.filename or u"", self.Materials)
|
||||||
|
|
||||||
@ -542,7 +543,6 @@ class SchematicFileAdapter(FakeChunkedLevelAdapter):
|
|||||||
# for tileEntity in self.TileEntities:
|
# for tileEntity in self.TileEntities:
|
||||||
# tileEntity["z"].value = self.Length - tileEntity["z"].value - 1
|
# tileEntity["z"].value = self.Length - tileEntity["z"].value - 1
|
||||||
|
|
||||||
|
|
||||||
def setBlockData(self, x, y, z, newdata):
|
def setBlockData(self, x, y, z, newdata):
|
||||||
if x < 0 or y < 0 or z < 0:
|
if x < 0 or y < 0 or z < 0:
|
||||||
return 0
|
return 0
|
||||||
|
Reference in New Issue
Block a user