Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 91f9ef3f4b | |||
| d52a3abb14 | |||
| 16370b0b6e | |||
| bfa60b48cf | |||
| 50518bfe21 | |||
| 80e4467829 | |||
| 396315bd05 | |||
| 7a0fec2c2f | |||
| 4afaaa7b12 | |||
| b057041467 | |||
| 33e6ce6376 | |||
| 118ef39c30 | |||
| 1013e1c824 | |||
| b0e924c7fe | |||
| 1777acd1d4 | |||
| 8276a862f8 | |||
| 4329acf91d | |||
| 72f83b40f7 | |||
| a33eb30a53 | |||
| d3e96f50a8 | |||
| 3aefeb98b4 | |||
| 3553ff8e60 | |||
| 945a2c0c5a | |||
| 8c7974e216 | |||
| 37756cd759 | |||
| c60cc4f013 | |||
| 87cce2e33c | |||
| 40ada9c186 | |||
| 55fb458266 | |||
| 79d2466fa2 | |||
| d750e489df | |||
| a206e49b2b | |||
| 0b691ebcd5 | |||
| 3c35c52803 | |||
| 0ed4964ee5 | |||
| b7cf7b61c8 | |||
| 54b0ccfce6 | |||
| 050d00b628 | |||
| 2733201ac3 | |||
| 26bf03205c | |||
| 628d57d216 | |||
| 58ed8259f2 | |||
| e5536de44f |
@@ -25,6 +25,8 @@ hs_err_pid*
|
||||
Merged/
|
||||
# Folder created by the buildAll scripts
|
||||
buildAllJars/
|
||||
_buildAllJars/
|
||||
_buildWorkers/
|
||||
|
||||
relocate_natives/.venv/
|
||||
relocate_natives/__pycache__/
|
||||
|
||||
@@ -5,4 +5,24 @@ plugins {
|
||||
|
||||
forgix {
|
||||
autoRun = true
|
||||
|
||||
// add the mod loaders to the end of the jar
|
||||
// put together in the format: "a", "a-b", "a-b-c"
|
||||
String modLoaders = "";
|
||||
((String) gradle.builds_for)
|
||||
.split(",")
|
||||
.each
|
||||
{ loader ->
|
||||
def loaderName = loader.trim()
|
||||
if (modLoaders != "")
|
||||
{
|
||||
modLoaders += "-";
|
||||
}
|
||||
|
||||
modLoaders += loaderName;
|
||||
}
|
||||
// merged jars are named in the format:
|
||||
// "DistantHorizons-3.0.1-b-dev-26.1-fabric-neoforge.jar"
|
||||
archiveClassifier = modLoaders
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,6 @@ for d in versionProperties/*; do
|
||||
sh gradlew build -PmcVer=$version
|
||||
if [ $? != 0 ]; then continue; fi
|
||||
|
||||
echo "==================== Merging $version ===================="
|
||||
sh gradlew mergeJars -PmcVer=$version
|
||||
if [ $? != 0 ]; then continue; fi
|
||||
|
||||
echo "==================== Moving jar ===================="
|
||||
mv build/forgix/*.jar buildAllJars/
|
||||
done
|
||||
|
||||
@@ -20,9 +20,6 @@ for %%f in (versionProperties\*) do (
|
||||
echo ==================== Building !version! ====================
|
||||
call .\gradlew.bat build -PmcVer="!version!"
|
||||
|
||||
echo ==================== Merging !version! ====================
|
||||
call .\gradlew.bat mergeJars -PmcVer="!version!"
|
||||
|
||||
echo ==================== Moving jar ====================
|
||||
move build\forgix\*.jar buildAllJars\
|
||||
)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
@echo off & setlocal enabledelayedexpansion
|
||||
|
||||
|
||||
echo ==================== Getting versions to build... ====================
|
||||
mkdir _buildAllJars 2>nul
|
||||
del _buildAllJars\* /Q 2>nul
|
||||
|
||||
set "ROOT=%~dp0"
|
||||
set "WORK_DIR=%ROOT%_buildWorkers"
|
||||
mkdir "%WORK_DIR%" 2>nul
|
||||
|
||||
|
||||
REM get the number of versions to compile
|
||||
set count=0
|
||||
for %%f in (versionProperties\*) do set /a count+=1
|
||||
echo ==================== Found %count% versions to build in parallel ====================
|
||||
|
||||
REM Launch a parallel job for each version
|
||||
for %%f in (%ROOT%versionProperties\*) do (
|
||||
set version=%%~nf
|
||||
|
||||
echo starting [!version!]...
|
||||
start "Build !version!" cmd /c ""%ROOT%build_worker.bat" "!version!" "%ROOT%" "%WORK_DIR%" ""..\..\_buildAllJars"""
|
||||
|
||||
REM Minor timeout between launches so we can stop the build early if we only want
|
||||
REM to test part of the script and to reduce startup load
|
||||
timeout /t 3 /nobreak
|
||||
|
||||
REM 2>nul to supress a harmless warning that the for loop
|
||||
REM "cannot find the drive specified"
|
||||
) 2>nul
|
||||
|
||||
|
||||
echo ==================== All builds started... Completed Jars will be in _buildAllJars ====================
|
||||
endlocal
|
||||
@@ -0,0 +1,41 @@
|
||||
@echo off & setlocal enabledelayedexpansion
|
||||
|
||||
set "VERSION=%~1"
|
||||
set "ROOT=%~2"
|
||||
set "WORK_DIR=%~3"
|
||||
set "WORKER=%WORK_DIR%\%VERSION%"
|
||||
set "JAR_OUTPUT_DIR=%~4"
|
||||
|
||||
REM remove the ending "\" from the root folder, otherwise the final quote
|
||||
REM in the robocopy command will be escaped and it won't run
|
||||
if "%ROOT:~-1%"=="\" set "ROOT=%ROOT:~0,-1%"
|
||||
set "WORKER=%~3\%~1"
|
||||
|
||||
set "BUILT_JAR_DIR=%WORKER%\build\forgix"
|
||||
|
||||
|
||||
|
||||
echo ==================== [%VERSION%] Copying workspace ====================
|
||||
mkdir "%WORKER%"
|
||||
robocopy "%ROOT%" "%WORKER%" /E /XD "%WORKER%" "_buildWorkers" "buildAllJars" ".gradle" "build" ".git" ".idea" ".gitlab" "run" "testScripts" /NFL /NDL
|
||||
|
||||
echo ==================== [%VERSION%] Cleaning ====================
|
||||
cd /d "%WORKER%"
|
||||
call .\gradlew.bat clean
|
||||
REM optional arg that can be added if we want to log the result to a file
|
||||
REM >"%WORK_DIR%\build_%VERSION%.log" 2>&1
|
||||
|
||||
echo ==================== [%VERSION%] Assembling ====================
|
||||
call .\gradlew.bat assemble -PmcVer="%VERSION%"
|
||||
REM optional arg that can be added if we want to log the result to a file
|
||||
REM >>"%WORK_DIR%\build_%VERSION%.log" 2>&1
|
||||
|
||||
echo ==================== [%VERSION%] Exporting ====================
|
||||
mkdir "%JAR_OUTPUT_DIR%"
|
||||
robocopy "%BUILT_JAR_DIR%" "%JAR_OUTPUT_DIR%" /NFL /NDL
|
||||
|
||||
echo ==================== [%VERSION%] Done ====================
|
||||
endlocal
|
||||
|
||||
REM can be uncommented for debugging
|
||||
REM pause
|
||||
@@ -8,8 +8,8 @@ import com.seibel.distanthorizons.common.commands.CommandInitializer;
|
||||
import com.seibel.distanthorizons.common.wrappers.DependencySetup;
|
||||
import com.seibel.distanthorizons.common.wrappers.gui.DhDebugScreenEntry;
|
||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftServerWrapper;
|
||||
import com.seibel.distanthorizons.core.Initializer;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.config.ConfigHandler;
|
||||
import com.seibel.distanthorizons.core.config.eventHandlers.presets.ThreadPresetConfigEventHandler;
|
||||
@@ -95,7 +95,8 @@ public abstract class AbstractModInitializer
|
||||
|
||||
// Client uses config for auto-updater, so it's initialized here instead of post-init stage
|
||||
this.initConfig();
|
||||
logModIncompatibilityWarnings(); // needs to be called after config loading
|
||||
logIncompatibilityWarnings(); // needs to be called after config loading
|
||||
Initializer.postConfigInit();
|
||||
|
||||
LOGGER.info(ModInfo.READABLE_NAME + " client Initialized.");
|
||||
|
||||
@@ -137,6 +138,7 @@ public abstract class AbstractModInitializer
|
||||
MinecraftServerWrapper.INSTANCE.dedicatedServer = (DedicatedServer)server;
|
||||
|
||||
this.initConfig();
|
||||
Initializer.postConfigInit();
|
||||
this.postInit();
|
||||
this.postServerInit();
|
||||
this.commandInitializer.onServerReady();
|
||||
@@ -159,7 +161,7 @@ public abstract class AbstractModInitializer
|
||||
private void startup()
|
||||
{
|
||||
DependencySetup.createSharedBindings();
|
||||
SharedApi.init();
|
||||
Initializer.preConfigInit();
|
||||
this.createInitialSharedBindings();
|
||||
}
|
||||
|
||||
@@ -261,9 +263,9 @@ public abstract class AbstractModInitializer
|
||||
|
||||
|
||||
|
||||
//==================================//
|
||||
// mod partial compatibility checks //
|
||||
//==================================//
|
||||
//======================//
|
||||
// compatibility checks //
|
||||
//======================//
|
||||
//region
|
||||
|
||||
/**
|
||||
@@ -272,7 +274,7 @@ public abstract class AbstractModInitializer
|
||||
* This method will log (and display to chat if enabled)
|
||||
* these warnings and potential fixes.
|
||||
*/
|
||||
private static void logModIncompatibilityWarnings()
|
||||
private static void logIncompatibilityWarnings()
|
||||
{
|
||||
boolean showChatWarnings = Config.Common.Logging.Warning.showModCompatibilityWarningsOnStartup.get();
|
||||
IModChecker modChecker = SingletonInjector.INSTANCE.get(IModChecker.class);
|
||||
|
||||
+21
-21
@@ -299,27 +299,27 @@ public class BlazeDebugWireframeRenderer extends AbstractDebugWireframeRenderer
|
||||
|
||||
// render //
|
||||
|
||||
//try (RenderPass renderPass = commandEncoder.createRenderPass(
|
||||
// this::getRenderPassName,
|
||||
// BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureView,
|
||||
// /*optionalClearColorAsInt*/ OptionalInt.empty(),
|
||||
// BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView,
|
||||
// /*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
||||
//{
|
||||
// // Bind instance data //
|
||||
// renderPass.setUniform("uniformBlock", this.uniformBuffer);
|
||||
//
|
||||
// renderPass.setPipeline(this.pipeline);
|
||||
// renderPass.setIndexBuffer(this.boxIndexBuffer, VertexFormat.IndexType.INT);
|
||||
//
|
||||
// renderPass.setVertexBuffer(0, this.boxVertexBuffer);
|
||||
//
|
||||
// renderPass.drawIndexed(
|
||||
// /*indexStart*/ 0,
|
||||
// /*firstIndex*/0,
|
||||
// /*indexCount*/BOX_OUTLINE_INDICES.length,
|
||||
// /*instanceCount*/1);
|
||||
//}
|
||||
try (RenderPass renderPass = commandEncoder.createRenderPass(
|
||||
this::getRenderPassName,
|
||||
BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureView,
|
||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
||||
BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView,
|
||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
||||
{
|
||||
// Bind instance data //
|
||||
renderPass.setUniform("uniformBlock", this.uniformBuffer);
|
||||
|
||||
renderPass.setPipeline(this.pipeline);
|
||||
renderPass.setIndexBuffer(this.boxIndexBuffer, VertexFormat.IndexType.INT);
|
||||
|
||||
renderPass.setVertexBuffer(0, this.boxVertexBuffer);
|
||||
|
||||
renderPass.drawIndexed(
|
||||
/*indexStart*/ 0,
|
||||
/*firstIndex*/0,
|
||||
/*indexCount*/BOX_OUTLINE_INDICES.length,
|
||||
/*instanceCount*/1);
|
||||
}
|
||||
}
|
||||
private String getRenderPassName() { return "distantHorizons:McDebugRenderer"; }
|
||||
|
||||
|
||||
+3
@@ -19,6 +19,7 @@ import com.mojang.blaze3d.systems.RenderPass;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeBufferRenderEvent;
|
||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeRenderPassEvent;
|
||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||
@@ -267,6 +268,8 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
||||
{
|
||||
profiler.popPush("rendering");
|
||||
|
||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam);
|
||||
|
||||
// create a render pass
|
||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
||||
this::getRenderPassName,
|
||||
|
||||
-2
@@ -10,7 +10,6 @@ import com.seibel.distanthorizons.common.render.openGl.glObject.GLProxy;
|
||||
import com.seibel.distanthorizons.common.render.openGl.glObject.GlDhFramebuffer;
|
||||
import com.seibel.distanthorizons.common.render.openGl.glObject.texture.*;
|
||||
import com.seibel.distanthorizons.common.render.openGl.postProcessing.apply.GlDhApplyShader;
|
||||
import com.seibel.distanthorizons.common.render.openGl.terrain.GlDhTerrainShaderProgram;
|
||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
@@ -22,7 +21,6 @@ import com.seibel.distanthorizons.core.render.DhApiRenderProxy;
|
||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.ILightMapWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.AbstractOptifineAccessor;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhMetaRenderer;
|
||||
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
||||
|
||||
+97
-39
@@ -21,7 +21,6 @@ package com.seibel.distanthorizons.common.render.openGl.glObject.buffer;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
|
||||
import com.seibel.distanthorizons.common.render.openGl.glObject.GLProxy;
|
||||
import com.seibel.distanthorizons.common.render.openGl.glObject.GLState;
|
||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||
@@ -39,6 +38,7 @@ import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.StampedLock;
|
||||
|
||||
public class GLBuffer implements AutoCloseable
|
||||
{
|
||||
@@ -62,14 +62,24 @@ public class GLBuffer implements AutoCloseable
|
||||
private static final ThreadPoolExecutor CLEANUP_THREAD = ThreadUtil.makeSingleDaemonThreadPool("GLBuffer Cleanup");
|
||||
|
||||
|
||||
protected int id;
|
||||
protected volatile int id = 0;
|
||||
public final int getId() { return this.id; }
|
||||
protected int size = 0;
|
||||
public int getSize() { return this.size; }
|
||||
protected boolean bufferStorage;
|
||||
public final boolean isBufferStorage() { return this.bufferStorage; }
|
||||
protected boolean isMapped = false;
|
||||
|
||||
/**
|
||||
* Locking on the render thread isn't great, but is needed due to an inconsistent
|
||||
* race condition where VBOs can be marked as deleted outside the render thread. <br><br>
|
||||
*
|
||||
* But, due to being a read-write lock the chance of freezing
|
||||
* the render thread is very low
|
||||
* and since this is a stamped lock, the optimistic read time is basically zero.
|
||||
* (The optimistic lock time doesn't even appear in the profiler).
|
||||
*/
|
||||
public final StampedLock renderStampLock = new StampedLock();
|
||||
|
||||
|
||||
|
||||
//==============//
|
||||
@@ -112,36 +122,73 @@ public class GLBuffer implements AutoCloseable
|
||||
LodUtil.assertNotReach("Thread ["+Thread.currentThread()+"] tried to create a GLBuffer outside the MC render thread.");
|
||||
}
|
||||
|
||||
// destroy the old buffer if one is present
|
||||
if (this.id != 0)
|
||||
|
||||
// lock to prevent the render thread from accessing the buffer's ID
|
||||
// while we are removing it
|
||||
long writeStamp = renderStampLock.writeLock();
|
||||
try
|
||||
{
|
||||
destroyBufferIdNow(this.id);
|
||||
int oldId = this.id;
|
||||
this.id = GLMC.glGenBuffers();
|
||||
|
||||
// destroy the old buffer
|
||||
// after the new one has been created
|
||||
// to hopefully prevent a rare race conditions where the old ID
|
||||
// is still used somewhere
|
||||
if (oldId != 0)
|
||||
{
|
||||
// this ID doesn't need to be tracked anymore
|
||||
tryRemoveBufferIdFromPhantom(oldId);
|
||||
destroyBufferIdNow(oldId);
|
||||
}
|
||||
|
||||
|
||||
this.bufferStorage = asBufferStorage;
|
||||
bufferCount.getAndIncrement();
|
||||
|
||||
PhantomReference<GLBuffer> phantom = new PhantomReference<>(this, PHANTOM_REFERENCE_QUEUE);
|
||||
PHANTOM_TO_BUFFER_ID.put(phantom, this.id);
|
||||
BUFFER_ID_TO_PHANTOM.put(this.id, phantom);
|
||||
}
|
||||
finally
|
||||
{
|
||||
renderStampLock.unlock(writeStamp);
|
||||
}
|
||||
|
||||
this.id = GLMC.glGenBuffers();
|
||||
this.bufferStorage = asBufferStorage;
|
||||
bufferCount.getAndIncrement();
|
||||
|
||||
PhantomReference<GLBuffer> phantom = new PhantomReference<>(this, PHANTOM_REFERENCE_QUEUE);
|
||||
PHANTOM_TO_BUFFER_ID.put(phantom, this.id);
|
||||
BUFFER_ID_TO_PHANTOM.put(this.id, phantom);
|
||||
|
||||
}
|
||||
|
||||
protected void destroyAsync()
|
||||
{
|
||||
if (this.id == 0)
|
||||
// lock to prevent the render thread from accessing the buffer's ID
|
||||
// while we are removing it
|
||||
long writeStamp = renderStampLock.writeLock();
|
||||
try
|
||||
{
|
||||
// the buffer has already been closed
|
||||
return;
|
||||
if (this.id == 0)
|
||||
{
|
||||
// the buffer has already been closed
|
||||
return;
|
||||
}
|
||||
|
||||
final int idToDelete = this.id; // saving the ID to a separate variable is necessary so it can be captured by the lambda
|
||||
|
||||
// remove the phantom tracking now so the phantom doesn't have the chance to
|
||||
// get garbage collected before the render thread task runs
|
||||
// (this can happen if MC is running at extremely low framerates like 1 fps via mods)
|
||||
tryRemoveBufferIdFromPhantom(idToDelete);
|
||||
|
||||
// mark the old data is invalid before deleting to prevent a rare race condition
|
||||
// where the queued on render thread task runs before the ID is cleared
|
||||
this.id = 0;
|
||||
this.size = 0;
|
||||
|
||||
RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("GLBuffer destroyAsync", () -> { destroyBufferIdNow(idToDelete); });
|
||||
}
|
||||
finally
|
||||
{
|
||||
renderStampLock.unlock(writeStamp);
|
||||
}
|
||||
|
||||
final int idToDelete = this.id; // saving the ID to a separate variable is necessary so it can be captured by the lambda
|
||||
RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("GLBuffer destroyAsync", () -> { destroyBufferIdNow(idToDelete); });
|
||||
|
||||
this.id = 0;
|
||||
this.size = 0;
|
||||
}
|
||||
|
||||
private static void destroyBufferIdNow(int id)
|
||||
{
|
||||
// only delete valid buffers
|
||||
@@ -151,20 +198,6 @@ public class GLBuffer implements AutoCloseable
|
||||
return;
|
||||
}
|
||||
|
||||
// remove and clear the phantom reference if present
|
||||
if (BUFFER_ID_TO_PHANTOM.containsKey(id))
|
||||
{
|
||||
Reference<? extends GLBuffer> phantom = BUFFER_ID_TO_PHANTOM.get(id);
|
||||
|
||||
// if we are manually closing this buffer, we don't want the phantom reference to accidentally close it again
|
||||
// this can cause a race condition were we accidentally delete an in-use buffer and cause NVIDIA
|
||||
// to throw an EXCEPTION_ACCESS_VIOLATION when we attempt to render it
|
||||
phantom.clear();
|
||||
|
||||
PHANTOM_TO_BUFFER_ID.remove(phantom);
|
||||
BUFFER_ID_TO_PHANTOM.remove(id);
|
||||
}
|
||||
|
||||
bufferCount.decrementAndGet();
|
||||
|
||||
// destroy the buffer if it exists,
|
||||
@@ -178,6 +211,32 @@ public class GLBuffer implements AutoCloseable
|
||||
LOGGER.info("destroyed buffer [" + id + "], remaining: [" + BUFFER_ID_TO_PHANTOM.size() + "]");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// shouldn't happen, but just in case
|
||||
LOGGER.warn("Attempted to destroy a non buffer object with ID ["+id+"].");
|
||||
}
|
||||
}
|
||||
|
||||
/** should be called before {@link GLBuffer#destroyBufferIdNow} */
|
||||
private static void tryRemoveBufferIdFromPhantom(int id)
|
||||
{
|
||||
if (BUFFER_ID_TO_PHANTOM.containsKey(id))
|
||||
{
|
||||
Reference<? extends GLBuffer> phantom = BUFFER_ID_TO_PHANTOM.get(id);
|
||||
|
||||
// if we are manually closing this buffer, we don't want the phantom reference to accidentally close it again
|
||||
// this can cause a race condition were we accidentally delete an in-use buffer and cause NVIDIA
|
||||
// to throw an EXCEPTION_ACCESS_VIOLATION when we attempt to render it
|
||||
phantom.clear();
|
||||
|
||||
PHANTOM_TO_BUFFER_ID.remove(phantom);
|
||||
BUFFER_ID_TO_PHANTOM.remove(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.warn("Unable to remove phantom GLBuffer with ID ["+id+"], buffer may have already been deleted.");
|
||||
}
|
||||
}
|
||||
|
||||
//endregion
|
||||
@@ -321,7 +380,6 @@ public class GLBuffer implements AutoCloseable
|
||||
{
|
||||
// recreate if the buffer storage type changed
|
||||
this.bind();
|
||||
destroyBufferIdNow(this.id);
|
||||
this.destroyOldAndCreate(uploadMethod.useBufferStorage);
|
||||
this.bind();
|
||||
}
|
||||
|
||||
+46
-17
@@ -289,6 +289,9 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
|
||||
GLMC.disableBlend();
|
||||
}
|
||||
|
||||
// needs to be triggered after DH attempts to set the GL state so that Iris
|
||||
// can override it as needed
|
||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam);
|
||||
|
||||
|
||||
|
||||
@@ -311,6 +314,12 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
|
||||
for (int lodIndex = 0; lodIndex < bufferContainers.size(); lodIndex++)
|
||||
{
|
||||
LodBufferContainer bufferContainer = bufferContainers.get(lodIndex);
|
||||
if (!bufferContainer.buffersUploaded)
|
||||
{
|
||||
// make sure we don't accidentally try
|
||||
// rendering a buffer that is (or is going to be) freed
|
||||
continue;
|
||||
}
|
||||
|
||||
// set uniforms and fire events
|
||||
{
|
||||
@@ -335,25 +344,45 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
|
||||
continue;
|
||||
}
|
||||
|
||||
if (vbo.getVertexCount() == 0)
|
||||
|
||||
// for lock information please view the lock's javadocs
|
||||
long vboReadStamp = vbo.renderStampLock.readLock();
|
||||
long iboReadStamp = vbo.getQuadIBO().renderStampLock.readLock();
|
||||
try
|
||||
{
|
||||
continue;
|
||||
// don't render empty sections
|
||||
if (vbo.getVertexCount() == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// don't render deleted VBOs (this will crash the driver/game)
|
||||
if (vbo.getId() == 0
|
||||
|| vbo.getQuadIBO().getId() == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// 4 vertices per face, but 6 indices (IE 2 triangles) per face, aka need to multiply by 1.5
|
||||
int indexCount = (int) (vbo.getVertexCount() * 1.5);
|
||||
|
||||
vbo.bind();
|
||||
vbo.getQuadIBO().bind();
|
||||
|
||||
GlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.bindVertexBuffer(vbo.getId());
|
||||
GL32.glDrawElements(
|
||||
GL32.GL_TRIANGLES,
|
||||
indexCount,
|
||||
vbo.getQuadIBO().getGlType(), 0);
|
||||
|
||||
vbo.unbind();
|
||||
vbo.getQuadIBO().unbind();
|
||||
}
|
||||
finally
|
||||
{
|
||||
vbo.renderStampLock.unlock(vboReadStamp);
|
||||
vbo.getQuadIBO().renderStampLock.unlock(iboReadStamp);
|
||||
}
|
||||
|
||||
// 4 vertices per face, but 6 indices (IE 2 triangles) per face, aka need to multiply by 1.5
|
||||
int indexCount = (int)(vbo.getVertexCount() * 1.5);
|
||||
|
||||
vbo.bind();
|
||||
vbo.getQuadIBO().bind();
|
||||
|
||||
GlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.bindVertexBuffer(vbo.getId());
|
||||
GL32.glDrawElements(
|
||||
GL32.GL_TRIANGLES,
|
||||
indexCount,
|
||||
vbo.getQuadIBO().getGlType(), 0);
|
||||
|
||||
vbo.unbind();
|
||||
vbo.getQuadIBO().unbind();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -80,9 +80,20 @@ public class DependencySetup
|
||||
SingletonInjector.INSTANCE.bind(IConfigGui.class, ClassicConfigGUI.CONFIG_CORE_INTERFACE);
|
||||
}
|
||||
|
||||
private static boolean renderingApiBindingsSet = false;
|
||||
/** will be called from a DH thread, not the render thread */
|
||||
public static void setRenderingApiBindings()
|
||||
public synchronized static void setRenderingApiBindings()
|
||||
{
|
||||
// shouldn't happen, but there was a single report that this method was triggered twice
|
||||
if (renderingApiBindingsSet)
|
||||
{
|
||||
LOGGER.warn("Rendering bindings already set, skipping. How did this happen?");
|
||||
return;
|
||||
}
|
||||
renderingApiBindingsSet = true;
|
||||
|
||||
|
||||
|
||||
EDhApiRenderApi renderingApiEnum = Config.Client.Advanced.Graphics.Experimental.renderingApi.get();
|
||||
if (renderingApiEnum == EDhApiRenderApi.AUTO)
|
||||
{
|
||||
|
||||
+433
-426
@@ -140,28 +140,8 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
//==============//
|
||||
//region
|
||||
|
||||
public static BlockStateWrapper fromBlockState(BlockState blockState, ILevelWrapper levelWrapper)
|
||||
{
|
||||
if (blockState == null || blockState.isAir())
|
||||
{
|
||||
return AIR;
|
||||
}
|
||||
|
||||
|
||||
if (WRAPPER_BY_BLOCK_STATE.containsKey(blockState))
|
||||
{
|
||||
return WRAPPER_BY_BLOCK_STATE.get(blockState);
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockStateWrapper newWrapper = createNewWrapper(blockState, levelWrapper);
|
||||
WRAPPER_BY_BLOCK_STATE.put(blockState, newWrapper);
|
||||
return newWrapper;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be faster than {@link BlockStateWrapper#fromBlockState(BlockState, ILevelWrapper)}
|
||||
/**
|
||||
* Can be faster than {@link BlockStateWrapper#fromBlockState(BlockState, ILevelWrapper)}
|
||||
* in cases where the same block state is expected to be referenced multiple times.
|
||||
*/
|
||||
public static BlockStateWrapper fromBlockState(BlockState blockState, ILevelWrapper levelWrapper, IBlockStateWrapper guess)
|
||||
@@ -179,9 +159,14 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
return fromBlockState(blockState, levelWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
private static BlockStateWrapper createNewWrapper(@Nullable BlockState blockState, ILevelWrapper levelWrapper)
|
||||
public static BlockStateWrapper fromBlockState(@Nullable BlockState blockState, ILevelWrapper levelWrapper)
|
||||
{
|
||||
// air is a special case
|
||||
if (isAir(blockState))
|
||||
{
|
||||
return AIR;
|
||||
}
|
||||
|
||||
// create a wrapper specifically for the API event to use
|
||||
BlockStateWrapper apiWrapper = new BlockStateWrapper(blockState, levelWrapper, null);
|
||||
DhApiBlockStateWrapperCreatedEvent.EventParam eventParam = new DhApiBlockStateWrapperCreatedEvent.EventParam(apiWrapper);
|
||||
@@ -197,212 +182,408 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
BlockStateWrapper returnWrapper = new BlockStateWrapper(blockState, levelWrapper, eventParam);
|
||||
return returnWrapper;
|
||||
}
|
||||
private BlockStateWrapper(@Nullable BlockState blockState, ILevelWrapper levelWrapper, @Nullable DhApiBlockStateWrapperCreatedEvent.EventParam overrideEventParam)
|
||||
private BlockStateWrapper(
|
||||
@Nullable BlockState blockState, ILevelWrapper levelWrapper,
|
||||
@Nullable DhApiBlockStateWrapperCreatedEvent.EventParam overrideEventParam)
|
||||
{
|
||||
this.blockState = blockState;
|
||||
this.serialString = this.serialize(levelWrapper);
|
||||
this.serialString = serialize(blockState, levelWrapper);
|
||||
this.hashCode = Objects.hash(this.serialString);
|
||||
|
||||
// allow overriding if present
|
||||
if (overrideEventParam != null
|
||||
&& overrideEventParam.getBlockMaterial() != null)
|
||||
{
|
||||
this.blockMaterialId = overrideEventParam.getBlockMaterial().index;
|
||||
}
|
||||
else
|
||||
{
|
||||
// no API override, use the base logic
|
||||
this.blockMaterialId = this.calculateEDhApiBlockMaterialId().index;
|
||||
}
|
||||
|
||||
// allow overriding if present
|
||||
if (overrideEventParam != null
|
||||
&& overrideEventParam.getOpacity() != null)
|
||||
{
|
||||
this.opacity = overrideEventParam.getOpacity();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.opacity = this.calculateOpacity();
|
||||
}
|
||||
|
||||
// allow overriding if present
|
||||
if (overrideEventParam != null
|
||||
&& overrideEventParam.getAllowApiColorOverride() != null)
|
||||
{
|
||||
this.allowApiColorOverride = overrideEventParam.getAllowApiColorOverride();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowApiColorOverride = false;
|
||||
}
|
||||
|
||||
String lowerCaseSerial = this.serialString.toLowerCase();
|
||||
|
||||
|
||||
|
||||
// beacon base blocks
|
||||
#if MC_VER <= MC_1_18_2
|
||||
|
||||
// Used to handle older MC versions that don't have an simple way of getting the block's tags
|
||||
List<String> oldBeaconBaseBlockNameList = Arrays.asList(
|
||||
"iron_block",
|
||||
"gold_block",
|
||||
"diamond_block",
|
||||
"emerald_block",
|
||||
"netherite_block"
|
||||
);
|
||||
|
||||
// Older MC versions are harder to get block tags, so just use a static list to determine beacon blocks
|
||||
boolean isBeaconBaseBlock = false;
|
||||
for (int i = 0; i < oldBeaconBaseBlockNameList.size(); i++)
|
||||
// is liquid //
|
||||
{
|
||||
String baseBlockName = oldBeaconBaseBlockNameList.get(i);
|
||||
if (lowerCaseSerial.contains(baseBlockName))
|
||||
if (this.isAir()
|
||||
|| this.blockState == null) // == null isn't necessary since its handled in isAir() but is here to prevent intellij from complaining
|
||||
{
|
||||
isBeaconBaseBlock = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.isBeaconBaseBlock = isBeaconBaseBlock;
|
||||
#else
|
||||
if (blockState != null)
|
||||
{
|
||||
// check if this block has any tags
|
||||
|
||||
Stream<TagKey<Block>> tags;
|
||||
#if MC_VER <= MC_1_21_11
|
||||
tags = blockState.getTags();
|
||||
#else
|
||||
tags = blockState.tags();
|
||||
#endif
|
||||
|
||||
this.isBeaconBaseBlock = tags.anyMatch((TagKey<Block> tag) -> tag.location().getPath().toLowerCase().contains("beacon_base_blocks"));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isBeaconBaseBlock = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// beacon block
|
||||
this.isBeaconBlock = lowerCaseSerial.contains("minecraft:beacon");
|
||||
|
||||
|
||||
// beacon tint color
|
||||
Color beaconTintColor = null;
|
||||
if (this.blockState != null
|
||||
// beacon blocks also show up here, but since they block the beacon beam we don't want their color
|
||||
&& !this.isBeaconBlock)
|
||||
{
|
||||
Block block = this.blockState.getBlock();
|
||||
if (block instanceof BeaconBeamBlock)
|
||||
{
|
||||
int colorInt;
|
||||
#if MC_VER <= MC_1_19_4
|
||||
colorInt = ((BeaconBeamBlock) block).getColor().getMaterialColor().col;
|
||||
#else
|
||||
colorInt = ((BeaconBeamBlock) block).getColor().getMapColor().col;
|
||||
#endif
|
||||
|
||||
beaconTintColor = ColorUtil.toColorObjRGB(colorInt);
|
||||
}
|
||||
}
|
||||
this.beaconTintColor = beaconTintColor;
|
||||
|
||||
|
||||
// allow/deny beacon beam passage
|
||||
boolean allowsBeaconBeamPassage;
|
||||
if (this.blockState != null)
|
||||
{
|
||||
// get block properties (defaults to the values used by air)
|
||||
boolean canOcclude = this.getCanOcclude();
|
||||
boolean propagatesSkyLightDown = this.getPropagatesSkyLightDown();
|
||||
|
||||
if (lowerCaseSerial.contains("minecraft:bedrock"))
|
||||
{
|
||||
// bedrock is a special case fully opaque block that does allow beacons through
|
||||
allowsBeaconBeamPassage = true;
|
||||
}
|
||||
else if (lowerCaseSerial.contains("minecraft:tinted_glass"))
|
||||
{
|
||||
// tinted glass is a special case where it isn't fully opaque,
|
||||
// but should block beacons
|
||||
allowsBeaconBeamPassage = false;
|
||||
}
|
||||
else if (propagatesSkyLightDown || !canOcclude)
|
||||
{
|
||||
// stairs, cake, fences, etc.
|
||||
allowsBeaconBeamPassage = true;
|
||||
this.isLiquid = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// non-opaque blocks (glass, mob spawners, etc.)
|
||||
// all allow beacons through
|
||||
allowsBeaconBeamPassage = (this.opacity != LodUtil.BLOCK_FULLY_OPAQUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// air allows beacons through
|
||||
allowsBeaconBeamPassage = true;
|
||||
}
|
||||
this.allowsBeaconBeamPassage = allowsBeaconBeamPassage;
|
||||
|
||||
|
||||
// map color
|
||||
if (this.blockState != null)
|
||||
{
|
||||
int mcColor = 0;
|
||||
|
||||
#if MC_VER < MC_1_20_1
|
||||
mcColor = this.blockState.getMaterial().getColor().col;
|
||||
#else
|
||||
mcColor = this.blockState.getMapColor(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).col;
|
||||
#endif
|
||||
|
||||
this.mapColor = ColorUtil.toColorObjRGB(mcColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mapColor = new Color(0,0,0,0);
|
||||
}
|
||||
|
||||
|
||||
// is solid
|
||||
if (this.isAir()
|
||||
|| this.blockState == null) // "== null" isn't necessary since its handled in isAir() but is here to prevent intellij from complaining
|
||||
{
|
||||
this.isSolid = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if MC_VER < MC_1_20_1
|
||||
this.isSolid = this.blockState.getMaterial().isSolid();
|
||||
#else
|
||||
this.isSolid = !this.blockState.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).isEmpty();
|
||||
#endif
|
||||
}
|
||||
|
||||
// is liquid
|
||||
if (this.isAir()
|
||||
|| this.blockState == null) // == null isn't necessary since its handled in isAir() but is here to prevent intellij from complaining
|
||||
{
|
||||
this.isLiquid = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if MC_VER < MC_1_20_1
|
||||
this.isLiquid = this.blockState.getMaterial().isLiquid() || !this.blockState.getFluidState().isEmpty();
|
||||
#else
|
||||
this.isLiquid = !this.blockState.getFluidState().isEmpty();
|
||||
this.isLiquid = !this.blockState.getFluidState().isEmpty();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// API overriding //
|
||||
{
|
||||
if (overrideEventParam != null
|
||||
&& overrideEventParam.getBlockMaterial() != null)
|
||||
{
|
||||
this.blockMaterialId = overrideEventParam.getBlockMaterial().index;
|
||||
}
|
||||
else
|
||||
{
|
||||
// no API override, use the base logic
|
||||
this.blockMaterialId = calculateEDhApiBlockMaterialId(this.blockState, lowerCaseSerial, this.isLiquid).index;
|
||||
}
|
||||
|
||||
// allow overriding if present
|
||||
if (overrideEventParam != null
|
||||
&& overrideEventParam.getOpacity() != null)
|
||||
{
|
||||
this.opacity = overrideEventParam.getOpacity();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.opacity = calculateOpacity(this.blockState, isAir(this.blockState), this.isLiquid);
|
||||
}
|
||||
|
||||
// allow overriding if present
|
||||
if (overrideEventParam != null
|
||||
&& overrideEventParam.getAllowApiColorOverride() != null)
|
||||
{
|
||||
this.allowApiColorOverride = overrideEventParam.getAllowApiColorOverride();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowApiColorOverride = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// beacon handling //
|
||||
{
|
||||
|
||||
// beacon base blocks
|
||||
#if MC_VER <= MC_1_18_2
|
||||
|
||||
// Used to handle older MC versions that don't have an simple way of getting the block's tags
|
||||
List<String> oldBeaconBaseBlockNameList = Arrays.asList(
|
||||
"iron_block",
|
||||
"gold_block",
|
||||
"diamond_block",
|
||||
"emerald_block",
|
||||
"netherite_block"
|
||||
);
|
||||
|
||||
// Older MC versions are harder to get block tags, so just use a static list to determine beacon blocks
|
||||
boolean isBeaconBaseBlock = false;
|
||||
for (int i = 0; i < oldBeaconBaseBlockNameList.size(); i++)
|
||||
{
|
||||
String baseBlockName = oldBeaconBaseBlockNameList.get(i);
|
||||
if (lowerCaseSerial.contains(baseBlockName))
|
||||
{
|
||||
isBeaconBaseBlock = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.isBeaconBaseBlock = isBeaconBaseBlock;
|
||||
#else
|
||||
if (blockState != null)
|
||||
{
|
||||
// check if this block has any tags
|
||||
|
||||
Stream<TagKey<Block>> tags;
|
||||
#if MC_VER <= MC_1_21_11
|
||||
tags = blockState.getTags();
|
||||
#else
|
||||
tags = blockState.tags();
|
||||
#endif
|
||||
|
||||
this.isBeaconBaseBlock = tags.anyMatch((TagKey<Block> tag) -> tag.location().getPath().toLowerCase().contains("beacon_base_blocks"));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isBeaconBaseBlock = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// beacon block
|
||||
this.isBeaconBlock = lowerCaseSerial.contains("minecraft:beacon");
|
||||
|
||||
|
||||
// beacon tint color
|
||||
Color beaconTintColor = null;
|
||||
if (this.blockState != null
|
||||
// beacon blocks also show up here, but since they block the beacon beam we don't want their color
|
||||
&& !this.isBeaconBlock)
|
||||
{
|
||||
Block block = this.blockState.getBlock();
|
||||
if (block instanceof BeaconBeamBlock)
|
||||
{
|
||||
int colorInt;
|
||||
#if MC_VER <= MC_1_19_4
|
||||
colorInt = ((BeaconBeamBlock) block).getColor().getMaterialColor().col;
|
||||
#else
|
||||
colorInt = ((BeaconBeamBlock) block).getColor().getMapColor().col;
|
||||
#endif
|
||||
|
||||
beaconTintColor = ColorUtil.toColorObjRGB(colorInt);
|
||||
}
|
||||
}
|
||||
this.beaconTintColor = beaconTintColor;
|
||||
|
||||
|
||||
// allow/deny beacon beam passage
|
||||
boolean allowsBeaconBeamPassage;
|
||||
if (this.blockState != null)
|
||||
{
|
||||
// get block properties (defaults to the values used by air)
|
||||
boolean canOcclude = getCanOcclude(this.blockState);
|
||||
boolean propagatesSkyLightDown = getPropagatesSkyLightDown(this.blockState);
|
||||
|
||||
if (lowerCaseSerial.contains("minecraft:bedrock"))
|
||||
{
|
||||
// bedrock is a special case fully opaque block that does allow beacons through
|
||||
allowsBeaconBeamPassage = true;
|
||||
}
|
||||
else if (lowerCaseSerial.contains("minecraft:tinted_glass"))
|
||||
{
|
||||
// tinted glass is a special case where it isn't fully opaque,
|
||||
// but should block beacons
|
||||
allowsBeaconBeamPassage = false;
|
||||
}
|
||||
else if (propagatesSkyLightDown || !canOcclude)
|
||||
{
|
||||
// stairs, cake, fences, etc.
|
||||
allowsBeaconBeamPassage = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// non-opaque blocks (glass, mob spawners, etc.)
|
||||
// all allow beacons through
|
||||
allowsBeaconBeamPassage = (this.opacity != LodUtil.BLOCK_FULLY_OPAQUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// air allows beacons through
|
||||
allowsBeaconBeamPassage = true;
|
||||
}
|
||||
this.allowsBeaconBeamPassage = allowsBeaconBeamPassage;
|
||||
}
|
||||
|
||||
|
||||
// map color //
|
||||
{
|
||||
if (this.blockState != null)
|
||||
{
|
||||
int mcColor = 0;
|
||||
|
||||
#if MC_VER < MC_1_20_1
|
||||
mcColor = this.blockState.getMaterial().getColor().col;
|
||||
#else
|
||||
mcColor = this.blockState.getMapColor(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).col;
|
||||
#endif
|
||||
|
||||
this.mapColor = ColorUtil.toColorObjRGB(mcColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mapColor = new Color(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// is solid //
|
||||
{
|
||||
if (this.isAir()
|
||||
|| this.blockState == null) // "== null" isn't necessary since its handled in isAir() but is here to prevent IntelliJ from complaining
|
||||
{
|
||||
this.isSolid = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if MC_VER < MC_1_20_1
|
||||
this.isSolid = this.blockState.getMaterial().isSolid();
|
||||
#else
|
||||
this.isSolid = !this.blockState.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).isEmpty();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// static constructor helpers //
|
||||
//region
|
||||
|
||||
private static EDhApiBlockMaterial calculateEDhApiBlockMaterialId(
|
||||
@Nullable BlockState blockState,
|
||||
String lowercaseSerialString,
|
||||
boolean isLiquid
|
||||
)
|
||||
{
|
||||
if (blockState == null)
|
||||
{
|
||||
return EDhApiBlockMaterial.AIR;
|
||||
}
|
||||
|
||||
|
||||
if (blockState.is(BlockTags.LEAVES)
|
||||
|| lowercaseSerialString.contains("bamboo")
|
||||
|| lowercaseSerialString.contains("cactus")
|
||||
|| lowercaseSerialString.contains("chorus_flower")
|
||||
|| lowercaseSerialString.contains("mushroom")
|
||||
)
|
||||
{
|
||||
return EDhApiBlockMaterial.LEAVES;
|
||||
}
|
||||
else if (blockState.is(Blocks.LAVA))
|
||||
{
|
||||
return EDhApiBlockMaterial.LAVA;
|
||||
}
|
||||
else if (isLiquid
|
||||
|| blockState.is(Blocks.WATER))
|
||||
{
|
||||
return EDhApiBlockMaterial.WATER;
|
||||
}
|
||||
else if (blockState.getSoundType() == SoundType.WOOD
|
||||
|| lowercaseSerialString.contains("root")
|
||||
#if MC_VER >= MC_1_19_4
|
||||
|| blockState.getSoundType() == SoundType.CHERRY_WOOD
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return EDhApiBlockMaterial.WOOD;
|
||||
}
|
||||
else if (blockState.getSoundType() == SoundType.METAL
|
||||
#if MC_VER >= MC_1_19_2
|
||||
|| blockState.getSoundType() == SoundType.COPPER
|
||||
#endif
|
||||
#if MC_VER >= MC_1_20_4
|
||||
|| blockState.getSoundType() == SoundType.COPPER_BULB
|
||||
|| blockState.getSoundType() == SoundType.COPPER_GRATE
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return EDhApiBlockMaterial.METAL;
|
||||
}
|
||||
else if (
|
||||
lowercaseSerialString.contains("grass_block")
|
||||
|| lowercaseSerialString.contains("grass_slab")
|
||||
)
|
||||
{
|
||||
return EDhApiBlockMaterial.GRASS;
|
||||
}
|
||||
else if (
|
||||
lowercaseSerialString.contains("dirt")
|
||||
|| lowercaseSerialString.contains("gravel")
|
||||
|| lowercaseSerialString.contains("mud")
|
||||
|| lowercaseSerialString.contains("podzol")
|
||||
|| lowercaseSerialString.contains("mycelium")
|
||||
)
|
||||
{
|
||||
return EDhApiBlockMaterial.DIRT;
|
||||
}
|
||||
#if MC_VER >= MC_1_17_1
|
||||
else if (blockState.getSoundType() == SoundType.DEEPSLATE
|
||||
|| blockState.getSoundType() == SoundType.DEEPSLATE_BRICKS
|
||||
|| blockState.getSoundType() == SoundType.DEEPSLATE_TILES
|
||||
|| blockState.getSoundType() == SoundType.POLISHED_DEEPSLATE
|
||||
|| lowercaseSerialString.contains("deepslate") )
|
||||
{
|
||||
return EDhApiBlockMaterial.DEEPSLATE;
|
||||
}
|
||||
#endif
|
||||
else if (lowercaseSerialString.contains("snow"))
|
||||
{
|
||||
return EDhApiBlockMaterial.SNOW;
|
||||
}
|
||||
else if (lowercaseSerialString.contains("sand"))
|
||||
{
|
||||
return EDhApiBlockMaterial.SAND;
|
||||
}
|
||||
else if (lowercaseSerialString.contains("terracotta"))
|
||||
{
|
||||
return EDhApiBlockMaterial.TERRACOTTA;
|
||||
}
|
||||
else if (blockState.is(BlockTags.BASE_STONE_NETHER))
|
||||
{
|
||||
return EDhApiBlockMaterial.NETHER_STONE;
|
||||
}
|
||||
else if (lowercaseSerialString.contains("stone")
|
||||
|| lowercaseSerialString.contains("ore"))
|
||||
{
|
||||
return EDhApiBlockMaterial.STONE;
|
||||
}
|
||||
else if (blockState.getLightEmission() > 0)
|
||||
{
|
||||
return EDhApiBlockMaterial.ILLUMINATED;
|
||||
}
|
||||
else
|
||||
{
|
||||
return EDhApiBlockMaterial.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
private static int calculateOpacity(
|
||||
@Nullable BlockState blockState,
|
||||
boolean isAir, boolean isLiquid
|
||||
)
|
||||
{
|
||||
// get block properties (defaults to the values used by air)
|
||||
boolean canOcclude = getCanOcclude(blockState);
|
||||
boolean propagatesSkyLightDown = getPropagatesSkyLightDown(blockState);
|
||||
|
||||
|
||||
|
||||
// this method isn't perfect, but works well enough for our use case
|
||||
int opacity;
|
||||
if (isAir)
|
||||
{
|
||||
opacity = LodUtil.BLOCK_FULLY_TRANSPARENT;
|
||||
}
|
||||
else if (isLiquid && !canOcclude)
|
||||
{
|
||||
// probably not a waterlogged block (which should block light entirely)
|
||||
|
||||
// +1 to indicate that the block is translucent (in between transparent and opaque)
|
||||
opacity = LodUtil.BLOCK_FULLY_TRANSPARENT + 1;
|
||||
}
|
||||
else if (propagatesSkyLightDown && !canOcclude)
|
||||
{
|
||||
// probably glass or some other fully transparent block
|
||||
|
||||
// !canOcclude is required to ignore stairs and slabs since
|
||||
// propagateSkyLightDown is true for them, but they're solid and don't actually let light through
|
||||
|
||||
opacity = LodUtil.BLOCK_FULLY_TRANSPARENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
// default for all other blocks
|
||||
opacity = LodUtil.BLOCK_FULLY_OPAQUE;
|
||||
}
|
||||
|
||||
|
||||
return opacity;
|
||||
}
|
||||
private static boolean getCanOcclude(@Nullable BlockState blockState)
|
||||
{
|
||||
// defaults to the value used by air
|
||||
boolean canOcclude = false;
|
||||
if (blockState != null)
|
||||
{
|
||||
canOcclude = blockState.canOcclude();
|
||||
}
|
||||
|
||||
return canOcclude;
|
||||
}
|
||||
private static boolean getPropagatesSkyLightDown(@Nullable BlockState blockState)
|
||||
{
|
||||
// defaults to the value used by air
|
||||
boolean propagatesSkyLightDown = true;
|
||||
if (blockState != null)
|
||||
{
|
||||
#if MC_VER < MC_1_21_3
|
||||
propagatesSkyLightDown = blockState.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
|
||||
#else
|
||||
propagatesSkyLightDown = blockState.propagatesSkylightDown();
|
||||
#endif
|
||||
}
|
||||
|
||||
return propagatesSkyLightDown;
|
||||
}
|
||||
|
||||
//endregion
|
||||
//endregion
|
||||
|
||||
|
||||
@@ -480,15 +661,6 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
return waterBlock;
|
||||
}
|
||||
|
||||
public static void clearCachedIgnoreBlocks()
|
||||
{
|
||||
rendererIgnoredBlocks = null;
|
||||
rendererIgnoredCaveBlocks = null;
|
||||
waterSurfaceReplacementBlocks = null;
|
||||
waterSubsurfaceReplacementBlocks = null;
|
||||
waterBlock = null;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
@@ -545,7 +717,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
List<BlockState> blockStatesToIgnore = defaultBlockStateToIgnore.blockState.getBlock().getStateDefinition().getPossibleStates();
|
||||
for (BlockState blockState : blockStatesToIgnore)
|
||||
{
|
||||
BlockStateWrapper newBlockToIgnore = BlockStateWrapper.fromBlockState(blockState, levelWrapper);
|
||||
BlockStateWrapper newBlockToIgnore = fromBlockState(blockState, levelWrapper);
|
||||
blockStateWrappers.add(newBlockToIgnore);
|
||||
}
|
||||
}
|
||||
@@ -568,6 +740,15 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
return blockStateWrappers;
|
||||
}
|
||||
|
||||
public static void clearCachedIgnoreBlocks()
|
||||
{
|
||||
rendererIgnoredBlocks = null;
|
||||
rendererIgnoredCaveBlocks = null;
|
||||
waterSurfaceReplacementBlocks = null;
|
||||
waterSubsurfaceReplacementBlocks = null;
|
||||
waterBlock = null;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
@@ -579,73 +760,6 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
|
||||
@Override
|
||||
public int getOpacity() { return this.opacity; }
|
||||
private int calculateOpacity()
|
||||
{
|
||||
// get block properties (defaults to the values used by air)
|
||||
boolean canOcclude = this.getCanOcclude();
|
||||
boolean propagatesSkyLightDown = this.getPropagatesSkyLightDown();
|
||||
|
||||
|
||||
|
||||
// this method isn't perfect, but works well enough for our use case
|
||||
int opacity;
|
||||
if (this.isAir())
|
||||
{
|
||||
opacity = LodUtil.BLOCK_FULLY_TRANSPARENT;
|
||||
}
|
||||
else if (this.isLiquid() && !canOcclude)
|
||||
{
|
||||
// probably not a waterlogged block (which should block light entirely)
|
||||
|
||||
// +1 to indicate that the block is translucent (in between transparent and opaque)
|
||||
opacity = LodUtil.BLOCK_FULLY_TRANSPARENT + 1;
|
||||
}
|
||||
else if (propagatesSkyLightDown && !canOcclude)
|
||||
{
|
||||
// probably glass or some other fully transparent block
|
||||
|
||||
// !canOcclude is required to ignore stairs and slabs since
|
||||
// propagateSkyLightDown is true for them, but they're solid and don't actually let light through
|
||||
|
||||
opacity = LodUtil.BLOCK_FULLY_TRANSPARENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
// default for all other blocks
|
||||
opacity = LodUtil.BLOCK_FULLY_OPAQUE;
|
||||
}
|
||||
|
||||
|
||||
return opacity;
|
||||
}
|
||||
private boolean getCanOcclude()
|
||||
{
|
||||
// defaults to the value used by air
|
||||
boolean canOcclude = false;
|
||||
if (this.blockState != null)
|
||||
{
|
||||
canOcclude = this.blockState.canOcclude();
|
||||
}
|
||||
|
||||
return canOcclude;
|
||||
}
|
||||
private boolean getPropagatesSkyLightDown()
|
||||
{
|
||||
// defaults to the value used by air
|
||||
boolean propagatesSkyLightDown = true;
|
||||
if (this.blockState != null)
|
||||
{
|
||||
#if MC_VER < MC_1_21_3
|
||||
propagatesSkyLightDown = this.blockState.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO);
|
||||
#else
|
||||
propagatesSkyLightDown = this.blockState.propagatesSkylightDown();
|
||||
#endif
|
||||
}
|
||||
|
||||
return propagatesSkyLightDown;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getLightEmission() { return (this.blockState != null) ? this.blockState.getLightEmission() : 0; }
|
||||
@@ -653,34 +767,12 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
@Override
|
||||
public String getSerialString() { return this.serialString; }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj == null || this.getClass() != obj.getClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockStateWrapper that = (BlockStateWrapper) obj;
|
||||
// the serialized value is used so we can test the contents instead of the references
|
||||
return Objects.equals(this.getSerialString(), that.getSerialString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() { return this.hashCode; }
|
||||
|
||||
|
||||
@Override
|
||||
public Object getWrappedMcObject() { return this.blockState; }
|
||||
|
||||
@Override
|
||||
public boolean isAir() { return this.isAir(this.blockState); }
|
||||
public boolean isAir(BlockState blockState) { return blockState == null || blockState.isAir(); }
|
||||
public boolean isAir() { return isAir(this.blockState); }
|
||||
public static boolean isAir(BlockState blockState) { return blockState == null || blockState.isAir(); }
|
||||
|
||||
@Override
|
||||
public boolean isSolid() { return this.isSolid; }
|
||||
@@ -705,9 +797,6 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
@Override
|
||||
public byte getMaterialId() { return this.blockMaterialId; }
|
||||
|
||||
@Override
|
||||
public String toString() { return this.getSerialString(); }
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
@@ -717,9 +806,9 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
//=======================//
|
||||
//region
|
||||
|
||||
private String serialize(ILevelWrapper levelWrapper)
|
||||
private static String serialize(BlockState blockState, ILevelWrapper levelWrapper)
|
||||
{
|
||||
if (this.blockState == null)
|
||||
if (blockState == null)
|
||||
{
|
||||
return AIR_STRING;
|
||||
}
|
||||
@@ -740,27 +829,26 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
#endif
|
||||
|
||||
#if MC_VER <= MC_1_17_1
|
||||
resourceLocation = Registry.BLOCK.getKey(this.blockState.getBlock());
|
||||
resourceLocation = Registry.BLOCK.getKey(blockState.getBlock());
|
||||
#elif MC_VER <= MC_1_19_2
|
||||
resourceLocation = registryAccess.registryOrThrow(Registry.BLOCK_REGISTRY).getKey(this.blockState.getBlock());
|
||||
resourceLocation = registryAccess.registryOrThrow(Registry.BLOCK_REGISTRY).getKey(blockState.getBlock());
|
||||
#elif MC_VER <= MC_1_21_1
|
||||
resourceLocation = registryAccess.registryOrThrow(Registries.BLOCK).getKey(this.blockState.getBlock());
|
||||
resourceLocation = registryAccess.registryOrThrow(Registries.BLOCK).getKey(blockState.getBlock());
|
||||
#else
|
||||
resourceLocation = registryAccess.lookupOrThrow(Registries.BLOCK).getKey(this.blockState.getBlock());
|
||||
resourceLocation = registryAccess.lookupOrThrow(Registries.BLOCK).getKey(blockState.getBlock());
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
if (resourceLocation == null)
|
||||
{
|
||||
LOGGER.warn("No ResourceLocation found, unable to serialize: " + this.blockState);
|
||||
LOGGER.warn("No ResourceLocation found, unable to serialize: " + blockState);
|
||||
return AIR_STRING;
|
||||
}
|
||||
|
||||
this.serialString = resourceLocation.getNamespace() + RESOURCE_LOCATION_SEPARATOR + resourceLocation.getPath()
|
||||
+ STATE_STRING_SEPARATOR + serializeBlockStateProperties(this.blockState);
|
||||
|
||||
return this.serialString;
|
||||
String serialString = resourceLocation.getNamespace() + RESOURCE_LOCATION_SEPARATOR + resourceLocation.getPath()
|
||||
+ STATE_STRING_SEPARATOR + serializeBlockStateProperties(blockState);
|
||||
return serialString;
|
||||
}
|
||||
|
||||
|
||||
@@ -899,7 +987,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
foundState = block.defaultBlockState();
|
||||
}
|
||||
|
||||
foundWrapper = createNewWrapper(foundState, levelWrapper);
|
||||
foundWrapper = fromBlockState(foundState, levelWrapper);
|
||||
return foundWrapper;
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -949,118 +1037,37 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
|
||||
|
||||
|
||||
//==============//
|
||||
// Iris methods //
|
||||
//==============//
|
||||
//================//
|
||||
// base overrides //
|
||||
//================//
|
||||
//region
|
||||
|
||||
private EDhApiBlockMaterial calculateEDhApiBlockMaterialId()
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this.blockState == null)
|
||||
if (this == obj)
|
||||
{
|
||||
return EDhApiBlockMaterial.AIR;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj == null || this.getClass() != obj.getClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String serialString = this.getSerialString().toLowerCase();
|
||||
|
||||
if (this.blockState.is(BlockTags.LEAVES)
|
||||
|| serialString.contains("bamboo")
|
||||
|| serialString.contains("cactus")
|
||||
|| serialString.contains("chorus_flower")
|
||||
|| serialString.contains("mushroom")
|
||||
)
|
||||
{
|
||||
return EDhApiBlockMaterial.LEAVES;
|
||||
}
|
||||
else if (this.blockState.is(Blocks.LAVA))
|
||||
{
|
||||
return EDhApiBlockMaterial.LAVA;
|
||||
}
|
||||
else if (this.isLiquid() || this.blockState.is(Blocks.WATER))
|
||||
{
|
||||
return EDhApiBlockMaterial.WATER;
|
||||
}
|
||||
else if (this.blockState.getSoundType() == SoundType.WOOD
|
||||
|| serialString.contains("root")
|
||||
#if MC_VER >= MC_1_19_4
|
||||
|| this.blockState.getSoundType() == SoundType.CHERRY_WOOD
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return EDhApiBlockMaterial.WOOD;
|
||||
}
|
||||
else if (this.blockState.getSoundType() == SoundType.METAL
|
||||
#if MC_VER >= MC_1_19_2
|
||||
|| this.blockState.getSoundType() == SoundType.COPPER
|
||||
#endif
|
||||
#if MC_VER >= MC_1_20_4
|
||||
|| this.blockState.getSoundType() == SoundType.COPPER_BULB
|
||||
|| this.blockState.getSoundType() == SoundType.COPPER_GRATE
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return EDhApiBlockMaterial.METAL;
|
||||
}
|
||||
else if (
|
||||
serialString.contains("grass_block")
|
||||
|| serialString.contains("grass_slab")
|
||||
)
|
||||
{
|
||||
return EDhApiBlockMaterial.GRASS;
|
||||
}
|
||||
else if (
|
||||
serialString.contains("dirt")
|
||||
|| serialString.contains("gravel")
|
||||
|| serialString.contains("mud")
|
||||
|| serialString.contains("podzol")
|
||||
|| serialString.contains("mycelium")
|
||||
)
|
||||
{
|
||||
return EDhApiBlockMaterial.DIRT;
|
||||
}
|
||||
#if MC_VER >= MC_1_17_1
|
||||
else if (this.blockState.getSoundType() == SoundType.DEEPSLATE
|
||||
|| this.blockState.getSoundType() == SoundType.DEEPSLATE_BRICKS
|
||||
|| this.blockState.getSoundType() == SoundType.DEEPSLATE_TILES
|
||||
|| this.blockState.getSoundType() == SoundType.POLISHED_DEEPSLATE
|
||||
|| serialString.contains("deepslate") )
|
||||
{
|
||||
return EDhApiBlockMaterial.DEEPSLATE;
|
||||
}
|
||||
#endif
|
||||
else if (this.serialString.contains("snow"))
|
||||
{
|
||||
return EDhApiBlockMaterial.SNOW;
|
||||
}
|
||||
else if (serialString.contains("sand"))
|
||||
{
|
||||
return EDhApiBlockMaterial.SAND;
|
||||
}
|
||||
else if (serialString.contains("terracotta"))
|
||||
{
|
||||
return EDhApiBlockMaterial.TERRACOTTA;
|
||||
}
|
||||
else if (this.blockState.is(BlockTags.BASE_STONE_NETHER))
|
||||
{
|
||||
return EDhApiBlockMaterial.NETHER_STONE;
|
||||
}
|
||||
else if (serialString.contains("stone")
|
||||
|| serialString.contains("ore"))
|
||||
{
|
||||
return EDhApiBlockMaterial.STONE;
|
||||
}
|
||||
else if (this.blockState.getLightEmission() > 0)
|
||||
{
|
||||
return EDhApiBlockMaterial.ILLUMINATED;
|
||||
}
|
||||
else
|
||||
{
|
||||
return EDhApiBlockMaterial.UNKNOWN;
|
||||
}
|
||||
BlockStateWrapper that = (BlockStateWrapper) obj;
|
||||
// the serialized value is used so we can test the contents instead of the references
|
||||
return Objects.equals(this.getSerialString(), that.getSerialString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() { return this.hashCode; }
|
||||
|
||||
@Override
|
||||
public String toString() { return this.getSerialString(); }
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+2
-17
@@ -154,22 +154,12 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm
|
||||
|
||||
static
|
||||
{
|
||||
boolean isTerraFirmaCraftPresent = false;
|
||||
try
|
||||
{
|
||||
Class.forName("net.dries007.tfc.world.TFCChunkGenerator");
|
||||
isTerraFirmaCraftPresent = true;
|
||||
LOGGER.info("TerraFirmaCraft detected.");
|
||||
}
|
||||
catch (ClassNotFoundException ignore) { }
|
||||
|
||||
|
||||
ImmutableMap.Builder<EDhApiWorldGenerationStep, Integer> builder = ImmutableMap.builder();
|
||||
builder.put(EDhApiWorldGenerationStep.EMPTY, 1);
|
||||
builder.put(EDhApiWorldGenerationStep.STRUCTURE_START, 0);
|
||||
builder.put(EDhApiWorldGenerationStep.STRUCTURE_REFERENCE, 0);
|
||||
builder.put(EDhApiWorldGenerationStep.BIOMES, isTerraFirmaCraftPresent ? 1 : 0);
|
||||
builder.put(EDhApiWorldGenerationStep.NOISE, isTerraFirmaCraftPresent ? 1 : 0);
|
||||
builder.put(EDhApiWorldGenerationStep.BIOMES, 0);
|
||||
builder.put(EDhApiWorldGenerationStep.NOISE, 0);
|
||||
builder.put(EDhApiWorldGenerationStep.SURFACE, 0);
|
||||
builder.put(EDhApiWorldGenerationStep.CARVERS, 0);
|
||||
builder.put(EDhApiWorldGenerationStep.LIQUID_CARVERS, 0);
|
||||
@@ -205,11 +195,6 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm
|
||||
LOGGER.info("TerraForge Chunk Generator detected: [" + generator.getClass() + "], Distant Generation will try its best to support it.");
|
||||
LOGGER.info("If it does crash, turn Distant Generation off or set it to to [" + EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY + "].");
|
||||
}
|
||||
else if (generator.getClass().toString().equals("class net.dries007.tfc.world.TFCChunkGenerator"))
|
||||
{
|
||||
LOGGER.info("TerraFirmaCraft Chunk Generator detected: [" + generator.getClass() + "], Distant Generation will try its best to support it.");
|
||||
LOGGER.info("If it does crash, turn Distant Generation off or set it to to [" + EDhApiDistantGeneratorMode.PRE_EXISTING_ONLY + "].");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.warn("Unknown Chunk Generator detected: [" + generator.getClass() + "], Distant Generation May Fail!");
|
||||
|
||||
+21
-5
@@ -12,11 +12,9 @@ import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||
import com.seibel.distanthorizons.core.enums.MinecraftTextFormat;
|
||||
import com.seibel.distanthorizons.core.generation.DhLightingEngine;
|
||||
import com.seibel.distanthorizons.core.level.DhServerLevel;
|
||||
import com.seibel.distanthorizons.core.level.IDhServerLevel;
|
||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
import com.seibel.distanthorizons.core.util.ExceptionUtil;
|
||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||
import com.seibel.distanthorizons.core.util.TimerUtil;
|
||||
@@ -195,12 +193,22 @@ public class InternalServerGenerator
|
||||
}
|
||||
finally
|
||||
{
|
||||
ArrayList<CompletableFuture<Void>> releaseFutures = new ArrayList<>();
|
||||
|
||||
// release all chunks from the server to prevent out of memory issues
|
||||
Iterator<ChunkPos> chunkPosIterator = ChunkPosGenStream.getIterator(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.widthInChunks, 0);
|
||||
while (chunkPosIterator.hasNext())
|
||||
{
|
||||
ChunkPos chunkPos = chunkPosIterator.next();
|
||||
this.releaseChunkFromServer(this.params.mcServerLevel, this.params.dhServerLevel, chunkPos);
|
||||
releaseFutures.add(this.releaseChunkFromServerAsync(this.params.mcServerLevel, chunkPos));
|
||||
}
|
||||
|
||||
// wait for all release futures to finish to prevent an issue where DH queues
|
||||
// tickets faster than MC can clear them out
|
||||
for (int i = 0; i < releaseFutures.size(); i++)
|
||||
{
|
||||
CompletableFuture<Void> releaseFuture = releaseFutures.get(i);
|
||||
releaseFuture.join();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -286,8 +294,10 @@ public class InternalServerGenerator
|
||||
* mitigates out of memory issues in the vanilla chunk system. <br>
|
||||
* See: https://github.com/pop4959/Chunky/pull/383
|
||||
*/
|
||||
private void releaseChunkFromServer(ServerLevel level, IDhServerLevel dhLevel, ChunkPos chunkPos)
|
||||
private CompletableFuture<Void> releaseChunkFromServerAsync(ServerLevel level, ChunkPos chunkPos)
|
||||
{
|
||||
CompletableFuture<Void> removeTicketFuture = new CompletableFuture<>();
|
||||
|
||||
level.getChunkSource().chunkMap.mainThreadExecutor.execute(() ->
|
||||
{
|
||||
try
|
||||
@@ -323,9 +333,15 @@ public class InternalServerGenerator
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warn("Failed to release chunk back to internal server. Error: ["+e.getMessage()+"]", e);
|
||||
LOGGER.warn("Failed to release chunk ["+chunkPos+"] back to internal server. Error: ["+e.getMessage()+"]", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
removeTicketFuture.complete(null);
|
||||
}
|
||||
});
|
||||
|
||||
return removeTicketFuture;
|
||||
}
|
||||
|
||||
|
||||
|
||||
-3
@@ -40,8 +40,6 @@ public final class ThreadWorldGenParams
|
||||
public StructureCheck structCheck;
|
||||
#endif
|
||||
|
||||
boolean isValid = true;
|
||||
|
||||
// used for some older MC versions
|
||||
private static GlobalWorldGenParams previousGlobalWorldGenParams = null;
|
||||
|
||||
@@ -55,7 +53,6 @@ public final class ThreadWorldGenParams
|
||||
{
|
||||
ThreadWorldGenParams threadParam = LOCAL_PARAM_REF.get();
|
||||
if (threadParam != null
|
||||
&& threadParam.isValid
|
||||
&& threadParam.level == globalParams.mcServerLevel)
|
||||
{
|
||||
return threadParam;
|
||||
|
||||
+1
-1
Submodule coreSubProjects updated: 53fcce9d7c...1b066327a8
+3
-2
@@ -5,8 +5,9 @@ org.gradle.caching=true
|
||||
|
||||
# Mod Info
|
||||
mod_name=DistantHorizons
|
||||
mod_version=3.0.0-b
|
||||
api_version=6.0.0
|
||||
api_name=DistantHorizonsApi
|
||||
mod_version=3.0.2-b
|
||||
api_version=6.1.0
|
||||
maven_group=com.seibel.distanthorizons
|
||||
mod_readable_name=Distant Horizons
|
||||
mod_description=This mod generates and renders simplified terrain beyond the normal view distance at a low performance cost. Allowing you to see much farther without turning your game into a slideshow.
|
||||
|
||||
@@ -4,7 +4,7 @@ minecraft_version=1.21.3
|
||||
parchment_version=1.21:2024.07.28
|
||||
compatible_minecraft_versions=["1.21.3"]
|
||||
accessWidenerVersion=1_21_3
|
||||
builds_for=neoforge,fabric
|
||||
builds_for=fabric,neoforge
|
||||
# forge is broken due to gradle/build script issues
|
||||
|
||||
# Netty
|
||||
|
||||
@@ -4,7 +4,7 @@ minecraft_version=1.21.4
|
||||
parchment_version=1.21:2024.07.28
|
||||
compatible_minecraft_versions=["1.21.4"]
|
||||
accessWidenerVersion=1_21_4
|
||||
builds_for=neoforge,fabric
|
||||
builds_for=fabric,neoforge
|
||||
# forge is broken due to gradle/build script issues
|
||||
|
||||
# Netty
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 26.1.2 version
|
||||
java_version=25
|
||||
minecraft_version=26.1
|
||||
minecraft_version=26.1.2
|
||||
parchment_version=1.21:2024.07.28
|
||||
# version range should be used instead of individual versions due to how NeoForge handles version loading
|
||||
compatible_minecraft_versions=["26.1.0", "26.1.2"]
|
||||
|
||||
Reference in New Issue
Block a user