From 4c5204172e343962519e677c4b566bd9ccb8fa4c Mon Sep 17 00:00:00 2001 From: James Seibel Date: Mon, 30 Oct 2023 18:43:04 -0500 Subject: [PATCH 1/5] fix server shutdown null pointer --- .../distanthorizons/core/api/internal/ServerApi.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 fc6fbd5a6..9f48f183b 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 @@ -101,8 +101,13 @@ public class ServerApi { LOGGER.debug("Server World " + SharedApi.getAbstractDhWorld() + " unloading"); - SharedApi.getAbstractDhWorld().close(); - SharedApi.setDhWorld(null); + // shutdown the world if it isn't already + AbstractDhWorld dhWorld = SharedApi.getAbstractDhWorld(); + if (dhWorld != null) + { + dhWorld.close(); + SharedApi.setDhWorld(null); + } } From e3eb08a983e093d8fb343ce03cf6283d698909da Mon Sep 17 00:00:00 2001 From: coolGi Date: Tue, 31 Oct 2023 19:35:07 +1030 Subject: [PATCH 2/5] Refactor of GitInfo. Removed core commit, and added Build Source --- .../jar/{ModGitInfo.java => ModJarInfo.java} | 26 +++++++++---------- .../core/jar/updater/SelfUpdater.java | 8 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) rename core/src/main/java/com/seibel/distanthorizons/core/jar/{ModGitInfo.java => ModJarInfo.java} (77%) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/jar/ModGitInfo.java b/core/src/main/java/com/seibel/distanthorizons/core/jar/ModJarInfo.java similarity index 77% rename from core/src/main/java/com/seibel/distanthorizons/core/jar/ModGitInfo.java rename to core/src/main/java/com/seibel/distanthorizons/core/jar/ModJarInfo.java index 3619a7170..fbbdded37 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/jar/ModGitInfo.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/jar/ModJarInfo.java @@ -31,16 +31,16 @@ import org.apache.logging.log4j.Logger; * * @author coolGi */ -public final class ModGitInfo +public final class ModJarInfo { private static final Logger LOGGER = LogManager.getLogger(); private static final String FILE_NAME = "build_info.json"; static { - String gitMainBranch = "UNKNOWN"; - String gitMainCommit = "UNKNOWN"; - String gitCoreCommit = "UNKNOWN"; + String gitBranch = "UNKNOWN"; + String gitCommit = "UNKNOWN"; + String buildSource = "UNKNOWN"; try { @@ -50,22 +50,22 @@ public final class ModGitInfo Config jsonObject = Config.inMemory(); JsonFormat.minimalInstance().createParser().parse(jsonString, jsonObject, ParsingMode.REPLACE); - gitCoreCommit = jsonObject.get("git_main_branch"); - gitMainCommit = jsonObject.get("git_main_commit"); - gitMainBranch = jsonObject.get("git_core_commit"); + gitBranch = jsonObject.get("info_git_branch"); + gitCommit = jsonObject.get("info_git_commit"); + buildSource = jsonObject.get("info_build_source"); } catch (Exception | Error e) { LOGGER.warn("Unable to get the Git information from " + FILE_NAME); } - Git_Core_Commit = gitMainBranch; - Git_Main_Commit = gitMainCommit; - Git_Main_Branch = gitCoreCommit; + Git_Commit = gitBranch; + Git_Branch = gitCommit; + Build_Source = buildSource; } - public static final String Git_Main_Branch; - public static final String Git_Main_Commit; - public static final String Git_Core_Commit; + public static final String Git_Branch; + public static final String Git_Commit; + public static final String Build_Source; } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java index e8126b5cb..88431fd46 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java @@ -22,7 +22,7 @@ package com.seibel.distanthorizons.core.jar.updater; import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.jar.JarUtils; -import com.seibel.distanthorizons.core.jar.ModGitInfo; +import com.seibel.distanthorizons.core.jar.ModJarInfo; import com.seibel.distanthorizons.core.jar.installer.GitlabGetter; import com.seibel.distanthorizons.core.jar.installer.ModrinthGetter; import com.seibel.distanthorizons.core.jar.installer.WebDownloader; @@ -126,7 +126,7 @@ public class SelfUpdater return false; com.electronwill.nightconfig.core.Config pipeline = GitlabGetter.INSTANCE.projectPipelines.get(0); - if (!pipeline.get("ref").equals(ModGitInfo.Git_Main_Branch)) + if (!pipeline.get("ref").equals(ModJarInfo.Git_Branch)) { //LOGGER.warn("Latest pipeline was found for branch ["+ pipeline.get("ref") +"], but we are on branch ["+ ModGitInfo.Git_Main_Branch +"]."); return false; @@ -134,7 +134,7 @@ public class SelfUpdater if (!pipeline.get("status").equals("success")) { - LOGGER.warn("Pipeline for branch ["+ ModGitInfo.Git_Main_Branch +"], commit ["+ pipeline.get("id") +"], has either failed to build, or still building."); + LOGGER.warn("Pipeline for branch ["+ ModJarInfo.Git_Branch +"], commit ["+ pipeline.get("id") +"], has either failed to build, or still building."); return false; } @@ -146,7 +146,7 @@ public class SelfUpdater String latestCommit = pipeline.get("sha"); - if (ModGitInfo.Git_Main_Commit.equals(latestCommit)) // If we are already on the latest commit, then dont update + if (ModJarInfo.Git_Commit.equals(latestCommit)) // If we are already on the latest commit, then dont update return false; From ad2e3e738efd40f871bab0d76e9db23a588e89ed Mon Sep 17 00:00:00 2001 From: James Seibel Date: Wed, 1 Nov 2023 21:05:13 -0500 Subject: [PATCH 3/5] Add try-finally for FullDataPointIdMap locks --- .../fullData/FullDataPointIdMap.java | 160 ++++++++++-------- 1 file changed, 90 insertions(+), 70 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/FullDataPointIdMap.java b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/FullDataPointIdMap.java index bf6e15a99..ced5f7e5d 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/FullDataPointIdMap.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/dataObjects/fullData/FullDataPointIdMap.java @@ -82,20 +82,26 @@ public class FullDataPointIdMap private Entry getEntry(int id) { - this.readWriteLock.readLock().lock(); - Entry entry; try { - entry = this.entryList.get(id); + this.readWriteLock.readLock().lock(); + Entry entry; + try + { + entry = this.entryList.get(id); + } + catch (IndexOutOfBoundsException e) + { + LOGGER.error("FullData ID Map out of sync for pos: " + this.pos + ". ID: [" + id + "] greater than the number of known ID's: [" + this.entryList.size() + "]."); + throw e; + } + + return entry; } - catch (IndexOutOfBoundsException e) + finally { - LOGGER.error("FullData ID Map out of sync for pos: " + this.pos + ". ID: [" + id + "] greater than the number of known ID's: [" + this.entryList.size() + "]."); - throw e; + this.readWriteLock.readLock().unlock(); } - - this.readWriteLock.readLock().unlock(); - return entry; } public IBiomeWrapper getBiomeWrapper(int id) { return this.getEntry(id).biome; } @@ -115,33 +121,37 @@ public class FullDataPointIdMap /** @param useWriteLocks should only be false if this method is already in a write lock to prevent unlocking at the wrong time */ private int addIfNotPresentAndGetId(Entry biomeBlockStateEntry, boolean useWriteLocks) { - if (useWriteLocks) + try { - this.readWriteLock.writeLock().lock(); + if (useWriteLocks) + { + this.readWriteLock.writeLock().lock(); + } + + + int id; + if (this.idMap.containsKey(biomeBlockStateEntry)) + { + // use the existing ID + id = this.idMap.get(biomeBlockStateEntry); + } + else + { + // Add the new ID + id = this.entryList.size(); + this.entryList.add(biomeBlockStateEntry); + this.idMap.put(biomeBlockStateEntry, id); + } + + return id; } - - - int id; - if (this.idMap.containsKey(biomeBlockStateEntry)) + finally { - // use the existing ID - id = this.idMap.get(biomeBlockStateEntry); + if (useWriteLocks) + { + this.readWriteLock.writeLock().unlock(); + } } - else - { - // Add the new ID - id = this.entryList.size(); - this.entryList.add(biomeBlockStateEntry); - this.idMap.put(biomeBlockStateEntry, id); - } - - - if (useWriteLocks) - { - this.readWriteLock.writeLock().unlock(); - } - - return id; } @@ -152,26 +162,31 @@ public class FullDataPointIdMap */ public int[] mergeAndReturnRemappedEntityIds(FullDataPointIdMap target) { - LOGGER.trace("merging {" + this.pos + ", " + this.entryList.size() + "} and {" + target.pos + ", " + target.entryList.size() + "}"); - - target.readWriteLock.readLock().lock(); - this.readWriteLock.writeLock().lock(); - - ArrayList entriesToMerge = target.entryList; - int[] remappedEntryIds = new int[entriesToMerge.size()]; - for (int i = 0; i < entriesToMerge.size(); i++) + try { - Entry entity = entriesToMerge.get(i); - int id = this.addIfNotPresentAndGetId(entity, false); - remappedEntryIds[i] = id; + LOGGER.trace("merging {" + this.pos + ", " + this.entryList.size() + "} and {" + target.pos + ", " + target.entryList.size() + "}"); + + target.readWriteLock.readLock().lock(); + this.readWriteLock.writeLock().lock(); + + ArrayList entriesToMerge = target.entryList; + int[] remappedEntryIds = new int[entriesToMerge.size()]; + for (int i = 0; i < entriesToMerge.size(); i++) + { + Entry entity = entriesToMerge.get(i); + int id = this.addIfNotPresentAndGetId(entity, false); + remappedEntryIds[i] = id; + } + + return remappedEntryIds; + } + finally + { + this.readWriteLock.writeLock().unlock(); + target.readWriteLock.readLock().unlock(); + + LOGGER.trace("finished merging {" + this.pos + ", " + this.entryList.size() + "} and {" + target.pos + ", " + target.entryList.size() + "}"); } - - this.readWriteLock.writeLock().unlock(); - target.readWriteLock.readLock().unlock(); - - LOGGER.trace("finished merging {" + this.pos + ", " + this.entryList.size() + "} and {" + target.pos + ", " + target.entryList.size() + "}"); - - return remappedEntryIds; } /** Should only be used if this map is going to be reused, otherwise bad things will happen. */ @@ -191,33 +206,38 @@ public class FullDataPointIdMap /** Serializes all contained entries into the given stream, formatted in UTF */ public void serialize(DhDataOutputStream outputStream) throws IOException { - this.readWriteLock.readLock().lock(); - outputStream.writeInt(this.entryList.size()); - - // only used when debugging - HashMap dataPointEntryBySerialization = new HashMap<>(); - - for (Entry entry : this.entryList) + try { - String entryString = entry.serialize(); - outputStream.writeUTF(entryString); + this.readWriteLock.readLock().lock(); + outputStream.writeInt(this.entryList.size()); - if (RUN_SERIALIZATION_DUPLICATE_VALIDATION) + // only used when debugging + HashMap dataPointEntryBySerialization = new HashMap<>(); + + for (Entry entry : this.entryList) { - if (dataPointEntryBySerialization.containsKey(entryString)) + String entryString = entry.serialize(); + outputStream.writeUTF(entryString); + + if (RUN_SERIALIZATION_DUPLICATE_VALIDATION) { - LOGGER.error("Duplicate serialized entry found with serial: " + entryString); + if (dataPointEntryBySerialization.containsKey(entryString)) + { + LOGGER.error("Duplicate serialized entry found with serial: " + entryString); + } + if (dataPointEntryBySerialization.containsValue(entry)) + { + LOGGER.error("Duplicate serialized entry found with value: " + entry.serialize()); + } + dataPointEntryBySerialization.put(entryString, entry); } - if (dataPointEntryBySerialization.containsValue(entry)) - { - LOGGER.error("Duplicate serialized entry found with value: " + entry.serialize()); - } - dataPointEntryBySerialization.put(entryString, entry); } } - this.readWriteLock.readLock().unlock(); - - LOGGER.trace("serialize " + this.pos + " " + this.entryList.size()); + finally + { + this.readWriteLock.readLock().unlock(); + LOGGER.trace("serialize " + this.pos + " " + this.entryList.size()); + } } /** Creates a new IdBiomeBlockStateMap from the given UTF formatted stream */ From 528499215a0c4ed5adf38c27eec4ea52c19e9d14 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Wed, 1 Nov 2023 21:13:38 -0500 Subject: [PATCH 4/5] re-add CPU option I_PAID_FOR_THE_WHOLE_CPU --- .../api/enums/config/quickOptions/EThreadPreset.java | 2 +- .../presets/ThreadPresetConfigEventHandler.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/src/main/java/com/seibel/distanthorizons/api/enums/config/quickOptions/EThreadPreset.java b/api/src/main/java/com/seibel/distanthorizons/api/enums/config/quickOptions/EThreadPreset.java index cbc098db7..8773ff1a4 100644 --- a/api/src/main/java/com/seibel/distanthorizons/api/enums/config/quickOptions/EThreadPreset.java +++ b/api/src/main/java/com/seibel/distanthorizons/api/enums/config/quickOptions/EThreadPreset.java @@ -46,6 +46,6 @@ public enum EThreadPreset AGGRESSIVE, // temporarily removed due to stability concerns - //I_PAID_FOR_THE_WHOLE_CPU; + I_PAID_FOR_THE_WHOLE_CPU, } \ No newline at end of file diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/presets/ThreadPresetConfigEventHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/presets/ThreadPresetConfigEventHandler.java index a7d47c523..67b7e2010 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/presets/ThreadPresetConfigEventHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/presets/ThreadPresetConfigEventHandler.java @@ -49,7 +49,7 @@ public class ThreadPresetConfigEventHandler extends AbstractPresetConfigEventHan this.put(EThreadPreset.LOW_IMPACT, getWorldGenDefaultThreadCount()); this.put(EThreadPreset.BALANCED, getThreadCountByPercent(0.25)); this.put(EThreadPreset.AGGRESSIVE, getThreadCountByPercent(0.5)); - //this.put(EThreadPreset.I_PAID_FOR_THE_WHOLE_CPU, getThreadCountByPercent(1.0)); + this.put(EThreadPreset.I_PAID_FOR_THE_WHOLE_CPU, getThreadCountByPercent(1.0)); }}); public static double getWorldGenDefaultRunTimeRatio() { return LOW_THREAD_COUNT_CPU ? 0.5 : 0.75; } private final ConfigEntryWithPresetOptions worldGenRunTime = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.runTimeRatioForWorldGenerationThreads, @@ -59,7 +59,7 @@ public class ThreadPresetConfigEventHandler extends AbstractPresetConfigEventHan this.put(EThreadPreset.LOW_IMPACT, getWorldGenDefaultRunTimeRatio()); this.put(EThreadPreset.BALANCED, LOW_THREAD_COUNT_CPU ? 0.5 : 0.75); this.put(EThreadPreset.AGGRESSIVE, LOW_THREAD_COUNT_CPU ? 0.75 : 1.0); - //this.put(EThreadPreset.I_PAID_FOR_THE_WHOLE_CPU, 1.0); + this.put(EThreadPreset.I_PAID_FOR_THE_WHOLE_CPU, 1.0); }}); @@ -71,7 +71,7 @@ public class ThreadPresetConfigEventHandler extends AbstractPresetConfigEventHan this.put(EThreadPreset.LOW_IMPACT, getFileHandlerDefaultThreadCount()); this.put(EThreadPreset.BALANCED, getThreadCountByPercent(0.2)); this.put(EThreadPreset.AGGRESSIVE, getThreadCountByPercent(0.2)); - //this.put(EThreadPreset.I_PAID_FOR_THE_WHOLE_CPU, getThreadCountByPercent(1.0)); + this.put(EThreadPreset.I_PAID_FOR_THE_WHOLE_CPU, getThreadCountByPercent(1.0)); }}); public static double getFileHandlerDefaultRunTimeRatio() { return 0.5; } private final ConfigEntryWithPresetOptions fileHandlerRunTime = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.runTimeRatioForFileHandlerThreads, @@ -81,7 +81,7 @@ public class ThreadPresetConfigEventHandler extends AbstractPresetConfigEventHan this.put(EThreadPreset.LOW_IMPACT, getFileHandlerDefaultRunTimeRatio()); this.put(EThreadPreset.BALANCED, 0.75); this.put(EThreadPreset.AGGRESSIVE, 1.0); - //this.put(EThreadPreset.I_PAID_FOR_THE_WHOLE_CPU, 1.0); + this.put(EThreadPreset.I_PAID_FOR_THE_WHOLE_CPU, 1.0); }}); @@ -93,7 +93,7 @@ public class ThreadPresetConfigEventHandler extends AbstractPresetConfigEventHan this.put(EThreadPreset.LOW_IMPACT, getLodBuilderDefaultThreadCount()); this.put(EThreadPreset.BALANCED, getThreadCountByPercent(0.2)); this.put(EThreadPreset.AGGRESSIVE, getThreadCountByPercent(0.4)); - //this.put(EThreadPreset.I_PAID_FOR_THE_WHOLE_CPU, getThreadCountByPercent(1.0)); + this.put(EThreadPreset.I_PAID_FOR_THE_WHOLE_CPU, getThreadCountByPercent(1.0)); }}); public static double getLodBuilderDefaultRunTimeRatio() { return LOW_THREAD_COUNT_CPU ? 0.25 : 0.5; } private final ConfigEntryWithPresetOptions lodBuilderRunTime = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.MultiThreading.runTimeRatioForLodBuilderThreads, @@ -103,7 +103,7 @@ public class ThreadPresetConfigEventHandler extends AbstractPresetConfigEventHan this.put(EThreadPreset.LOW_IMPACT, getLodBuilderDefaultRunTimeRatio()); this.put(EThreadPreset.BALANCED, LOW_THREAD_COUNT_CPU ? 0.5 : 0.75); this.put(EThreadPreset.AGGRESSIVE, 1.0); - //this.put(EThreadPreset.I_PAID_FOR_THE_WHOLE_CPU, 1.0); + this.put(EThreadPreset.I_PAID_FOR_THE_WHOLE_CPU, 1.0); }}); From 0b3958eb58386e76fd380e161cc22e251ad113b0 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Thu, 2 Nov 2023 21:44:57 -0500 Subject: [PATCH 5/5] Fix Optifine shaders not rendering --- .../core/api/internal/SharedApi.java | 6 +++++- .../core/render/renderer/LodRenderer.java | 21 ++++++++++++++++--- .../minecraft/IMinecraftRenderWrapper.java | 7 +++++++ 3 files changed, 30 insertions(+), 4 deletions(-) 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 e697ed20c..9691c82a4 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 @@ -21,6 +21,7 @@ package com.seibel.distanthorizons.core.api.internal; import com.seibel.distanthorizons.core.Initializer; import com.seibel.distanthorizons.core.config.Config; +import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.generation.DhLightingEngine; import com.seibel.distanthorizons.core.level.IDhLevel; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; @@ -30,6 +31,7 @@ import com.seibel.distanthorizons.core.util.objects.Pair; import com.seibel.distanthorizons.core.util.threading.ThreadPools; import com.seibel.distanthorizons.core.world.*; import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper; +import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; import org.apache.logging.log4j.Logger; @@ -45,9 +47,10 @@ import java.util.concurrent.ThreadPoolExecutor; /** Contains code and variables used by both {@link ClientApi} and {@link ServerApi} */ public class SharedApi { - private static final Logger LOGGER = DhLoggerBuilder.getLogger(); public static final SharedApi INSTANCE = new SharedApi(); + private static final Logger LOGGER = DhLoggerBuilder.getLogger(); + private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class); private static final Set UPDATING_CHUNK_SET = ConcurrentHashMap.newKeySet(); @@ -88,6 +91,7 @@ public class SharedApi { ThreadPools.shutdownThreadPools(); DebugRenderer.clearRenderables(); + MC_RENDER.clearTargetFrameBuffer(); // recommend that the garbage collector cleans up any objects from the old world and thread pools System.gc(); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/LodRenderer.java b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/LodRenderer.java index a6650fcbd..bc229309c 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/LodRenderer.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/renderer/LodRenderer.java @@ -231,6 +231,12 @@ public class LodRenderer return; } + if (AbstractOptifineAccessor.optifinePresent() && MC_RENDER.getTargetFrameBuffer() == -1) + { + // wait for MC to finish setting up their renderer + return; + } + if (!renderLock.tryLock()) { // never lock the render thread, if the lock isn't available don't wait for it @@ -298,8 +304,17 @@ public class LodRenderer // Bind LOD frame buffer this.framebuffer.bind(); - // Clear LOD framebuffer and depth buffers - GL32.glClear(GL32.GL_COLOR_BUFFER_BIT | GL32.GL_DEPTH_BUFFER_BIT); + + if (this.usingMcFrameBuffer) + { + // don't clear the color texture, that removes the sky + GL32.glClear(GL32.GL_DEPTH_BUFFER_BIT); + } + else + { + GL32.glClear(GL32.GL_COLOR_BUFFER_BIT | GL32.GL_DEPTH_BUFFER_BIT); + } + GL32.glEnable(GL32.GL_DEPTH_TEST); GL32.glDepthFunc(GL32.GL_LESS); @@ -514,7 +529,7 @@ public class LodRenderer if (AbstractOptifineAccessor.optifinePresent()) { // use MC/Optifine's default FrameBuffer so shaders won't remove the LODs - int currentFrameBufferId = GL32.glGetInteger(GL32.GL_FRAMEBUFFER_BINDING); + int currentFrameBufferId = MC_RENDER.getTargetFrameBuffer(); this.framebuffer = new DhFramebuffer(currentFrameBufferId); this.usingMcFrameBuffer = true; } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/minecraft/IMinecraftRenderWrapper.java b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/minecraft/IMinecraftRenderWrapper.java index 82d440737..7ca801e3f 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/minecraft/IMinecraftRenderWrapper.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/minecraft/IMinecraftRenderWrapper.java @@ -75,11 +75,18 @@ public interface IMinecraftRenderWrapper extends IBindable int getScreenWidth(); int getScreenHeight(); + /** @return -1 if no valid framebuffer is available yet */ int getTargetFrameBuffer(); int getDepthTextureId(); int getTargetFrameBufferViewportWidth(); int getTargetFrameBufferViewportHeight(); + /** + * generally shouldn't be needed, the frame buffer should generally stay the same + * but in case something goes wrong this allows for re-getting the buffer ID. + */ + void clearTargetFrameBuffer(); + /** * This method returns the ChunkPos of all chunks that Minecraft * is going to render this frame.