Skip to content

Commit 3c7d42f

Browse files
committed
Move mod download to avoid black screen issue.
1 parent 5495e30 commit 3c7d42f

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

.idea/compiler.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/main/java/pojlib/instance/MinecraftInstance.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ public List<String> generateLaunchArgs(MinecraftAccount account) {
106106
}
107107

108108
public void updateOrDownloadsMods() {
109+
API_V1.finishedDownloading = false;
110+
new Thread(()->{
109111
try {
110112
File mods = new File(Constants.USER_HOME + "/mods-new.json");
111113
File modsOld = new File(Constants.USER_HOME + "/mods.json");
@@ -142,6 +144,7 @@ public void updateOrDownloadsMods() {
142144
boolean downloadAll = !(new File(Constants.MC_DIR + "/mods/" + this.versionName).exists());
143145
for (String download : downloads) {
144146
if(!Objects.equals(versions.get(i), ((JsonObject) objOld.getAsJsonArray(versionName).get(i)).getAsJsonPrimitive("version").getAsString()) || downloadAll) {
147+
API_V1.currentDownload = name.get(i);
145148
DownloadUtils.downloadFile(download, new File(Constants.MC_DIR + "/mods/" + this.versionName + "/" + name.get(i) + ".jar"));
146149
}
147150
i++;
@@ -156,6 +159,7 @@ public void updateOrDownloadsMods() {
156159
FileUtil.write(modsOld.getAbsolutePath(), buffer);
157160
int i = 0;
158161
for (String download : downloads) {
162+
API_V1.currentDownload = name.get(i);
159163
DownloadUtils.downloadFile(download, new File(Constants.MC_DIR + "/mods/" + this.versionName + "/" + name.get(i) + ".jar"));
160164
i++;
161165
}
@@ -164,12 +168,11 @@ public void updateOrDownloadsMods() {
164168

165169
if(customMods.exists()) {
166170
for(CustomMods.InstanceMods instMods : customModsObj.instances) {
167-
System.out.println("Before mod download | Line 145");
168171
if(!instMods.version.equals(this.versionName)) {
169172
continue;
170173
}
171174
for(CustomMods.ModInfo info : instMods.mods) {
172-
System.out.println("Before mod download | Line 150");
175+
API_V1.currentDownload = info.name;
173176
DownloadUtils.downloadFile(info.url, new File(Constants.MC_DIR + "/mods/" + this.versionName + "/" + info.name + ".jar"));
174177
}
175178
}
@@ -178,6 +181,9 @@ public void updateOrDownloadsMods() {
178181
} catch (IOException e) {
179182
e.printStackTrace();
180183
}
184+
185+
API_V1.finishedDownloading = true;
186+
}).start();
181187
}
182188

183189
public void addCustomMod(String name, String version, String url) {
@@ -305,7 +311,6 @@ public boolean removeMod(String name) {
305311

306312
public void launchInstance(Activity activity, MinecraftAccount account) {
307313
try {
308-
updateOrDownloadsMods();
309314
JREUtils.redirectAndPrintJRELog();
310315
VLoader.setAndroidInitInfo(activity);
311316
VLoader.setEGLGlobal(JREUtils.getEGLContextPtr(), JREUtils.getEGLDisplayPtr(), JREUtils.getEGLConfigPtr());

0 commit comments

Comments
 (0)