mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 02:55:17 +00:00
Clean up the mod loading context objects. There is only one ThreadLocal now.
**BREAKING CHANGE** FMLModLoadingContext is renamed to FMLJavaModLoadingContext. LanguageProviders can setup additional contextual data. Signed-off-by: cpw <[email protected]>
This commit is contained in:
8 files changed
+100
-95
No files matched your search
@@ -19,11 +19,15 @@
|
||||
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ModLoadingContext
|
||||
{
|
||||
private static ThreadLocal<ModLoadingContext> context = ThreadLocal.withInitial(ModLoadingContext::new);
|
||||
private Object languageExtension;
|
||||
|
||||
public static ModLoadingContext get() {
|
||||
return context.get();
|
||||
@@ -31,8 +35,9 @@ public class ModLoadingContext
|
||||
|
||||
private ModContainer activeContainer;
|
||||
|
||||
public void setActiveContainer(final ModContainer container) {
|
||||
public void setActiveContainer(final ModContainer container, final Object languageExtension) {
|
||||
this.activeContainer = container;
|
||||
this.languageExtension = languageExtension;
|
||||
}
|
||||
|
||||
public ModContainer getActiveContainer() {
|
||||
@@ -49,4 +54,17 @@ public class ModLoadingContext
|
||||
getActiveContainer().registerExtensionPoint(point, extension);
|
||||
}
|
||||
|
||||
public void registerConfig(ModConfig.Type type, ForgeConfigSpec spec) {
|
||||
getActiveContainer().addConfig(new ModConfig(type, spec, getActiveContainer()));
|
||||
}
|
||||
|
||||
public void registerConfig(ModConfig.Type type, ForgeConfigSpec spec, String fileName) {
|
||||
getActiveContainer().addConfig(new ModConfig(type, spec, getActiveContainer(), fileName));
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T extension() {
|
||||
return (T)languageExtension;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user