diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/DependencySetup.java b/common/src/main/java/com/seibel/lod/common/wrappers/DependencySetup.java index 9699a6316..a6bdb9809 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/DependencySetup.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/DependencySetup.java @@ -26,7 +26,7 @@ import com.seibel.lod.common.wrappers.minecraft.MinecraftClientWrapper; import com.seibel.lod.common.wrappers.minecraft.MinecraftRenderWrapper; import com.seibel.lod.core.handlers.IReflectionHandler; import com.seibel.lod.core.handlers.ReflectionHandler; -import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; +import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector; import com.seibel.lod.core.wrapperInterfaces.IVersionConstants; import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory; import com.seibel.lod.core.wrapperInterfaces.config.ILodConfigWrapperSingleton; @@ -36,7 +36,6 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.server.dedicated.DedicatedServer; /** * Binds all necessary dependencies, so we @@ -51,23 +50,23 @@ import net.minecraft.server.dedicated.DedicatedServer; public class DependencySetup { public static void createSharedBindings() { - SingletonHandler.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE); // TODO: Remove - SingletonHandler.bind(IConfigWrapper.class, ConfigWrapper.INSTANCE); - SingletonHandler.bind(IVersionConstants.class, VersionConstants.INSTANCE); - SingletonHandler.bind(IWrapperFactory.class, WrapperFactory.INSTANCE); + SingletonInjector.INSTANCE.bind(ILodConfigWrapperSingleton.class, LodConfigWrapperSingleton.INSTANCE); // TODO: Remove + SingletonInjector.INSTANCE.bind(IConfigWrapper.class, ConfigWrapper.INSTANCE); + SingletonInjector.INSTANCE.bind(IVersionConstants.class, VersionConstants.INSTANCE); + SingletonInjector.INSTANCE.bind(IWrapperFactory.class, WrapperFactory.INSTANCE); DependencySetupDoneCheck.isDone = true; } @Environment(EnvType.SERVER) public static void createServerBindings() { - SingletonHandler.bind(IMinecraftSharedWrapper.class, MinecraftDedicatedServerWrapper.INSTANCE); + SingletonInjector.INSTANCE.bind(IMinecraftSharedWrapper.class, MinecraftDedicatedServerWrapper.INSTANCE); } @Environment(EnvType.CLIENT) public static void createClientBindings() { - SingletonHandler.bind(IMinecraftClientWrapper.class, MinecraftClientWrapper.INSTANCE); - SingletonHandler.bind(IMinecraftSharedWrapper.class, MinecraftClientWrapper.INSTANCE); - SingletonHandler.bind(IMinecraftRenderWrapper.class, MinecraftRenderWrapper.INSTANCE); - SingletonHandler.bind(IReflectionHandler.class, ReflectionHandler.createSingleton()); + SingletonInjector.INSTANCE.bind(IMinecraftClientWrapper.class, MinecraftClientWrapper.INSTANCE); + SingletonInjector.INSTANCE.bind(IMinecraftSharedWrapper.class, MinecraftClientWrapper.INSTANCE); + SingletonInjector.INSTANCE.bind(IMinecraftRenderWrapper.class, MinecraftRenderWrapper.INSTANCE); + SingletonInjector.INSTANCE.bind(IReflectionHandler.class, ReflectionHandler.createSingleton()); } } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailWrapper.java index 8573c3023..a04184730 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/block/BlockDetailWrapper.java @@ -27,7 +27,6 @@ import com.seibel.lod.common.wrappers.McObjectConverter; import com.seibel.lod.common.wrappers.chunk.ChunkWrapper; import com.seibel.lod.core.config.Config; import com.seibel.lod.core.enums.ELodDirection; -import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; import com.seibel.lod.core.objects.DHBlockPos; import com.seibel.lod.core.util.ColorUtil; import com.seibel.lod.core.wrapperInterfaces.block.IBlockDetailWrapper; diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java index ceec9a959..79b3bbc47 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftRenderWrapper.java @@ -30,7 +30,7 @@ import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.systems.RenderSystem; import com.seibel.lod.core.objects.DHChunkPos; import com.seibel.lod.common.wrappers.misc.LightMapWrapper; -import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorHandler; +import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorInjector; import com.seibel.lod.core.logging.DhLoggerBuilder; import com.seibel.lod.core.wrapperInterfaces.misc.ILightMapWrapper; @@ -52,7 +52,6 @@ import net.fabricmc.api.Environment; import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.FogRenderer; -import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.core.BlockPos; import net.minecraft.world.effect.MobEffects; @@ -224,11 +223,11 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper public boolean usingBackupGetVanillaRenderedChunks = false; @Override public HashSet getVanillaRenderedChunks() { - ISodiumAccessor sodium = ModAccessorHandler.get(ISodiumAccessor.class); + ISodiumAccessor sodium = ModAccessorInjector.INSTANCE.get(ISodiumAccessor.class); if (sodium != null) { return sodium.getNormalRenderedChunks(); } - IOptifineAccessor optifine = ModAccessorHandler.get(IOptifineAccessor.class); + IOptifineAccessor optifine = ModAccessorInjector.INSTANCE.get(IOptifineAccessor.class); if (optifine != null) { HashSet pos = optifine.getNormalRenderedChunks(); if (pos == null) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/world/LevelWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/world/LevelWrapper.java index bde65634c..fdb7784e3 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/world/LevelWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/world/LevelWrapper.java @@ -24,10 +24,9 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import com.seibel.lod.common.wrappers.minecraft.MinecraftClientWrapper; -import com.seibel.lod.core.a7.world.IServerWorld; import com.seibel.lod.core.a7.world.WorldEnvironment; import com.seibel.lod.core.api.internal.a7.SharedApi; -import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; +import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector; import com.seibel.lod.core.objects.DHChunkPos; import com.seibel.lod.core.enums.ELevelType; import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper; @@ -41,7 +40,6 @@ import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.chunk.ChunkAccess; @@ -60,7 +58,7 @@ public class LevelWrapper implements ILevelWrapper private static final ConcurrentMap levelWrapperMap = new ConcurrentHashMap<>(); private final LevelAccessor level; public final ELevelType levelType; - private static final IMinecraftSharedWrapper MC = SingletonHandler.get(IMinecraftSharedWrapper.class); + private static final IMinecraftSharedWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class); public LevelWrapper(LevelAccessor newWorld) @@ -68,11 +66,11 @@ public class LevelWrapper implements ILevelWrapper level = newWorld; if (level.getClass() == ServerLevel.class) - levelType = ELevelType.ServerLevel; + levelType = ELevelType.SERVER_LEVEL; else if (level.getClass() == ClientLevel.class) - levelType = ELevelType.ClientLevel; + levelType = ELevelType.CLIENT_LEVEL; else - levelType = ELevelType.Unknown; + levelType = ELevelType.UNKNOWN; } @Environment(EnvType.CLIENT) @@ -172,7 +170,7 @@ public class LevelWrapper implements ILevelWrapper @Override public File getSaveFolder() throws UnsupportedOperationException { - if (levelType != ELevelType.ServerLevel) + if (levelType != ELevelType.SERVER_LEVEL) throw new UnsupportedOperationException("getSaveFolder can only be called for ServerWorlds."); ServerChunkCache chunkSource = ((ServerLevel) level).getChunkSource(); @@ -183,7 +181,7 @@ public class LevelWrapper implements ILevelWrapper /** @throws UnsupportedOperationException if the WorldWrapper isn't for a ServerWorld */ public ServerLevel getServerWorld() throws UnsupportedOperationException { - if (levelType != ELevelType.ServerLevel) + if (levelType != ELevelType.SERVER_LEVEL) throw new UnsupportedOperationException("getSaveFolder can only be called for ServerWorlds."); return (ServerLevel) level; diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index 8dc7e8b9f..ed9a3b969 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -28,11 +28,9 @@ import com.seibel.lod.core.builders.lodBuilding.LodBuilder; import com.seibel.lod.core.builders.lodBuilding.LodBuilderConfig; import com.seibel.lod.core.enums.config.EDistanceGenerationMode; import com.seibel.lod.core.enums.config.ELightGenerationMode; -import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; import com.seibel.lod.core.objects.lod.LodDimension; import com.seibel.lod.core.util.gridList.ArrayGridList; import com.seibel.lod.core.util.LodThreadFactory; -import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper; import com.seibel.lod.core.wrapperInterfaces.worldGeneration.AbstractBatchGenerationEnvionmentWrapper; diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightGetterAdaptor.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightGetterAdaptor.java index 01adb1c36..562ad247e 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightGetterAdaptor.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightGetterAdaptor.java @@ -19,7 +19,7 @@ package com.seibel.lod.common.wrappers.worldGeneration.mimicObject; -import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorHandler; +import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorInjector; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IStarlightAccessor; import net.minecraft.world.level.BlockGetter; @@ -36,7 +36,7 @@ public class LightGetterAdaptor implements LightChunkGetter { public LightGetterAdaptor(BlockGetter heightAccessor) { this.heightGetter = heightAccessor; - shouldReturnNull = ModAccessorHandler.get(IStarlightAccessor.class) != null; + shouldReturnNull = ModAccessorInjector.INSTANCE.get(IStarlightAccessor.class) != null; } public void setRegion(LightedWorldGenRegion region) { diff --git a/core b/core index cca82fd67..c7e4781a9 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit cca82fd67af45bff0e64ff56383790f7a529ad2f +Subproject commit c7e4781a95d6cbe968b3a79139f9274f9f59797b diff --git a/fabric/src/main/java/com/seibel/lod/fabric/FabricMain.java b/fabric/src/main/java/com/seibel/lod/fabric/FabricMain.java index cc1ab6c6d..a98ca763e 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/FabricMain.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/FabricMain.java @@ -20,11 +20,9 @@ package com.seibel.lod.fabric; import com.seibel.lod.common.LodCommonMain; -import com.seibel.lod.common.wrappers.DependencySetup; import com.seibel.lod.core.ModInfo; -import com.seibel.lod.core.api.internal.a7.SharedApi; -import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorHandler; -import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; +import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorInjector; +import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector; import com.seibel.lod.core.logging.DhLoggerBuilder; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor; @@ -35,14 +33,8 @@ import com.seibel.lod.fabric.wrappers.modAccessor.SodiumAccessor; import com.seibel.lod.fabric.wrappers.modAccessor.StarlightAccessor; import com.seibel.lod.fabric.wrappers.FabricDependencySetup; -import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.api.DedicatedServerModInitializer; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; -import net.minecraft.client.Minecraft; import org.apache.logging.log4j.Logger; -import java.lang.invoke.MethodHandles; - /** * Initialize and setup the Mod.
* If you are looking for the real start of the mod @@ -69,19 +61,17 @@ public class FabricMain LOGGER.info("Initializing Mod"); LodCommonMain.startup(null); FabricDependencySetup.createInitialBindings(); - FabricDependencySetup.finishBinding(); LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION); - if (SingletonHandler.get(IModChecker.class).isModLoaded("sodium")) { - ModAccessorHandler.bind(ISodiumAccessor.class, new SodiumAccessor()); + if (SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("sodium")) { + ModAccessorInjector.INSTANCE.bind(ISodiumAccessor.class, new SodiumAccessor()); } - if (SingletonHandler.get(IModChecker.class).isModLoaded("starlight")) { - ModAccessorHandler.bind(IStarlightAccessor.class, new StarlightAccessor()); + if (SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("starlight")) { + ModAccessorInjector.INSTANCE.bind(IStarlightAccessor.class, new StarlightAccessor()); } - if (SingletonHandler.get(IModChecker.class).isModLoaded("optifine")) { - ModAccessorHandler.bind(IOptifineAccessor.class, new OptifineAccessor()); + if (SingletonInjector.INSTANCE.get(IModChecker.class).isModLoaded("optifine")) { + ModAccessorInjector.INSTANCE.bind(IOptifineAccessor.class, new OptifineAccessor()); } - ModAccessorHandler.finishBinding(); LOGGER.info(ModInfo.READABLE_NAME + " Initialized"); } } diff --git a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/FabricDependencySetup.java b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/FabricDependencySetup.java index 57856c439..4c2294707 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/FabricDependencySetup.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/FabricDependencySetup.java @@ -19,7 +19,7 @@ package com.seibel.lod.fabric.wrappers; -import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; +import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker; import com.seibel.lod.fabric.wrappers.modAccessor.ModChecker; @@ -37,14 +37,10 @@ public class FabricDependencySetup { public static void createInitialBindings() { - SingletonHandler.bind(IModChecker.class, ModChecker.INSTANCE); + SingletonInjector.INSTANCE.bind(IModChecker.class, ModChecker.INSTANCE); } - - public static void finishBinding() { - SingletonHandler.finishBinding(); - } - + public static void runDelayedSetup() { - SingletonHandler.runDelayedSetup(); + SingletonInjector.INSTANCE.runDelayedSetup(); } } diff --git a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/modAccessor/SodiumAccessor.java b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/modAccessor/SodiumAccessor.java index 417bf6c0a..ccd8efea8 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/modAccessor/SodiumAccessor.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/modAccessor/SodiumAccessor.java @@ -23,7 +23,7 @@ import java.util.HashSet; import java.util.stream.Collectors; import com.seibel.lod.core.objects.DHChunkPos; -import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; +import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector; import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory; import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor; @@ -43,8 +43,8 @@ import net.minecraft.world.level.LevelHeightAccessor; #endif public class SodiumAccessor implements ISodiumAccessor { - private final IWrapperFactory factory = SingletonHandler.get(IWrapperFactory.class); - private final IMinecraftRenderWrapper MC_RENDER = SingletonHandler.get(IMinecraftRenderWrapper.class); + private final IWrapperFactory factory = SingletonInjector.INSTANCE.get(IWrapperFactory.class); + private final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class); @Override public String getModName() { diff --git a/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java b/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java index ee8bd2f16..75c45dd6f 100644 --- a/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java +++ b/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java @@ -26,7 +26,7 @@ import com.seibel.lod.common.wrappers.minecraft.MinecraftClientWrapper; import com.seibel.lod.core.ModInfo; import com.seibel.lod.core.api.internal.InternalApiShared; import com.seibel.lod.core.handlers.ReflectionHandler; -import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorHandler; +import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorInjector; import com.seibel.lod.core.logging.DhLoggerBuilder; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IOptifineAccessor; import com.seibel.lod.forge.wrappers.ForgeDependencySetup; @@ -49,7 +49,6 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fml.loading.FMLLoader; #if PRE_MC_1_17_1 import net.minecraftforge.fml.ExtensionPoint; #elif MC_1_17_1 @@ -85,7 +84,6 @@ public class ForgeMain implements LodForgeMethodCaller // LodCommonMain.startup(this, !FMLLoader.getDist().isClient()); LodCommonMain.startup(this); ForgeDependencySetup.createInitialBindings(); - ForgeDependencySetup.finishBinding(); LodCommonMain.initConfig(); LOGGER.info(ModInfo.READABLE_NAME + " initializing..."); } @@ -100,11 +98,9 @@ public class ForgeMain implements LodForgeMethodCaller private void onClientStart(final FMLClientSetupEvent event) { if (ReflectionHandler.instance.optifinePresent()) { - ModAccessorHandler.bind(IOptifineAccessor.class, new OptifineAccessor()); + ModAccessorInjector.bind(IOptifineAccessor.class, new OptifineAccessor()); } - ModAccessorHandler.finishBinding(); - #if PRE_MC_1_17_1 ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY, () -> (client, parent) -> GetConfigScreen.getScreen(parent)); diff --git a/forge/src/main/java/com/seibel/lod/forge/wrappers/ForgeDependencySetup.java b/forge/src/main/java/com/seibel/lod/forge/wrappers/ForgeDependencySetup.java index 7611aa7b4..c9ea56727 100644 --- a/forge/src/main/java/com/seibel/lod/forge/wrappers/ForgeDependencySetup.java +++ b/forge/src/main/java/com/seibel/lod/forge/wrappers/ForgeDependencySetup.java @@ -19,8 +19,7 @@ package com.seibel.lod.forge.wrappers; -import com.seibel.lod.common.LodCommonMain; -import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; +import com.seibel.lod.core.handlers.dependencyInjection.SingletonInjector; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker; import com.seibel.lod.forge.wrappers.modAccessor.ModChecker; @@ -38,11 +37,7 @@ public class ForgeDependencySetup { public static void createInitialBindings() { - SingletonHandler.bind(IModChecker.class, ModChecker.INSTANCE); + SingletonInjector.INSTANCE.bind(IModChecker.class, ModChecker.INSTANCE); } - public static void finishBinding() - { - SingletonHandler.finishBinding(); - } }