def _findTileEntitiesInChunk(chunk): for tileEntity in chunk.TileEntities: if tileEntity.Position not in selection: continue if len(targetTileEntityIDs) and tileEntity.id not in targetTileEntityIDs: continue if not searchNames and not searchValues: # Finding tile entities only self.resultsModel.addEntry(tagName="id", value=tileEntity.id, id=tileEntity.id, path=[], position=tileEntity.Position, uuid=None, resultType=NBTResultsEntry.TileEntityResult) continue tag = tileEntity.raw_tag() for name, subtag, path in nbt.walk(tag): result = _findTag(name, subtag, path) if result: name, path, value = result self.resultsModel.addEntry(tagName=name, value=value, id=tileEntity.id, path=path, position=tileEntity.Position, uuid=None, resultType=NBTResultsEntry.TileEntityResult)
def getItemStackVersionFromEntities(self): for listTag in self.rootTag["Entities"], self.rootTag["TileEntities"]: for name, tag, path in nbt.walk(listTag): if ItemRef.tagIsItem(tag): if tag["id"].tagID == nbt.ID_STRING: return VERSION_1_8 if tag["id"].tagID == nbt.ID_SHORT: return VERSION_1_7 # No itemstacks - use version 1.8 since ItemIDs won't need to # be added to the root tag. return VERSION_1_8
def getItemStackVersionFromEntities(self): for listTag in self.rootTag["Entities"], self.rootTag["TileEntities"]: for name, tag, path in nbt.walk(listTag): if ItemStackRef.tagIsItemStack(tag): if tag["id"].tagID == nbt.ID_STRING: return VERSION_1_8 if tag["id"].tagID == nbt.ID_SHORT: return VERSION_1_7 # No itemstacks - use version 1.8 since ItemIDs won't need to # be added to the root tag. return VERSION_1_8
def _findInChunk(chunk): tag = chunk.rootTag for name, subtag, path in nbt.walk(tag): if len(path) >= 2 and path[0] == "Level": if path[1] in ("Entities", "TileEntities"): continue result = _findTag(name, subtag, path) if result: name, path, value = result self.resultsModel.addEntry(tagName=name, value=value, ID="chunk", path=path, position=chunk.chunkPosition, uuid=None, resultType=NBTResultsEntry.ChunkResult, dimension=self.editorSession.currentDimension)
def _findEntitiesInChunk(chunk): for entity in chunk.Entities: if entity.Position not in selection: continue if len(targetEntityIDs) and entity.id not in targetEntityIDs: continue try: uuid = entity.UUID except KeyError: uuid = None # Don't want to use find/replace on entities without UUIDs if not searchNames and not searchValues: # Finding entities only self.resultsModel.addEntry( tagName="id", value=entity.id, ID=entity.id, path=[], position=entity.Position, uuid=uuid, resultType=NBTResultsEntry.EntityResult, dimension=self.editorSession.currentDimension) continue tag = entity.raw_tag() for name, subtag, path in nbt.walk(tag): result = _findTag(name, subtag, path) if result: name, path, value = result self.resultsModel.addEntry( tagName=name, value=value, ID=entity.id, path=path, position=entity.Position, uuid=uuid, resultType=NBTResultsEntry.EntityResult, dimension=self.editorSession.currentDimension)
def _findInChunk(chunk): tag = chunk.rootTag for name, subtag, path in nbt.walk(tag): if len(path) >= 2 and path[0] == "Level": if path[1] in ("Entities", "TileEntities"): continue result = _findTag(name, subtag, path) if result: name, path, value = result self.resultsModel.addEntry( tagName=name, value=value, ID="chunk", path=path, position=chunk.chunkPosition, uuid=None, resultType=NBTResultsEntry.ChunkResult, dimension=self.editorSession.currentDimension)
def _findEntitiesInChunk(chunk): for entity in chunk.Entities: if entity.Position not in selection: continue if len(targetEntityIDs) and entity.id not in targetEntityIDs: continue try: uuid = entity.UUID except KeyError: uuid = None # Don't want to use find/replace on entities without UUIDs if not searchNames and not searchValues: # Finding entities only self.resultsModel.addEntry(tagName="id", value=entity.id, ID=entity.id, path=[], position=entity.Position, uuid=uuid, resultType=NBTResultsEntry.EntityResult, dimension=self.editorSession.currentDimension) continue tag = entity.raw_tag() for name, subtag, path in nbt.walk(tag): result = _findTag(name, subtag, path) if result: name, path, value = result self.resultsModel.addEntry(tagName=name, value=value, ID=entity.id, path=path, position=entity.Position, uuid=uuid, resultType=NBTResultsEntry.EntityResult, dimension=self.editorSession.currentDimension)