diff --git a/src/mcedit2/editorapp.py b/src/mcedit2/editorapp.py index 2ac1743..85e3bad 100644 --- a/src/mcedit2/editorapp.py +++ b/src/mcedit2/editorapp.py @@ -647,31 +647,6 @@ class MCEditApp(QtGui.QApplication): tab = self.currentTab() return getattr(tab, 'editorSession', None) - def getResourceLoaderForFilename(self, filename): - # Is this world inside a MultiMC instance? - filename = os.path.normpath(filename) - installs = minecraftinstall.GetInstalls() - for instance in installs.instances: - savesFolder = os.path.normpath(instance.saveFileDir) - if filename.startswith(savesFolder): - return instance.getResourceLoader() - - # Nope. Use the version and respack chosen in the world list. - # ... should search for installs matching this one, but vanilla installs are still multi-version... - return self.getSelectedResourceLoader() - - def getSelectedResourceLoader(self): - i = minecraftinstall.currentInstallOption.value() - if i == -1: - return minecraftinstall.GetInstalls().getDefaultResourceLoader() - - install = minecraftinstall.GetInstalls().getInstall(i) - v = minecraftinstall.currentVersionOption.value() - if not v: - v = list(install.versions)[0] - p = minecraftinstall.currentResourcePackOption.value() or None - return install.getResourceLoader(v, p) - def loadFile(self, filename, readonly=False): self.hideWorldList() fileLoadingDialog = QtGui.QProgressDialog(self.tr("Loading world..."), @@ -692,7 +667,7 @@ class MCEditApp(QtGui.QApplication): fileLoadingDialog.setLabelText(status) try: - resourceLoader = self.getResourceLoaderForFilename(filename) + resourceLoader = minecraftinstall.getResourceLoaderForFilename(filename) configuredBlocks = self.configureBlocksDialog.getConfiguredBlocks() session = EditorSession(filename, resourceLoader, configuredBlocks, readonly=readonly, progressCallback=callback) self.undoGroup.addStack(session.undoStack) diff --git a/src/mcedit2/util/minecraftinstall.py b/src/mcedit2/util/minecraftinstall.py index 16b2cd0..9a1620e 100644 --- a/src/mcedit2/util/minecraftinstall.py +++ b/src/mcedit2/util/minecraftinstall.py @@ -27,6 +27,32 @@ currentMMCInstanceOption = settings.Settings().getOption("minecraft_installs/cur _installs = None +def getResourceLoaderForFilename(filename): + # Is this world inside a MultiMC instance? + filename = os.path.normpath(filename) + installs = GetInstalls() + for instance in installs.instances: + savesFolder = os.path.normpath(instance.saveFileDir) + if filename.startswith(savesFolder): + return instance.getResourceLoader() + + # Nope. Use the version and respack chosen in the world list. + # ... should search for installs matching this one, but vanilla installs are still multi-version... + return getSelectedResourceLoader() + +def getSelectedResourceLoader(): + i = currentInstallOption.value() + if i == -1: + return GetInstalls().getDefaultResourceLoader() + + install = GetInstalls().getInstall(i) + v = currentVersionOption.value() + if not v: + v = list(install.versions)[0] + p = currentResourcePackOption.value() or None + return install.getResourceLoader(v, p) + + def GetInstalls(): global _installs if _installs is None: diff --git a/src/mcedit2/worldlist.py b/src/mcedit2/worldlist.py index 59eed6d..bb61058 100644 --- a/src/mcedit2/worldlist.py +++ b/src/mcedit2/worldlist.py @@ -367,7 +367,7 @@ class WorldListWidget(QtGui.QDialog): try: worldEditor = worldeditor.WorldEditor(filename, readonly=True) - resLoader = QtGui.qApp.getResourceLoaderForFilename(filename) + resLoader = minecraftinstall.getResourceLoaderForFilename(filename) blockModels = BlockModels(worldEditor.blocktypes, resLoader) textureAtlas = TextureAtlas(worldEditor, resLoader, blockModels)