(No Fabric) Update the DependencyHandler to support circular references

This commit is contained in:
James Seibel
2022-03-05 17:41:37 -06:00
parent 96ac022cbf
commit 0b0a69aabe
3 changed files with 21 additions and 7 deletions
+1 -1
Submodule core updated: 2149da59df...58392a8ac1
@@ -68,16 +68,22 @@ public class ForgeMain implements LodForgeMethodCaller
private void init(final FMLCommonSetupEvent event)
{
// make sure the dependencies are set up before the mod needs them
LodCommonMain.initConfig();
LodCommonMain.startup(this, !FMLLoader.getDist().isClient());
ForgeDependencySetup.createInitialBindings();
ApiShared.LOGGER.info("Distant Horizons initializing...");
SingletonHandler.bind(IModChecker.class, ModChecker.INSTANCE);
// make sure the dependencies are set up before the mod needs them
ForgeDependencySetup.createInitialBindings();
ForgeDependencySetup.finishBinding();
// mod dependencies
if (ReflectionHandler.instance.optifinePresent()) {
ModAccessorHandler.bind(IOptifineAccessor.class, new OptifineAccessor());
}
ModAccessorHandler.finishBinding();
}
@@ -3,21 +3,29 @@ package com.seibel.lod.forge.wrappers;
import com.seibel.lod.common.wrappers.config.LodConfigWrapperSingleton;
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton;
import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker;
import com.seibel.lod.forge.wrappers.modAccessor.ModChecker;
/**
* Binds all necessary dependencies, so we
* Binds all necessary dependencies so we
* can access them in Core. <br>
* This needs to be called before any Core classes
* are loaded.
*
* @author James Seibel
* @author Ran
* @version 12-1-2021
* @version 3-5-2022
*/
public class ForgeDependencySetup
{
public static void createInitialBindings()
{
SingletonHandler.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE);
SingletonHandler.bind(IModChecker.class, ModChecker.INSTANCE);
}
public static void finishBinding()
{
SingletonHandler.finishBinding();
}
}