From fa325b2eb85950b0490578e5a62edc364c934946 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 3 Mar 2022 19:41:31 -0600 Subject: [PATCH] Start updating for changed core --- .../lod/common/wrappers/VersionConstants.java | 9 ++++- .../lod/common/wrappers/config/ConfigGui.java | 2 +- .../minecraft/MinecraftRenderWrapper.java | 3 +- .../wrappers/minecraft/MinecraftWrapper.java | 3 +- .../BatchGenerationEnvironment.java | 35 ++++++++++--------- .../worldGeneration/GenerationEvent.java | 3 +- .../mimicObject/ChunkLoader.java | 6 ++-- .../mimicObject/LightedWorldGenRegion.java | 3 +- core | 2 +- .../main/java/com/seibel/lod/fabric/Main.java | 5 +-- .../mixins/MixinUtilBackgroudThread.java | 4 +-- .../java/com/seibel/lod/forge/ForgeMain.java | 3 +- .../mixins/MixinUtilBackgroudThread.java | 4 +-- 13 files changed, 48 insertions(+), 34 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/VersionConstants.java b/common/src/main/java/com/seibel/lod/common/wrappers/VersionConstants.java index 2cd381534..0603a4f40 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/VersionConstants.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/VersionConstants.java @@ -5,7 +5,7 @@ import com.seibel.lod.core.wrapperInterfaces.IVersionConstants; /** * @author James Seibel - * @version 12-11-2021 + * @version 3-3-2022 */ public class VersionConstants implements IVersionConstants { public static final VersionConstants INSTANCE = new VersionConstants(); @@ -52,4 +52,11 @@ public class VersionConstants implements IVersionConstants { public boolean hasBatchGenerationImplementation() { return true; } + + + @Override + public boolean isVanillaRenderedChunkSquare() + { + return false; + } } \ No newline at end of file diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/ConfigGui.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/ConfigGui.java index 7f36da00c..37745722b 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/config/ConfigGui.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/ConfigGui.java @@ -92,7 +92,7 @@ public abstract class ConfigGui // Change these to your own mod private static final String MOD_NAME = ModInfo.NAME; // For file saving and identifying private static final String MOD_NAME_READABLE = ModInfo.READABLE_NAME; // For logs - // private static final Logger LOGGER = ClientApi.LOGGER; // For logs + // private static final Logger LOGGER = ApiShared.LOGGER; // For logs private static final Logger LOGGER = LogManager.getLogger(ModInfo.NAME); // For logs (this inits before ClientAPI so this is a temp fix) 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 d961e2275..a0416806a 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 @@ -7,6 +7,7 @@ import java.util.stream.Collectors; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.systems.RenderSystem; import com.seibel.lod.common.wrappers.misc.LightMapWrapper; +import com.seibel.lod.core.api.ApiShared; import com.seibel.lod.core.api.ClientApi; import com.seibel.lod.core.util.LodUtil; import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorHandler; @@ -181,7 +182,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper MinecraftWrapper.INSTANCE.sendChatMessage( "\u00A7eOverdraw prevention will be worse than normal."); } catch (Exception e2) {} - ClientApi.LOGGER.error("getVanillaRenderedChunks Error: {}", e); + ApiShared.LOGGER.error("getVanillaRenderedChunks Error: {}", e); usingBackupGetVanillaRenderedChunks = true; } } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftWrapper.java index 9701c0836..c6c2a9748 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftWrapper.java @@ -26,6 +26,7 @@ import java.util.ArrayList; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.platform.Window; import com.seibel.lod.core.ModInfo; +import com.seibel.lod.core.api.ApiShared; import com.seibel.lod.core.api.ClientApi; import com.seibel.lod.core.enums.LodDirection; import com.seibel.lod.core.util.LodUtil; @@ -418,7 +419,7 @@ public class MinecraftWrapper implements IMinecraftWrapper @Override public void crashMinecraft(String errorMessage, Throwable exception) { - ClientApi.LOGGER.error(ModInfo.READABLE_NAME + " had the following error: [" + errorMessage + "]. Crashing Minecraft..."); + ApiShared.LOGGER.error(ModInfo.READABLE_NAME + " had the following error: [" + errorMessage + "]. Crashing Minecraft..."); CrashReport report = new CrashReport(errorMessage, exception); Minecraft.crash(report); } 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 33d859882..c411e5322 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 @@ -19,6 +19,7 @@ package com.seibel.lod.common.wrappers.worldGeneration; +import com.seibel.lod.core.api.ApiShared; import com.seibel.lod.core.api.ClientApi; import com.seibel.lod.core.builders.lodBuilding.LodBuilder; import com.seibel.lod.core.builders.lodBuilding.LodBuilderConfig; @@ -251,7 +252,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv if (!unsafeThreadingRecorded && !f.isDone()) { MC.sendChatMessage("\u00A74\u00A7l\u00A7uERROR: Distant Horizons: Unsafe Threading in Chunk Generator Detected!"); MC.sendChatMessage("\u00A7eTo increase stability, it is recommended to set world generation threads count to 1."); - ClientApi.LOGGER.error("Unsafe Threading in Chunk Generator: ", new RuntimeException("Concurrent future")); + ApiShared.LOGGER.error("Unsafe Threading in Chunk Generator: ", new RuntimeException("Concurrent future")); unsafeThreadingRecorded = true; } return f.join(); @@ -299,8 +300,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv } catch (Throwable e) { - ClientApi.LOGGER.error("Batching World Generator: Event {} gotten an exception", event); - ClientApi.LOGGER.error("Exception: ", e); + ApiShared.LOGGER.error("Batching World Generator: Event {} gotten an exception", event); + ApiShared.LOGGER.error("Exception: ", e); unknownExceptionCount++; lastExceptionTriggerTime = System.nanoTime(); } @@ -311,12 +312,12 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv } else if (event.hasTimeout(TIMEOUT_SECONDS, TimeUnit.SECONDS)) { - ClientApi.LOGGER.error("Batching World Generator: " + event + " timed out and terminated!"); - ClientApi.LOGGER.info("Dump PrefEvent: " + event.pEvent); + ApiShared.LOGGER.error("Batching World Generator: " + event + " timed out and terminated!"); + ApiShared.LOGGER.info("Dump PrefEvent: " + event.pEvent); try { if (!event.terminate()) - ClientApi.LOGGER.error("Failed to terminate the stuck generation event!"); + ApiShared.LOGGER.error("Failed to terminate the stuck generation event!"); } finally { @@ -328,7 +329,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv try { MC.sendChatMessage("\u00A74\u00A7l\u00A7uERROR: Distant Horizons: Too many exceptions in Batching World Generator! Disabling the generator."); } catch (Exception e) {} - ClientApi.LOGGER.error("Too many exceptions in Batching World Generator! Now disabling."); + ApiShared.LOGGER.error("Too many exceptions in Batching World Generator! Now disabling."); unknownExceptionCount = 0; CONFIG.client().worldGenerator().setEnableDistantGeneration(false); } @@ -337,14 +338,14 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv public BatchGenerationEnvironment(IWorldWrapper serverlevel, LodBuilder lodBuilder, LodDimension lodDim) { super(serverlevel, lodBuilder, lodDim); - ClientApi.LOGGER.info("================WORLD_GEN_STEP_INITING============="); + ApiShared.LOGGER.info("================WORLD_GEN_STEP_INITING============="); ChunkGenerator generator = ((WorldWrapper) serverlevel).getServerWorld().getChunkSource().getGenerator(); if (!(generator instanceof NoiseBasedChunkGenerator || generator instanceof DebugLevelSource || generator instanceof FlatLevelSource)) { MC.sendChatMessage("\u00A74\u00A7l\u00A7uWARNING: Distant Horizons: Unknown Chunk Generator Detected! Distant Generation May Fail!"); MC.sendChatMessage("\u00A7eIf it does crash, set Distant Generation to OFF or Generation Mode to None."); - ClientApi.LOGGER.warn("Unknown Chunk Generator detected: {}", generator.getClass()); + ApiShared.LOGGER.warn("Unknown Chunk Generator detected: {}", generator.getClass()); } params = new GlobalParameters((ServerLevel) ((WorldWrapper) serverlevel).getWorld(), lodBuilder, lodDim); } @@ -359,7 +360,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv } catch (Exception e) { - ClientApi.LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e); + ApiShared.LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e); } if (chunkData == null) { @@ -370,7 +371,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv try { return ChunkLoader.read(level, lightEngine, chunkPos, chunkData); } catch (Exception e) { - ClientApi.LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e); + ApiShared.LOGGER.error("DistantHorizons: Couldn't load chunk {}", chunkPos, e); return new ProtoChunk(chunkPos, UpgradeData.EMPTY, level); } } @@ -380,7 +381,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv public void generateLodFromList(GenerationEvent e) { if (ENABLE_EVENT_LOGGING) - ClientApi.LOGGER.info("Lod Generate Event: " + e.pos); + ApiShared.LOGGER.info("Lod Generate Event: " + e.pos); e.pEvent.beginNano = System.nanoTime(); GridList referencedChunks; DistanceGenerationMode generationMode; @@ -479,7 +480,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv if (isFull) { if (ENABLE_LOAD_EVENT_LOGGING) - ClientApi.LOGGER.info("Detected full existing chunk at {}", target.getPos()); + ApiShared.LOGGER.info("Detected full existing chunk at {}", target.getPos()); params.lodBuilder.generateLodNodeFromChunk(params.lodDim, new ChunkWrapper(target, region), new LodBuilderConfig(DistanceGenerationMode.FULL), true, e.genAllDetails); } @@ -505,7 +506,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv if (ENABLE_PERF_LOGGING) { e.tParam.perf.recordEvent(e.pEvent); - ClientApi.LOGGER.info(e.tParam.perf); + ApiShared.LOGGER.info(e.tParam.perf); } } @@ -588,14 +589,14 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv @Override public void stop(boolean blocking) { - ClientApi.LOGGER.info("Batch Chunk Generator shutting down..."); + ApiShared.LOGGER.info("Batch Chunk Generator shutting down..."); executors.shutdownNow(); if (blocking) try { if (!executors.awaitTermination(10, TimeUnit.SECONDS)) { - ClientApi.LOGGER.error("Batch Chunk Generator shutdown failed! Ignoring child threads..."); + ApiShared.LOGGER.error("Batch Chunk Generator shutdown failed! Ignoring child threads..."); } } catch (InterruptedException e) { - ClientApi.LOGGER.error("Batch Chunk Generator shutdown failed! Ignoring child threads...", e); + ApiShared.LOGGER.error("Batch Chunk Generator shutdown failed! Ignoring child threads...", e); } } } \ No newline at end of file diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GenerationEvent.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GenerationEvent.java index 4cc7153da..2bb177d71 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GenerationEvent.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/GenerationEvent.java @@ -6,6 +6,7 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment.PrefEvent; +import com.seibel.lod.core.api.ApiShared; import com.seibel.lod.core.api.ClientApi; import com.seibel.lod.core.enums.config.LightGenerationMode; import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; @@ -70,7 +71,7 @@ public final class GenerationEvent public boolean terminate() { future.cancel(true); - ClientApi.LOGGER.info("======================DUMPING ALL THREADS FOR WORLD GEN======================="); + ApiShared.LOGGER.info("======================DUMPING ALL THREADS FOR WORLD GEN======================="); BatchGenerationEnvironment.threadFactory.dumpAllThreadStacks(); return future.isCancelled(); } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java index b83b70bea..480aa91eb 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java @@ -1,7 +1,7 @@ package com.seibel.lod.common.wrappers.worldGeneration.mimicObject; -import com.seibel.lod.core.api.ClientApi; +import com.seibel.lod.core.api.ApiShared; import java.util.Objects; @@ -30,7 +30,7 @@ import net.minecraft.world.level.material.Fluids; import org.apache.logging.log4j.Logger; public class ChunkLoader { - private static final Logger LOGGER = ClientApi.LOGGER; + private static final Logger LOGGER = ApiShared.LOGGER; private static LevelChunkSection[] readSections(WorldGenLevel level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag tagLevel) { @@ -142,7 +142,7 @@ public class ChunkLoader { chunk.setLightCorrect(tagLevel.getBoolean("isLightOn")); readHeightmaps(chunk, tagLevel); readPostPocessings(chunk, tagLevel); - // ClientApi.LOGGER.info("Loaded chunk @ "+chunk.getPos()); + // ApiShared.LOGGER.info("Loaded chunk @ "+chunk.getPos()); return chunk; } } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightedWorldGenRegion.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightedWorldGenRegion.java index 921f09dde..c28fa93a5 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightedWorldGenRegion.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/LightedWorldGenRegion.java @@ -6,6 +6,7 @@ import java.util.stream.Stream; import org.jetbrains.annotations.Nullable; import com.seibel.lod.common.wrappers.worldGeneration.BatchGenerationEnvironment.EmptyChunkGenerator; +import com.seibel.lod.core.api.ApiShared; import com.seibel.lod.core.api.ClientApi; import com.seibel.lod.core.enums.config.LightGenerationMode; @@ -183,7 +184,7 @@ public class LightedWorldGenRegion extends WorldGenRegion { } } if (chunkStatus != ChunkStatus.EMPTY && chunkStatus != debugTriggeredForStatus) { - ClientApi.LOGGER.info("WorldGen requiring " + chunkStatus + ApiShared.LOGGER.info("WorldGen requiring " + chunkStatus + " outside expected range detected. Force passing EMPTY chunk and seeing if it works."); debugTriggeredForStatus = chunkStatus; } diff --git a/core b/core index d84d53589..2149da59d 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit d84d535896a911340cc661e349a7f813ce0b0c9b +Subproject commit 2149da59df12c2aa55a69c3e93bfcbc19e2f26ae diff --git a/fabric/src/main/java/com/seibel/lod/fabric/Main.java b/fabric/src/main/java/com/seibel/lod/fabric/Main.java index 5f7fce99e..4946531a1 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/Main.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/Main.java @@ -21,6 +21,7 @@ package com.seibel.lod.fabric; import com.seibel.lod.common.LodCommonMain; import com.seibel.lod.core.ModInfo; +import com.seibel.lod.core.api.ApiShared; import com.seibel.lod.core.api.ClientApi; import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorHandler; import com.seibel.lod.core.handlers.dependencyInjection.SingletonHandler; @@ -64,7 +65,7 @@ public class Main implements ClientModInitializer LodCommonMain.startup(null, false); DependencySetup.createInitialBindings(); SingletonHandler.bind(IModChecker.class, ModChecker.INSTANCE); - ClientApi.LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION); + ApiShared.LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION); // Check if this works client_proxy = new ClientProxy(); @@ -81,6 +82,6 @@ public class Main implements ClientModInitializer LodCommonMain.initConfig(); LodCommonMain.startup(null, true); DependencySetup.createInitialBindings(); - ClientApi.LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION); + ApiShared.LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION); } } diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinUtilBackgroudThread.java b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinUtilBackgroudThread.java index b97b15645..c1b67baca 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinUtilBackgroudThread.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinUtilBackgroudThread.java @@ -31,7 +31,7 @@ public class MixinUtilBackgroudThread { if (DependencySetupDoneCheck.isDone && doTriggerOverride()) { - // ClientApi.LOGGER.info("util wrapThreadWithTaskName(Runnable) triggered"); + // ApiShared.LOGGER.info("util wrapThreadWithTaskName(Runnable) triggered"); ci.setReturnValue(r); } } @@ -41,7 +41,7 @@ public class MixinUtilBackgroudThread { if (DependencySetupDoneCheck.isDone && doTriggerOverride()) { - // ClientApi.LOGGER.info("util backgroundExecutor triggered"); + // ApiShared.LOGGER.info("util backgroundExecutor triggered"); ci.setReturnValue(Runnable::run); } } 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 cb5fee480..c10ed01b7 100644 --- a/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java +++ b/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java @@ -24,6 +24,7 @@ import com.seibel.lod.common.forge.LodForgeMethodCaller; import com.seibel.lod.common.wrappers.config.ConfigGui; import com.seibel.lod.common.wrappers.minecraft.MinecraftWrapper; import com.seibel.lod.core.ModInfo; +import com.seibel.lod.core.api.ApiShared; import com.seibel.lod.core.api.ClientApi; import com.seibel.lod.core.handlers.dependencyInjection.ModAccessorHandler; import com.seibel.lod.core.handlers.ReflectionHandler; @@ -71,7 +72,7 @@ public class ForgeMain implements LodForgeMethodCaller LodCommonMain.initConfig(); LodCommonMain.startup(this, !FMLLoader.getDist().isClient()); ForgeDependencySetup.createInitialBindings(); - ClientApi.LOGGER.info("Distant Horizons initializing..."); + ApiShared.LOGGER.info("Distant Horizons initializing..."); SingletonHandler.bind(IModChecker.class, ModChecker.INSTANCE); if (ReflectionHandler.instance.optifinePresent()) { diff --git a/forge/src/main/java/com/seibel/lod/forge/mixins/MixinUtilBackgroudThread.java b/forge/src/main/java/com/seibel/lod/forge/mixins/MixinUtilBackgroudThread.java index 4ecd3610d..4fe9447b1 100644 --- a/forge/src/main/java/com/seibel/lod/forge/mixins/MixinUtilBackgroudThread.java +++ b/forge/src/main/java/com/seibel/lod/forge/mixins/MixinUtilBackgroudThread.java @@ -31,7 +31,7 @@ public class MixinUtilBackgroudThread { if (DependencySetupDoneCheck.isDone && doTriggerOverride()) { - // ClientApi.LOGGER.info("util wrapThreadWithTaskName(Runnable) triggered"); + // ApiShared.LOGGER.info("util wrapThreadWithTaskName(Runnable) triggered"); ci.setReturnValue(r); } } @@ -41,7 +41,7 @@ public class MixinUtilBackgroudThread { if (DependencySetupDoneCheck.isDone && doTriggerOverride()) { - // ClientApi.LOGGER.info("util backgroundExecutor triggered"); + // ApiShared.LOGGER.info("util backgroundExecutor triggered"); ci.setReturnValue(Runnable::run); } }