Fixup some init order errors and work on able to enter world.
This commit is contained in:
@@ -22,11 +22,11 @@ package com.seibel.lod.core.handlers;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.seibel.lod.core.ModInfo;
|
||||
import com.seibel.lod.core.enums.rendering.FogDrawMode;
|
||||
|
||||
/**
|
||||
@@ -45,35 +45,36 @@ public class ReflectionHandler implements IReflectionHandler
|
||||
public static ReflectionHandler instance;
|
||||
|
||||
private Field ofFogField = null;
|
||||
private final Object mcOptionsObject;
|
||||
private Object mcOptionsObject;
|
||||
|
||||
private Boolean sodiumPresent = null;
|
||||
private boolean optifinePresent = false;
|
||||
|
||||
|
||||
|
||||
|
||||
private ReflectionHandler(Field[] optionFields, Object newMcOptionsObject)
|
||||
|
||||
@Override
|
||||
public void finishDelayedSetup()
|
||||
{
|
||||
mcOptionsObject = newMcOptionsObject;
|
||||
|
||||
setupFogField(optionFields);
|
||||
mcOptionsObject = SingletonHandler.get(IMinecraftClientWrapper.class).getOptionsObject();
|
||||
setupFogField(mcOptionsObject.getClass().getDeclaredFields());
|
||||
}
|
||||
|
||||
|
||||
private ReflectionHandler()
|
||||
{
|
||||
mcOptionsObject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param optionFields the fields that should contain "ofFogType"
|
||||
* @param newMcOptionsObject the object instance that contains "ofFogType"
|
||||
* @return the ReflectionHandler just created
|
||||
* @throws IllegalStateException if a ReflectionHandler already exists
|
||||
*/
|
||||
public static ReflectionHandler createSingleton(Field[] optionFields, Object newMcOptionsObject) throws IllegalStateException
|
||||
public static ReflectionHandler createSingleton() throws IllegalStateException
|
||||
{
|
||||
if (instance != null)
|
||||
{
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
instance = new ReflectionHandler(optionFields, newMcOptionsObject);
|
||||
instance = new ReflectionHandler();
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
+8
-6
@@ -148,12 +148,6 @@ public class DependencyHandler
|
||||
// (yes technically the binding isn't finished,
|
||||
// but this needs to be set to "true" so we can use "get")
|
||||
bindingFinished = true;
|
||||
|
||||
for (Class<?> interfaceKey : dependencies.keySet())
|
||||
{
|
||||
IBindable concreteObject = get(interfaceKey);
|
||||
concreteObject.finishDelayedSetup();
|
||||
}
|
||||
}
|
||||
|
||||
/** returns whether the finishBinding method has been called */
|
||||
@@ -161,4 +155,12 @@ public class DependencyHandler
|
||||
{
|
||||
return bindingFinished;
|
||||
}
|
||||
|
||||
public void runDelayedSetup() {
|
||||
for (Class<?> interfaceKey : dependencies.keySet())
|
||||
{
|
||||
IBindable concreteObject = get(interfaceKey);
|
||||
concreteObject.finishDelayedSetup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -88,5 +88,8 @@ public class SingletonHandler
|
||||
{
|
||||
return dependencyHandler.getBindingFinished();
|
||||
}
|
||||
|
||||
|
||||
public static void runDelayedSetup() {
|
||||
dependencyHandler.runDelayedSetup();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ public class DHWorld implements Closeable {
|
||||
public EventLoop eventLoop = new EventLoop(dhTickerThread, this::tick);
|
||||
|
||||
public DHWorld() {
|
||||
//Note: this changes the singleplayer lod save location.
|
||||
saveDir = DHFolderHandler.getCurrentWorldFolder();
|
||||
levels = new HashMap<>();
|
||||
}
|
||||
|
||||
@@ -31,8 +31,7 @@ public class DHFolderHandler {
|
||||
if (MC.hasSinglePlayerServer())
|
||||
{
|
||||
// local world
|
||||
IWorldWrapper serverWorld = MC.getWrappedServerWorld();
|
||||
dimensionFolder = new File(serverWorld.getSaveFolder().getCanonicalFile().getPath() + File.separatorChar + "lod");
|
||||
dimensionFolder = new File(MC.getSinglePlayerServerFolder(), "lod");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+3
-17
@@ -117,21 +117,7 @@ public interface IMinecraftClientWrapper extends IBindable
|
||||
*/
|
||||
void crashMinecraft(String errorMessage, Throwable exception);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Object getOptionsObject();
|
||||
|
||||
File getSinglePlayerServerFolder();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user