diff --git a/src/mceditlib/schematic.py b/src/mceditlib/schematic.py index c0ea2f4..76db3ea 100644 --- a/src/mceditlib/schematic.py +++ b/src/mceditlib/schematic.py @@ -27,6 +27,7 @@ log = getLogger(__name__) blocktypeClassesByName = {"Alpha": PCBlockTypeSet} + def createSchematic(shape, blocktypes='Alpha'): """ 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) return editor + def blockIDMapping(blocktypes): mapping = nbt.TAG_Compound() for name, ID in blocktypes.IDsByName.iteritems(): @@ -53,12 +55,14 @@ def blockIDMapping(blocktypes): return mapping + def itemIDMapping(blocktypes): mapping = nbt.TAG_Compound() for name, ID in blocktypes.itemTypes.IDsByInternalName.iteritems(): mapping[str(ID)] = nbt.TAG_String(name) return mapping + class SchematicChunkData(FakeChunkData): def addEntity(self, entity): self.dimension.addEntity(entity) @@ -66,6 +70,7 @@ class SchematicChunkData(FakeChunkData): def addTileEntity(self, tileEntity): self.dimension.addTileEntity(tileEntity) + class SchematicFileAdapter(FakeChunkedLevelAdapter): """ @@ -180,7 +185,6 @@ class SchematicFileAdapter(FakeChunkedLevelAdapter): # the type of its `id` tag. If no itemStacks are found, the # version defaults to 1.8 which does not need an ItemIDs tag. - if "itemStackVersion" in self.rootTag: itemStackVersion = self.rootTag["itemStackVersion"].value if itemStackVersion not in (VERSION_1_7, VERSION_1_8): @@ -194,7 +198,6 @@ class SchematicFileAdapter(FakeChunkedLevelAdapter): else: self.blocktypes.itemStackVersion = self.getItemStackVersionFromEntities() - else: rootTag = nbt.TAG_Compound(name="Schematic") rootTag["Height"] = nbt.TAG_Short(shape[1]) @@ -261,7 +264,6 @@ class SchematicFileAdapter(FakeChunkedLevelAdapter): # be added to the root tag. return VERSION_1_8 - def fakeEntitiesForChunk(self, cx, cz): return self.entitiesByChunk[cx, cz], self.tileEntitiesByChunk[cx, cz] @@ -330,7 +332,6 @@ class SchematicFileAdapter(FakeChunkedLevelAdapter): del self.rootTag["Blocks"] self.rootTag.pop("AddBlocks", None) - def __repr__(self): 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: # tileEntity["z"].value = self.Length - tileEntity["z"].value - 1 - def setBlockData(self, x, y, z, newdata): if x < 0 or y < 0 or z < 0: return 0