input)
{
this.onTestEvent(input);
if (input.value)
diff --git a/api/src/test/java/tests/EventInjectorTest.java b/api/src/test/java/tests/EventInjectorTest.java
index 70ad89118..67fb480cb 100644
--- a/api/src/test/java/tests/EventInjectorTest.java
+++ b/api/src/test/java/tests/EventInjectorTest.java
@@ -133,7 +133,7 @@ public class EventInjectorTest
oneTimeEventList = TEST_EVENT_HANDLER.getAll(AbstractDhApiCancelableOneTimeTestEvent.class);
for (int i = 0; i < oneTimeEventList.size(); i++)
{
- Assert.assertEquals("Event not fired for object ["+i+"].", true, oneTimeEventList.get(i).getTestValue());
+ Assert.assertEquals("Event not fired for object [" + i + "].", true, oneTimeEventList.get(i).getTestValue());
}
diff --git a/api/src/test/java/tests/ExampleTest.java b/api/src/test/java/tests/ExampleTest.java
index de45feab0..150f77422 100644
--- a/api/src/test/java/tests/ExampleTest.java
+++ b/api/src/test/java/tests/ExampleTest.java
@@ -24,7 +24,7 @@ import org.junit.Test;
/**
* This is just a quick demo to confirm the testing system is set up correctly.
- *
+ *
* @author James Seibel
* @version 2022-9-5
*/
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/IReflectionHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/IReflectionHandler.java
index f20788af3..9755811e4 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/IReflectionHandler.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/IReflectionHandler.java
@@ -23,7 +23,7 @@ import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindab
/**
* A singleton used to get variables from methods
- * where they are private or potentially absent.
+ * where they are private or potentially absent.
* Specifically the fog setting used by Optifine or the
* presence/absence of other mods.
*
@@ -32,7 +32,7 @@ import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindab
* passing in interfaces), and it may be needed in the future if
* we find that reflection handlers need to be different for
* different MC versions.
- *
+ *
* @author James Seibel
* @version 2022-11-24
*/
@@ -40,7 +40,7 @@ public interface IReflectionHandler extends IBindable
{
/** @return if Sodium (or a sodium like) mod is present. */
boolean sodiumPresent();
-
+
boolean optifinePresent();
}
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/Initializer.java b/core/src/main/java/com/seibel/distanthorizons/core/Initializer.java
index a580e8d2a..3684e61a6 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/Initializer.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/Initializer.java
@@ -17,9 +17,9 @@ import org.apache.logging.log4j.Logger;
/** Handles first time Core setup. */
public class Initializer
{
- private static final Logger LOGGER = LogManager.getLogger(ModInfo.NAME+"-"+Initializer.class.getSimpleName());
+ private static final Logger LOGGER = LogManager.getLogger(ModInfo.NAME + "-" + Initializer.class.getSimpleName());
- public static void init()
+ public static void init()
{
// confirm that all referenced libraries are available to use
try
@@ -33,15 +33,15 @@ public class Initializer
}
catch (NoClassDefFoundError e)
{
- LOGGER.fatal("Critical programmer error: One or more libraries aren't present. Error: ["+e.getMessage()+"].");
+ LOGGER.fatal("Critical programmer error: One or more libraries aren't present. Error: [" + e.getMessage() + "].");
throw e;
}
- CompleteFullDataSourceLoader unused2 = new CompleteFullDataSourceLoader(); // Auto register into the loader system
- HighDetailIncompleteFullDataSourceLoader unused3 = new HighDetailIncompleteFullDataSourceLoader(); // Auto register
- LowDetailIncompleteFullDataSourceLoader unused4 = new LowDetailIncompleteFullDataSourceLoader(); // Auto register
+ CompleteFullDataSourceLoader unused2 = new CompleteFullDataSourceLoader(); // Auto register into the loader system
+ HighDetailIncompleteFullDataSourceLoader unused3 = new HighDetailIncompleteFullDataSourceLoader(); // Auto register
+ LowDetailIncompleteFullDataSourceLoader unused4 = new LowDetailIncompleteFullDataSourceLoader(); // Auto register
// link Core's config to the API
DhApi.Delayed.configs = DhApiConfig.INSTANCE;
@@ -49,5 +49,6 @@ public class Initializer
DhApi.Delayed.worldProxy = DhApiWorldProxy.INSTANCE;
DhApi.Delayed.renderProxy = DhApiRenderProxy.INSTANCE;
- }
+ }
+
}
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/ReflectionHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/ReflectionHandler.java
index e8e385b28..2690144b7 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/ReflectionHandler.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/ReflectionHandler.java
@@ -26,12 +26,12 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.AbstractOpt
import org.apache.logging.log4j.Logger;
/**
- * A singleton used to determine if a class is present or
- * access variables from methods where they are private
+ * A singleton used to determine if a class is present or
+ * access variables from methods where they are private
* or potentially absent.
- *
+ *
* For example: presence/absence of Optifine.
- *
+ *
* @author James Seibel
* @version 2022-11-24
*/
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/DhApiConfig.java b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/DhApiConfig.java
index 3713ac7e1..46c9bc022 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/DhApiConfig.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/DhApiConfig.java
@@ -10,21 +10,21 @@ public class DhApiConfig implements IDhApiConfig
{
public static final DhApiConfig INSTANCE = new DhApiConfig();
- private DhApiConfig() { }
+ private DhApiConfig() { }
@Override
public IDhApiGraphicsConfig graphics() { return DhApiGraphicsConfig.INSTANCE; }
- @Override
+ @Override
public IDhApiWorldGenerationConfig worldGenerator() { return DhApiWorldGenerationConfig.INSTANCE; }
@Override
public IDhApiMultiplayerConfig multiplayer() { return DhApiMultiplayerConfig.INSTANCE; }
@Override
public IDhApiMultiThreadingConfig multiThreading() { return DhApiMultiThreadingConfig.INSTANCE; }
- @Override
+ @Override
public IDhApiGpuBuffersConfig gpuBuffers() { return DhApiGpuBuffersConfig.INSTANCE; }
- @Override
+ @Override
public IDhApiDebuggingConfig debugging() { return DhApiDebuggingConfig.INSTANCE; }
}
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiGraphicsConfig.java b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiGraphicsConfig.java
index 867d6484c..c07bb82cf 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiGraphicsConfig.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/client/DhApiGraphicsConfig.java
@@ -106,7 +106,7 @@ public class DhApiGraphicsConfig implements IDhApiGraphicsConfig
//===========================//
// advanced graphic settings //
//===========================//
-
+
// @Override
// public IDhApiConfigValue getDisableDirectionalCulling()
// { return new DhApiConfigValue(AdvancedGraphics.disableDirectionalCulling); }
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/common/DhApiWorldGenerationConfig.java b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/common/DhApiWorldGenerationConfig.java
index b69711a46..ef0f93dd3 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/common/DhApiWorldGenerationConfig.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/config/common/DhApiWorldGenerationConfig.java
@@ -36,7 +36,7 @@ import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGenerat
*/
public class DhApiWorldGenerationConfig implements IDhApiWorldGenerationConfig
{
- public static DhApiWorldGenerationConfig INSTANCE = new DhApiWorldGenerationConfig();
+ public static DhApiWorldGenerationConfig INSTANCE = new DhApiWorldGenerationConfig();
private DhApiWorldGenerationConfig() { }
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/data/DhApiTerrainDataRepo.java b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/data/DhApiTerrainDataRepo.java
index bc27d82bd..1968658ee 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/data/DhApiTerrainDataRepo.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/api/external/methods/data/DhApiTerrainDataRepo.java
@@ -55,7 +55,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
- private DhApiTerrainDataRepo()
+ private DhApiTerrainDataRepo()
{
}
@@ -67,12 +67,12 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
//================//
@Override
- public DhApiResult getSingleDataPointAtBlockPos(IDhApiLevelWrapper levelWrapper, int blockPosX, int blockPosY, int blockPosZ)
+ public DhApiResult getSingleDataPointAtBlockPos(IDhApiLevelWrapper levelWrapper, int blockPosX, int blockPosY, int blockPosZ)
{
return getTerrainDataAtBlockYPos(levelWrapper, new DhLodPos(LodUtil.BLOCK_DETAIL_LEVEL, blockPosX, blockPosZ), blockPosY);
}
@Override
- public DhApiResult getColumnDataAtBlockPos(IDhApiLevelWrapper levelWrapper, int blockPosX, int blockPosZ)
+ public DhApiResult getColumnDataAtBlockPos(IDhApiLevelWrapper levelWrapper, int blockPosX, int blockPosZ)
{
return getTerrainDataColumnArray(levelWrapper, new DhLodPos(LodUtil.BLOCK_DETAIL_LEVEL, blockPosX, blockPosZ), null);
}
@@ -112,14 +112,14 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
}
}
- /**
+ /**
* Returns all the block columns represented by the given {@link DhLodPos}.
* IE, A position with the detail level:
* 0 (block): will return a 1x1 matrix of data. (don't do this, we have a specific method for that.)
* 1 (2 blocks): will return a 2x2 matrix of data.
* 4 (chunk): will return a 16x16 matrix of data.
- *
- * will stop and return the in progress data if any errors are encountered.
+ *
+ * will stop and return the in progress data if any errors are encountered.
*/
private static DhApiResult getTerrainDataOverAreaForPositionDetailLevel(IDhApiLevelWrapper levelWrapper, DhLodPos requestedAreaPos)
{
@@ -151,10 +151,10 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
return dataColumnsReturned != 0 ? DhApiResult.createSuccess("[" + dataColumnsReturned + "] columns returned.", returnArray) : DhApiResult.createSuccess("No data found.", returnArray);
}
- /**
+ /**
* If nullableBlockYPos is null: returns every datapoint in the column defined by the DhLodPos.
* If nullableBlockYPos is NOT null: returns a single datapoint in the column defined by the DhLodPos which contains the block Y position.
- *
+ *
* If the ApiResult is successful there will be an array of data.
* The returned array will be empty if no data could be retrieved.
*/
@@ -170,7 +170,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
{
// custom level wrappers aren't supported,
// the API user must get a level wrapper from our code somewhere
- return DhApiResult.createFail("Unsupported ["+IDhApiLevelWrapper.class.getSimpleName()+"] implementation, only the core class ["+ IDhLevel.class.getSimpleName()+"] is a valid parameter.");
+ return DhApiResult.createFail("Unsupported [" + IDhApiLevelWrapper.class.getSimpleName() + "] implementation, only the core class [" + IDhLevel.class.getSimpleName() + "] is a valid parameter.");
}
ILevelWrapper coreLevelWrapper = (ILevelWrapper) levelWrapper;
@@ -256,7 +256,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
catch (InterruptedException | ExecutionException e)
{
// shouldn't normally happen, but just in case
- LOGGER.error("Unexpected exception in getTerrainDataColumnArray. Error: ["+e.getMessage()+"]", e);
+ LOGGER.error("Unexpected exception in getTerrainDataColumnArray. Error: [" + e.getMessage() + "]", e);
return DhApiResult.createFail("Unexpected exception: [" + e.getMessage() + "].");
}
}
@@ -270,7 +270,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
int height = FullDataPointUtil.getHeight(dataPoint);
int topY = bottomY + height;
- return new DhApiTerrainDataPoint(detailLevel,
+ return new DhApiTerrainDataPoint(detailLevel,
FullDataPointUtil.getLight(dataPoint), topY, bottomY,
blockState, biomeWrapper);
}
@@ -282,7 +282,8 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
//====================//
@Override
- public DhApiResult raycast(IDhApiLevelWrapper levelWrapper,
+ public DhApiResult raycast(
+ IDhApiLevelWrapper levelWrapper,
double rayOriginX, double rayOriginY, double rayOriginZ,
float rayDirectionX, float rayDirectionY, float rayDirectionZ,
int maxRayBlockLength)
@@ -340,7 +341,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
{
// does this LOD contain the given Y position?
Vec3i dataPointPos = new Vec3i(columnPos.x, dataPoint.bottomYBlockPos, columnPos.z);
- if (exactPos.y >= dataPoint.bottomYBlockPos && exactPos.y <= dataPoint.topYBlockPos)
+ if (exactPos.y >= dataPoint.bottomYBlockPos && exactPos.y <= dataPoint.topYBlockPos)
{
if (closetFoundDataPoint == null)
{
@@ -423,7 +424,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
{
if (!(levelWrapper instanceof ILevelWrapper))
{
- return DhApiResult.createFail("Level wrapper needs to be an instance of ["+IDhApiLevelWrapper.class.getSimpleName()+"].");
+ return DhApiResult.createFail("Level wrapper needs to be an instance of [" + IDhApiLevelWrapper.class.getSimpleName() + "].");
}
AbstractDhWorld dhWorld = SharedApi.getAbstractDhWorld();
if (dhWorld == null)
@@ -452,8 +453,8 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
// debug methods //
//===============//
- /**
- * This method is here for debugging the repo and isn't intended for normal use.
+ /**
+ * This method is here for debugging the repo and isn't intended for normal use.
* The method need to be async because pausing the main thread with a breakpoint and hot swapping will crash the program
*/
public static void asyncDebugMethod(IDhApiLevelWrapper levelWrapper, int blockPosX, int blockPosY, int blockPosZ)
@@ -476,7 +477,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
if (rayCast.payload != null && !rayCast.payload.pos.equals(currentDebugVec3i))
{
currentDebugVec3i = rayCast.payload.pos;
-
+
// get a string for the block
String blockString = "[NULL BLOCK]"; // shouldn't normally happen unless there is an issue with getting the terrain at the given position
if (rayCast.payload.dataPoint.blockStateWrapper != null)
@@ -487,10 +488,10 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
}
else
{
- blockString = "[AIR]";
+ blockString = "[AIR]";
}
}
-
+
LOGGER.info("raycast: " + currentDebugVec3i + "\t block: " + blockString);
}
else if (rayCast.payload == null && currentDebugVec3i != null)
@@ -504,7 +505,7 @@ public class DhApiTerrainDataRepo implements IDhApiTerrainDataRepo
}
catch (Exception e)
{
- LOGGER.error("Test method Error: ["+e.getMessage()+"]", e);
+ LOGGER.error("Test method Error: [" + e.getMessage() + "]", e);
}
finally
{
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java
index 37a4d8ed6..15e950e4a 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ClientApi.java
@@ -106,7 +106,7 @@ public class ClientApi
// world events //
//==============//
- /**
+ /**
* May be fired slightly before or after the associated
* {@link ClientApi#clientLevelLoadEvent(IClientLevelWrapper)} event
* depending on how the host mod loader functions.
@@ -123,7 +123,7 @@ public class ClientApi
SharedApi.setDhWorld(new DhClientWorld());
- LOGGER.info("Loading ["+this.waitingClientLevels.size()+"] waiting client level wrappers.");
+ LOGGER.info("Loading [" + this.waitingClientLevels.size() + "] waiting client level wrappers.");
for (IClientLevelWrapper level : this.waitingClientLevels)
{
this.clientLevelLoadEvent(level);
@@ -132,7 +132,7 @@ public class ClientApi
this.waitingClientLevels.clear();
}
}
-
+
public void onClientOnlyDisconnected()
{
if (MC.clientConnectedToDedicatedServer())
@@ -141,7 +141,7 @@ public class ClientApi
if (world != null)
{
LOGGER.info("Client on ClientOnly mode disconnecting.");
-
+
world.close();
SharedApi.setDhWorld(null);
}
@@ -166,7 +166,7 @@ public class ClientApi
public void clientLevelUnloadEvent(IClientLevelWrapper level)
{
- LOGGER.info("Unloading client level ["+level+"].");
+ LOGGER.info("Unloading client level [" + level + "].");
AbstractDhWorld world = SharedApi.getAbstractDhWorld();
if (world != null)
@@ -191,7 +191,7 @@ public class ClientApi
}
- LOGGER.info("Loading "+(isServerCommunication ? "Multiverse" : "")+" client level [" + level + "].");
+ LOGGER.info("Loading " + (isServerCommunication ? "Multiverse" : "") + " client level [" + level + "].");
AbstractDhWorld world = SharedApi.getAbstractDhWorld();
if (world != null)
@@ -220,7 +220,7 @@ public class ClientApi
keysToRemove.add(levelChunkPair);
}
}
- LOGGER.info("Loaded ["+keysToRemove.size()+"] waiting chunk wrappers.");
+ LOGGER.info("Loaded [" + keysToRemove.size() + "] waiting chunk wrappers.");
for (Pair keyToRemove : keysToRemove)
{
@@ -263,8 +263,8 @@ public class ClientApi
{
for (int zOffset = -1; zOffset <= 1; zOffset++)
{
- DhChunkPos neighbourPos = new DhChunkPos(chunk.getChunkPos().x+xOffset, chunk.getChunkPos().z+zOffset);
- IChunkWrapper neighbourChunk = dhLevel.getLevelWrapper().tryGetChunk(neighbourPos);
+ DhChunkPos neighbourPos = new DhChunkPos(chunk.getChunkPos().x + xOffset, chunk.getChunkPos().z + zOffset);
+ IChunkWrapper neighbourChunk = dhLevel.getLevelWrapper().tryGetChunk(neighbourPos);
if (neighbourChunk != null)
{
dhLevel.updateChunkAsync(neighbourChunk);
@@ -282,20 +282,20 @@ public class ClientApi
public void rendererShutdownEvent()
{
LOGGER.info("Renderer shutting down.");
-
+
IProfilerWrapper profiler = MC.getProfiler();
profiler.push("DH-RendererShutdown");
-
+
profiler.pop();
}
public void rendererStartupEvent()
{
LOGGER.info("Renderer starting up.");
-
+
IProfilerWrapper profiler = MC.getProfiler();
profiler.push("DH-RendererStartup");
-
+
// make sure the GLProxy is created before the LodBufferBuilder needs it
GLProxy.getInstance();
profiler.pop();
@@ -305,7 +305,7 @@ public class ClientApi
{
IProfilerWrapper profiler = MC.getProfiler();
profiler.push("DH-ClientTick");
-
+
boolean doFlush = System.nanoTime() - this.lastFlushNanoTime >= SPAM_LOGGER_FLUSH_NS;
if (doFlush)
{
@@ -314,7 +314,7 @@ public class ClientApi
}
ConfigBasedLogger.updateAll();
ConfigBasedSpamLogger.updateAll(doFlush);
-
+
IDhClientWorld clientWorld = SharedApi.getIDhClientWorld();
if (clientWorld != null)
{
@@ -384,7 +384,7 @@ public class ClientApi
short commandLength = byteBuf.readShort();
if (commandLength < 1 || commandLength > 32)
{
- LOGGER.error("Server command length ["+commandLength+"] outside the expected range of 1 to 32 (inclusive).");
+ LOGGER.error("Server command length [" + commandLength + "] outside the expected range of 1 to 32 (inclusive).");
ClientApi.INSTANCE.serverNetworkingIsMalformed = true;
return;
}
@@ -397,7 +397,7 @@ public class ClientApi
}
catch (Exception e)
{
- LOGGER.error("Server sent un-parsable command. Error: "+e.getMessage());
+ LOGGER.error("Server sent un-parsable command. Error: " + e.getMessage());
return;
}
@@ -407,7 +407,7 @@ public class ClientApi
LOGGER.info("Server supports DH multiverse protocol.");
ClientApi.INSTANCE.isServerCommunicationEnabled = true;
KEYED_CLIENT_LEVEL_MANAGER.setUseOverrideWrapper(true);
- MC.executeOnRenderThread(() ->
+ MC.executeOnRenderThread(() ->
{
// Unload the current world, since it may be wrong.
// A followup WorldChanged event should be received from the server soon after this.
@@ -420,7 +420,7 @@ public class ClientApi
short levelKeyLength = byteBuf.readShort();
if (levelKeyLength < 1 || levelKeyLength > 128) // TODO 128 should be put into a constant somewhere
{
- LOGGER.error("Server [LevelChanged] command length ["+commandLength+"] outside the expected range of 1 to 128 (inclusive).");
+ LOGGER.error("Server [LevelChanged] command length [" + commandLength + "] outside the expected range of 1 to 128 (inclusive).");
this.serverNetworkingIsMalformed = true;
return;
}
@@ -434,7 +434,7 @@ public class ClientApi
return;
}
- LOGGER.info("Server level change event received, changing the level to ["+levelKey+"].");
+ LOGGER.info("Server level change event received, changing the level to [" + levelKey + "].");
MC.executeOnRenderThread(() -> {
if (MC.getWrappedClientWorld() != null)
{
@@ -464,8 +464,8 @@ public class ClientApi
MC.sendChatMessage("Here be dragons!");
this.configOverrideReminderPrinted = true;
}
-
-
+
+
IProfilerWrapper profiler = MC.getProfiler();
profiler.pop(); // get out of "terrain"
profiler.push("DH-RenderLevel");
@@ -475,20 +475,20 @@ public class ClientApi
{
return;
}
-
-
+
+
//FIXME: Improve class hierarchy of DhWorld, IClientWorld, IServerWorld to fix all this hard casting
// (also in RenderUtil)
IDhClientWorld dhClientWorld = SharedApi.getIDhClientWorld();
IDhClientLevel level = dhClientWorld.getOrLoadClientLevel(levelWrapper);
-
+
if (prefLoggerEnabled)
{
level.dumpRamUsage();
}
-
-
-
+
+
+
try
{
@@ -496,9 +496,9 @@ public class ClientApi
{
DhApiRenderParam renderEventParam =
new DhApiRenderParam(mcProjectionMatrix, mcModelViewMatrix,
- RenderUtil.createLodProjectionMatrix(mcProjectionMatrix, partialTicks),
- RenderUtil.createLodModelViewMatrix(mcModelViewMatrix), partialTicks);
-
+ RenderUtil.createLodProjectionMatrix(mcProjectionMatrix, partialTicks),
+ RenderUtil.createLodModelViewMatrix(mcModelViewMatrix), partialTicks);
+
boolean renderingCanceled = ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderEvent.class, new DhApiBeforeRenderEvent.EventParam(renderEventParam));
if (!this.rendererDisabledBecauseOfExceptions && !renderingCanceled)
{
@@ -518,7 +518,7 @@ public class ClientApi
{
this.rendererDisabledBecauseOfExceptions = true;
LOGGER.error("Renderer thrown an uncaught exception: ", e);
-
+
MC.sendChatMessage("\u00A74\u00A7l\u00A7uERROR: Distant Horizons"
+ " renderer has encountered an exception!");
MC.sendChatMessage("\u00A74Renderer is now disabled to prevent further issues.");
@@ -535,13 +535,13 @@ public class ClientApi
profiler.push("terrain"); // go back into "terrain"
}
}
-
-
-
+
+
+
//=================//
// DEBUG USE //
//=================//
-
+
/** Trigger once on key press, with CLIENT PLAYER. */
public void keyPressedEvent(int glfwKey)
{
@@ -550,8 +550,8 @@ public class ClientApi
// keybindings are disabled
return;
}
-
-
+
+
if (glfwKey == GLFW.GLFW_KEY_F8)
{
Config.Client.Advanced.Debugging.debugRendering.set(EDebugRendering.next(Config.Client.Advanced.Debugging.debugRendering.get()));
@@ -568,6 +568,4 @@ public class ClientApi
MC.sendChatMessage("P: Debug Pref Logger is " + (prefLoggerEnabled ? "enabled" : "disabled"));
}
}
-
-
}
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ServerApi.java b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ServerApi.java
index 2b1c68735..c79c76908 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ServerApi.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/ServerApi.java
@@ -22,6 +22,7 @@ package com.seibel.distanthorizons.core.api.internal;
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiLevelLoadEvent;
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiLevelUnloadEvent;
import com.seibel.distanthorizons.core.generation.DhLightingEngine;
+import com.seibel.distanthorizons.core.util.ThreadUtil;
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
import com.seibel.distanthorizons.core.level.IDhLevel;
@@ -37,6 +38,7 @@ import org.apache.logging.log4j.Logger;
import java.util.LinkedList;
import java.util.List;
+import java.util.concurrent.ThreadPoolExecutor;
/**
* This holds the methods that should be called by the host mod loader (Fabric,
@@ -48,6 +50,14 @@ public class ServerApi
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
+ private static final ThreadPoolExecutor LIGHT_POPULATOR_THREAD_POOL = ThreadUtil.makeRateLimitedThreadPool(
+ // thread count doesn't need to be very high since the player can only move so fast, 1 should be plenty
+ (Runtime.getRuntime().availableProcessors() <= 12) ? 1 : 2,
+ "Server Light Populator",
+ // only run the thread 50% of the time to prevent lagging the server thread
+ 0.5,
+ ThreadUtil.MINIMUM_RELATIVE_PRIORITY);
+
private int lastWorldGenTickDelta = 0;
@@ -56,9 +66,9 @@ public class ServerApi
- // =============//
- // tick events //
- // =============//
+ //=============//
+ // tick events //
+ //=============//
public void serverTickEvent()
{
@@ -74,23 +84,23 @@ public class ServerApi
catch (Exception e)
{
// try catch is necessary to prevent crashing the internal server when an exception is thrown
- LOGGER.error("ServerTickEvent error: "+e.getMessage(), e);
+ LOGGER.error("ServerTickEvent error: " + e.getMessage(), e);
}
}
public void serverLevelTickEvent(IServerLevelWrapper level)
{
//TODO
}
-
+
public void serverLoadEvent(boolean isDedicatedEnvironment)
{
- LOGGER.debug("Server World loading with (dedicated?:"+isDedicatedEnvironment+")");
+ LOGGER.debug("Server World loading with (dedicated?:" + isDedicatedEnvironment + ")");
SharedApi.setDhWorld(isDedicatedEnvironment ? new DhServerWorld() : new DhClientServerWorld());
}
public void serverUnloadEvent()
{
- LOGGER.debug("Server World "+SharedApi.getAbstractDhWorld()+" unloading");
+ LOGGER.debug("Server World " + SharedApi.getAbstractDhWorld() + " unloading");
SharedApi.getAbstractDhWorld().close();
SharedApi.setDhWorld(null);
@@ -98,7 +108,7 @@ public class ServerApi
public void serverLevelLoadEvent(IServerLevelWrapper level)
{
- LOGGER.debug("Server Level "+level+" loading");
+ LOGGER.debug("Server Level " + level + " loading");
AbstractDhWorld serverWorld = SharedApi.getAbstractDhWorld();
if (serverWorld != null)
@@ -109,7 +119,7 @@ public class ServerApi
}
public void serverLevelUnloadEvent(IServerLevelWrapper level)
{
- LOGGER.debug("Server Level "+level+" unloading");
+ LOGGER.debug("Server Level " + level + " unloading");
AbstractDhWorld serverWorld = SharedApi.getAbstractDhWorld();
if (serverWorld != null)
@@ -118,11 +128,11 @@ public class ServerApi
ApiEventInjector.INSTANCE.fireAllEvents(DhApiLevelUnloadEvent.class, new DhApiLevelUnloadEvent.EventParam(level));
}
}
-
+
@Deprecated // TODO not implemented, remove
public void serverSaveEvent()
{
- LOGGER.debug("Server world "+SharedApi.getAbstractDhWorld()+" saving");
+ LOGGER.debug("Server world " + SharedApi.getAbstractDhWorld() + " saving");
AbstractDhWorld serverWorld = SharedApi.getAbstractDhWorld();
if (serverWorld != null)
@@ -130,7 +140,7 @@ public class ServerApi
serverWorld.saveAndFlush();
}
}
-
+
public void serverChunkLoadEvent(IChunkWrapper chunk, ILevelWrapper level)
{
// the world should always be non-null, this != null is just in case the world was removed accidentally
@@ -147,40 +157,48 @@ public class ServerApi
public void serverChunkSaveEvent(IChunkWrapper chunk, ILevelWrapper level)
{
AbstractDhWorld dhWorld = SharedApi.getAbstractDhWorld();
- if (dhWorld != null)
+ if (dhWorld == null)
{
- IDhLevel dhLevel = SharedApi.getAbstractDhWorld().getLevel(level);
- if (dhLevel != null)
+ return;
+ }
+
+ IDhLevel dhLevel = SharedApi.getAbstractDhWorld().getLevel(level);
+ if (dhLevel == null)
+ {
+ return;
+ }
+
+
+ // lighting the chunk needs to be done outside the event thread to prevent lagging the server thread
+ LIGHT_POPULATOR_THREAD_POOL.execute(() ->
+ {
+ // Save or populate the chunk wrapper's lighting
+ // this is done so we don't have to worry about MC unloading the lighting data for this chunk
+ if (chunk.isLightCorrect())
{
-
- // Save or populate the chunk wrapper's lighting
- // this is done so we don't have to worry about MC unloading the lighting data for this chunk
- if (chunk.isLightCorrect())
+ try
{
- try
- {
- chunk.bakeDhLightingUsingMcLightingEngine();
- chunk.setUseDhLighting(true);
- }
- catch (IllegalStateException e)
- {
- LOGGER.warn(e.getMessage(), e);
- }
- }
- else
- {
- // generate the chunk's lighting, ignoring neighbors.
- // not a perfect solution, but should prevent chunks from having completely broken lighting
- List nearbyChunkList = new LinkedList<>();
- nearbyChunkList.add(chunk);
- DhLightingEngine.INSTANCE.lightChunks(chunk, nearbyChunkList, level.hasSkyLight() ? 15 : 0);
+ // If MC's lighting engine isn't thread safe this may cause the server thread to lag
+ chunk.bakeDhLightingUsingMcLightingEngine();
chunk.setUseDhLighting(true);
}
-
-
- dhLevel.updateChunkAsync(chunk);
+ catch (IllegalStateException e)
+ {
+ LOGGER.warn(e.getMessage(), e);
+ }
}
- }
+ else
+ {
+ // generate the chunk's lighting, ignoring neighbors.
+ // not a perfect solution, but should prevent chunks from having completely broken lighting
+ List nearbyChunkList = new LinkedList<>();
+ nearbyChunkList.add(chunk);
+ DhLightingEngine.INSTANCE.lightChunks(chunk, nearbyChunkList, level.hasSkyLight() ? 15 : 0);
+ chunk.setUseDhLighting(true);
+ }
+
+ dhLevel.updateChunkAsync(chunk);
+ });
}
public void serverPlayerJoinEvent(IServerPlayerWrapper player)
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/SharedApi.java b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/SharedApi.java
index c6ba85169..ff2fdca79 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/api/internal/SharedApi.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/api/internal/SharedApi.java
@@ -11,22 +11,16 @@ import com.seibel.distanthorizons.core.world.*;
/** Contains code and variables used by both {@link ClientApi} and {@link ServerApi} */
public class SharedApi
{
- private static AbstractDhWorld currentWorld;
+ private static AbstractDhWorld currentWorld;
private static int lastWorldGenTickDelta = 0;
-
-
-
-
- public static void init() { Initializer.init(); }
-
+ public static void init() { Initializer.init(); }
public static EWorldEnvironment getEnvironment() { return (currentWorld == null) ? null : currentWorld.environment; }
-
- public static void setDhWorld(AbstractDhWorld newWorld)
+ public static void setDhWorld(AbstractDhWorld newWorld)
{
- currentWorld = newWorld;
+ currentWorld = newWorld;
// starting and stopping the DataRenderTransformer is necessary to prevent attempting to
// access the MC level at inappropriate times, which can cause exceptions
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/AppliedConfigState.java b/core/src/main/java/com/seibel/distanthorizons/core/config/AppliedConfigState.java
index 658b374e8..8c8a6be15 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/config/AppliedConfigState.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/config/AppliedConfigState.java
@@ -5,31 +5,31 @@ import com.seibel.distanthorizons.core.config.types.ConfigEntry;
// TODO: Make this intergrate with the config system
public class AppliedConfigState
{
- final ConfigEntry entry;
- T activeValue;
+ final ConfigEntry entry;
+ T activeValue;
- public AppliedConfigState(ConfigEntry entryToWatch)
+ public AppliedConfigState(ConfigEntry entryToWatch)
{
- this.entry = entryToWatch;
- this.activeValue = entryToWatch.get();
- }
+ this.entry = entryToWatch;
+ this.activeValue = entryToWatch.get();
+ }
/** Returns true if the value was changed */
- public boolean pollNewValue()
+ public boolean pollNewValue()
{
- T newValue = this.entry.get();
- if (newValue.equals(this.activeValue))
+ T newValue = this.entry.get();
+ if (newValue.equals(this.activeValue))
{
- return false;
- }
+ return false;
+ }
this.activeValue = newValue;
- return true;
- }
+ return true;
+ }
- public T get() { return this.activeValue; }
+ public T get() { return this.activeValue; }
}
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java
index 516927657..424ece2f4 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java
@@ -43,12 +43,12 @@ import java.util.*;
/**
* This handles any configuration the user has access to.
- *
+ *
* Note:
* Only add simpler listeners here (IE listeners that only depend on 1 config entry).
* For listeners that depend on 2 or more config entries, add them before the config menu is opened.
* Otherwise, you will have issues where only some of the config entries will exist when your listener is created.
- *
+ *
* @author coolGi
* @version 2023-7-16
*/
@@ -57,11 +57,11 @@ public class Config
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
- public static ConfigCategory client = new ConfigCategory.Builder().set(Client.class).build();
+ public static ConfigCategory client = new ConfigCategory.Builder().set(Client.class).build();
- public static class Client
- {
+ public static class Client
+ {
public static ConfigEntry quickEnableRendering = new ConfigEntry.Builder()
.set(true)
.comment(""
@@ -105,7 +105,7 @@ public class Config
public static ConfigEntry optionsButton = new ConfigEntry.Builder()
.set(true)
.comment("" +
- "Should Distant Horizon's config button appear in the options screen next to fov slider?")
+ "Should Distant Horizon's config button appear in the options screen next to fov slider?")
.build();
@@ -219,7 +219,7 @@ public class Config
+ "\n"
+ "True: a red flower will tint the grass below it red. \n"
+ "False: skipped blocks will not change color of surface below them. "
- +"")
+ + "")
.setPerformance(EConfigEntryPerformance.NONE)
.addListener(RenderCacheConfigEventHandler.INSTANCE)
.build();
@@ -310,7 +310,7 @@ public class Config
.build();
public static ConfigEntry farFogMin = new ConfigEntry.Builder()
- .setMinDefaultMax(-5.0,0.0, FOG_RANGE_MAX)
+ .setMinDefaultMax(-5.0, 0.0, FOG_RANGE_MAX)
.comment(""
+ "What is the minimum fog thickness? \n"
+ "\n"
@@ -338,7 +338,7 @@ public class Config
.build();
public static ConfigEntry farFogDensity = new ConfigEntry.Builder()
- .setMinDefaultMax(0.01,2.5, 50.0)
+ .setMinDefaultMax(0.01, 2.5, 50.0)
.comment(""
+ "Used in conjunction with the Fog Falloff.")
.build();
@@ -367,7 +367,7 @@ public class Config
+ EHeightFogMixMode.INVERSE_MULTIPLY_ADDITION + ": farFog + 1 - (1-heightFog) * (1-farFog) \n"
+ EHeightFogMixMode.AVERAGE + ": farFog*0.5 + heightFog*0.5 \n"
+ "\n"
- + "Note: height fog settings are ignored if '"+EHeightFogMixMode.BASIC+"' or '"+EHeightFogMixMode.IGNORE_HEIGHT+"' are selected.")
+ + "Note: height fog settings are ignored if '" + EHeightFogMixMode.BASIC + "' or '" + EHeightFogMixMode.IGNORE_HEIGHT + "' are selected.")
.build();
public static ConfigEntry heightFogMode = new ConfigEntry.Builder()
@@ -440,7 +440,9 @@ public class Config
.build();
}
+
}
+
}
public static class NoiseTextureSettings
@@ -449,7 +451,7 @@ public class Config
.set(true)
.comment(""
+ "Should a noise texture be applied to LODs? \n"
- +"\n"
+ + "\n"
+ "This is done to simulate textures and make the LODs appear more detailed. \n"
+ "")
.build();
@@ -472,6 +474,7 @@ public class Config
+ "Defines how far should the noise texture render before it fades away. (in blocks) \n"
+ "Set to 0 to disable noise from fading away")
.build();
+
}
public static class AdvancedGraphics
@@ -512,7 +515,7 @@ public class Config
+ "reducing overdraw. \n"
+ "\n"
+ "Only functional on Fabric.\n"
- + "Works best with an overdraw prevention setting of "+EOverdrawPrevention.MEDIUM+" or higher \n"
+ + "Works best with an overdraw prevention setting of " + EOverdrawPrevention.MEDIUM + " or higher \n"
+ " and cave culling is disabled. \n"
+ "")
.setPerformance(EConfigEntryPerformance.NONE)
@@ -553,13 +556,13 @@ public class Config
.build();
public static ConfigEntry caveCullingHeight = new ConfigEntry.Builder()
- .setMinDefaultMax(-4096,40,4096)
- .comment(""
+ .setMinDefaultMax(-4096, 40, 4096)
+ .comment(""
+ "At what Y value should cave culling start?")
.build();
public static ConfigEntry earthCurveRatio = new ConfigEntry.Builder()
- .setMinDefaultMax(0,0,5000)
+ .setMinDefaultMax(0, 0, 5000)
.comment(""
+ "This is the earth size ratio when applying the curvature shader effect. \n"
+ "Note: Enabling this feature may cause rendering bugs. \n"
@@ -643,14 +646,14 @@ public class Config
+ "WARNING: This may cause world generator bugs or instability when paired with certain world generator mods. \n"
+ "- Fast \n"
+ "")
- /*
- // FULL isn't currently implemented
- + "\n"
- + EDhApiDistantGeneratorMode.FULL + " \n"
- + "Ask the local server to generate/load each chunk. \n"
- + "This is the most compatible, but will cause server/simulation lag. \n"
- + "- Slow (15-50 ms, with spikes up to 200 ms) \n"
- */
+ /*
+ // FULL isn't currently implemented
+ + "\n"
+ + EDhApiDistantGeneratorMode.FULL + " \n"
+ + "Ask the local server to generate/load each chunk. \n"
+ + "This is the most compatible, but will cause server/simulation lag. \n"
+ + "- Slow (15-50 ms, with spikes up to 200 ms) \n"
+ */
.build();
public static ConfigEntry worldGenLightingEngine = new ConfigEntry.Builder()
@@ -667,7 +670,7 @@ public class Config
.build();
public static ConfigEntry worldGenerationTimeoutLengthInSeconds = new ConfigEntry.Builder()
- .setMinDefaultMax(5, 60, 60*10/*10 minutes*/)
+ .setMinDefaultMax(5, 60, 60 * 10/*10 minutes*/ )
.comment(""
+ "How long should a world generator thread run for before timing out? \n"
+ "Note: If you are experiencing timeout errors it is better to lower your CPU usage first \n"
@@ -695,7 +698,7 @@ public class Config
+ " fake chunks. \n"
+ "\n"
+ EGenerationPriority.BALANCED + " \n"
- + "A mix between "+ EGenerationPriority.NEAR_FIRST+"and"+ EGenerationPriority.FAR_FIRST+". \n"
+ + "A mix between " + EGenerationPriority.NEAR_FIRST + "and" + EGenerationPriority.FAR_FIRST + ". \n"
+ "First prioritise completing nearby highest detail chunks, \n"
+ " then focus on filling in the low detail areas away from the player. \n"
+ "\n"
@@ -944,6 +947,7 @@ public class Config
+ "How frequently should vertex buffers (geometry) be rebuilt and sent to the GPU? \n"
+ "Higher settings may cause stuttering, but will prevent holes in the world")
.build();
+
}
public static class AutoUpdater
@@ -956,10 +960,11 @@ public class Config
public static ConfigEntry enableSilentUpdates = new ConfigEntry.Builder()
.set(false)
- .comment(""
+ .comment(""
+ "Should Distant Horizons silently, automatically download and install new versions? "
+ "")
.build();
+
}
public static class Logging
@@ -1028,6 +1033,7 @@ public class Config
+ "If enabled, the mod will log information about network operations. \n"
+ "This can be useful for debugging.")
.build();
+
}
public static class Debugging
@@ -1079,7 +1085,7 @@ public class Config
+ " This setting is only for fun and debugging. \n"
+ " Mod compatibility is not guaranteed.")
.build();
-
+
public static ConfigEntry debugWireframeRendering = new ConfigEntry.Builder()
.set(false)
.comment(""
@@ -1089,21 +1095,21 @@ public class Config
+ " Additionally, only stuff that's loaded after you enable this \n"
+ " will render their debug wireframes.")
.build();
-
+
public static ConfigEntry enableWhiteWorld = new ConfigEntry.Builder()
.set(false)
.comment(""
+ "Stops vertex colors from being passed. \n"
+ "Useful for debugging shaders")
.build();
-
+
// Note: This will reset on game restart, and should have a warning on the tooltip
public static ConfigEntry allowUnsafeValues = new ConfigEntry.Builder()
.set(false)
.setAppearance(EConfigEntryAppearance.ONLY_IN_GUI)
.addListener(UnsafeValuesConfigListener.INSTANCE)
.build();
-
+
// can be set to public inorder to show in the config file and UI
public static ConfigCategory exampleConfigScreen = new ConfigCategory.Builder()
@@ -1141,7 +1147,7 @@ public class Config
public static ConfigEntry longTest = new ConfigEntry.Builder()
.set(42069L)
.build();
-
+
public static ConfigEntry floatTest = new ConfigEntry.Builder()
.set(0.42069f)
.build();
@@ -1153,15 +1159,15 @@ public class Config
public static ConfigEntry> listTest = new ConfigEntry.Builder>()
.set(new ArrayList(Arrays.asList("option 1", "option 2", "option 3")))
.build();
-
+
public static ConfigEntry