Fix config screen crashing because no category is defined if no pack is installed
This commit is contained in:
parent
4a23568235
commit
7939fd4861
12
build.gradle
12
build.gradle
@ -17,6 +17,7 @@ repositories {
|
|||||||
maven { url = "https://maven.dblsaiko.net/"; name = "dblsaiko" }
|
maven { url = "https://maven.dblsaiko.net/"; name = "dblsaiko" }
|
||||||
maven { url = "https://minecraft.curseforge.com/api/maven"; name = "CurseForge" }
|
maven { url = "https://minecraft.curseforge.com/api/maven"; name = "CurseForge" }
|
||||||
maven { url = 'https://maven.terraformersmc.com/'; name = "ModMenu" }
|
maven { url = 'https://maven.terraformersmc.com/'; name = "ModMenu" }
|
||||||
|
maven { url = "https://maven.shedaniel.me/"; name = "Cloth" }
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -26,18 +27,19 @@ dependencies {
|
|||||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||||
|
|
||||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:0.30.3+1.16"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:0.32.5+1.16"
|
||||||
|
|
||||||
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
|
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
|
||||||
// You may need to force-disable transitiveness on them.
|
// You may need to force-disable transitiveness on them.
|
||||||
modCompile("com.terraformersmc:modmenu:1.16.7")
|
modCompile("com.terraformersmc:modmenu:1.16.8")
|
||||||
|
|
||||||
include modApi("me.shedaniel.cloth:config-2:4.8.3")
|
include modApi("me.shedaniel.cloth:cloth-config-fabric:4.+")
|
||||||
|
|
||||||
modApi "io.github.cottonmc:LibCD:3.0.3+1.16.3"
|
modApi "io.github.cottonmc:LibCD:3.0.3+1.16.3"
|
||||||
modCompile "grondag:frex-mc116:4.0+"
|
modCompile "grondag:frex-mc116:+"
|
||||||
modCompile("grondag:canvas-mc116:1.0.+") {
|
modCompile("grondag:canvas-mc116:+") {
|
||||||
exclude(group: "io.github.prospector")
|
exclude(group: "io.github.prospector")
|
||||||
|
exclude(group: "me.shedaniel.cloth")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://modmuss50.me/fabric.html
|
# check these on https://modmuss50.me/fabric.html
|
||||||
minecraft_version=1.16.5
|
minecraft_version=1.16.5
|
||||||
yarn_mappings=1.16.5+build.4
|
yarn_mappings=1.16.5+build.6
|
||||||
loader_version=0.11.1
|
loader_version=0.11.3
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.4.0
|
mod_version=1.4.1
|
||||||
maven_group=io.gitlab.jfronny
|
maven_group=io.gitlab.jfronny
|
||||||
archives_base_name=respackopts
|
archives_base_name=respackopts
|
@ -9,8 +9,11 @@ import me.shedaniel.clothconfig2.api.ConfigCategory;
|
|||||||
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.screen.FatalErrorScreen;
|
import net.minecraft.client.gui.screen.FatalErrorScreen;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public class ModMenuCompat implements ModMenuApi {
|
public class ModMenuCompat implements ModMenuApi {
|
||||||
@Override
|
@Override
|
||||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||||
@ -25,10 +28,16 @@ public class ModMenuCompat implements ModMenuApi {
|
|||||||
Respackopts.save();
|
Respackopts.save();
|
||||||
MinecraftClient.getInstance().reloadResources();
|
MinecraftClient.getInstance().reloadResources();
|
||||||
});
|
});
|
||||||
|
AtomicBoolean categoryAdded = new AtomicBoolean(false);
|
||||||
Respackopts.resPackMetas.forEach((s, v) -> {
|
Respackopts.resPackMetas.forEach((s, v) -> {
|
||||||
|
categoryAdded.set(true);
|
||||||
ConfigCategory config = builder.getOrCreateCategory(new TranslatableText("respackopts.title." + v.id));
|
ConfigCategory config = builder.getOrCreateCategory(new TranslatableText("respackopts.title." + v.id));
|
||||||
Respackopts.factory.buildCategory(v.conf, v.id, new JfConfigCategoryPrimary(config), entryBuilder, "");
|
Respackopts.factory.buildCategory(v.conf, v.id, new JfConfigCategoryPrimary(config), entryBuilder, "");
|
||||||
});
|
});
|
||||||
|
if (!categoryAdded.get()) {
|
||||||
|
builder.getOrCreateCategory(new TranslatableText("respackopts.mainconfig"))
|
||||||
|
.addEntry(entryBuilder.startTextDescription(new TranslatableText("respackopts.noPack")).build());
|
||||||
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
catch (Throwable t) {
|
catch (Throwable t) {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
"respackopts.loadFailed": "Failed to load resourcepacks",
|
"respackopts.loadFailed": "Failed to load resourcepacks",
|
||||||
"respackopts.loadError": "There is an issue with the resourcepack configs. Please take a look at the game log",
|
"respackopts.loadError": "There is an issue with the resourcepack configs. Please take a look at the game log",
|
||||||
"respackopts.configure": "Configure",
|
"respackopts.configure": "Configure",
|
||||||
"respackopts.mainconfig": "ResPack Opts",
|
"respackopts.mainconfig": "ResPackOpts",
|
||||||
"respackopts.invalid": "Invalid value"
|
"respackopts.invalid": "Invalid value",
|
||||||
|
"respackopts.noPack": "No resource pack that supports RPO could be found. Install one and it will appear here"
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user