Skip to content

Commit 85961b0

Browse files
LostLumaProspector
authored andcommitted
Automatically detect parent relationships for generated mods (#838)
Signed-off-by: Lilly Rose Berner <lilly@lostluma.net> - Make generated mods appear as children of their containing mod
1 parent c41200e commit 85961b0

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

  • src/main/java/com/terraformersmc/modmenu/util/mod/fabric

src/main/java/com/terraformersmc/modmenu/util/mod/fabric/FabricMod.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ public FabricMod(ModContainer modContainer, Set<String> modpackMods) {
9393
allowsUpdateChecks = CustomValueUtil.getBoolean("update_checker", modMenuObject).orElse(true);
9494
}
9595

96+
boolean isGenerated = CustomValueUtil.getBoolean("fabric-loom:generated", metadata).orElse(false);
97+
98+
/* Automatically set the mod containing a Loom-generated library as its parent */
99+
if (isGenerated && parentId.isEmpty() && container.getContainingMod().isPresent()) {
100+
ModContainer inside = container.getContainingMod().get();
101+
parentId = Optional.of(inside.getMetadata().getId());
102+
}
96103
this.modMenuData = new ModMenuData(badgeNames, parentId, parentData, id);
97104

98105
/* Hardcode parents and badges for Fabric API & Fabric Loader */
@@ -119,10 +126,7 @@ public FabricMod(ModContainer modContainer, Set<String> modpackMods) {
119126
badges.add(Badge.CLIENT);
120127
}
121128

122-
if (OptionalUtil.isPresentAndTrue(CustomValueUtil.getBoolean(
123-
"fabric-loom:generated",
124-
metadata
125-
)) || "java".equals(id)) {
129+
if (isGenerated || "java".equals(id)) {
126130
badges.add(Badge.LIBRARY);
127131
}
128132

0 commit comments

Comments
 (0)