Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/net/minecraftforge/common/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* The mod id that this configuration is associated with.
*/
String modid();
String modid() default "";
/**
* A user friendly name for the config file,
* the default will be modid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData;
import net.minecraftforge.fml.common.discovery.asm.ModAnnotation.EnumHolder;

import com.cleanroommc.discovery.CleanroomModDiscoverer;

import org.apache.commons.lang3.StringUtils;

public class ConfigManager
Expand Down Expand Up @@ -113,6 +115,19 @@ public static void loadData(ASMDataTable data)
for (ASMData target : data.getAll(Config.class))
{
String modid = (String)target.getAnnotationInfo().get("modid");
if (modid == null) {
var containedMods = target.getCandidate().getContainedMods();
if (containedMods != null && containedMods.isEmpty()) {
modid = containedMods.getFirst().getModId();
} else {
modid = CleanroomModDiscoverer.instance()
.modFromSource(target.getCandidate().getModContainer());
if (modid == null) throw new IllegalStateException(
"Could not infer the modid for the config " + target.getClassName()
);
}
}

Multimap<Config.Type, ASMData> map = asm_data.computeIfAbsent(modid, k -> ArrayListMultimap.create());

EnumHolder tholder = (EnumHolder)target.getAnnotationInfo().get("type");
Expand Down Expand Up @@ -460,4 +475,4 @@ public static void sync(Class<?> configClass) {
cfg.save();
}

}
}