diff --git a/src/main/java/com/seibel/lod/core/api/internal/ClientApi.java b/src/main/java/com/seibel/lod/core/api/internal/ClientApi.java index ddd50af4d..ee18790f6 100644 --- a/src/main/java/com/seibel/lod/core/api/internal/ClientApi.java +++ b/src/main/java/com/seibel/lod/core/api/internal/ClientApi.java @@ -61,6 +61,7 @@ import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper; * @author James Seibel * @version 2022-4-27 */ +@Deprecated public class ClientApi { public static final Logger LOGGER = LogManager.getLogger(ClientApi.class.getSimpleName()); diff --git a/src/main/java/com/seibel/lod/core/api/internal/EventApi.java b/src/main/java/com/seibel/lod/core/api/internal/EventApi.java index 2b33d8c04..5a83ad557 100644 --- a/src/main/java/com/seibel/lod/core/api/internal/EventApi.java +++ b/src/main/java/com/seibel/lod/core/api/internal/EventApi.java @@ -48,6 +48,7 @@ import java.lang.invoke.MethodHandles; * @author James Seibel * @version 2021-11-12 */ +@Deprecated public class EventApi { public static final boolean ENABLE_STACK_DUMP_LOGGING = false; diff --git a/src/main/java/com/seibel/lod/core/api/internal/InternalApiShared.java b/src/main/java/com/seibel/lod/core/api/internal/InternalApiShared.java index db64edfff..9f461a93a 100644 --- a/src/main/java/com/seibel/lod/core/api/internal/InternalApiShared.java +++ b/src/main/java/com/seibel/lod/core/api/internal/InternalApiShared.java @@ -34,6 +34,7 @@ import com.seibel.lod.core.objects.lod.LodWorld; * @author James Seibel * @version 2022-4-24 */ +@Deprecated public class InternalApiShared { public InternalApiShared INSTANCE = new InternalApiShared(); diff --git a/src/main/java/com/seibel/lod/core/api/internal/a7/ClientApi.java b/src/main/java/com/seibel/lod/core/api/internal/a7/ClientApi.java index f0ab942c2..0f161ab8e 100644 --- a/src/main/java/com/seibel/lod/core/api/internal/a7/ClientApi.java +++ b/src/main/java/com/seibel/lod/core/api/internal/a7/ClientApi.java @@ -67,8 +67,8 @@ public class ClientApi public static final long LAG_SPIKE_THRESHOLD_NS = TimeUnit.NANOSECONDS.convert(16, TimeUnit.MILLISECONDS); public static final long SPAM_LOGGER_FLUSH_NS = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS); - - public static class LagSpikeCatcher { + + public static class LagSpikeCatcher { long timer = System.nanoTime(); public LagSpikeCatcher() {} public void end(String source) { @@ -139,10 +139,25 @@ public class ClientApi private long lastFlush = 0; - public void preRender() { + + public void rendererShutdownEvent() { IProfilerWrapper profiler = MC.getProfiler(); - profiler.pop(); // get out of "terrain" - profiler.push("DH-PreRender"); + profiler.push("DH-RendererShutdown"); + + profiler.pop(); + } + public void rendererStartupEvent() { + IProfilerWrapper profiler = MC.getProfiler(); + profiler.push("DH-RendererStartup"); + // make sure the GLProxy is created before the LodBufferBuilder needs it + GLProxy.getInstance(); + profiler.pop(); + } + + public void clientTickEvent() { + IProfilerWrapper profiler = MC.getProfiler(); + profiler.push("DH-ClientTick"); + boolean doFlush = System.nanoTime() - lastFlush >= SPAM_LOGGER_FLUSH_NS; if (doFlush) { lastFlush = System.nanoTime(); @@ -150,20 +165,18 @@ public class ClientApi } ConfigBasedLogger.updateAll(); ConfigBasedSpamLogger.updateAll(doFlush); - // only run the first time setup once - if (!firstTimeSetupComplete) firstFrameSetup(); - if (ModInfo.IS_DEV_BUILD) - { - // config overrides should only be used in the developer builds - applyDeveloperConfigOverrides(); - } - if (SharedApi.currentServer == null && SharedApi.currentWorld != null) { - // In single player. - SharedApi.currentWorld.asyncTick(); + if (SharedApi.currentWorld != null) { + if (ModInfo.IS_DEV_BUILD) { + // config overrides should only be used in the developer builds + applyDeveloperConfigOverrides(); + } + if (SharedApi.currentServer == null) { + // In single player. Do client-side ticking system. + SharedApi.currentWorld.asyncTick(); + } } - //FIXME: Is it always 'terrain' that is the previous thing in the profiler? - profiler.push("terrain"); // go back into "terrain" + profiler.pop(); } public void renderLods(IWorldWrapper world, Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks) @@ -280,28 +293,6 @@ public class ClientApi MC.sendChatMessage("P: Debug Pref Logger is " + (prefLoggerEnabled ? "enabled" : "disabled")); } } - - //=================// - // Lod maintenance // - //=================// - - // FIXME: I need a onLastFrameCleanup() callback in Render Thread... Which calls renderer.cleanup() - - /** This event is called once during the first frame Minecraft renders in the world. */ - public void firstFrameSetup() - { - // make sure the GLProxy is created before the LodBufferBuilder needs it - GLProxy.getInstance(); - - firstTimeSetupComplete = true; - } - - - - - - - } diff --git a/src/main/java/com/seibel/lod/core/api/internal/a7/ServerApi.java b/src/main/java/com/seibel/lod/core/api/internal/a7/ServerApi.java index 9f4e80c66..0210843af 100644 --- a/src/main/java/com/seibel/lod/core/api/internal/a7/ServerApi.java +++ b/src/main/java/com/seibel/lod/core/api/internal/a7/ServerApi.java @@ -90,4 +90,7 @@ public class ServerApi public void chunkSaveEvent(IChunkWrapper chunk, IWorldWrapper world) { //TODO } + + public void serverChunkLoadEvent(IChunkWrapper chunk, IWorldWrapper world) { + } } diff --git a/src/main/java/com/seibel/lod/core/api/internal/a7/SharedApi.java b/src/main/java/com/seibel/lod/core/api/internal/a7/SharedApi.java index 0820e4e5e..36956f306 100644 --- a/src/main/java/com/seibel/lod/core/api/internal/a7/SharedApi.java +++ b/src/main/java/com/seibel/lod/core/api/internal/a7/SharedApi.java @@ -1,51 +1,18 @@ package com.seibel.lod.core.api.internal.a7; +import com.seibel.lod.core.logging.DhLoggerBuilder; import com.seibel.lod.core.objects.a7.DHWorld; import com.seibel.lod.core.objects.a7.Server; +import com.seibel.lod.core.util.LodUtil; import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper; import com.seibel.lod.core.wrapperInterfaces.world.IWorldWrapper; +import org.apache.logging.log4j.Logger; public class SharedApi { public static DHWorld currentWorld; public static Server currentServer; public static IMinecraftSharedWrapper MC; - public static IMinecraftClientWrapper MC_CLIENT; - - public static void onServerStart() { - if (MC.isServerJar()) { - ServerApi.INSTANCE.serverWorldLoadEvent(); - } else if (MC_CLIENT.hasSinglePlayerServer()) { - ServerApi.INSTANCE.serverWorldLoadEvent(); - } // else do nothing - } - - public static void onServerStop() { - if (MC.isServerJar()) { - ServerApi.INSTANCE.serverWorldUnloadEvent(); - } else if (MC_CLIENT.hasSinglePlayerServer()) { - ServerApi.INSTANCE.serverWorldUnloadEvent(); - } // else do nothing - } - - public static void onLevelLoad(IWorldWrapper world) { - if (MC.isServerJar()) { - ServerApi.INSTANCE.serverLevelLoadEvent(world); - } else if (MC_CLIENT.hasSinglePlayerServer()) { - ServerApi.INSTANCE.serverLevelLoadEvent(world); - } else { - ClientApi.INSTANCE.clientLevelLoadEvent(world); - } - } - - public static void onLevelUnload(IWorldWrapper world) { - if (MC.isServerJar()) { - ServerApi.INSTANCE.serverLevelUnloadEvent(world); - } else if (MC_CLIENT.hasSinglePlayerServer()) { - ServerApi.INSTANCE.serverLevelUnloadEvent(world); - } else { - ClientApi.INSTANCE.clientLevelUnloadEvent(world); - } - } + public static Logger LOGGER = DhLoggerBuilder.getLogger("DH Events"); }