Compare commits
62 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| de33cbce2b | |||
| 2b5f621ff8 | |||
| 1681adc10b | |||
| f606f2b7c2 | |||
| e3f9b66994 | |||
| ec3ff260fe | |||
| fafab30a09 | |||
| 707352ce51 | |||
| a9f5dafefe | |||
| 291ffd311b | |||
| 0e8c0b459b | |||
| c575a2968b | |||
| 0b297b4cd7 | |||
| b8c90985ce | |||
| b924576983 | |||
| a8b62b31a1 | |||
| 95b2d5a908 | |||
| 7d2ccc302d | |||
| 1ba1bff859 | |||
| 9409841c89 | |||
| 6c4e8021d6 | |||
| 4b1623e8c0 | |||
| a1e88bff70 | |||
| f3c20cde30 | |||
| eb601d9276 | |||
| 17a13993cc | |||
| 16e7254179 | |||
| ab055f1a0e | |||
| 0cb3716dc7 | |||
| 71e9877808 | |||
| f05e424c49 | |||
| 646882e1a9 | |||
| 482311fe48 | |||
| 97a80ed887 | |||
| 0e547c80a9 | |||
| b792487b60 | |||
| 7920415d18 | |||
| ada7668c28 | |||
| e7a34f9498 | |||
| 2a5c465923 | |||
| a14a558f0d | |||
| 66db5f0df1 | |||
| 2dc4ba20fb | |||
| 2f14d7ac27 | |||
| 6cc659bda5 | |||
| 206e492e7c | |||
| 09289e72a1 | |||
| 7861b63c99 | |||
| 965b9c948e | |||
| ae4ca8cd6b | |||
| 2dec862c3b | |||
| f9d8073e80 | |||
| 2ca99c29d2 | |||
| 2e4477b533 | |||
| b0c7919dda | |||
| 398c14ee96 | |||
| 422e54b488 | |||
| 64d8f7ee2d | |||
| d8b3aee9dc | |||
| fce94fa4bf | |||
| 254d671629 | |||
| e66e7e627a |
@@ -4,6 +4,7 @@ image: eclipse-temurin:25
|
|||||||
|
|
||||||
# all stages need to be defined here
|
# all stages need to be defined here
|
||||||
stages:
|
stages:
|
||||||
|
- translations
|
||||||
- build
|
- build
|
||||||
- api
|
- api
|
||||||
- pages
|
- pages
|
||||||
@@ -32,6 +33,9 @@ variables:
|
|||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
|
needs:
|
||||||
|
- job: translations
|
||||||
|
artifacts: true
|
||||||
parallel:
|
parallel:
|
||||||
matrix:
|
matrix:
|
||||||
- MC_VER: [
|
- MC_VER: [
|
||||||
@@ -102,3 +106,17 @@ pages:
|
|||||||
- public
|
- public
|
||||||
allow_failure: false
|
allow_failure: false
|
||||||
extends: .build_java
|
extends: .build_java
|
||||||
|
|
||||||
|
translations:
|
||||||
|
stage: translations
|
||||||
|
needs: []
|
||||||
|
image: crowdin/cli:latest
|
||||||
|
script:
|
||||||
|
- if [ "$CI_COMMIT_BEFORE_SHA" = "0000000000000000000000000000000000000000" ] || git diff --name-only "$CI_COMMIT_BEFORE_SHA" "$CI_COMMIT_SHA" -- coreSubProjects/core/src/main/resources/assets/distanthorizons/lang | grep -q .; then crowdin upload sources; fi
|
||||||
|
- crowdin download --export-only-approved --skip-untranslated-files
|
||||||
|
- for f in coreSubProjects/core/src/main/resources/assets/distanthorizons/lang/*.json; do [ -e "$f" ] || continue; sed -i 's/\\\\n/\\n/g' "$f"; n="$(basename "$f" | tr '[:upper:]' '[:lower:]')"; [ "$(basename "$f")" = "$n" ] || mv "$f" "$(dirname "$f")/$n"; done
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- coreSubProjects/core/src/main/resources/assets/distanthorizons/lang/**
|
||||||
|
expire_in: 1 day
|
||||||
|
when: always
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ Below is a video demonstrating the system:
|
|||||||
|
|
||||||
<a href="https://youtu.be/SxQdbtjGEsc" target="_blank"></a>
|
<a href="https://youtu.be/SxQdbtjGEsc" target="_blank"></a>
|
||||||
|
|
||||||
|
## Translations
|
||||||
|
|
||||||
|
[](https://crowdin.com/project/distant-horizons)\
|
||||||
|
Crowdin Project: [Distant Horizons](https://crowdin.com/project/distant-horizons)\
|
||||||
|
Guidelines: [translations.md](translations.md)
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## Source Code Installation
|
## Source Code Installation
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ if (isNotCommonProject) {
|
|||||||
'MixinConfigs': "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json",
|
'MixinConfigs': "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json",
|
||||||
'FMLCorePlugin': 'com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin',
|
'FMLCorePlugin': 'com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin',
|
||||||
'FMLCorePluginContainsFMLMod': true,
|
'FMLCorePluginContainsFMLMod': true,
|
||||||
'FMLAT': "src/main/resources/${gradle.ext.accessWidenerVersion}.distanthorizons_at.cfg"
|
'FMLAT': "${gradle.ext.accessWidenerVersion}.distanthorizons_at.cfg"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -188,6 +188,7 @@ if (isNotCommonProject) {
|
|||||||
if (gradle.ext.minecraft_version.equals("1.12.2")) {
|
if (gradle.ext.minecraft_version.equals("1.12.2")) {
|
||||||
cleanroom {
|
cleanroom {
|
||||||
loader gradle.ext.cleanroom_loader_version
|
loader gradle.ext.cleanroom_loader_version
|
||||||
|
accessTransformer project.file("src/main/resources/${gradle.ext.accessWidenerVersion}.distanthorizons_at.cfg")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fabric {
|
fabric {
|
||||||
@@ -483,7 +484,11 @@ if (isNotCommonProject) {
|
|||||||
"META-INF/neoforge.mods.toml",
|
"META-INF/neoforge.mods.toml",
|
||||||
]
|
]
|
||||||
|
|
||||||
def compatible_forgemc_versions = "${rootProject.compatible_minecraft_versions}".replaceAll("\"", "").replaceAll("]", ",)")
|
// incoming format: `["26.2.0","26.2-alpha.9"]`
|
||||||
|
// outgoing format: `[26.2.0],[26.2-alpha.9]`
|
||||||
|
def compatible_forgemc_versions = "${rootProject.compatible_minecraft_versions}"
|
||||||
|
.replaceAll("\",\"", "],[")
|
||||||
|
.replaceAll("\"", "")
|
||||||
|
|
||||||
// Quilt contributors
|
// Quilt contributors
|
||||||
def quilt_contributors = []
|
def quilt_contributors = []
|
||||||
|
|||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package com.seibel.distanthorizons.cleanroom.mixins.common;
|
||||||
|
|
||||||
|
import net.minecraft.world.storage.ThreadedFileIOBase;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(ThreadedFileIOBase.class)
|
||||||
|
public class MixinThreadedFileIOBase
|
||||||
|
{
|
||||||
|
@Redirect(method = "processQueue", at = @At(value = "INVOKE", target = "Ljava/lang/Thread;sleep(J)V"))
|
||||||
|
private void reduceSleep(long millis) throws InterruptedException
|
||||||
|
{
|
||||||
|
// 0ms between chunks, 5ms when idle
|
||||||
|
Thread.sleep(millis == 25L ? 5L : 0L);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,9 @@
|
|||||||
"package": "com.seibel.distanthorizons.cleanroom.mixins",
|
"package": "com.seibel.distanthorizons.cleanroom.mixins",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"target": "@env(DEFAULT)",
|
"target": "@env(DEFAULT)",
|
||||||
"mixins": [],
|
"mixins": [
|
||||||
|
"common.MixinThreadedFileIOBase"
|
||||||
|
],
|
||||||
"minVersion": "0.8.7",
|
"minVersion": "0.8.7",
|
||||||
"server": [
|
"server": [
|
||||||
"server.MixinEntityPlayerMP"
|
"server.MixinEntityPlayerMP"
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package com.seibel.distanthorizons.common;
|
package com.seibel.distanthorizons.common;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiMcRenderingFadeMode;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderingEngine;
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi;
|
|
||||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode;
|
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent;
|
||||||
import com.seibel.distanthorizons.common.commands.CommandInitializer;
|
import com.seibel.distanthorizons.common.commands.CommandInitializer;
|
||||||
@@ -387,17 +385,17 @@ public abstract class AbstractModInitializer
|
|||||||
if (iris != null)
|
if (iris != null)
|
||||||
{
|
{
|
||||||
// get the currently selected rendering API
|
// get the currently selected rendering API
|
||||||
EDhApiRenderApi renderApi = Config.Client.Advanced.Graphics.Experimental.renderingApi.get();
|
EDhApiRenderingEngine renderApi = Config.Client.Advanced.Graphics.Experimental.renderingEngine.get();
|
||||||
if (renderApi == EDhApiRenderApi.AUTO)
|
if (renderApi == EDhApiRenderingEngine.AUTO)
|
||||||
{
|
{
|
||||||
IVersionConstants versionConstants = SingletonInjector.INSTANCE.get(IVersionConstants.class);
|
IVersionConstants versionConstants = SingletonInjector.INSTANCE.get(IVersionConstants.class);
|
||||||
renderApi = versionConstants.getDefaultRenderingApi();
|
renderApi = versionConstants.getDefaultRenderingEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iris only supports native OpenGL
|
// Iris only supports native OpenGL
|
||||||
if (renderApi != EDhApiRenderApi.OPEN_GL)
|
if (renderApi != EDhApiRenderingEngine.OPEN_GL)
|
||||||
{
|
{
|
||||||
String irisUnsupportedMessage = "Iris doesn't support DH when using the ["+EDhApiRenderApi.BLAZE_3D+"] rendering API, this will need to be fixed on Iris end. As a temporary fix please change the rendering API to ["+EDhApiRenderApi.OPEN_GL+"] in the DH config file.";
|
String irisUnsupportedMessage = "Iris doesn't support DH when using the ["+ EDhApiRenderingEngine.BLAZE_3D+"] rendering engine, this will need to be fixed on Iris end. As a temporary fix please change the rendering engine to ["+ EDhApiRenderingEngine.OPEN_GL+"] in the DH config file.";
|
||||||
LOGGER.fatal(irisUnsupportedMessage);
|
LOGGER.fatal(irisUnsupportedMessage);
|
||||||
NativeDialogUtil.showDialog(ModInfo.READABLE_NAME, irisUnsupportedMessage, "ok", "error");
|
NativeDialogUtil.showDialog(ModInfo.READABLE_NAME, irisUnsupportedMessage, "ok", "error");
|
||||||
|
|
||||||
@@ -421,11 +419,11 @@ public abstract class AbstractModInitializer
|
|||||||
{
|
{
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
Config.Client.Advanced.Graphics.Experimental.renderingApi.setMcVersionOverrideValue(EDhApiRenderApi.OPEN_GL);
|
Config.Client.Advanced.Graphics.Experimental.renderingEngine.setMcVersionOverrideValue(EDhApiRenderingEngine.OPEN_GL);
|
||||||
Config.Client.Advanced.Graphics.Quality.vanillaFadeMode.setMcVersionOverrideValue(EDhApiMcRenderingFadeMode.NONE);
|
Config.Client.Advanced.Graphics.Quality.vanillaFadeMode.setMcVersionOverrideValue(EDhApiMcRenderingFadeMode.NONE);
|
||||||
Config.Common.WorldGenerator.distantGeneratorMode.setMcVersionOverrideValue(EDhApiDistantGeneratorMode.INTERNAL_SERVER);
|
Config.Common.WorldGenerator.distantGeneratorMode.setMcVersionOverrideValue(EDhApiDistantGeneratorMode.INTERNAL_SERVER);
|
||||||
#elif MC_VER <= MC_1_21_10
|
#elif MC_VER <= MC_1_21_10
|
||||||
Config.Client.Advanced.Graphics.Experimental.renderingApi.setMcVersionOverrideValue(EDhApiRenderApi.OPEN_GL);
|
Config.Client.Advanced.Graphics.Experimental.renderingEngine.setMcVersionOverrideValue(EDhApiRenderingEngine.OPEN_GL);
|
||||||
#else
|
#else
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-17
@@ -1,7 +1,7 @@
|
|||||||
package com.seibel.distanthorizons.common.commonMixins;
|
package com.seibel.distanthorizons.common.commonMixins;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.gui.DhScreenUtil;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.updater.UpdateModScreen;
|
import com.seibel.distanthorizons.common.wrappers.gui.updater.UpdateModScreen;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
@@ -10,10 +10,11 @@ import com.seibel.distanthorizons.core.jar.installer.ModrinthGetter;
|
|||||||
import com.seibel.distanthorizons.core.jar.updater.SelfUpdater;
|
import com.seibel.distanthorizons.core.jar.updater.SelfUpdater;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
|
import net.minecraft.client.gui.GuiMainMenu;
|
||||||
#else
|
#else
|
||||||
import net.minecraft.client.gui.screens.TitleScreen;
|
import net.minecraft.client.gui.screens.TitleScreen;
|
||||||
#endif
|
#endif
|
||||||
@@ -23,8 +24,11 @@ public class DhUpdateScreenBase
|
|||||||
{
|
{
|
||||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
private static final Minecraft MC = Minecraft #if MC_VER <= MC_1_12_2 .getMinecraft() #else .getInstance() #endif;
|
#if MC_VER <= MC_1_12_2
|
||||||
|
private static final Minecraft MC = Minecraft.getMinecraft();
|
||||||
|
#else
|
||||||
|
private static final Minecraft MC = Minecraft.getInstance();
|
||||||
|
#endif
|
||||||
|
|
||||||
public static void tryShowUpdateScreenAndRunAutoUpdateStartup(Runnable runnable)
|
public static void tryShowUpdateScreenAndRunAutoUpdateStartup(Runnable runnable)
|
||||||
{
|
{
|
||||||
@@ -71,22 +75,33 @@ public class DhUpdateScreenBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try
|
// running on the render thread is required since setting the MC screen may trigger
|
||||||
|
// before its allowed, silently failing
|
||||||
|
RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("Update Screen", () ->
|
||||||
{
|
{
|
||||||
MC.setScreen(new UpdateModScreen(
|
try
|
||||||
new TitleScreen(false),
|
{
|
||||||
versionId
|
#if MC_VER <= MC_1_12_2
|
||||||
));
|
DhScreenUtil.showScreen(new UpdateModScreen(
|
||||||
}
|
new TitleScreen(false),
|
||||||
catch (Exception e)
|
versionId
|
||||||
{
|
));
|
||||||
// info instead of error since this can be ignored and probably just means
|
#else
|
||||||
// there isn't a new DH version available
|
DhScreenUtil.setScreen(new UpdateModScreen(
|
||||||
LOGGER.info("Unable to show DH update screen, reason: ["+e.getMessage()+"].");
|
new TitleScreen(false),
|
||||||
}
|
versionId
|
||||||
|
));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// info instead of error since this can be ignored and probably just means
|
||||||
|
// there isn't a new DH version available
|
||||||
|
LOGGER.error("Unable to show DH update screen, reason: ["+e.getMessage()+"].");
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
runnable.run();
|
runnable.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+4
-1
@@ -72,9 +72,12 @@ public class MixinVanillaFogCommon
|
|||||||
#elif MC_VER <= MC_1_21_10
|
#elif MC_VER <= MC_1_21_10
|
||||||
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
||||||
Entity entity = camera.getEntity();
|
Entity entity = camera.getEntity();
|
||||||
#else
|
#elif MC_VER <= MC_26_1_2
|
||||||
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
||||||
Entity entity = camera.entity();
|
Entity entity = camera.entity();
|
||||||
|
#else
|
||||||
|
Camera camera = Minecraft.getInstance().gameRenderer.mainCamera();
|
||||||
|
Entity entity = camera.entity();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
|
|||||||
+36
-54
@@ -26,34 +26,30 @@ public class BlazeDebugWireframeRenderer {}
|
|||||||
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBuffer;
|
import com.mojang.blaze3d.buffers.GpuBuffer;
|
||||||
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
||||||
import com.mojang.blaze3d.buffers.Std140Builder;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
import com.mojang.blaze3d.platform.PolygonMode;
|
|
||||||
import com.mojang.blaze3d.shaders.UniformType;
|
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
import com.mojang.blaze3d.systems.RenderPass;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.BlazeVertexFormatBuilder;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeUniformBufferWrapper;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
import com.seibel.distanthorizons.core.render.EDhRenderDepth;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.AbstractDebugWireframeRenderer;
|
import com.seibel.distanthorizons.core.render.renderer.AbstractDebugWireframeRenderer;
|
||||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||||
import com.seibel.distanthorizons.core.util.math.Vec3d;
|
import com.seibel.distanthorizons.core.util.math.Vec3d;
|
||||||
import com.seibel.distanthorizons.core.util.math.Vec3f;
|
import com.seibel.distanthorizons.core.util.math.Vec3f;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
import net.minecraft.resources.Identifier;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
||||||
import org.lwjgl.system.MemoryUtil;
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.util.OptionalDouble;
|
|
||||||
import java.util.OptionalInt;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles rendering the wireframe particles
|
* Handles rendering the wireframe particles
|
||||||
@@ -64,11 +60,10 @@ public class BlazeDebugWireframeRenderer extends AbstractDebugWireframeRenderer
|
|||||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
||||||
|
private static final AbstractDhRenderApiDefinition RENDER_API_DEF = SingletonInjector.INSTANCE.get(AbstractDhRenderApiDefinition.class);
|
||||||
|
|
||||||
public static BlazeDebugWireframeRenderer INSTANCE = new BlazeDebugWireframeRenderer();
|
public static BlazeDebugWireframeRenderer INSTANCE = new BlazeDebugWireframeRenderer();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** A box from 0,0,0 to 1,1,1 */
|
/** A box from 0,0,0 to 1,1,1 */
|
||||||
private static final float[] BOX_VERTICES = {
|
private static final float[] BOX_VERTICES = {
|
||||||
//region
|
//region
|
||||||
@@ -103,6 +98,7 @@ public class BlazeDebugWireframeRenderer extends AbstractDebugWireframeRenderer
|
|||||||
//endregion
|
//endregion
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final Mat4f TRANSFORM_MATRIX = new Mat4f();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -114,7 +110,7 @@ public class BlazeDebugWireframeRenderer extends AbstractDebugWireframeRenderer
|
|||||||
private GpuBuffer boxVertexBuffer;
|
private GpuBuffer boxVertexBuffer;
|
||||||
private GpuBuffer boxIndexBuffer;
|
private GpuBuffer boxIndexBuffer;
|
||||||
|
|
||||||
private GpuBuffer uniformBuffer;
|
private final BlazeUniformBufferWrapper uniformBufferWrapper = new BlazeUniformBufferWrapper("debugWireframeUniformBlock");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -143,7 +139,14 @@ public class BlazeDebugWireframeRenderer extends AbstractDebugWireframeRenderer
|
|||||||
{
|
{
|
||||||
pipelineBuilder.withFaceCulling(false);
|
pipelineBuilder.withFaceCulling(false);
|
||||||
pipelineBuilder.withDepthWrite(true);
|
pipelineBuilder.withDepthWrite(true);
|
||||||
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.LESS);
|
if (RENDER_API_DEF.getRenderDepth() == EDhRenderDepth.FORWARD_Z)
|
||||||
|
{
|
||||||
|
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.LESS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.GREATER);
|
||||||
|
}
|
||||||
pipelineBuilder.withColorWrite(true);
|
pipelineBuilder.withColorWrite(true);
|
||||||
pipelineBuilder.withoutBlend();
|
pipelineBuilder.withoutBlend();
|
||||||
pipelineBuilder.withPolygonMode(RenderPipelineBuilderWrapper.EDhPolygonMode.WIREFRAME);
|
pipelineBuilder.withPolygonMode(RenderPipelineBuilderWrapper.EDhPolygonMode.WIREFRAME);
|
||||||
@@ -155,7 +158,7 @@ public class BlazeDebugWireframeRenderer extends AbstractDebugWireframeRenderer
|
|||||||
pipelineBuilder.withUniformBuffer("uniformBlock");
|
pipelineBuilder.withUniformBuffer("uniformBlock");
|
||||||
|
|
||||||
|
|
||||||
VertexFormat vertexFormat = VertexFormat.builder()
|
VertexFormat vertexFormat = new BlazeVertexFormatBuilder()
|
||||||
.add("vPosition", BlazeDhVertexFormatUtil.FLOAT_XYZ_POS)
|
.add("vPosition", BlazeDhVertexFormatUtil.FLOAT_XYZ_POS)
|
||||||
.build();
|
.build();
|
||||||
pipelineBuilder.withVertexFormat(vertexFormat);
|
pipelineBuilder.withVertexFormat(vertexFormat);
|
||||||
@@ -181,7 +184,7 @@ public class BlazeDebugWireframeRenderer extends AbstractDebugWireframeRenderer
|
|||||||
int usage = GpuBuffer.USAGE_COPY_DST
|
int usage = GpuBuffer.USAGE_COPY_DST
|
||||||
| GpuBuffer.USAGE_VERTEX;
|
| GpuBuffer.USAGE_VERTEX;
|
||||||
int size = BOX_VERTICES.length * Float.BYTES;
|
int size = BOX_VERTICES.length * Float.BYTES;
|
||||||
this.boxVertexBuffer = GPU_DEVICE.createBuffer(() -> "distantHorizons:McDebugWireframeBox", usage, size);
|
this.boxVertexBuffer = GPU_DEVICE.createBuffer(() -> "distantHorizons:DebugWireframeBox", usage, size);
|
||||||
|
|
||||||
{
|
{
|
||||||
int length = BOX_VERTICES.length * Float.BYTES;
|
int length = BOX_VERTICES.length * Float.BYTES;
|
||||||
@@ -251,14 +254,7 @@ public class BlazeDebugWireframeRenderer extends AbstractDebugWireframeRenderer
|
|||||||
|
|
||||||
// uniforms
|
// uniforms
|
||||||
{
|
{
|
||||||
int uniformBufferSize = new Std140SizeCalculator()
|
|
||||||
.putMat4f() // uTransform
|
|
||||||
.putVec4() // uColor
|
|
||||||
.get();
|
|
||||||
|
|
||||||
|
|
||||||
// create data //
|
// create data //
|
||||||
|
|
||||||
Vec3d camPos = MC_RENDER.getCameraExactPosition();
|
Vec3d camPos = MC_RENDER.getCameraExactPosition();
|
||||||
Vec3f camPosFloatThisFrame = new Vec3f((float) camPos.x, (float) camPos.y, (float) camPos.z);
|
Vec3f camPosFloatThisFrame = new Vec3f((float) camPos.x, (float) camPos.y, (float) camPos.z);
|
||||||
|
|
||||||
@@ -271,57 +267,43 @@ public class BlazeDebugWireframeRenderer extends AbstractDebugWireframeRenderer
|
|||||||
box.maxPos.y - box.minPos.y,
|
box.maxPos.y - box.minPos.y,
|
||||||
box.maxPos.z - box.minPos.z));
|
box.maxPos.z - box.minPos.z));
|
||||||
|
|
||||||
Mat4f transformMatrix = this.dhMvmProjMatrixThisFrame.copy();
|
TRANSFORM_MATRIX.set(this.dhMvmProjMatrixThisFrame);
|
||||||
transformMatrix.multiply(boxTransform);
|
TRANSFORM_MATRIX.multiply(boxTransform);
|
||||||
|
|
||||||
|
|
||||||
// upload data //
|
// upload data //
|
||||||
|
this.uniformBufferWrapper
|
||||||
ByteBuffer buffer = ByteBuffer.allocateDirect(uniformBufferSize);
|
.putMat4f(TRANSFORM_MATRIX) // uTransform
|
||||||
buffer.order(ByteOrder.nativeOrder());
|
.putVec4f(
|
||||||
buffer = Std140Builder.intoBuffer(buffer)
|
|
||||||
.putMat4f(transformMatrix.createJomlMatrix()) // uTransform
|
|
||||||
.putVec4(
|
|
||||||
box.color.getRed() / 255.0f,
|
box.color.getRed() / 255.0f,
|
||||||
box.color.getGreen() / 255.0f,
|
box.color.getGreen() / 255.0f,
|
||||||
box.color.getBlue() / 255.0f,
|
box.color.getBlue() / 255.0f,
|
||||||
box.color.getAlpha() / 255.0f) // uColor
|
box.color.getAlpha() / 255.0f) // uColor
|
||||||
.get()
|
.finishAndUpload()
|
||||||
;
|
;
|
||||||
|
|
||||||
this.uniformBuffer = BlazeUniformUtil.createBuffer("uniformBlock", uniformBufferSize, this.uniformBuffer);
|
|
||||||
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.uniformBuffer, 0, uniformBufferSize);
|
|
||||||
|
|
||||||
commandEncoder.writeToBuffer(bufferSlice, buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// render //
|
// render //
|
||||||
|
|
||||||
try (RenderPass renderPass = commandEncoder.createRenderPass(
|
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureView,
|
BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper))
|
||||||
BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView,
|
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
|
||||||
{
|
{
|
||||||
// Bind instance data //
|
// Bind instance data //
|
||||||
renderPass.setUniform("uniformBlock", this.uniformBuffer);
|
renderPassWrapper.setUniform("uniformBlock", this.uniformBufferWrapper);
|
||||||
|
|
||||||
renderPass.setPipeline(this.pipeline);
|
renderPassWrapper.setPipeline(this.pipeline);
|
||||||
renderPass.setIndexBuffer(this.boxIndexBuffer, VertexFormat.IndexType.INT);
|
renderPassWrapper.setIndexBuffer(this.boxIndexBuffer);
|
||||||
|
|
||||||
renderPass.setVertexBuffer(0, this.boxVertexBuffer);
|
renderPassWrapper.setVertexBuffer(this.boxVertexBuffer);
|
||||||
|
|
||||||
renderPass.drawIndexed(
|
renderPassWrapper.drawIndexed(BOX_OUTLINE_INDICES.length);
|
||||||
/*indexStart*/ 0,
|
|
||||||
/*firstIndex*/0,
|
|
||||||
/*indexCount*/BOX_OUTLINE_INDICES.length,
|
|
||||||
/*instanceCount*/1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private String getRenderPassName() { return "distantHorizons:McDebugRenderer"; }
|
private String getRenderPassName() { return "distantHorizons:DebugRenderer"; }
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|||||||
+44
-73
@@ -24,17 +24,10 @@ public class BlazeDhGenericObjectRenderer {}
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBuffer;
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140Builder;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
|
||||||
import com.mojang.blaze3d.pipeline.BlendFunction;
|
import com.mojang.blaze3d.pipeline.BlendFunction;
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
import com.mojang.blaze3d.platform.PolygonMode;
|
|
||||||
import com.mojang.blaze3d.shaders.UniformType;
|
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
import com.mojang.blaze3d.systems.RenderPass;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiBlockMaterial;
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiBlockMaterial;
|
||||||
@@ -43,22 +36,27 @@ import com.seibel.distanthorizons.api.interfaces.render.IDhApiRenderableBoxGroup
|
|||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeGenericObjectRenderEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeGenericObjectRenderEvent;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeGenericRenderCleanupEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeGenericRenderCleanupEvent;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeGenericRenderSetupEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeGenericRenderSetupEvent;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||||
import com.seibel.distanthorizons.api.objects.math.DhApiVec3d;
|
import com.seibel.distanthorizons.api.objects.math.DhApiVec3d;
|
||||||
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
|
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
|
||||||
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBoxGroupShading;
|
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBoxGroupShading;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.objects.BlazeGenericObjectVertexContainer;
|
import com.seibel.distanthorizons.common.render.blaze.objects.BlazeGenericObjectVertexContainer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.BlazeVertexFormatBuilder;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeUniformBufferWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.logging.f3.F3Screen;
|
import com.seibel.distanthorizons.core.logging.f3.F3Screen;
|
||||||
|
import com.seibel.distanthorizons.core.render.EDhRenderDepth;
|
||||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||||
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
|
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.GenericRenderObjectFactory;
|
import com.seibel.distanthorizons.core.render.renderer.GenericRenderObjectFactory;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IDhGenericObjectVertexBufferContainer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IDhGenericObjectVertexBufferContainer;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.RenderableBoxGroup;
|
import com.seibel.distanthorizons.core.render.renderer.RenderableBoxGroup;
|
||||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||||
@@ -69,15 +67,10 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IProfilerWrap
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhGenericRenderer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhGenericRenderer;
|
||||||
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
import net.minecraft.resources.Identifier;
|
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.ByteOrder;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.OptionalDouble;
|
|
||||||
import java.util.OptionalInt;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,6 +84,7 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
||||||
|
private static final AbstractDhRenderApiDefinition RENDER_API_DEF = SingletonInjector.INSTANCE.get(AbstractDhRenderApiDefinition.class);
|
||||||
|
|
||||||
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
||||||
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
||||||
@@ -103,6 +97,10 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
*/
|
*/
|
||||||
public static final boolean RENDER_DEBUG_OBJECTS = false;
|
public static final boolean RENDER_DEBUG_OBJECTS = false;
|
||||||
|
|
||||||
|
private static final DhApiBeforeGenericObjectRenderEvent.EventParam EVENT_PARAM = new DhApiBeforeGenericObjectRenderEvent.EventParam();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private final ConcurrentHashMap<Long, RenderableBoxGroup> boxGroupById = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Long, RenderableBoxGroup> boxGroupById = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|
||||||
@@ -111,7 +109,7 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
private RenderPipeline pipeline;
|
private RenderPipeline pipeline;
|
||||||
|
|
||||||
private GpuBuffer vertUniformBuffer;
|
private final BlazeUniformBufferWrapper vertUniformBufferWrapper = new BlazeUniformBufferWrapper("vertUniformBlock");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -143,7 +141,14 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
{
|
{
|
||||||
pipelineBuilder.withFaceCulling(true);
|
pipelineBuilder.withFaceCulling(true);
|
||||||
pipelineBuilder.withDepthWrite(true);
|
pipelineBuilder.withDepthWrite(true);
|
||||||
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.LESS);
|
if (RENDER_API_DEF.getRenderDepth() == EDhRenderDepth.FORWARD_Z)
|
||||||
|
{
|
||||||
|
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.LESS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.GREATER);
|
||||||
|
}
|
||||||
pipelineBuilder.withBlend(BlendFunction.TRANSLUCENT); // TRANSLUCENT = new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ONE_MINUS_SRC_ALPHA);
|
pipelineBuilder.withBlend(BlendFunction.TRANSLUCENT); // TRANSLUCENT = new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
pipelineBuilder.withColorWrite(true);
|
pipelineBuilder.withColorWrite(true);
|
||||||
pipelineBuilder.withPolygonMode(RenderPipelineBuilderWrapper.EDhPolygonMode.FILL);
|
pipelineBuilder.withPolygonMode(RenderPipelineBuilderWrapper.EDhPolygonMode.FILL);
|
||||||
@@ -156,7 +161,7 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
pipelineBuilder.withUniformBuffer("vertUniformBlock");
|
pipelineBuilder.withUniformBuffer("vertUniformBlock");
|
||||||
|
|
||||||
VertexFormat vertexFormat = VertexFormat.builder()
|
VertexFormat vertexFormat = new BlazeVertexFormatBuilder()
|
||||||
.add("vPosition", BlazeDhVertexFormatUtil.FLOAT_XYZ_POS)
|
.add("vPosition", BlazeDhVertexFormatUtil.FLOAT_XYZ_POS)
|
||||||
.add("aColor", BlazeDhVertexFormatUtil.RGBA_UBYTE_COLOR)
|
.add("aColor", BlazeDhVertexFormatUtil.RGBA_UBYTE_COLOR)
|
||||||
.add("aMaterial", BlazeDhVertexFormatUtil.IRIS_MATERIAL)
|
.add("aMaterial", BlazeDhVertexFormatUtil.IRIS_MATERIAL)
|
||||||
@@ -343,7 +348,7 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
this.init();
|
this.init();
|
||||||
|
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericRenderSetupEvent.class, renderEventParam);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericRenderSetupEvent.class, renderEventParam.apiCopy);
|
||||||
|
|
||||||
Vec3d camPos = MC_RENDER.getCameraExactPosition();
|
Vec3d camPos = MC_RENDER.getCameraExactPosition();
|
||||||
|
|
||||||
@@ -389,7 +394,8 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// allow API users to cancel this object's rendering
|
// allow API users to cancel this object's rendering
|
||||||
boolean cancelRendering = ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericObjectRenderEvent.class, new DhApiBeforeGenericObjectRenderEvent.EventParam(renderEventParam, boxGroup));
|
EVENT_PARAM.update(renderEventParam, boxGroup);
|
||||||
|
boolean cancelRendering = ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericObjectRenderEvent.class, EVENT_PARAM);
|
||||||
if (cancelRendering)
|
if (cancelRendering)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -415,28 +421,6 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
// uniforms
|
// uniforms
|
||||||
{
|
{
|
||||||
int uniformBufferSize = new Std140SizeCalculator()
|
|
||||||
.putIVec3() // uOffsetChunk
|
|
||||||
.putVec3() // uOffsetSubChunk
|
|
||||||
.putIVec3() // uCameraPosChunk
|
|
||||||
.putVec3() // uCameraPosSubChunk
|
|
||||||
|
|
||||||
.putVec3() // aTranslateChunk
|
|
||||||
.putVec3() // aTranslateSubChunk
|
|
||||||
|
|
||||||
.putMat4f() // uProjectionMvm
|
|
||||||
.putInt() // uSkyLight
|
|
||||||
.putInt() // uBlockLight
|
|
||||||
|
|
||||||
.putFloat() // uNorthShading
|
|
||||||
.putFloat() // uSouthShading
|
|
||||||
.putFloat() // uEastShading
|
|
||||||
.putFloat() // uWestShading
|
|
||||||
.putFloat() // uTopShading
|
|
||||||
.putFloat() // uBottomShading
|
|
||||||
.get();
|
|
||||||
|
|
||||||
|
|
||||||
// create data //
|
// create data //
|
||||||
|
|
||||||
Mat4f projectionMvmMatrix = new Mat4f(renderEventParam.dhProjectionMatrix);
|
Mat4f projectionMvmMatrix = new Mat4f(renderEventParam.dhProjectionMatrix);
|
||||||
@@ -445,31 +429,29 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
// upload data //
|
// upload data //
|
||||||
|
|
||||||
ByteBuffer buffer = ByteBuffer.allocateDirect(uniformBufferSize);
|
this.vertUniformBufferWrapper
|
||||||
buffer.order(ByteOrder.nativeOrder());
|
.putVec3i(
|
||||||
buffer = Std140Builder.intoBuffer(buffer)
|
|
||||||
.putIVec3(
|
|
||||||
LodUtil.getChunkPosFromDouble(boxGroup.getOriginBlockPos().x),
|
LodUtil.getChunkPosFromDouble(boxGroup.getOriginBlockPos().x),
|
||||||
LodUtil.getChunkPosFromDouble(boxGroup.getOriginBlockPos().y),
|
LodUtil.getChunkPosFromDouble(boxGroup.getOriginBlockPos().y),
|
||||||
LodUtil.getChunkPosFromDouble(boxGroup.getOriginBlockPos().z)
|
LodUtil.getChunkPosFromDouble(boxGroup.getOriginBlockPos().z)
|
||||||
) // uOffsetChunk
|
) // uOffsetChunk
|
||||||
.putVec3(
|
.putVec3f(
|
||||||
LodUtil.getSubChunkPosFromDouble(boxGroup.getOriginBlockPos().x),
|
LodUtil.getSubChunkPosFromDouble(boxGroup.getOriginBlockPos().x),
|
||||||
LodUtil.getSubChunkPosFromDouble(boxGroup.getOriginBlockPos().y),
|
LodUtil.getSubChunkPosFromDouble(boxGroup.getOriginBlockPos().y),
|
||||||
LodUtil.getSubChunkPosFromDouble(boxGroup.getOriginBlockPos().z)
|
LodUtil.getSubChunkPosFromDouble(boxGroup.getOriginBlockPos().z)
|
||||||
) // uOffsetSubChunk
|
) // uOffsetSubChunk
|
||||||
.putIVec3(
|
.putVec3i(
|
||||||
LodUtil.getChunkPosFromDouble(camPos.x),
|
LodUtil.getChunkPosFromDouble(camPos.x),
|
||||||
LodUtil.getChunkPosFromDouble(camPos.y),
|
LodUtil.getChunkPosFromDouble(camPos.y),
|
||||||
LodUtil.getChunkPosFromDouble(camPos.z)
|
LodUtil.getChunkPosFromDouble(camPos.z)
|
||||||
) // uCameraPosChunk
|
) // uCameraPosChunk
|
||||||
.putVec3(
|
.putVec3f(
|
||||||
LodUtil.getSubChunkPosFromDouble(camPos.x),
|
LodUtil.getSubChunkPosFromDouble(camPos.x),
|
||||||
LodUtil.getSubChunkPosFromDouble(camPos.y),
|
LodUtil.getSubChunkPosFromDouble(camPos.y),
|
||||||
LodUtil.getSubChunkPosFromDouble(camPos.z)
|
LodUtil.getSubChunkPosFromDouble(camPos.z)
|
||||||
) // uCameraPosSubChunk
|
) // uCameraPosSubChunk
|
||||||
|
|
||||||
.putMat4f(projectionMvmMatrix.createJomlMatrix()) // uProjectionMvm
|
.putMat4f(projectionMvmMatrix) // uProjectionMvm
|
||||||
.putInt(boxGroup.getSkyLight()) // uSkyLight
|
.putInt(boxGroup.getSkyLight()) // uSkyLight
|
||||||
.putInt(boxGroup.getBlockLight()) // uBlockLight
|
.putInt(boxGroup.getBlockLight()) // uBlockLight
|
||||||
|
|
||||||
@@ -480,13 +462,8 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
.putFloat(shading.top)
|
.putFloat(shading.top)
|
||||||
.putFloat(shading.bottom)
|
.putFloat(shading.bottom)
|
||||||
|
|
||||||
.get()
|
.finishAndUpload()
|
||||||
;
|
;
|
||||||
|
|
||||||
this.vertUniformBuffer = BlazeUniformUtil.createBuffer("vertUniformBlock", uniformBufferSize, this.vertUniformBuffer);
|
|
||||||
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.vertUniformBuffer, 0, uniformBufferSize);
|
|
||||||
|
|
||||||
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -520,7 +497,7 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private String getRenderPassName() { return "distantHorizons:McGenericObjectRenderer"; }
|
private String getRenderPassName() { return "distantHorizons:GenericObjectRenderer"; }
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
@@ -536,12 +513,10 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
RenderableBoxGroup boxGroup,
|
RenderableBoxGroup boxGroup,
|
||||||
IProfilerWrapper profiler)
|
IProfilerWrapper profiler)
|
||||||
{
|
{
|
||||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureView,
|
BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper))
|
||||||
BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView,
|
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
|
||||||
{
|
{
|
||||||
|
|
||||||
// update instance data //
|
// update instance data //
|
||||||
@@ -550,30 +525,26 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
LightMapWrapper lightMapWrapper = (LightMapWrapper) renderEventParam.lightmap;
|
LightMapWrapper lightMapWrapper = (LightMapWrapper) renderEventParam.lightmap;
|
||||||
BlazeTextureViewWrapper lightmapTextureViewWrapper = lightMapWrapper.getTextureViewWrapper();
|
BlazeTextureViewWrapper lightmapTextureViewWrapper = lightMapWrapper.getTextureViewWrapper();
|
||||||
renderPass.bindTexture("uLightMap", lightmapTextureViewWrapper.textureView, lightmapTextureViewWrapper.textureSampler);
|
renderPassWrapper.bindTexture("uLightMap", lightmapTextureViewWrapper);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Bind instance data //
|
// Bind instance data //
|
||||||
|
|
||||||
|
|
||||||
renderPass.setUniform("vertUniformBlock", this.vertUniformBuffer);
|
renderPassWrapper.setUniform("vertUniformBlock", this.vertUniformBufferWrapper);
|
||||||
|
|
||||||
// set pipeline
|
// set pipeline
|
||||||
renderPass.setPipeline(this.pipeline);
|
renderPassWrapper.setPipeline(this.pipeline);
|
||||||
renderPass.setIndexBuffer(container.indexGpuBuffer, VertexFormat.IndexType.INT);
|
renderPassWrapper.setIndexBuffer(container.indexGpuBuffer);
|
||||||
|
|
||||||
renderPass.setVertexBuffer(0, container.vboGpuBuffer);
|
renderPassWrapper.setVertexBuffer(container.vboGpuBuffer);
|
||||||
|
|
||||||
// Draw instanced
|
// Draw instanced
|
||||||
if (container.uploadedBoxCount > 0)
|
if (container.uploadedBoxCount > 0)
|
||||||
{
|
{
|
||||||
renderPass.drawIndexed(
|
// 36 = 6 faces * 6 verticies per face
|
||||||
/*indexStart*/ 0,
|
renderPassWrapper.drawIndexed(container.uploadedBoxCount * 36);
|
||||||
/*firstIndex*/0,
|
|
||||||
/*indexCount*/container.uploadedBoxCount * 36, // 36 = 6 faces * 6 verticies per face
|
|
||||||
/*instanceCount*/1);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -627,9 +598,9 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
// close is called outside the render thread and buffer closing must be done on the render thread
|
// close is called outside the render thread and buffer closing must be done on the render thread
|
||||||
RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("Generic Obj Cleanup", () ->
|
RenderThreadTaskHandler.INSTANCE.queueRunningOnRenderThread("Generic Obj Cleanup", () ->
|
||||||
{
|
{
|
||||||
if (this.vertUniformBuffer != null)
|
if (this.vertUniformBufferWrapper != null)
|
||||||
{
|
{
|
||||||
this.vertUniformBuffer.close();
|
this.vertUniformBufferWrapper.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-2
@@ -10,8 +10,10 @@ import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterCo
|
|||||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiTextureCreatedParam;
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiTextureCreatedParam;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
||||||
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhMetaRenderer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhMetaRenderer;
|
||||||
@@ -28,6 +30,7 @@ public class BlazeDhMetaRenderer implements IDhMetaRenderer
|
|||||||
|
|
||||||
|
|
||||||
private BlazeDhApplyRenderer applyRenderer;
|
private BlazeDhApplyRenderer applyRenderer;
|
||||||
|
private final float clearDepth;
|
||||||
|
|
||||||
public final BlazeTextureWrapper dhDepthTextureWrapper = BlazeTextureWrapper.createDepth("DhDepthTexture");
|
public final BlazeTextureWrapper dhDepthTextureWrapper = BlazeTextureWrapper.createDepth("DhDepthTexture");
|
||||||
public final BlazeTextureWrapper dhColorTextureWrapper = BlazeTextureWrapper.createColor("DhColorTexture");
|
public final BlazeTextureWrapper dhColorTextureWrapper = BlazeTextureWrapper.createColor("DhColorTexture");
|
||||||
@@ -41,6 +44,9 @@ public class BlazeDhMetaRenderer implements IDhMetaRenderer
|
|||||||
|
|
||||||
private BlazeDhMetaRenderer()
|
private BlazeDhMetaRenderer()
|
||||||
{
|
{
|
||||||
|
AbstractDhRenderApiDefinition renderApiDefinition = SingletonInjector.INSTANCE.get(AbstractDhRenderApiDefinition.class);
|
||||||
|
this.clearDepth = renderApiDefinition.getRenderDepth().farDepth;
|
||||||
|
|
||||||
this.applyRenderer = new BlazeDhApplyRenderer(
|
this.applyRenderer = new BlazeDhApplyRenderer(
|
||||||
"dh_apply_to_mc",
|
"dh_apply_to_mc",
|
||||||
null,
|
null,
|
||||||
@@ -86,7 +92,7 @@ public class BlazeDhMetaRenderer implements IDhMetaRenderer
|
|||||||
@Override
|
@Override
|
||||||
public void applyToMcTexture(RenderParams renderParams)
|
public void applyToMcTexture(RenderParams renderParams)
|
||||||
{
|
{
|
||||||
GpuTexture mcColorTexture = Minecraft.getInstance().getMainRenderTarget().getColorTexture();
|
GpuTexture mcColorTexture = MinecraftRenderWrapper.INSTANCE.getRenderTarget().getColorTexture();
|
||||||
this.applyRenderer.render(this.dhColorTextureWrapper.texture, this.dhDepthTextureWrapper.texture, mcColorTexture);
|
this.applyRenderer.render(this.dhColorTextureWrapper.texture, this.dhDepthTextureWrapper.texture, mcColorTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +108,7 @@ public class BlazeDhMetaRenderer implements IDhMetaRenderer
|
|||||||
@Override
|
@Override
|
||||||
public void clearDhDepthAndColorTextures(RenderParams renderParams)
|
public void clearDhDepthAndColorTextures(RenderParams renderParams)
|
||||||
{
|
{
|
||||||
this.dhDepthTextureWrapper.clearDepth(1.0f);
|
this.dhDepthTextureWrapper.clearDepth(this.clearDepth);
|
||||||
|
|
||||||
Color color = MC_RENDER.getSkyColor();
|
Color color = MC_RENDER.getSkyColor();
|
||||||
this.dhColorTextureWrapper.clearColor(ColorUtil.toColorInt(color));
|
this.dhColorTextureWrapper.clearColor(ColorUtil.toColorInt(color));
|
||||||
@@ -111,5 +117,6 @@ public class BlazeDhMetaRenderer implements IDhMetaRenderer
|
|||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
+45
-1
@@ -5,6 +5,8 @@ public class BlazeDhRenderApiDefinition {}
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderingApi;
|
||||||
|
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderingEngine;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.objects.BlazeGenericObjectVertexContainer;
|
import com.seibel.distanthorizons.common.render.blaze.objects.BlazeGenericObjectVertexContainer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.postProcessing.BlazeDhFarFadeRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.postProcessing.BlazeDhFarFadeRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.postProcessing.BlazeDhFogRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.postProcessing.BlazeDhFogRenderer;
|
||||||
@@ -13,6 +15,8 @@ import com.seibel.distanthorizons.common.render.blaze.postProcessing.BlazeVanill
|
|||||||
import com.seibel.distanthorizons.common.render.blaze.test.BlazeDhTestTriangleRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.test.BlazeDhTestTriangleRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.buffer.BlazeVertexBufferWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.buffer.BlazeVertexBufferWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeLodUniformBufferWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeLodUniformBufferWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.render.EDhRenderDepth;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.AbstractDebugWireframeRenderer;
|
import com.seibel.distanthorizons.core.render.renderer.AbstractDebugWireframeRenderer;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IDhGenericObjectVertexBufferContainer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IDhGenericObjectVertexBufferContainer;
|
||||||
@@ -20,6 +24,10 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.ILodCont
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IVertexBufferWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IVertexBufferWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.*;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.*;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
|
||||||
public class BlazeDhRenderApiDefinition extends AbstractDhRenderApiDefinition
|
public class BlazeDhRenderApiDefinition extends AbstractDhRenderApiDefinition
|
||||||
{
|
{
|
||||||
//=========//
|
//=========//
|
||||||
@@ -27,7 +35,43 @@ public class BlazeDhRenderApiDefinition extends AbstractDhRenderApiDefinition
|
|||||||
//=========//
|
//=========//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
public String getApiName() { return "Blaze3D"; }
|
private final String apiName;
|
||||||
|
public String getApiName() { return this.apiName; }
|
||||||
|
|
||||||
|
public EDhRenderDepth getRenderDepth()
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
return EDhRenderDepth.FORWARD_Z;
|
||||||
|
#else
|
||||||
|
return EDhRenderDepth.REVERSE_Z;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private final EDhApiRenderingApi renderApi;
|
||||||
|
public EDhApiRenderingApi getRenderApi() { return renderApi; }
|
||||||
|
public boolean isNativeRenderer() { return false; }
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=============//
|
||||||
|
// constructor //
|
||||||
|
//=============//
|
||||||
|
//region
|
||||||
|
|
||||||
|
public BlazeDhRenderApiDefinition()
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
renderApi = EDhApiRenderingApi.OPEN_GL;
|
||||||
|
#else
|
||||||
|
// use the same rendering API as Minecraft
|
||||||
|
this.renderApi = MinecraftRenderWrapper.INSTANCE.getMcRenderingApi();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
this.apiName = "Blaze3D: " + this.getRenderApi();
|
||||||
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|||||||
+64
-92
@@ -5,33 +5,31 @@ public class BlazeDhTerrainRenderer {}
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBuffer;
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140Builder;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
|
||||||
import com.mojang.blaze3d.pipeline.BlendFunction;
|
import com.mojang.blaze3d.pipeline.BlendFunction;
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
import com.mojang.blaze3d.platform.PolygonMode;
|
|
||||||
import com.mojang.blaze3d.shaders.UniformType;
|
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
import com.mojang.blaze3d.systems.RenderPass;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeBufferRenderEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeBufferRenderEvent;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeRenderPassEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeRenderPassEvent;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
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.BlazeVertexFormatBuilder;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeLodUniformBufferWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeLodUniformBufferWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.buffer.BlazeVertexBufferWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.buffer.BlazeVertexBufferWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeUniformBufferWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodBufferContainer;
|
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodBufferContainer;
|
||||||
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
import com.seibel.distanthorizons.core.pos.DhSectionPos;
|
||||||
|
import com.seibel.distanthorizons.core.render.EDhRenderDepth;
|
||||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||||
import com.seibel.distanthorizons.core.util.RenderUtil;
|
import com.seibel.distanthorizons.core.util.RenderUtil;
|
||||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||||
@@ -39,34 +37,34 @@ import com.seibel.distanthorizons.core.util.math.Vec3d;
|
|||||||
import com.seibel.distanthorizons.core.util.math.Vec3f;
|
import com.seibel.distanthorizons.core.util.math.Vec3f;
|
||||||
import com.seibel.distanthorizons.core.util.objects.SortedArraySet;
|
import com.seibel.distanthorizons.core.util.objects.SortedArraySet;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IProfilerWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IProfilerWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhTerrainRenderer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhTerrainRenderer;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IVertexBufferWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IVertexBufferWrapper;
|
||||||
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
import com.seibel.distanthorizons.coreapi.DependencyInjection.ApiEventInjector;
|
||||||
import net.minecraft.resources.Identifier;
|
|
||||||
import org.lwjgl.system.MemoryUtil;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.ByteOrder;
|
|
||||||
import java.util.OptionalDouble;
|
|
||||||
import java.util.OptionalInt;
|
|
||||||
|
|
||||||
/** Renders rendering DH's LOD terrain. */
|
/** Renders rendering DH's LOD terrain. */
|
||||||
public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
||||||
{
|
{
|
||||||
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
|
private static final AbstractDhRenderApiDefinition RENDER_API_DEF = SingletonInjector.INSTANCE.get(AbstractDhRenderApiDefinition.class);
|
||||||
|
|
||||||
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
||||||
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
||||||
|
|
||||||
public static final BlazeDhTerrainRenderer INSTANCE = new BlazeDhTerrainRenderer();
|
public static final BlazeDhTerrainRenderer INSTANCE = new BlazeDhTerrainRenderer();
|
||||||
|
|
||||||
|
private static final Vec3f MODEL_POS = new Vec3f();
|
||||||
|
/** single event object used to reduce GC pressure */
|
||||||
|
private static final DhApiBeforeBufferRenderEvent.EventParam BEFORE_BUFFER_RENDER_EVENT_PARAM = new DhApiBeforeBufferRenderEvent.EventParam();
|
||||||
|
|
||||||
|
|
||||||
private RenderPipeline opaquePipeline;
|
private RenderPipeline opaquePipeline;
|
||||||
private RenderPipeline transparentPipeline;
|
private RenderPipeline transparentPipeline;
|
||||||
private boolean init = false;
|
private boolean init = false;
|
||||||
|
|
||||||
private GpuBuffer fragUniformBuffer;
|
private final BlazeUniformBufferWrapper fragUniformBufferWrapper = new BlazeUniformBufferWrapper("fragUniformBlock");
|
||||||
private GpuBuffer vertSharedUniformBuffer;
|
private final BlazeUniformBufferWrapper vertSharedUniformBufferWrapper = new BlazeUniformBufferWrapper("vertSharedUniformBlock");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -86,14 +84,28 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
RenderPipelineBuilderWrapper pipelineBuilder = new RenderPipelineBuilderWrapper();
|
RenderPipelineBuilderWrapper opaquePipelineBuilder = new RenderPipelineBuilderWrapper();
|
||||||
|
RenderPipelineBuilderWrapper translucentPipelineBuilder = new RenderPipelineBuilderWrapper();
|
||||||
|
|
||||||
|
// apply shared options to both pipelines
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
|
RenderPipelineBuilderWrapper pipelineBuilder = (i == 0)
|
||||||
|
? opaquePipelineBuilder
|
||||||
|
: translucentPipelineBuilder;
|
||||||
|
|
||||||
pipelineBuilder.withFaceCulling(true);
|
pipelineBuilder.withFaceCulling(true);
|
||||||
pipelineBuilder.withDepthWrite(true);
|
pipelineBuilder.withDepthWrite(true);
|
||||||
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.LESS);
|
if (RENDER_API_DEF.getRenderDepth() == EDhRenderDepth.FORWARD_Z)
|
||||||
|
{
|
||||||
|
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.LESS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pipelineBuilder.withDepthTest(RenderPipelineBuilderWrapper.EDhDepthTest.GREATER);
|
||||||
|
}
|
||||||
pipelineBuilder.withColorWrite(true);
|
pipelineBuilder.withColorWrite(true);
|
||||||
pipelineBuilder.withPolygonMode(RenderPipelineBuilderWrapper.EDhPolygonMode.FILL);
|
pipelineBuilder.withPolygonMode(RenderPipelineBuilderWrapper.EDhPolygonMode.FILL);
|
||||||
pipelineBuilder.withName("terrain");
|
|
||||||
|
|
||||||
pipelineBuilder.withSampler("uLightMap");
|
pipelineBuilder.withSampler("uLightMap");
|
||||||
|
|
||||||
@@ -104,7 +116,7 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
pipelineBuilder.withUniformBuffer("vertSharedUniformBlock");
|
pipelineBuilder.withUniformBuffer("vertSharedUniformBlock");
|
||||||
pipelineBuilder.withUniformBuffer("fragUniformBlock");
|
pipelineBuilder.withUniformBuffer("fragUniformBlock");
|
||||||
|
|
||||||
VertexFormat vertexFormat = VertexFormat.builder()
|
VertexFormat vertexFormat = new BlazeVertexFormatBuilder()
|
||||||
.add("vPosition", BlazeDhVertexFormatUtil.SHORT_XYZ_POS)
|
.add("vPosition", BlazeDhVertexFormatUtil.SHORT_XYZ_POS)
|
||||||
.add("meta", BlazeDhVertexFormatUtil.META)
|
.add("meta", BlazeDhVertexFormatUtil.META)
|
||||||
.add("vColor", BlazeDhVertexFormatUtil.RGBA_UBYTE_COLOR)
|
.add("vColor", BlazeDhVertexFormatUtil.RGBA_UBYTE_COLOR)
|
||||||
@@ -120,15 +132,17 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
|
|
||||||
// opaque
|
// opaque
|
||||||
{
|
{
|
||||||
pipelineBuilder.withoutBlend();
|
opaquePipelineBuilder.withName("opaque_terrain");
|
||||||
this.opaquePipeline = pipelineBuilder.build();
|
opaquePipelineBuilder.withoutBlend();
|
||||||
|
this.opaquePipeline = opaquePipelineBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
// transparent
|
// transparent
|
||||||
{
|
{
|
||||||
|
translucentPipelineBuilder.withName("transparent_terrain");
|
||||||
// TRANSLUCENT = new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ONE_MINUS_SRC_ALPHA);
|
// TRANSLUCENT = new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
pipelineBuilder.withBlend(BlendFunction.TRANSLUCENT);
|
translucentPipelineBuilder.withBlend(BlendFunction.TRANSLUCENT);
|
||||||
this.transparentPipeline = pipelineBuilder.build();
|
this.transparentPipeline = translucentPipelineBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.init = true;
|
this.init = true;
|
||||||
@@ -161,7 +175,7 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
for (int lodIndex = 0; lodIndex < bufferContainers.size(); lodIndex++)
|
for (int lodIndex = 0; lodIndex < bufferContainers.size(); lodIndex++)
|
||||||
{
|
{
|
||||||
LodBufferContainer bufferContainer = bufferContainers.get(lodIndex);
|
LodBufferContainer bufferContainer = bufferContainers.get(lodIndex);
|
||||||
bufferContainer.uniformContainer.tryUpload();
|
bufferContainer.uniformContainer.tryUpload(bufferContainer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,53 +198,25 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
|
|
||||||
// upload data //
|
// upload data //
|
||||||
|
|
||||||
int uniformBufferSize = new Std140SizeCalculator()
|
int i = Config.Client.Advanced.Debugging.enableWhiteWorld.get() ? 1 : 0;
|
||||||
.putInt() // uIsWhiteWorld
|
|
||||||
|
|
||||||
.putFloat() // uWorldYOffset
|
|
||||||
.putFloat() // uMircoOffset
|
|
||||||
.putFloat() // uEarthRadius
|
|
||||||
|
|
||||||
.putVec3() // uCameraPos
|
|
||||||
.putMat4f() // uCombinedMatrix
|
|
||||||
.get();
|
|
||||||
|
|
||||||
ByteBuffer buffer = MemoryUtil.memAlloc(uniformBufferSize);
|
this.vertSharedUniformBufferWrapper
|
||||||
buffer.order(ByteOrder.nativeOrder());
|
.putInt(i) // uIsWhiteWorld
|
||||||
Std140Builder.intoBuffer(buffer)
|
|
||||||
.putInt(0) // uIsWhiteWorld
|
|
||||||
|
|
||||||
.putFloat((float) renderEventParam.worldYOffset) // uWorldYOffset
|
.putFloat((float) renderEventParam.worldYOffset) // uWorldYOffset
|
||||||
.putFloat(0.01f) // uMircoOffset // 0.01 block offset
|
.putFloat(0.01f) // uMircoOffset // 0.01 block offset
|
||||||
.putFloat(earthCurveRatio) // uEarthRadius
|
.putFloat(earthCurveRatio) // uEarthRadius
|
||||||
|
|
||||||
.putVec3(
|
.putVec3f(
|
||||||
(float) renderEventParam.exactCameraPosition.x,
|
(float) renderEventParam.exactCameraPosition.x,
|
||||||
(float) renderEventParam.exactCameraPosition.y,
|
(float) renderEventParam.exactCameraPosition.y,
|
||||||
(float) renderEventParam.exactCameraPosition.z) // uCameraPos
|
(float) renderEventParam.exactCameraPosition.z) // uCameraPos
|
||||||
.putMat4f(combinedMatrix.createJomlMatrix()) // uCombinedMatrix
|
.putMat4f(combinedMatrix) // uCombinedMatrix
|
||||||
.get();
|
.finishAndUpload();
|
||||||
|
|
||||||
this.vertSharedUniformBuffer = BlazeUniformUtil.createBuffer("vertSharedUniformBlock", uniformBufferSize, this.vertSharedUniformBuffer);
|
|
||||||
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.vertSharedUniformBuffer, 0, uniformBufferSize);
|
|
||||||
|
|
||||||
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
|
|
||||||
|
|
||||||
MemoryUtil.memFree(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
profiler.popPush("set frag uniforms");
|
profiler.popPush("set frag uniforms");
|
||||||
{
|
{
|
||||||
int uniformBufferSize = new Std140SizeCalculator()
|
|
||||||
.putFloat() // uClipDistance
|
|
||||||
.putFloat() // uNoiseIntensity
|
|
||||||
.putInt() // uNoiseSteps
|
|
||||||
.putInt() // uNoiseDropoff
|
|
||||||
.putInt() // uDitherDhRendering
|
|
||||||
.putInt() // uNoiseEnabled
|
|
||||||
.get();
|
|
||||||
|
|
||||||
|
|
||||||
// create data //
|
// create data //
|
||||||
|
|
||||||
float dhNearClipDistance = RenderUtil.getNearClipPlaneInBlocks();
|
float dhNearClipDistance = RenderUtil.getNearClipPlaneInBlocks();
|
||||||
@@ -242,24 +228,15 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
|
|
||||||
|
|
||||||
// upload data //
|
// upload data //
|
||||||
|
this.fragUniformBufferWrapper
|
||||||
ByteBuffer buffer = MemoryUtil.memAlloc(uniformBufferSize);
|
|
||||||
buffer.order(ByteOrder.nativeOrder());
|
|
||||||
buffer = Std140Builder.intoBuffer(buffer)
|
|
||||||
.putFloat(dhNearClipDistance) // uClipDistance
|
.putFloat(dhNearClipDistance) // uClipDistance
|
||||||
.putFloat(Config.Client.Advanced.Graphics.NoiseTexture.noiseIntensity.get()) // uNoiseIntensity
|
.putFloat(Config.Client.Advanced.Graphics.NoiseTexture.noiseIntensity.get()) // uNoiseIntensity
|
||||||
.putInt(Config.Client.Advanced.Graphics.NoiseTexture.noiseSteps.get()) // uNoiseSteps
|
.putInt(Config.Client.Advanced.Graphics.NoiseTexture.noiseSteps.get()) // uNoiseSteps
|
||||||
.putInt(Config.Client.Advanced.Graphics.NoiseTexture.noiseDropoff.get()) // uNoiseDropoff
|
.putInt(Config.Client.Advanced.Graphics.NoiseTexture.noiseDropoff.get()) // uNoiseDropoff
|
||||||
.putInt(Config.Client.Advanced.Graphics.Quality.ditherDhFade.get() ? 1 : 0) // uDitherDhRendering
|
.putInt(Config.Client.Advanced.Graphics.Quality.ditherDhFade.get() ? 1 : 0) // uDitherDhRendering
|
||||||
.putInt(Config.Client.Advanced.Graphics.NoiseTexture.enableNoiseTexture.get() ? 1 : 0) // uNoiseEnabled
|
.putInt(Config.Client.Advanced.Graphics.NoiseTexture.enableNoiseTexture.get() ? 1 : 0) // uNoiseEnabled
|
||||||
.get()
|
.finishAndUpload()
|
||||||
;
|
;
|
||||||
|
|
||||||
this.fragUniformBuffer = BlazeUniformUtil.createBuffer("fragUniformBlock", uniformBufferSize, this.fragUniformBuffer);
|
|
||||||
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.fragUniformBuffer, 0, uniformBufferSize);
|
|
||||||
|
|
||||||
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
|
|
||||||
MemoryUtil.memFree(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -268,27 +245,25 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
{
|
{
|
||||||
profiler.popPush("rendering");
|
profiler.popPush("rendering");
|
||||||
|
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam.apiCopy);
|
||||||
|
|
||||||
// create a render pass
|
// create a render pass
|
||||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureView,
|
BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper)
|
||||||
BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView,
|
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty())
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
LightMapWrapper lightMapWrapper = (LightMapWrapper) renderEventParam.lightmap;
|
LightMapWrapper lightMapWrapper = (LightMapWrapper) renderEventParam.lightmap;
|
||||||
BlazeTextureViewWrapper lightmapTextureViewWrapper = lightMapWrapper.getTextureViewWrapper();
|
BlazeTextureViewWrapper lightmapTextureViewWrapper = lightMapWrapper.getTextureViewWrapper();
|
||||||
renderPass.bindTexture("uLightMap", lightmapTextureViewWrapper.textureView, lightmapTextureViewWrapper.textureSampler);
|
renderPassWrapper.bindTexture("uLightMap", lightmapTextureViewWrapper);
|
||||||
|
|
||||||
// set pipeline
|
// set pipeline
|
||||||
renderPass.setPipeline(opaquePass ? this.opaquePipeline : this.transparentPipeline);
|
renderPassWrapper.setPipeline(opaquePass ? this.opaquePipeline : this.transparentPipeline);
|
||||||
|
|
||||||
// shared uniforms
|
// shared uniforms
|
||||||
renderPass.setUniform("fragUniformBlock", this.fragUniformBuffer);
|
renderPassWrapper.setUniform("fragUniformBlock", this.fragUniformBufferWrapper);
|
||||||
renderPass.setUniform("vertSharedUniformBlock", this.vertSharedUniformBuffer);
|
renderPassWrapper.setUniform("vertSharedUniformBlock", this.vertSharedUniformBufferWrapper);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -312,7 +287,7 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
renderPass.setUniform("vertUniqueUniformBlock", uniformWrapper.gpuBuffer);
|
renderPassWrapper.setUniform("vertUniqueUniformBlock", uniformWrapper);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -330,23 +305,20 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
// fire render event
|
// fire render event
|
||||||
{
|
{
|
||||||
Vec3d camPos = renderEventParam.exactCameraPosition;
|
Vec3d camPos = renderEventParam.exactCameraPosition;
|
||||||
Vec3f modelPos = new Vec3f(
|
MODEL_POS.set(
|
||||||
(float) (bufferContainer.minCornerBlockPos.getX() - camPos.x),
|
(float) (bufferContainer.minCornerBlockPos.getX() - camPos.x),
|
||||||
(float) (bufferContainer.minCornerBlockPos.getY() - camPos.y),
|
(float) (bufferContainer.minCornerBlockPos.getY() - camPos.y),
|
||||||
(float) (bufferContainer.minCornerBlockPos.getZ() - camPos.z));
|
(float) (bufferContainer.minCornerBlockPos.getZ() - camPos.z));
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeBufferRenderEvent.class, new DhApiBeforeBufferRenderEvent.EventParam(renderEventParam, modelPos));
|
BEFORE_BUFFER_RENDER_EVENT_PARAM.update(renderEventParam, MODEL_POS);
|
||||||
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeBufferRenderEvent.class, BEFORE_BUFFER_RENDER_EVENT_PARAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderPass.setIndexBuffer(bufferWrapper.getIndexGpuBuffer(), VertexFormat.IndexType.INT);
|
renderPassWrapper.setIndexBuffer(bufferWrapper.getIndexGpuBuffer());
|
||||||
renderPass.setVertexBuffer(0, bufferWrapper.vertexGpuBuffer); // vertex buffer can only be "0" lol
|
renderPassWrapper.setVertexBuffer(bufferWrapper.vertexGpuBuffer);
|
||||||
|
|
||||||
if (!bufferWrapper.vertexGpuBuffer.isClosed())
|
if (!bufferWrapper.vertexGpuBuffer.isClosed())
|
||||||
{
|
{
|
||||||
renderPass.drawIndexed(
|
renderPassWrapper.drawIndexed(bufferWrapper.indexCount);
|
||||||
/*indexStart*/ 0,
|
|
||||||
/*firstIndex*/0,
|
|
||||||
/*indexCount*/bufferWrapper.indexCount,
|
|
||||||
/*instanceCount*/1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -356,7 +328,7 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private String getIndexBufferName() { return "distantHorizons:LodIndexBuffer"; }
|
private String getIndexBufferName() { return "distantHorizons:LodIndexBuffer"; }
|
||||||
private String getRenderPassName() { return "distantHorizons:McLodRenderer"; }
|
private String getRenderPassName() { return "distantHorizons:TerrainRenderer"; }
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|||||||
+37
-23
@@ -29,23 +29,26 @@ import com.mojang.blaze3d.pipeline.BlendFunction;
|
|||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
import com.mojang.blaze3d.systems.RenderPass;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.textures.*;
|
import com.mojang.blaze3d.textures.*;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.BlazeVertexFormatBuilder;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeUniformBufferWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
import com.seibel.distanthorizons.core.render.EDhRenderDepth;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.OptionalDouble;
|
|
||||||
import java.util.OptionalInt;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies the given color texture
|
* Copies the given color texture
|
||||||
@@ -57,13 +60,17 @@ import java.util.OptionalInt;
|
|||||||
*/
|
*/
|
||||||
public class BlazeDhApplyRenderer
|
public class BlazeDhApplyRenderer
|
||||||
{
|
{
|
||||||
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
|
private static final AbstractDhRenderApiDefinition RENDER_API_DEF = SingletonInjector.INSTANCE.get(AbstractDhRenderApiDefinition.class);
|
||||||
|
|
||||||
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
||||||
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
||||||
|
|
||||||
private RenderPipeline pipeline;
|
private RenderPipeline pipeline;
|
||||||
|
|
||||||
|
private final BlazeUniformBufferWrapper fragUniformBufferWrapper = new BlazeUniformBufferWrapper("baseFragUniformBlock");
|
||||||
|
|
||||||
protected GpuBuffer vboGpuBuffer;
|
protected GpuBuffer vboGpuBuffer;
|
||||||
|
|
||||||
protected final String name;
|
protected final String name;
|
||||||
@@ -92,7 +99,7 @@ public class BlazeDhApplyRenderer
|
|||||||
*/
|
*/
|
||||||
private final String[] uniformNames;
|
private final String[] uniformNames;
|
||||||
/** will be an empty array if unneeded */
|
/** will be an empty array if unneeded */
|
||||||
private final GpuBuffer[] uniformBuffers;
|
private final BlazeUniformBufferWrapper[] uniformBufferWrappers;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -128,7 +135,7 @@ public class BlazeDhApplyRenderer
|
|||||||
this.fragmentShaderPath = fragmentShaderPath;
|
this.fragmentShaderPath = fragmentShaderPath;
|
||||||
|
|
||||||
this.uniformNames = uniformNames;
|
this.uniformNames = uniformNames;
|
||||||
this.uniformBuffers = new GpuBuffer[this.uniformNames.length];
|
this.uniformBufferWrappers = new BlazeUniformBufferWrapper[this.uniformNames.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryInit(
|
private void tryInit(
|
||||||
@@ -179,10 +186,12 @@ public class BlazeDhApplyRenderer
|
|||||||
pipelineBuilder.withUniformBuffer(uniformName);
|
pipelineBuilder.withUniformBuffer(uniformName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pipelineBuilder.withUniformBuffer("baseFragUniformBlock");
|
||||||
|
|
||||||
pipelineBuilder.withSampler("uSourceColorTexture");
|
pipelineBuilder.withSampler("uSourceColorTexture");
|
||||||
pipelineBuilder.withSampler("uSourceDepthTexture");
|
pipelineBuilder.withSampler("uSourceDepthTexture");
|
||||||
|
|
||||||
VertexFormat vertexFormat = VertexFormat.builder()
|
VertexFormat vertexFormat = new BlazeVertexFormatBuilder()
|
||||||
.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
|
.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
|
||||||
.build();
|
.build();
|
||||||
pipelineBuilder.withVertexFormat(vertexFormat);
|
pipelineBuilder.withVertexFormat(vertexFormat);
|
||||||
@@ -191,7 +200,6 @@ public class BlazeDhApplyRenderer
|
|||||||
this.pipeline = pipelineBuilder.build();
|
this.pipeline = pipelineBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -201,7 +209,7 @@ public class BlazeDhApplyRenderer
|
|||||||
//========//
|
//========//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
public void setUniform(String uniformName, GpuBuffer uniformBuffer)
|
public void setUniform(String uniformName, BlazeUniformBufferWrapper uniformBufferWrapper)
|
||||||
{
|
{
|
||||||
// the uniform array should be short enough (less than 10 items)
|
// the uniform array should be short enough (less than 10 items)
|
||||||
// where a sequential search should be plenty fast
|
// where a sequential search should be plenty fast
|
||||||
@@ -210,7 +218,7 @@ public class BlazeDhApplyRenderer
|
|||||||
String nameAtIndex = this.uniformNames[i];
|
String nameAtIndex = this.uniformNames[i];
|
||||||
if (nameAtIndex.equals(uniformName))
|
if (nameAtIndex.equals(uniformName))
|
||||||
{
|
{
|
||||||
this.uniformBuffers[i] = uniformBuffer;
|
this.uniformBufferWrappers[i] = uniformBufferWrapper;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,32 +233,38 @@ public class BlazeDhApplyRenderer
|
|||||||
|
|
||||||
this.dummyDepthTextureWrapper.tryCreateOrResize();
|
this.dummyDepthTextureWrapper.tryCreateOrResize();
|
||||||
|
|
||||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
|
||||||
|
this.fragUniformBufferWrapper
|
||||||
|
.putInt((RENDER_API_DEF.getRenderDepth() == EDhRenderDepth.REVERSE_Z) ? 1 : 0) // uIsReverseZDepth
|
||||||
|
.finishAndUpload();
|
||||||
|
;
|
||||||
|
|
||||||
|
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||||
this::getIdentifierName,
|
this::getIdentifierName,
|
||||||
this.destinationColorTextureViewWrapper.textureView,
|
this.destinationColorTextureViewWrapper,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
this.dummyDepthTextureWrapper))
|
||||||
this.dummyDepthTextureWrapper.textureView,
|
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
|
||||||
{
|
{
|
||||||
renderPass.bindTexture("uSourceColorTexture", this.sourceColorTextureViewWrapper.textureView, this.sourceColorTextureViewWrapper.textureSampler);
|
renderPassWrapper.bindTexture("uSourceColorTexture", this.sourceColorTextureViewWrapper);
|
||||||
renderPass.bindTexture("uSourceDepthTexture", this.sourceDepthTextureViewWrapper.textureView, this.sourceDepthTextureViewWrapper.textureSampler);
|
renderPassWrapper.bindTexture("uSourceDepthTexture", this.sourceDepthTextureViewWrapper);
|
||||||
|
|
||||||
for (int i = 0; i < this.uniformNames.length; i++)
|
for (int i = 0; i < this.uniformNames.length; i++)
|
||||||
{
|
{
|
||||||
String uniformName = this.uniformNames[i];
|
String uniformName = this.uniformNames[i];
|
||||||
GpuBuffer uniformBuffer = this.uniformBuffers[i];
|
BlazeUniformBufferWrapper uniformBuffer = this.uniformBufferWrappers[i];
|
||||||
if (uniformBuffer == null)
|
if (uniformBuffer == null)
|
||||||
{
|
{
|
||||||
throw new IllegalStateException("Missing uniform ["+uniformName+"], please set the uniform before rendering.");
|
throw new IllegalStateException("Missing uniform ["+uniformName+"], please set the uniform before rendering.");
|
||||||
}
|
}
|
||||||
|
|
||||||
renderPass.setUniform(uniformName, uniformBuffer);
|
renderPassWrapper.setUniform(uniformName, uniformBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderPass.setVertexBuffer(0, this.vboGpuBuffer);
|
renderPassWrapper.setUniform("baseFragUniformBlock", this.fragUniformBufferWrapper);
|
||||||
renderPass.setPipeline(this.pipeline);
|
|
||||||
|
|
||||||
renderPass.draw(/*indexStart*/ 0, /*indexCount*/ 4);
|
renderPassWrapper.setVertexBuffer(this.vboGpuBuffer);
|
||||||
|
renderPassWrapper.setPipeline(this.pipeline);
|
||||||
|
|
||||||
|
renderPassWrapper.draw(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -258,7 +272,7 @@ public class BlazeDhApplyRenderer
|
|||||||
// so we can check if they're missing during next frame's rendering
|
// so we can check if they're missing during next frame's rendering
|
||||||
if (ModInfo.IS_DEV_BUILD)
|
if (ModInfo.IS_DEV_BUILD)
|
||||||
{
|
{
|
||||||
Arrays.fill(this.uniformBuffers, null);
|
Arrays.fill(this.uniformBufferWrappers, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-36
@@ -28,19 +28,16 @@ import com.mojang.blaze3d.buffers.GpuBuffer;
|
|||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
import com.mojang.blaze3d.systems.RenderPass;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.textures.*;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.IDhBlazeTexture;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
|
||||||
import java.util.OptionalDouble;
|
|
||||||
import java.util.OptionalInt;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blindly copies one texture into another.
|
* Blindly copies one texture into another.
|
||||||
*
|
*
|
||||||
@@ -103,7 +100,7 @@ public class BlazeDhCopyRenderer
|
|||||||
this.pipeline = pipelineBuilder.build();
|
this.pipeline = pipelineBuilder.build();
|
||||||
|
|
||||||
|
|
||||||
this.vboGpuBuffer = BlazePostProcessUtil.createAndUploadScreenVertexData("McCopyRenderer");
|
this.vboGpuBuffer = BlazePostProcessUtil.createAndUploadScreenVertexData("CopyRenderer");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,48 +114,28 @@ public class BlazeDhCopyRenderer
|
|||||||
//region
|
//region
|
||||||
|
|
||||||
public void render(
|
public void render(
|
||||||
BlazeTextureWrapper sourceColorTextureWrapper,
|
IDhBlazeTexture sourceColorTextureWrapper,
|
||||||
BlazeTextureViewWrapper destinationColorTextureWrapper)
|
IDhBlazeTexture destinationColorTextureWrapper)
|
||||||
{
|
|
||||||
this.render(
|
|
||||||
sourceColorTextureWrapper.textureView, sourceColorTextureWrapper.textureSampler,
|
|
||||||
destinationColorTextureWrapper.textureView);
|
|
||||||
}
|
|
||||||
public void render(
|
|
||||||
BlazeTextureWrapper sourceColorTextureWrapper,
|
|
||||||
BlazeTextureWrapper destinationColorTextureWrapper)
|
|
||||||
{
|
|
||||||
this.render(
|
|
||||||
sourceColorTextureWrapper.textureView, sourceColorTextureWrapper.textureSampler,
|
|
||||||
destinationColorTextureWrapper.textureView);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void render(
|
|
||||||
GpuTextureView sourceTextureView,
|
|
||||||
GpuSampler sourceTextureSampler,
|
|
||||||
GpuTextureView destinationTextureView)
|
|
||||||
{
|
{
|
||||||
this.tryInit();
|
this.tryInit();
|
||||||
|
|
||||||
this.dummyDepthTextureWrapper.tryCreateOrResize();
|
this.dummyDepthTextureWrapper.tryCreateOrResize();
|
||||||
|
|
||||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
destinationTextureView,
|
destinationColorTextureWrapper,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
this.dummyDepthTextureWrapper))
|
||||||
this.dummyDepthTextureWrapper.textureView,
|
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
|
||||||
{
|
{
|
||||||
renderPass.bindTexture("uCopyTexture", sourceTextureView, sourceTextureSampler);
|
renderPassWrapper.bindTexture("uCopyTexture", sourceColorTextureWrapper);
|
||||||
|
|
||||||
renderPass.setVertexBuffer(0, this.vboGpuBuffer); // vertex buffer can only be "0" lol
|
renderPassWrapper.setVertexBuffer(this.vboGpuBuffer); // vertex buffer can only be "0" lol
|
||||||
|
|
||||||
renderPass.setPipeline(this.pipeline);
|
renderPassWrapper.setPipeline(this.pipeline);
|
||||||
renderPass.draw(/*indexStart*/ 0, /*indexCount*/ 4);
|
renderPassWrapper.draw(4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getRenderPassName() { return "distantHorizons:McCopyRenderer"; }
|
private String getRenderPassName() { return "distantHorizons:CopyRenderer"; }
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|||||||
+25
-54
@@ -25,33 +25,28 @@ public class BlazeDhFarFadeRenderer {}
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBuffer;
|
import com.mojang.blaze3d.buffers.GpuBuffer;
|
||||||
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140Builder;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
import com.mojang.blaze3d.systems.RenderPass;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhCopyRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhCopyRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeUniformBufferWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
import com.seibel.distanthorizons.core.render.EDhRenderDepth;
|
||||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||||
import com.seibel.distanthorizons.core.util.RenderUtil;
|
import com.seibel.distanthorizons.core.util.RenderUtil;
|
||||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhFarFadeRenderer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhFarFadeRenderer;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.ByteOrder;
|
|
||||||
import java.util.OptionalDouble;
|
|
||||||
import java.util.OptionalInt;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fades out DH's far clip plane
|
* Fades out DH's far clip plane
|
||||||
@@ -62,13 +57,14 @@ public class BlazeDhFarFadeRenderer implements IDhFarFadeRenderer
|
|||||||
|
|
||||||
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
||||||
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
||||||
|
private static final AbstractDhRenderApiDefinition RENDER_API_DEF = SingletonInjector.INSTANCE.get(AbstractDhRenderApiDefinition.class);
|
||||||
|
|
||||||
public static final BlazeDhFarFadeRenderer INSTANCE = new BlazeDhFarFadeRenderer();
|
public static final BlazeDhFarFadeRenderer INSTANCE = new BlazeDhFarFadeRenderer();
|
||||||
|
|
||||||
private RenderPipeline pipeline;
|
private RenderPipeline pipeline;
|
||||||
private boolean init = false;
|
private boolean init = false;
|
||||||
|
|
||||||
private GpuBuffer fragUniformBuffer;
|
private final BlazeUniformBufferWrapper fragUniformBufferWrapper = new BlazeUniformBufferWrapper("fragUniformBlock");
|
||||||
|
|
||||||
private GpuBuffer vboGpuBuffer;
|
private GpuBuffer vboGpuBuffer;
|
||||||
|
|
||||||
@@ -123,7 +119,7 @@ public class BlazeDhFarFadeRenderer implements IDhFarFadeRenderer
|
|||||||
this.pipeline = pipelineBuilder.build();
|
this.pipeline = pipelineBuilder.build();
|
||||||
|
|
||||||
|
|
||||||
this.vboGpuBuffer = BlazePostProcessUtil.createAndUploadScreenVertexData("McFadeRenderer");
|
this.vboGpuBuffer = BlazePostProcessUtil.createAndUploadScreenVertexData("DhFarFadeRenderer");
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
@@ -151,18 +147,11 @@ public class BlazeDhFarFadeRenderer implements IDhFarFadeRenderer
|
|||||||
|
|
||||||
// textures
|
// textures
|
||||||
this.dhFadeColorTextureWrapper.tryCreateOrResize();
|
this.dhFadeColorTextureWrapper.tryCreateOrResize();
|
||||||
this.mcColorTextureViewWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getColorTexture());
|
this.mcColorTextureViewWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getColorTexture());
|
||||||
|
|
||||||
this.dhFadeDepthTextureWrapper.tryCreateOrResize();
|
this.dhFadeDepthTextureWrapper.tryCreateOrResize();
|
||||||
|
|
||||||
{
|
{
|
||||||
int uniformBufferSize = new Std140SizeCalculator()
|
|
||||||
.putFloat() // uStartFadeBlockDistance
|
|
||||||
.putFloat() // uEndFadeBlockDistance
|
|
||||||
.putMat4f() // uDhInvMvmProj
|
|
||||||
.get();
|
|
||||||
|
|
||||||
|
|
||||||
// create data //
|
// create data //
|
||||||
|
|
||||||
float dhFarClipDistance = RenderUtil.getFarClipPlaneDistanceInBlocks();
|
float dhFarClipDistance = RenderUtil.getFarClipPlaneDistanceInBlocks();
|
||||||
@@ -170,30 +159,14 @@ public class BlazeDhFarFadeRenderer implements IDhFarFadeRenderer
|
|||||||
float fadeEndDistance = dhFarClipDistance * 0.9f;
|
float fadeEndDistance = dhFarClipDistance * 0.9f;
|
||||||
|
|
||||||
|
|
||||||
Mat4f dhProjectionMatrix = RenderUtil.createLodProjectionMatrix(renderParams.mcProjectionMatrix);
|
|
||||||
Mat4f dhModelViewMatrix = RenderUtil.createLodModelViewMatrix(renderParams.mcModelViewMatrix);
|
|
||||||
|
|
||||||
Mat4f inverseDhMvmProjMatrix = new Mat4f(dhProjectionMatrix);
|
|
||||||
inverseDhMvmProjMatrix.multiply(dhModelViewMatrix);
|
|
||||||
inverseDhMvmProjMatrix.invert();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// upload data //
|
// upload data //
|
||||||
|
fragUniformBufferWrapper
|
||||||
ByteBuffer buffer = ByteBuffer.allocateDirect(uniformBufferSize);
|
|
||||||
buffer.order(ByteOrder.nativeOrder());
|
|
||||||
buffer = Std140Builder.intoBuffer(buffer)
|
|
||||||
.putFloat(fadeStartDistance) // uStartFadeBlockDistance
|
.putFloat(fadeStartDistance) // uStartFadeBlockDistance
|
||||||
.putFloat(fadeEndDistance) // uEndFadeBlockDistance
|
.putFloat(fadeEndDistance) // uEndFadeBlockDistance
|
||||||
.putMat4f(inverseDhMvmProjMatrix.createJomlMatrix()) // uDhInvMvmProj
|
.putMat4f(renderParams.dhInverseMvmProjectionMatrix) // uDhInvMvmProj
|
||||||
.get()
|
.putInt((RENDER_API_DEF.getRenderDepth() == EDhRenderDepth.REVERSE_Z) ? 1 : 0) // uIsReverseZDepth
|
||||||
|
.finishAndUpload()
|
||||||
;
|
;
|
||||||
|
|
||||||
this.fragUniformBuffer = BlazeUniformUtil.createBuffer("fragUniformBlock", uniformBufferSize, this.fragUniformBuffer);
|
|
||||||
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.fragUniformBuffer, 0, uniformBufferSize);
|
|
||||||
|
|
||||||
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -204,29 +177,27 @@ public class BlazeDhFarFadeRenderer implements IDhFarFadeRenderer
|
|||||||
|
|
||||||
private void renderFadeToTexture()
|
private void renderFadeToTexture()
|
||||||
{
|
{
|
||||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
this.dhFadeColorTextureWrapper.textureView,
|
this.dhFadeColorTextureWrapper,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
this.dhFadeDepthTextureWrapper))
|
||||||
this.dhFadeDepthTextureWrapper.textureView,
|
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
|
||||||
{
|
{
|
||||||
// MC texture
|
// MC texture
|
||||||
renderPass.bindTexture("uMcColorTexture", this.mcColorTextureViewWrapper.textureView, this.mcColorTextureViewWrapper.textureSampler);
|
renderPassWrapper.bindTexture("uMcColorTexture", this.mcColorTextureViewWrapper);
|
||||||
|
|
||||||
// DH textures
|
// DH textures
|
||||||
renderPass.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView, BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureSampler);
|
renderPassWrapper.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper);
|
||||||
renderPass.bindTexture("uDhColorTexture", BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureView, BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureSampler);
|
renderPassWrapper.bindTexture("uDhColorTexture", BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper);
|
||||||
|
|
||||||
renderPass.setUniform("fragUniformBlock", this.fragUniformBuffer);
|
renderPassWrapper.setUniform("fragUniformBlock", this.fragUniformBufferWrapper);
|
||||||
|
|
||||||
renderPass.setVertexBuffer(0, this.vboGpuBuffer); // vertex buffer can only be "0" lol
|
renderPassWrapper.setVertexBuffer(this.vboGpuBuffer);
|
||||||
renderPass.setPipeline(this.pipeline);
|
renderPassWrapper.setPipeline(this.pipeline);
|
||||||
|
|
||||||
renderPass.draw(/*indexStart*/ 0, /*indexCount*/ 4);
|
renderPassWrapper.draw(4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private String getRenderPassName() { return "distantHorizons:McFadeRenderer"; }
|
private String getRenderPassName() { return "distantHorizons:DhFarFadeRenderer"; }
|
||||||
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|||||||
+70
-156
@@ -23,44 +23,44 @@ package com.seibel.distanthorizons.common.render.blaze.postProcessing;
|
|||||||
public class BlazeDhFogRenderer {}
|
public class BlazeDhFogRenderer {}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBuffer;
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140Builder;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
|
||||||
import com.mojang.blaze3d.pipeline.BlendFunction;
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
|
||||||
import com.mojang.blaze3d.platform.DestFactor;
|
|
||||||
import com.mojang.blaze3d.platform.SourceFactor;
|
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
|
||||||
import com.mojang.blaze3d.systems.RenderPass;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogColorMode;
|
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection;
|
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiFogRenderParam;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeUniformBufferWrapper;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
import com.seibel.distanthorizons.core.render.EDhRenderDepth;
|
||||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhFogRenderer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhFogRenderer;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.ByteOrder;
|
import com.mojang.blaze3d.buffers.GpuBuffer;
|
||||||
import java.util.OptionalDouble;
|
import com.mojang.blaze3d.pipeline.BlendFunction;
|
||||||
import java.util.OptionalInt;
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
import com.mojang.blaze3d.platform.DestFactor;
|
||||||
|
import com.mojang.blaze3d.platform.SourceFactor;
|
||||||
|
#else
|
||||||
|
import com.mojang.blaze3d.platform.BlendFactor;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders fog onto the LODs.
|
* Renders fog onto the LODs.
|
||||||
@@ -71,6 +71,7 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
|
|||||||
|
|
||||||
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
||||||
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
||||||
|
private static final AbstractDhRenderApiDefinition RENDER_API_DEF = SingletonInjector.INSTANCE.get(AbstractDhRenderApiDefinition.class);
|
||||||
|
|
||||||
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
||||||
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
||||||
@@ -83,7 +84,7 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
|
|||||||
private RenderPipeline pipeline;
|
private RenderPipeline pipeline;
|
||||||
private boolean init = false;
|
private boolean init = false;
|
||||||
|
|
||||||
private GpuBuffer fragUniformBuffer;
|
private final BlazeUniformBufferWrapper fragUniformBufferWrapper = new BlazeUniformBufferWrapper("dh_fog_frag_uniform");
|
||||||
|
|
||||||
private GpuBuffer vboGpuBuffer;
|
private GpuBuffer vboGpuBuffer;
|
||||||
|
|
||||||
@@ -109,11 +110,16 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
|
|||||||
this.init = true;
|
this.init = true;
|
||||||
|
|
||||||
|
|
||||||
|
BlendFunction blendFunc;
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
blendFunc = new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
|
#else
|
||||||
|
blendFunc = new BlendFunction(BlendFactor.SRC_ALPHA, BlendFactor.ONE_MINUS_SRC_ALPHA, BlendFactor.ONE, BlendFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
|
#endif
|
||||||
|
|
||||||
this.applyRenderer = new BlazeDhApplyRenderer(
|
this.applyRenderer = new BlazeDhApplyRenderer(
|
||||||
"fog_apply_to_dh",
|
"fog_apply_to_dh",
|
||||||
new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ONE_MINUS_SRC_ALPHA),
|
blendFunc,
|
||||||
"apply/blaze/vert", "apply/blaze/frag"
|
"apply/blaze/vert", "apply/blaze/frag"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -140,7 +146,7 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
|
|||||||
this.pipeline = pipelineBuilder.build();
|
this.pipeline = pipelineBuilder.build();
|
||||||
|
|
||||||
|
|
||||||
this.vboGpuBuffer = BlazePostProcessUtil.createAndUploadScreenVertexData("McFogRenderer");
|
this.vboGpuBuffer = BlazePostProcessUtil.createAndUploadScreenVertexData("FogRenderer");
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
@@ -153,7 +159,7 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
|
|||||||
//region
|
//region
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(RenderParams renderParams)
|
public void render(RenderParams renderParams, DhApiFogRenderParam fogRenderParams)
|
||||||
{
|
{
|
||||||
this.tryInit();
|
this.tryInit();
|
||||||
|
|
||||||
@@ -170,144 +176,68 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
|
|||||||
this.fogDepthTextureWrapper.tryCreateOrResize();
|
this.fogDepthTextureWrapper.tryCreateOrResize();
|
||||||
|
|
||||||
{
|
{
|
||||||
int uniformBufferSize = new Std140SizeCalculator()
|
|
||||||
|
|
||||||
// fog uniforms
|
|
||||||
.putVec4() // uFogColor
|
|
||||||
.putFloat() //uFogScale
|
|
||||||
.putFloat() //uFogVerticalScale
|
|
||||||
// only used for debugging
|
|
||||||
.putInt() //uFogDebugMode // 1 = render everything with fog color // 7 = use debug rendering
|
|
||||||
.putInt() //uFogFalloffType
|
|
||||||
|
|
||||||
// fog config
|
|
||||||
.putFloat() // uFarFogStart
|
|
||||||
.putFloat() // uFarFogLength
|
|
||||||
.putFloat() // uFarFogMin
|
|
||||||
.putFloat() // uFarFogRange
|
|
||||||
.putFloat() // uFarFogDensity
|
|
||||||
|
|
||||||
// height fog config
|
|
||||||
.putFloat() // uHeightFogStart
|
|
||||||
.putFloat() // uHeightFogLength
|
|
||||||
.putFloat() // uHeightFogMin
|
|
||||||
.putFloat() // uHeightFogRange
|
|
||||||
.putFloat() // uHeightFogDensity
|
|
||||||
|
|
||||||
// ??
|
|
||||||
.putInt() // uHeightFogEnabled
|
|
||||||
.putInt() // uHeightFogFalloffType
|
|
||||||
.putInt() // uHeightBasedOnCamera
|
|
||||||
.putFloat() // uHeightFogBaseHeight
|
|
||||||
.putInt() // uHeightFogAppliesUp
|
|
||||||
.putInt() // uHeightFogAppliesDown
|
|
||||||
.putInt() // uUseSphericalFog
|
|
||||||
.putInt() // uHeightFogMixingMode
|
|
||||||
.putFloat() // uCameraBlockYPos
|
|
||||||
|
|
||||||
.putMat4f() // uInvMvmProj
|
|
||||||
|
|
||||||
.get();
|
|
||||||
|
|
||||||
|
|
||||||
// create data //
|
// create data //
|
||||||
|
|
||||||
|
|
||||||
int lodDrawDistance = Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius.get() * LodUtil.CHUNK_WIDTH;
|
int lodDrawDistance = Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius.get() * LodUtil.CHUNK_WIDTH;
|
||||||
|
|
||||||
|
|
||||||
Mat4f inverseMvmProjMatrix = new Mat4f(renderParams.dhMvmProjMatrix);
|
Mat4f inverseMvmProjMatrix = new Mat4f(renderParams.dhMvmProjMatrix);
|
||||||
inverseMvmProjMatrix.invert();
|
inverseMvmProjMatrix.invert();
|
||||||
|
|
||||||
if (renderParams.dhMvmProjMatrix == null)
|
EDhApiHeightFogMixMode heightFogMixingMode = fogRenderParams.getHeightFogMixingMode();
|
||||||
{
|
boolean heightFogEnabled =
|
||||||
return;
|
heightFogMixingMode != EDhApiHeightFogMixMode.SPHERICAL
|
||||||
}
|
&& heightFogMixingMode != EDhApiHeightFogMixMode.CYLINDRICAL;
|
||||||
|
|
||||||
|
|
||||||
Color fogColor = this.getFogColor(renderParams.partialTicks);
|
|
||||||
|
|
||||||
// fog config
|
|
||||||
float farFogStart = Config.Client.Advanced.Graphics.Fog.farFogStart.get();
|
|
||||||
float farFogEnd = Config.Client.Advanced.Graphics.Fog.farFogEnd.get();
|
|
||||||
float farFogMin = Config.Client.Advanced.Graphics.Fog.farFogMin.get();
|
|
||||||
float farFogMax = Config.Client.Advanced.Graphics.Fog.farFogMax.get();
|
|
||||||
float farFogDensity = Config.Client.Advanced.Graphics.Fog.farFogDensity.get();
|
|
||||||
|
|
||||||
// override fog if underwater
|
|
||||||
if (MC_RENDER.isFogStateSpecial())
|
|
||||||
{
|
|
||||||
// hide everything behind fog
|
|
||||||
farFogStart = 0.0f;
|
|
||||||
farFogEnd = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// height config
|
|
||||||
EDhApiHeightFogMixMode heightFogMixingMode = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMixMode.get();
|
|
||||||
boolean heightFogEnabled = heightFogMixingMode != EDhApiHeightFogMixMode.SPHERICAL && heightFogMixingMode != EDhApiHeightFogMixMode.CYLINDRICAL;
|
|
||||||
boolean useSphericalFog = heightFogMixingMode == EDhApiHeightFogMixMode.SPHERICAL;
|
boolean useSphericalFog = heightFogMixingMode == EDhApiHeightFogMixMode.SPHERICAL;
|
||||||
EDhApiHeightFogDirection heightFogCameraDirection = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogDirection.get();
|
|
||||||
|
|
||||||
float heightFogStart = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogStart.get();
|
Color fogColor = fogRenderParams.getFogColor();
|
||||||
float heightFogEnd = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogEnd.get();
|
|
||||||
float heightFogMin = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMin.get();
|
|
||||||
float heightFogMax = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMax.get();
|
|
||||||
float heightFogDensity = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogDensity.get();
|
|
||||||
|
|
||||||
|
|
||||||
// upload data //
|
// upload data //
|
||||||
|
|
||||||
ByteBuffer buffer = ByteBuffer.allocateDirect(uniformBufferSize);
|
this.fragUniformBufferWrapper
|
||||||
buffer.order(ByteOrder.nativeOrder());
|
|
||||||
buffer = Std140Builder.intoBuffer(buffer)
|
|
||||||
|
|
||||||
// fog uniforms
|
// fog uniforms
|
||||||
.putVec4(
|
.putVec4f(
|
||||||
fogColor.getRed() / 255.0f,
|
fogColor.getRed() / 255.0f,
|
||||||
fogColor.getGreen() / 255.0f,
|
fogColor.getGreen() / 255.0f,
|
||||||
fogColor.getBlue() / 255.0f,
|
fogColor.getBlue() / 255.0f,
|
||||||
fogColor.getAlpha() / 255.0f) // uFogColor
|
fogColor.getAlpha() / 255.0f) // uFogColor
|
||||||
.putFloat(1.f / lodDrawDistance) //uFogScale
|
.putFloat(1.f / lodDrawDistance) //uFogScale
|
||||||
.putFloat(1.f / MC.getWrappedClientLevel().getMaxHeight()) //uFogVerticalScale
|
.putFloat(1.f / MC.getWrappedClientLevel().getMaxHeight()) //uFogVerticalScale
|
||||||
// only used for debugging
|
.putInt(0) //uFogDebugMode // 0 = normal // 1 = render everything with fog color // 7 = use debug rendering
|
||||||
.putInt(0) //uFogDebugMode // 1 = render everything with fog color // 7 = use debug rendering
|
.putInt(fogRenderParams.getFarFogFalloff().value) //uFogFalloffType
|
||||||
.putInt(Config.Client.Advanced.Graphics.Fog.farFogFalloff.get().value) //uFogFalloffType
|
|
||||||
|
|
||||||
// fog config
|
// fog config
|
||||||
.putFloat(farFogStart) // uFarFogStart
|
.putFloat(fogRenderParams.getFarFogStartPercent()) // uFarFogStart
|
||||||
.putFloat(farFogEnd - farFogStart) // uFarFogLength
|
.putFloat(fogRenderParams.getFarFogEndPercent() - fogRenderParams.getFarFogStartPercent()) // uFarFogLength
|
||||||
.putFloat(farFogMin) // uFarFogMin
|
.putFloat(fogRenderParams.getFarFogMinThickness()) // uFarFogMin
|
||||||
.putFloat(farFogMax - farFogMin) // uFarFogRange
|
.putFloat(fogRenderParams.getFarFogMaxThickness() - fogRenderParams.getFarFogMinThickness()) // uFarFogRange
|
||||||
.putFloat(farFogDensity) // uFarFogDensity
|
.putFloat(fogRenderParams.getFarFogDensity()) // uFarFogDensity
|
||||||
|
|
||||||
// height fog config
|
// height fog config
|
||||||
.putFloat(heightFogStart) // uHeightFogStart
|
.putFloat(fogRenderParams.getHeightFogStartPercent()) // uHeightFogStart
|
||||||
.putFloat(heightFogEnd - heightFogStart) // uHeightFogLength
|
.putFloat(fogRenderParams.getHeightFogEndPercent() - fogRenderParams.getHeightFogStartPercent()) // uHeightFogLength
|
||||||
.putFloat(heightFogMin) // uHeightFogMin
|
.putFloat(fogRenderParams.getHeightFogMinThickness()) // uHeightFogMin
|
||||||
.putFloat(heightFogMax - heightFogMin) // uHeightFogRange
|
.putFloat(fogRenderParams.getHeightFogMaxThickness() - fogRenderParams.getHeightFogMinThickness()) // uHeightFogRange
|
||||||
.putFloat(heightFogDensity) // uHeightFogDensity
|
.putFloat(fogRenderParams.getHeightFogDensity()) // uHeightFogDensity
|
||||||
|
|
||||||
// ??
|
// ??
|
||||||
.putInt(heightFogEnabled ? 1 : 0) // uHeightFogEnabled
|
.putInt(heightFogEnabled ? 1 : 0) // uHeightFogEnabled
|
||||||
.putInt(Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogFalloff.get().value) // uHeightFogFalloffType
|
.putInt(fogRenderParams.getHeightFogFalloff().value) // uHeightFogFalloffType
|
||||||
.putInt(heightFogCameraDirection.basedOnCamera ? 1 : 0) // uHeightBasedOnCamera
|
.putInt(fogRenderParams.getHeightFogDirection().basedOnCamera ? 1 : 0) // uHeightBasedOnCamera
|
||||||
.putFloat(Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogBaseHeight.get()) // uHeightFogBaseHeight
|
.putFloat(fogRenderParams.getHeightFogBaseHeight()) // uHeightFogBaseHeight
|
||||||
.putInt(heightFogCameraDirection.fogAppliesUp ? 1 : 0) // uHeightFogAppliesUp
|
.putInt(fogRenderParams.getHeightFogDirection().fogAppliesUp ? 1 : 0) // uHeightFogAppliesUp
|
||||||
.putInt(heightFogCameraDirection.fogAppliesDown ? 1 : 0) // uHeightFogAppliesDown
|
.putInt(fogRenderParams.getHeightFogDirection().fogAppliesDown ? 1 : 0) // uHeightFogAppliesDown
|
||||||
.putInt(useSphericalFog ? 1 : 0) // uUseSphericalFog
|
.putInt(useSphericalFog ? 1 : 0) // uUseSphericalFog
|
||||||
.putInt(heightFogMixingMode.value) // uHeightFogMixingMode
|
.putInt(heightFogMixingMode.value) // uHeightFogMixingMode
|
||||||
.putFloat((float)MC_RENDER.getCameraExactPosition().y) // uCameraBlockYPos
|
.putFloat((float)MC_RENDER.getCameraExactPosition().y) // uCameraBlockYPos
|
||||||
|
|
||||||
.putMat4f(inverseMvmProjMatrix.createJomlMatrix()) // uInvMvmProj
|
.putMat4f(inverseMvmProjMatrix) // uInvMvmProj
|
||||||
|
|
||||||
.get()
|
.putInt((RENDER_API_DEF.getRenderDepth() == EDhRenderDepth.REVERSE_Z) ? 1 : 0) // uIsReverseZDepth
|
||||||
|
|
||||||
|
.finishAndUpload()
|
||||||
;
|
;
|
||||||
|
|
||||||
this.fragUniformBuffer = BlazeUniformUtil.createBuffer("fragUniformBlock", uniformBufferSize, this.fragUniformBuffer);
|
|
||||||
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.fragUniformBuffer, 0, uniformBufferSize);
|
|
||||||
|
|
||||||
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -316,42 +246,26 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Color getFogColor(float partialTicks)
|
|
||||||
{
|
|
||||||
Color fogColor;
|
|
||||||
|
|
||||||
if (Config.Client.Advanced.Graphics.Fog.colorMode.get() == EDhApiFogColorMode.USE_SKY_COLOR)
|
|
||||||
{
|
|
||||||
fogColor = MC_RENDER.getSkyColor();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fogColor = MC_RENDER.getFogColor(partialTicks);
|
|
||||||
}
|
|
||||||
|
|
||||||
return fogColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderFogToTexture()
|
private void renderFogToTexture()
|
||||||
{
|
{
|
||||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
this.fogColorTextureWrapper.textureView,
|
this.fogColorTextureWrapper,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
this.fogDepthTextureWrapper))
|
||||||
this.fogDepthTextureWrapper.textureView,
|
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
|
||||||
{
|
{
|
||||||
renderPass.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView, BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureSampler);
|
renderPassWrapper.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper);
|
||||||
|
|
||||||
renderPass.setUniform("fragUniformBlock", this.fragUniformBuffer);
|
renderPassWrapper.setUniform("fragUniformBlock", this.fragUniformBufferWrapper);
|
||||||
|
|
||||||
renderPass.setVertexBuffer(0, this.vboGpuBuffer); // vertex buffer can only be "0" lol
|
renderPassWrapper.setVertexBuffer(this.vboGpuBuffer); // vertex buffer can only be "0" lol
|
||||||
renderPass.setPipeline(this.pipeline);
|
renderPassWrapper.setPipeline(this.pipeline);
|
||||||
|
|
||||||
renderPass.draw(/*indexStart*/ 0, /*indexCount*/ 4);
|
renderPassWrapper.draw(/*indexCount*/ 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private String getRenderPassName() { return "distantHorizons:McFogRenderer"; }
|
private String getRenderPassName() { return "distantHorizons:FogRenderer"; }
|
||||||
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|||||||
+49
-79
@@ -23,38 +23,38 @@ package com.seibel.distanthorizons.common.render.blaze.postProcessing;
|
|||||||
public class BlazeDhSsaoRenderer {}
|
public class BlazeDhSsaoRenderer {}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBuffer;
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140Builder;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
|
||||||
import com.mojang.blaze3d.pipeline.BlendFunction;
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
|
||||||
import com.mojang.blaze3d.platform.DestFactor;
|
|
||||||
import com.mojang.blaze3d.platform.SourceFactor;
|
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
|
||||||
import com.mojang.blaze3d.systems.RenderPass;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeUniformBufferWrapper;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
import com.seibel.distanthorizons.core.render.EDhRenderDepth;
|
||||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||||
import com.seibel.distanthorizons.core.util.RenderUtil;
|
import com.seibel.distanthorizons.core.util.RenderUtil;
|
||||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhSsaoRenderer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhSsaoRenderer;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import com.mojang.blaze3d.buffers.GpuBuffer;
|
||||||
import java.nio.ByteOrder;
|
import com.mojang.blaze3d.pipeline.BlendFunction;
|
||||||
import java.util.OptionalDouble;
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
import java.util.OptionalInt;
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
import com.mojang.blaze3d.platform.DestFactor;
|
||||||
|
import com.mojang.blaze3d.platform.SourceFactor;
|
||||||
|
#else
|
||||||
|
import com.mojang.blaze3d.platform.BlendFactor;
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Renders SSAO to the DH LODs. */
|
/** Renders SSAO to the DH LODs. */
|
||||||
public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
||||||
@@ -62,6 +62,7 @@ public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
|||||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
||||||
|
private static final AbstractDhRenderApiDefinition RENDER_API_DEF = SingletonInjector.INSTANCE.get(AbstractDhRenderApiDefinition.class);
|
||||||
|
|
||||||
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
||||||
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
||||||
@@ -74,8 +75,8 @@ public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
|||||||
private RenderPipeline pipeline;
|
private RenderPipeline pipeline;
|
||||||
private boolean init = false;
|
private boolean init = false;
|
||||||
|
|
||||||
private GpuBuffer fragUniformBuffer;
|
private final BlazeUniformBufferWrapper fragUniformBufferWrapper = new BlazeUniformBufferWrapper("fragUniformBlock");
|
||||||
private GpuBuffer applyFragUniformBuffer;
|
private final BlazeUniformBufferWrapper applyFragUniformBufferWrapper = new BlazeUniformBufferWrapper("applyFragUniformBlock");
|
||||||
|
|
||||||
private GpuBuffer vboGpuBuffer;
|
private GpuBuffer vboGpuBuffer;
|
||||||
|
|
||||||
@@ -101,9 +102,17 @@ public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
|||||||
this.init = true;
|
this.init = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BlendFunction blendFunc;
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
blendFunc = new BlendFunction(SourceFactor.ZERO, DestFactor.SRC_ALPHA, SourceFactor.ZERO, DestFactor.ONE);
|
||||||
|
#else
|
||||||
|
blendFunc = new BlendFunction(BlendFactor.ZERO, BlendFactor.SRC_ALPHA, BlendFactor.ZERO, BlendFactor.ONE);
|
||||||
|
#endif
|
||||||
|
|
||||||
this.applyRenderer = new BlazeDhApplyRenderer(
|
this.applyRenderer = new BlazeDhApplyRenderer(
|
||||||
"ssao_apply_to_dh",
|
"ssao_apply_to_dh",
|
||||||
new BlendFunction(SourceFactor.ZERO, DestFactor.SRC_ALPHA, SourceFactor.ZERO, DestFactor.ONE),
|
blendFunc,
|
||||||
"apply/blaze/vert", "ssao/blaze/apply",
|
"apply/blaze/vert", "ssao/blaze/apply",
|
||||||
/*uniforms*/ new String[] { "applyFragUniformBlock" }
|
/*uniforms*/ new String[] { "applyFragUniformBlock" }
|
||||||
);
|
);
|
||||||
@@ -163,32 +172,14 @@ public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
|||||||
|
|
||||||
// frag uniforms
|
// frag uniforms
|
||||||
{
|
{
|
||||||
int uniformBufferSize = new Std140SizeCalculator()
|
|
||||||
.putInt() // uSampleCount\
|
|
||||||
|
|
||||||
.putFloat() // uRadius
|
|
||||||
.putFloat() // uStrength
|
|
||||||
.putFloat() // uMinLight
|
|
||||||
.putFloat() // uBias
|
|
||||||
.putFloat() // uFadeDistanceInBlocks
|
|
||||||
|
|
||||||
.putMat4f() // uInvProj
|
|
||||||
.putMat4f() // uProj
|
|
||||||
.get();
|
|
||||||
|
|
||||||
|
|
||||||
// create data //
|
// create data //
|
||||||
|
|
||||||
Mat4f projMatrix = new Mat4f(renderParams.dhProjectionMatrix);
|
Mat4f projMatrix = new Mat4f(renderParams.dhProjectionMatrix);
|
||||||
Mat4f invertedProjMatrix = new Mat4f(renderParams.dhProjectionMatrix);
|
Mat4f invertedProjMatrix = new Mat4f(renderParams.dhProjectionMatrix);
|
||||||
invertedProjMatrix.invert();
|
invertedProjMatrix.invert();
|
||||||
|
|
||||||
|
|
||||||
// upload data //
|
// upload data //
|
||||||
|
this.fragUniformBufferWrapper
|
||||||
ByteBuffer buffer = ByteBuffer.allocateDirect(uniformBufferSize);
|
|
||||||
buffer.order(ByteOrder.nativeOrder());
|
|
||||||
buffer = Std140Builder.intoBuffer(buffer)
|
|
||||||
.putInt(6) // uSampleCount
|
.putInt(6) // uSampleCount
|
||||||
|
|
||||||
.putFloat(4.0f) // uRadius
|
.putFloat(4.0f) // uRadius
|
||||||
@@ -197,27 +188,16 @@ public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
|||||||
.putFloat(0.02f) // uBias
|
.putFloat(0.02f) // uBias
|
||||||
.putFloat(1_600.0f) // uFadeDistanceInBlocks
|
.putFloat(1_600.0f) // uFadeDistanceInBlocks
|
||||||
|
|
||||||
.putMat4f(invertedProjMatrix.createJomlMatrix())
|
.putMat4f(invertedProjMatrix)
|
||||||
.putMat4f(projMatrix.createJomlMatrix())
|
.putMat4f(projMatrix)
|
||||||
.get()
|
|
||||||
|
.putInt((RENDER_API_DEF.getRenderDepth() == EDhRenderDepth.REVERSE_Z) ? 1 : 0) // uIsReverseZDepth
|
||||||
|
.finishAndUpload()
|
||||||
;
|
;
|
||||||
|
|
||||||
this.fragUniformBuffer = BlazeUniformUtil.createBuffer("fragUniformBlock", uniformBufferSize, this.fragUniformBuffer);
|
|
||||||
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.fragUniformBuffer, 0, uniformBufferSize);
|
|
||||||
|
|
||||||
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply frag uniforms
|
// apply frag uniforms
|
||||||
{
|
{
|
||||||
int uniformBufferSize = new Std140SizeCalculator()
|
|
||||||
.putVec2() // uViewSize
|
|
||||||
.putInt() // uBlurRadius
|
|
||||||
.putFloat() // uNearClipPlane
|
|
||||||
.putFloat() // uFarClipPlane
|
|
||||||
.get();
|
|
||||||
|
|
||||||
|
|
||||||
// create data //
|
// create data //
|
||||||
|
|
||||||
float viewWidth = (float)MC_RENDER.getTargetFramebufferViewportWidth();
|
float viewWidth = (float)MC_RENDER.getTargetFramebufferViewportWidth();
|
||||||
@@ -228,51 +208,41 @@ public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
|
|||||||
|
|
||||||
|
|
||||||
// upload data //
|
// upload data //
|
||||||
|
this.applyFragUniformBufferWrapper
|
||||||
ByteBuffer buffer = ByteBuffer.allocateDirect(uniformBufferSize);
|
.putVec2f(viewWidth, viewHeight) // uViewSize
|
||||||
buffer.order(ByteOrder.nativeOrder());
|
|
||||||
buffer = Std140Builder.intoBuffer(buffer)
|
|
||||||
.putVec2(viewWidth, viewHeight) // uViewSize
|
|
||||||
.putInt(2) // uBlurRadius
|
.putInt(2) // uBlurRadius
|
||||||
.putFloat(nearClipPlane) // uNearClipPlane
|
.putFloat(nearClipPlane) // uNearClipPlane
|
||||||
.putFloat(farClipPlane) // uFarClipPlane
|
.putFloat(farClipPlane) // uFarClipPlane
|
||||||
.get()
|
.finishAndUpload()
|
||||||
;
|
;
|
||||||
|
|
||||||
this.applyFragUniformBuffer = BlazeUniformUtil.createBuffer("applyFragUniformBlock", uniformBufferSize, this.applyFragUniformBuffer);
|
|
||||||
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.applyFragUniformBuffer, 0, uniformBufferSize);
|
|
||||||
|
|
||||||
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.renderSsaoToTexture();
|
this.renderSsaoToTexture();
|
||||||
|
|
||||||
this.applyRenderer.setUniform("applyFragUniformBlock", this.applyFragUniformBuffer);
|
this.applyRenderer.setUniform("applyFragUniformBlock", this.applyFragUniformBufferWrapper);
|
||||||
this.applyRenderer.render(this.ssaoColorTextureWrapper.texture, BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.texture, BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.texture);
|
this.applyRenderer.render(this.ssaoColorTextureWrapper.texture, BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.texture, BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.texture);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderSsaoToTexture()
|
private void renderSsaoToTexture()
|
||||||
{
|
{
|
||||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
this.ssaoColorTextureWrapper.textureView,
|
this.ssaoColorTextureWrapper,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
this.ssaoDepthTextureWrapper))
|
||||||
this.ssaoDepthTextureWrapper.textureView,
|
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
|
||||||
{
|
{
|
||||||
renderPass.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView, BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureSampler);
|
renderPassWrapper.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper);
|
||||||
|
|
||||||
renderPass.setUniform("fragUniformBlock", this.fragUniformBuffer);
|
renderPassWrapper.setUniform("fragUniformBlock", this.fragUniformBufferWrapper);
|
||||||
|
|
||||||
renderPass.setVertexBuffer(0, this.vboGpuBuffer); // vertex buffer can only be "0" lol
|
renderPassWrapper.setVertexBuffer(this.vboGpuBuffer);
|
||||||
|
|
||||||
renderPass.setPipeline(this.pipeline);
|
renderPassWrapper.setPipeline(this.pipeline);
|
||||||
renderPass.draw(/*indexStart*/ 0, /*indexCount*/ 4);
|
renderPassWrapper.draw(4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private String getRenderPassName() { return "distantHorizons:McSsaoRenderer"; }
|
private String getRenderPassName() { return "distantHorizons:SsaoRenderer"; }
|
||||||
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|||||||
+30
-60
@@ -25,40 +25,30 @@ public class BlazeVanillaFadeRenderer {}
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBuffer;
|
import com.mojang.blaze3d.buffers.GpuBuffer;
|
||||||
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140Builder;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
import com.mojang.blaze3d.platform.PolygonMode;
|
|
||||||
import com.mojang.blaze3d.shaders.UniformType;
|
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
import com.mojang.blaze3d.systems.RenderPass;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
|
||||||
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhCopyRenderer;
|
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhCopyRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeUniformBufferWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
import com.seibel.distanthorizons.core.render.EDhRenderDepth;
|
||||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||||
import com.seibel.distanthorizons.core.util.RenderUtil;
|
import com.seibel.distanthorizons.core.util.RenderUtil;
|
||||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhVanillaFadeRenderer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhVanillaFadeRenderer;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.resources.Identifier;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.ByteOrder;
|
|
||||||
import java.util.OptionalDouble;
|
|
||||||
import java.util.OptionalInt;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fades the vanilla chunks
|
* Fades the vanilla chunks
|
||||||
@@ -69,16 +59,18 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
||||||
|
private static final AbstractDhRenderApiDefinition RENDER_API_DEF = SingletonInjector.INSTANCE.get(AbstractDhRenderApiDefinition.class);
|
||||||
|
|
||||||
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
||||||
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
||||||
|
|
||||||
public static final BlazeVanillaFadeRenderer INSTANCE = new BlazeVanillaFadeRenderer();
|
public static final BlazeVanillaFadeRenderer INSTANCE = new BlazeVanillaFadeRenderer();
|
||||||
|
|
||||||
|
|
||||||
private RenderPipeline pipeline;
|
private RenderPipeline pipeline;
|
||||||
private boolean init = false;
|
private boolean init = false;
|
||||||
|
|
||||||
private GpuBuffer fragUniformBuffer;
|
private final BlazeUniformBufferWrapper fragUniformBufferWrapper = new BlazeUniformBufferWrapper("fragUniformBlock");
|
||||||
|
|
||||||
private GpuBuffer vboGpuBuffer;
|
private GpuBuffer vboGpuBuffer;
|
||||||
|
|
||||||
@@ -136,7 +128,7 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
this.pipeline = pipelineBuilder.build();
|
this.pipeline = pipelineBuilder.build();
|
||||||
|
|
||||||
|
|
||||||
this.vboGpuBuffer = BlazePostProcessUtil.createAndUploadScreenVertexData("McFadeRenderer");
|
this.vboGpuBuffer = BlazePostProcessUtil.createAndUploadScreenVertexData("VanillaFadeRenderer");
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
@@ -164,21 +156,11 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
this.fadeColorTextureWrapper.tryCreateOrResize();
|
this.fadeColorTextureWrapper.tryCreateOrResize();
|
||||||
this.fadeDepthTextureWrapper.tryCreateOrResize();
|
this.fadeDepthTextureWrapper.tryCreateOrResize();
|
||||||
|
|
||||||
this.mcDepthTextureWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getDepthTexture());
|
this.mcDepthTextureWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getDepthTexture());
|
||||||
this.mcColorTextureWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getColorTexture());
|
this.mcColorTextureWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getColorTexture());
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
int uniformBufferSize = new Std140SizeCalculator()
|
|
||||||
.putInt() // uOnlyRenderLods
|
|
||||||
.putFloat() // uStartFadeBlockDistance
|
|
||||||
.putFloat() // uEndFadeBlockDistance
|
|
||||||
.putFloat() // uMaxLevelHeight
|
|
||||||
.putMat4f() // uDhInvMvmProj
|
|
||||||
.putMat4f() // uMcInvMvmProj
|
|
||||||
.get();
|
|
||||||
|
|
||||||
|
|
||||||
// create data //
|
// create data //
|
||||||
|
|
||||||
float dhNearClipDistance = RenderUtil.getNearClipPlaneInBlocks();
|
float dhNearClipDistance = RenderUtil.getNearClipPlaneInBlocks();
|
||||||
@@ -198,34 +180,24 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
Mat4f inverseMcMvmProjMatrix = inverseMcModelViewProjectionMatrix;
|
Mat4f inverseMcMvmProjMatrix = inverseMcModelViewProjectionMatrix;
|
||||||
|
|
||||||
|
|
||||||
Mat4f dhProjectionMatrix = RenderUtil.createLodProjectionMatrix(renderParams.mcProjectionMatrix);
|
Mat4f inverseDhModelViewProjectionMatrix = new Mat4f(renderParams.dhProjectionMatrix);
|
||||||
Mat4f dhModelViewMatrix = RenderUtil.createLodModelViewMatrix(renderParams.mcModelViewMatrix);
|
inverseDhModelViewProjectionMatrix.multiply(renderParams.dhModelViewMatrix);
|
||||||
|
|
||||||
Mat4f inverseDhModelViewProjectionMatrix = new Mat4f(dhProjectionMatrix);
|
|
||||||
inverseDhModelViewProjectionMatrix.multiply(dhModelViewMatrix);
|
|
||||||
inverseDhModelViewProjectionMatrix.invert();
|
inverseDhModelViewProjectionMatrix.invert();
|
||||||
Mat4f inverseDhMvmProjMatrix = inverseDhModelViewProjectionMatrix;
|
Mat4f inverseDhMvmProjMatrix = inverseDhModelViewProjectionMatrix;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// upload data //
|
// upload data //
|
||||||
|
this.fragUniformBufferWrapper
|
||||||
ByteBuffer buffer = ByteBuffer.allocateDirect(uniformBufferSize);
|
|
||||||
buffer.order(ByteOrder.nativeOrder());
|
|
||||||
buffer = Std140Builder.intoBuffer(buffer)
|
|
||||||
.putInt(Config.Client.Advanced.Debugging.lodOnlyMode.get() ? 1 : 0) // uOnlyRenderLods
|
.putInt(Config.Client.Advanced.Debugging.lodOnlyMode.get() ? 1 : 0) // uOnlyRenderLods
|
||||||
.putFloat(fadeStartDistance) // uStartFadeBlockDistance
|
.putFloat(fadeStartDistance) // uStartFadeBlockDistance
|
||||||
.putFloat(fadeEndDistance) // uEndFadeBlockDistance
|
.putFloat(fadeEndDistance) // uEndFadeBlockDistance
|
||||||
.putFloat(renderParams.clientLevelWrapper.getMaxHeight()) // uMaxLevelHeight
|
.putFloat(renderParams.clientLevelWrapper.getMaxHeight()) // uMaxLevelHeight
|
||||||
.putMat4f(inverseDhMvmProjMatrix.createJomlMatrix()) // uDhInvMvmProj
|
.putMat4f(inverseDhMvmProjMatrix) // uDhInvMvmProj
|
||||||
.putMat4f(inverseMcMvmProjMatrix.createJomlMatrix()) // uMcInvMvmProj
|
.putMat4f(inverseMcMvmProjMatrix) // uMcInvMvmProj
|
||||||
.get()
|
.putInt((RENDER_API_DEF.getRenderDepth() == EDhRenderDepth.REVERSE_Z) ? 1 : 0) // uIsReverseZDepth
|
||||||
|
.finishAndUpload()
|
||||||
;
|
;
|
||||||
|
|
||||||
this.fragUniformBuffer = BlazeUniformUtil.createBuffer("fragUniformBlock", uniformBufferSize, this.fragUniformBuffer);
|
|
||||||
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.fragUniformBuffer, 0, uniformBufferSize);
|
|
||||||
|
|
||||||
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -236,28 +208,26 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
|
|
||||||
private void renderFadeToTexture()
|
private void renderFadeToTexture()
|
||||||
{
|
{
|
||||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
this.fadeColorTextureWrapper.textureView,
|
this.fadeColorTextureWrapper,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
this.fadeDepthTextureWrapper))
|
||||||
this.fadeDepthTextureWrapper.textureView,
|
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
|
||||||
{
|
{
|
||||||
renderPass.bindTexture("uMcDepthTexture", this.mcDepthTextureWrapper.textureView, this.mcDepthTextureWrapper.textureSampler);
|
renderPassWrapper.bindTexture("uMcDepthTexture", this.mcDepthTextureWrapper);
|
||||||
renderPass.bindTexture("uCombinedMcDhColorTexture", this.mcColorTextureWrapper.textureView, this.mcColorTextureWrapper.textureSampler);
|
renderPassWrapper.bindTexture("uCombinedMcDhColorTexture", this.mcColorTextureWrapper);
|
||||||
|
|
||||||
renderPass.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureView, BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper.textureSampler);
|
renderPassWrapper.bindTexture("uDhDepthTexture", BlazeDhMetaRenderer.INSTANCE.dhDepthTextureWrapper);
|
||||||
renderPass.bindTexture("uDhColorTexture", BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureView, BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper.textureSampler);
|
renderPassWrapper.bindTexture("uDhColorTexture", BlazeDhMetaRenderer.INSTANCE.dhColorTextureWrapper);
|
||||||
|
|
||||||
renderPass.setUniform("fragUniformBlock", this.fragUniformBuffer);
|
renderPassWrapper.setUniform("fragUniformBlock", this.fragUniformBufferWrapper);
|
||||||
|
|
||||||
renderPass.setVertexBuffer(0, this.vboGpuBuffer); // vertex buffer can only be "0" lol
|
renderPassWrapper.setVertexBuffer(this.vboGpuBuffer);
|
||||||
|
|
||||||
renderPass.setPipeline(this.pipeline);
|
renderPassWrapper.setPipeline(this.pipeline);
|
||||||
renderPass.draw(/*indexStart*/ 0, /*indexCount*/ 4);
|
renderPassWrapper.draw(/*indexCount*/ 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private String getRenderPassName() { return "distantHorizons:McFadeRenderer"; }
|
private String getRenderPassName() { return "distantHorizons:VanillaFadeRenderer"; }
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|||||||
+12
-11
@@ -35,8 +35,11 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||||||
import com.mojang.blaze3d.textures.*;
|
import com.mojang.blaze3d.textures.*;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.BlazeVertexFormatBuilder;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.render.RenderParams;
|
import com.seibel.distanthorizons.core.render.RenderParams;
|
||||||
@@ -106,7 +109,7 @@ public class BlazeDhTestTriangleRenderer implements IDhTestTriangleRenderer
|
|||||||
pipelineBuilder.withVertexShader("test/blaze/vert");
|
pipelineBuilder.withVertexShader("test/blaze/vert");
|
||||||
pipelineBuilder.withFragmentShader("test/blaze/frag");
|
pipelineBuilder.withFragmentShader("test/blaze/frag");
|
||||||
|
|
||||||
VertexFormat vertexFormat = VertexFormat.builder()
|
VertexFormat vertexFormat = new BlazeVertexFormatBuilder()
|
||||||
.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
|
.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
|
||||||
.add("vColor", BlazeDhVertexFormatUtil.RGBA_FLOAT_COLOR)
|
.add("vColor", BlazeDhVertexFormatUtil.RGBA_FLOAT_COLOR)
|
||||||
.build();
|
.build();
|
||||||
@@ -164,19 +167,17 @@ public class BlazeDhTestTriangleRenderer implements IDhTestTriangleRenderer
|
|||||||
{
|
{
|
||||||
this.tryInit();
|
this.tryInit();
|
||||||
|
|
||||||
this.mcColorTextureViewWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getColorTexture());
|
this.mcColorTextureViewWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getColorTexture());
|
||||||
this.mcDepthTextureViewWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getDepthTexture());
|
this.mcDepthTextureViewWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getDepthTexture());
|
||||||
|
|
||||||
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
|
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||||
this::getRenderPassName,
|
this::getRenderPassName,
|
||||||
this.mcColorTextureViewWrapper.textureView,
|
this.mcColorTextureViewWrapper,
|
||||||
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
this.mcDepthTextureViewWrapper))
|
||||||
this.mcDepthTextureViewWrapper.textureView,
|
|
||||||
/*optionalDepthValueAsDouble*/ OptionalDouble.empty()))
|
|
||||||
{
|
{
|
||||||
renderPass.setVertexBuffer(0, this.vboGpuBuffer);
|
renderPassWrapper.setVertexBuffer(this.vboGpuBuffer);
|
||||||
renderPass.setPipeline(this.pipeline);
|
renderPassWrapper.setPipeline(this.pipeline);
|
||||||
renderPass.draw(/*indexStart*/ 0, /*indexCount*/ 3);
|
renderPassWrapper.draw(3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private String getRenderPassName() { return "distantHorizons:DhTestRenderer"; }
|
private String getRenderPassName() { return "distantHorizons:DhTestRenderer"; }
|
||||||
|
|||||||
+43
-7
@@ -4,9 +4,9 @@ package com.seibel.distanthorizons.common.render.blaze.util;
|
|||||||
public class BlazeDhVertexFormatUtil {}
|
public class BlazeDhVertexFormatUtil {}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderingEngine;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodQuadBuilder;
|
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodQuadBuilder;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
@@ -16,6 +16,11 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
#else
|
||||||
|
import com.mojang.blaze3d.GpuFormat;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see LodQuadBuilder
|
* @see LodQuadBuilder
|
||||||
*/
|
*/
|
||||||
@@ -43,14 +48,14 @@ public class BlazeDhVertexFormatUtil
|
|||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
EDhApiRenderApi renderingApi = Config.Client.Advanced.Graphics.Experimental.renderingApi.get();
|
EDhApiRenderingEngine renderingApi = Config.Client.Advanced.Graphics.Experimental.renderingEngine.get();
|
||||||
if (renderingApi == EDhApiRenderApi.AUTO)
|
if (renderingApi == EDhApiRenderingEngine.AUTO)
|
||||||
{
|
{
|
||||||
IVersionConstants versionConstants = SingletonInjector.INSTANCE.get(IVersionConstants.class);
|
IVersionConstants versionConstants = SingletonInjector.INSTANCE.get(IVersionConstants.class);
|
||||||
renderingApi = versionConstants.getDefaultRenderingApi();
|
renderingApi = versionConstants.getDefaultRenderingEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean register = (renderingApi == EDhApiRenderApi.BLAZE_3D);
|
boolean register = (renderingApi == EDhApiRenderingEngine.BLAZE_3D);
|
||||||
if (register)
|
if (register)
|
||||||
{
|
{
|
||||||
LOGGER.debug("Attempting to register ["+VertexFormatElement.class.getSimpleName()+"]...");
|
LOGGER.debug("Attempting to register ["+VertexFormatElement.class.getSimpleName()+"]...");
|
||||||
@@ -70,7 +75,7 @@ public class BlazeDhVertexFormatUtil
|
|||||||
IRIS_NORMAL = VertexFormatElement.register(/*id*/29, /*index*/0, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, /*count*/ 1);
|
IRIS_NORMAL = VertexFormatElement.register(/*id*/29, /*index*/0, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, /*count*/ 1);
|
||||||
|
|
||||||
FLOAT_XYZ_POS = VertexFormatElement.register(/*id*/30, /*index*/0, VertexFormatElement.Type.FLOAT, VertexFormatElement.Usage.POSITION, /*count*/ 3);
|
FLOAT_XYZ_POS = VertexFormatElement.register(/*id*/30, /*index*/0, VertexFormatElement.Type.FLOAT, VertexFormatElement.Usage.POSITION, /*count*/ 3);
|
||||||
#else
|
#elif MC_VER <= MC_26_1_2
|
||||||
SCREEN_POS = VertexFormatElement.register(/*id*/22, /*index*/0, VertexFormatElement.Type.FLOAT, false, /*count*/ 2);
|
SCREEN_POS = VertexFormatElement.register(/*id*/22, /*index*/0, VertexFormatElement.Type.FLOAT, false, /*count*/ 2);
|
||||||
RGBA_FLOAT_COLOR = VertexFormatElement.register(/*id*/23, /*index*/0, VertexFormatElement.Type.FLOAT, false, /*count*/ 4);
|
RGBA_FLOAT_COLOR = VertexFormatElement.register(/*id*/23, /*index*/0, VertexFormatElement.Type.FLOAT, false, /*count*/ 4);
|
||||||
|
|
||||||
@@ -83,6 +88,35 @@ public class BlazeDhVertexFormatUtil
|
|||||||
IRIS_NORMAL = VertexFormatElement.register(/*id*/29, /*index*/0, VertexFormatElement.Type.BYTE, false, /*count*/ 1);
|
IRIS_NORMAL = VertexFormatElement.register(/*id*/29, /*index*/0, VertexFormatElement.Type.BYTE, false, /*count*/ 1);
|
||||||
|
|
||||||
FLOAT_XYZ_POS = VertexFormatElement.register(/*id*/30, /*index*/0, VertexFormatElement.Type.FLOAT, false, /*count*/ 3);
|
FLOAT_XYZ_POS = VertexFormatElement.register(/*id*/30, /*index*/0, VertexFormatElement.Type.FLOAT, false, /*count*/ 3);
|
||||||
|
#elif MC_VER <= MC_26_1_2
|
||||||
|
|
||||||
|
SCREEN_POS = VertexFormatElement.register(/*id*/22, /*index*/0, GpuFormat.RG32_FLOAT); // 2 floats
|
||||||
|
RGBA_FLOAT_COLOR = VertexFormatElement.register(/*id*/23, /*index*/0, GpuFormat.RGBA32_FLOAT); // 4 floats
|
||||||
|
|
||||||
|
SHORT_XYZ_POS = VertexFormatElement.register(/*id*/24, /*index*/0, GpuFormat.RGB16_UINT); // 3 ushorts
|
||||||
|
BYTE_PAD = VertexFormatElement.register(/*id*/25, /*index*/0, GpuFormat.R8_UINT); // 1 byte
|
||||||
|
|
||||||
|
META = VertexFormatElement.register(/*id*/26, /*index*/0, GpuFormat.R16_UINT); // 1 ushort
|
||||||
|
RGBA_UBYTE_COLOR = VertexFormatElement.register(/*id*/27, /*index*/0, GpuFormat.RGBA8_UNORM); // 4 ubytes
|
||||||
|
IRIS_MATERIAL = VertexFormatElement.register(/*id*/28, /*index*/0, GpuFormat.R8_UINT); // 1 byte
|
||||||
|
IRIS_NORMAL = VertexFormatElement.register(/*id*/29, /*index*/0, GpuFormat.R8_UINT); // 1 byte
|
||||||
|
|
||||||
|
FLOAT_XYZ_POS = VertexFormatElement.register(/*id*/30, /*index*/0, GpuFormat.RGB32_FLOAT); // 3 floats
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
SCREEN_POS = new VertexFormatElement("Screen Pos", Float.BYTES * 2, GpuFormat.RG32_FLOAT);
|
||||||
|
RGBA_FLOAT_COLOR = new VertexFormatElement("RGBA Float Color", Float.BYTES * 4, GpuFormat.RGBA32_FLOAT);
|
||||||
|
|
||||||
|
SHORT_XYZ_POS = new VertexFormatElement("Short XYZ Pos", Short.BYTES * 3, GpuFormat.RGB16_UINT);
|
||||||
|
BYTE_PAD = new VertexFormatElement("Byte Pad", 1, GpuFormat.R8_UINT);
|
||||||
|
|
||||||
|
META = new VertexFormatElement("DH Meta", Short.BYTES, GpuFormat.R16_UINT);
|
||||||
|
RGBA_UBYTE_COLOR = new VertexFormatElement("Rgba Ubyte Color", 4, GpuFormat.RGBA8_UNORM);
|
||||||
|
IRIS_MATERIAL = new VertexFormatElement("Iris Material", 1, GpuFormat.R8_UINT);
|
||||||
|
IRIS_NORMAL = new VertexFormatElement("Iris Normal", 1, GpuFormat.R8_UINT);
|
||||||
|
|
||||||
|
FLOAT_XYZ_POS = new VertexFormatElement("Float XYZ Pos", Float.BYTES * 3, GpuFormat.RGB32_FLOAT);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -118,5 +152,7 @@ public class BlazeDhVertexFormatUtil
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
+2
-1
@@ -11,6 +11,7 @@ import com.mojang.blaze3d.systems.CommandEncoder;
|
|||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.BlazeVertexFormatBuilder;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
@@ -67,7 +68,7 @@ public class BlazePostProcessUtil
|
|||||||
|
|
||||||
public static VertexFormat createVertexFormat()
|
public static VertexFormat createVertexFormat()
|
||||||
{
|
{
|
||||||
VertexFormat vertexFormat = VertexFormat.builder()
|
VertexFormat vertexFormat = new BlazeVertexFormatBuilder()
|
||||||
.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
|
.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
|
||||||
.build();
|
.build();
|
||||||
return vertexFormat;
|
return vertexFormat;
|
||||||
|
|||||||
+58
@@ -0,0 +1,58 @@
|
|||||||
|
package com.seibel.distanthorizons.common.render.blaze.wrappers;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_10
|
||||||
|
public class BlazeVertexFormatBuilder {}
|
||||||
|
#else
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
||||||
|
|
||||||
|
public class BlazeVertexFormatBuilder
|
||||||
|
{
|
||||||
|
private final VertexFormat.Builder builder;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=============//
|
||||||
|
// constructor //
|
||||||
|
//=============//
|
||||||
|
//region
|
||||||
|
|
||||||
|
public BlazeVertexFormatBuilder()
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
this.builder = VertexFormat.builder();
|
||||||
|
#else
|
||||||
|
this.builder = VertexFormat.builder(0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//==========//
|
||||||
|
// building //
|
||||||
|
//==========//
|
||||||
|
//region
|
||||||
|
|
||||||
|
public BlazeVertexFormatBuilder add(String name, VertexFormatElement element)
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
this.builder.add(name, element);
|
||||||
|
#else
|
||||||
|
this.builder.addAttribute(name, element.format());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VertexFormat build() { return this.builder.build(); }
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
+162
@@ -0,0 +1,162 @@
|
|||||||
|
package com.seibel.distanthorizons.common.render.blaze.wrappers;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_10
|
||||||
|
public class RenderPassWrapper {}
|
||||||
|
#else
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.buffers.GpuBuffer;
|
||||||
|
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||||
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
|
import com.mojang.blaze3d.systems.RenderPass;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.IDhBlazeTexture;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeUniformBufferWrapper;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
|
||||||
|
import java.util.OptionalDouble;
|
||||||
|
import java.util.OptionalInt;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
#else
|
||||||
|
import com.mojang.blaze3d.IndexType;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public class RenderPassWrapper implements AutoCloseable
|
||||||
|
{
|
||||||
|
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
|
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
|
||||||
|
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
||||||
|
|
||||||
|
|
||||||
|
private final RenderPass renderPass;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=============//
|
||||||
|
// constructor //
|
||||||
|
//=============//
|
||||||
|
//region
|
||||||
|
|
||||||
|
public RenderPassWrapper(
|
||||||
|
final Supplier<String> nameGetterFunc,
|
||||||
|
final IDhBlazeTexture colorTexture,
|
||||||
|
final IDhBlazeTexture depthTexture)
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
this.renderPass = COMMAND_ENCODER.createRenderPass(
|
||||||
|
nameGetterFunc,
|
||||||
|
colorTexture.getTextureView(),
|
||||||
|
/*optionalClearColorAsInt*/ OptionalInt.empty(),
|
||||||
|
depthTexture.getTextureView(),
|
||||||
|
/*optionalDepthValueAsDouble*/ OptionalDouble.empty());
|
||||||
|
#else
|
||||||
|
this.renderPass = COMMAND_ENCODER.createRenderPass(
|
||||||
|
nameGetterFunc,
|
||||||
|
colorTexture.getTextureView(),
|
||||||
|
/*clearColor*/ Optional.empty(),
|
||||||
|
depthTexture.getTextureView(),
|
||||||
|
/*clearDepth*/ OptionalDouble.empty());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=======//
|
||||||
|
// setup //
|
||||||
|
//=======//
|
||||||
|
//region
|
||||||
|
|
||||||
|
public void bindTexture(
|
||||||
|
final String name,
|
||||||
|
final IDhBlazeTexture textureView)
|
||||||
|
{
|
||||||
|
this.renderPass.bindTexture(
|
||||||
|
name,
|
||||||
|
textureView.getTextureView(),
|
||||||
|
textureView.getTextureSampler());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVertexBuffer(GpuBuffer buffer)
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
this.renderPass.setVertexBuffer(/*slot*/0, buffer);
|
||||||
|
#else
|
||||||
|
this.renderPass.setVertexBuffer(/*slot*/0, buffer.slice());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndexBuffer(GpuBuffer buffer)
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
this.renderPass.setIndexBuffer(buffer, VertexFormat.IndexType.INT);
|
||||||
|
#else
|
||||||
|
this.renderPass.setIndexBuffer(buffer, IndexType.INT);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUniform(String uniformName, BlazeUniformBufferWrapper uniformBuffer) { this.renderPass.setUniform(uniformName, uniformBuffer.getGpuBuffer()); }
|
||||||
|
|
||||||
|
public void setPipeline(RenderPipeline pipeline) { this.renderPass.setPipeline(pipeline); }
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//===========//
|
||||||
|
// rendering //
|
||||||
|
//===========//
|
||||||
|
//region
|
||||||
|
|
||||||
|
public void draw(int vertexCount)
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
this.renderPass.draw(0, vertexCount);
|
||||||
|
#else
|
||||||
|
this.renderPass.draw(vertexCount, /*instanceCount*/1, /*firstVertex*/0, /*firstInstance*/0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawIndexed(int indexCount)
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
this.renderPass.drawIndexed(
|
||||||
|
/*indexStart*/ 0,
|
||||||
|
/*firstIndex*/0,
|
||||||
|
indexCount,
|
||||||
|
/*instanceCount*/1);
|
||||||
|
#else
|
||||||
|
this.renderPass.drawIndexed(
|
||||||
|
indexCount,
|
||||||
|
/*instanceCount*/1,
|
||||||
|
/*firstVertex*/0,
|
||||||
|
/*vertexOffset*/0,
|
||||||
|
/*firstInstance*/0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//================//
|
||||||
|
// base overrides //
|
||||||
|
//================//
|
||||||
|
//region
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() { this.renderPass.close(); }
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
+82
-5
@@ -6,8 +6,7 @@ public class RenderPipelineBuilderWrapper {}
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.pipeline.BlendFunction;
|
import com.mojang.blaze3d.pipeline.*;
|
||||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
|
||||||
import com.mojang.blaze3d.platform.PolygonMode;
|
import com.mojang.blaze3d.platform.PolygonMode;
|
||||||
import com.mojang.blaze3d.shaders.UniformType;
|
import com.mojang.blaze3d.shaders.UniformType;
|
||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
@@ -15,14 +14,17 @@ import net.minecraft.resources.Identifier;
|
|||||||
|
|
||||||
#if MC_VER <= MC_1_21_11
|
#if MC_VER <= MC_1_21_11
|
||||||
import com.mojang.blaze3d.platform.DepthTestFunction;
|
import com.mojang.blaze3d.platform.DepthTestFunction;
|
||||||
#else
|
#elif MC_VER <= MC_26_1_2
|
||||||
import com.mojang.blaze3d.pipeline.ColorTargetState;
|
|
||||||
import com.mojang.blaze3d.pipeline.DepthStencilState;
|
|
||||||
import com.mojang.blaze3d.platform.CompareOp;
|
import com.mojang.blaze3d.platform.CompareOp;
|
||||||
|
#else
|
||||||
|
import com.mojang.blaze3d.platform.CompareOp;
|
||||||
|
import com.mojang.blaze3d.GpuFormat;
|
||||||
|
import com.mojang.blaze3d.PrimitiveTopology;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class RenderPipelineBuilderWrapper
|
public class RenderPipelineBuilderWrapper
|
||||||
@@ -130,15 +132,27 @@ public class RenderPipelineBuilderWrapper
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final ArrayList<String> samplerNames = new ArrayList<>();
|
||||||
public RenderPipelineBuilderWrapper withSampler(String name) throws IllegalArgumentException
|
public RenderPipelineBuilderWrapper withSampler(String name) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
this.blazePipelineBuilder.withSampler(name);
|
this.blazePipelineBuilder.withSampler(name);
|
||||||
|
#else
|
||||||
|
samplerNames.add(name);
|
||||||
|
#endif
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final ArrayList<String> uniformBufferNames = new ArrayList<>();
|
||||||
public RenderPipelineBuilderWrapper withUniformBuffer(String name) throws IllegalArgumentException
|
public RenderPipelineBuilderWrapper withUniformBuffer(String name) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
this.blazePipelineBuilder.withUniform(name, UniformType.UNIFORM_BUFFER);
|
this.blazePipelineBuilder.withUniform(name, UniformType.UNIFORM_BUFFER);
|
||||||
|
#else
|
||||||
|
uniformBufferNames.add(name);
|
||||||
|
#endif
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,18 +257,31 @@ public class RenderPipelineBuilderWrapper
|
|||||||
case LESS:
|
case LESS:
|
||||||
compareOp = CompareOp.LESS_THAN;
|
compareOp = CompareOp.LESS_THAN;
|
||||||
break;
|
break;
|
||||||
|
case GREATER:
|
||||||
|
compareOp = CompareOp.GREATER_THAN;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedOperationException("No depth test defined for type ["+this.depthTest+"].");
|
throw new UnsupportedOperationException("No depth test defined for type ["+this.depthTest+"].");
|
||||||
}
|
}
|
||||||
this.blazePipelineBuilder.withDepthStencilState(new DepthStencilState(compareOp, this.writeDepth));
|
this.blazePipelineBuilder.withDepthStencilState(new DepthStencilState(compareOp, this.writeDepth));
|
||||||
|
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
this.blazePipelineBuilder.withColorTargetState(
|
this.blazePipelineBuilder.withColorTargetState(
|
||||||
new ColorTargetState(
|
new ColorTargetState(
|
||||||
Optional.ofNullable(this.blendFunction),
|
Optional.ofNullable(this.blendFunction),
|
||||||
this.writeColor ? ColorTargetState.WRITE_ALL : ColorTargetState.WRITE_NONE
|
this.writeColor ? ColorTargetState.WRITE_ALL : ColorTargetState.WRITE_NONE
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
#else
|
||||||
|
this.blazePipelineBuilder.withColorTargetState(
|
||||||
|
new ColorTargetState(
|
||||||
|
Optional.ofNullable(this.blendFunction),
|
||||||
|
GpuFormat.RGBA8_UNORM,
|
||||||
|
this.writeColor ? ColorTargetState.WRITE_ALL : ColorTargetState.WRITE_NONE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -262,6 +289,7 @@ public class RenderPipelineBuilderWrapper
|
|||||||
|
|
||||||
// vertex format
|
// vertex format
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
VertexFormat.Mode blazeVertexMode;
|
VertexFormat.Mode blazeVertexMode;
|
||||||
switch (this.vertexMode)
|
switch (this.vertexMode)
|
||||||
{
|
{
|
||||||
@@ -280,8 +308,56 @@ public class RenderPipelineBuilderWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.blazePipelineBuilder.withVertexFormat(vertexFormat, blazeVertexMode);
|
this.blazePipelineBuilder.withVertexFormat(vertexFormat, blazeVertexMode);
|
||||||
|
#else
|
||||||
|
|
||||||
|
PrimitiveTopology primitiveTopology;
|
||||||
|
switch (this.vertexMode)
|
||||||
|
{
|
||||||
|
case TRIANGLES:
|
||||||
|
primitiveTopology = PrimitiveTopology.TRIANGLES;
|
||||||
|
break;
|
||||||
|
case TRIANGLE_FAN:
|
||||||
|
primitiveTopology = PrimitiveTopology.TRIANGLE_FAN;
|
||||||
|
break;
|
||||||
|
case LINES:
|
||||||
|
primitiveTopology = PrimitiveTopology.DEBUG_LINES;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new UnsupportedOperationException("No PrimitiveTopology defined for type ["+this.vertexMode+"].");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.blazePipelineBuilder.withVertexBinding(0, vertexFormat);
|
||||||
|
this.blazePipelineBuilder.withPrimitiveTopology(primitiveTopology);
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// uniform buffers
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
// handled before this point
|
||||||
|
#else
|
||||||
|
|
||||||
|
BindGroupLayout.Builder bindGroupBuilder = BindGroupLayout.builder();
|
||||||
|
|
||||||
|
for (String name : this.samplerNames)
|
||||||
|
{
|
||||||
|
bindGroupBuilder.withSampler(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String name : this.uniformBufferNames)
|
||||||
|
{
|
||||||
|
bindGroupBuilder.withUniform(name, UniformType.UNIFORM_BUFFER);
|
||||||
|
}
|
||||||
|
|
||||||
|
BindGroupLayout bindGroup = bindGroupBuilder.build();
|
||||||
|
this.blazePipelineBuilder.withBindGroupLayout(bindGroup);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return this.blazePipelineBuilder.build();
|
return this.blazePipelineBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,6 +418,7 @@ public class RenderPipelineBuilderWrapper
|
|||||||
public enum EDhDepthTest
|
public enum EDhDepthTest
|
||||||
{
|
{
|
||||||
NONE,
|
NONE,
|
||||||
|
GREATER,
|
||||||
LESS;
|
LESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-3
@@ -14,7 +14,7 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
|||||||
|
|
||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
|
|
||||||
public class BlazeTextureViewWrapper
|
public class BlazeTextureViewWrapper implements IDhBlazeTexture
|
||||||
{
|
{
|
||||||
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
@@ -22,8 +22,11 @@ public class BlazeTextureViewWrapper
|
|||||||
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
|
||||||
|
|
||||||
|
|
||||||
public GpuTextureView textureView = null;
|
private GpuTextureView textureView = null;
|
||||||
public GpuSampler textureSampler = null;
|
public GpuTextureView getTextureView() { return this.textureView; }
|
||||||
|
|
||||||
|
private GpuSampler textureSampler = null;
|
||||||
|
public GpuSampler getTextureSampler() { return this.textureSampler; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+59
-13
@@ -5,11 +5,6 @@ public class BlazeTextureWrapper {}
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBuffer;
|
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.mojang.blaze3d.textures.*;
|
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
@@ -18,7 +13,19 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRen
|
|||||||
|
|
||||||
import java.util.OptionalDouble;
|
import java.util.OptionalDouble;
|
||||||
|
|
||||||
public class BlazeTextureWrapper
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.textures.*;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
|
||||||
|
#else
|
||||||
|
import com.mojang.blaze3d.GpuFormat;
|
||||||
|
import org.joml.Vector4f;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public class BlazeTextureWrapper implements IDhBlazeTexture
|
||||||
{
|
{
|
||||||
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
@@ -29,11 +36,20 @@ public class BlazeTextureWrapper
|
|||||||
|
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
public final TextureFormat textureFormat;
|
public final TextureFormat textureFormat;
|
||||||
|
#else
|
||||||
|
public final GpuFormat textureFormat;
|
||||||
|
#endif
|
||||||
|
|
||||||
public GpuTexture texture = null;
|
public GpuTexture texture = null;
|
||||||
public GpuTextureView textureView = null;
|
|
||||||
public GpuSampler textureSampler = null;
|
private GpuTextureView textureView = null;
|
||||||
|
public GpuTextureView getTextureView() { return this.textureView; }
|
||||||
|
|
||||||
|
private GpuSampler textureSampler = null;
|
||||||
|
public GpuSampler getTextureSampler() { return this.textureSampler; }
|
||||||
|
|
||||||
|
|
||||||
private int width = -1;
|
private int width = -1;
|
||||||
private int height = -1;
|
private int height = -1;
|
||||||
@@ -45,10 +61,27 @@ public class BlazeTextureWrapper
|
|||||||
//==============//
|
//==============//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
public static BlazeTextureWrapper createDepth(String name) { return new BlazeTextureWrapper(name, TextureFormat.DEPTH32); }
|
public static BlazeTextureWrapper createDepth(String name)
|
||||||
public static BlazeTextureWrapper createColor(String name) { return new BlazeTextureWrapper(name, TextureFormat.RGBA8); }
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
return new BlazeTextureWrapper(name, TextureFormat.DEPTH32);
|
||||||
|
#else
|
||||||
|
return new BlazeTextureWrapper(name, GpuFormat.D32_FLOAT);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
public static BlazeTextureWrapper createColor(String name)
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
return new BlazeTextureWrapper(name, TextureFormat.RGBA8);
|
||||||
|
#else
|
||||||
|
return new BlazeTextureWrapper(name, GpuFormat.RGBA8_UNORM);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
private BlazeTextureWrapper(String name, TextureFormat textureFormat)
|
private BlazeTextureWrapper(
|
||||||
|
String name,
|
||||||
|
#if MC_VER <= MC_26_1_2 TextureFormat #else GpuFormat #endif textureFormat
|
||||||
|
)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.textureFormat = textureFormat;
|
this.textureFormat = textureFormat;
|
||||||
@@ -116,11 +149,13 @@ public class BlazeTextureWrapper
|
|||||||
| GpuTexture.USAGE_TEXTURE_BINDING
|
| GpuTexture.USAGE_TEXTURE_BINDING
|
||||||
| GpuTexture.USAGE_COPY_SRC
|
| GpuTexture.USAGE_COPY_SRC
|
||||||
| GpuTexture.USAGE_RENDER_ATTACHMENT;
|
| GpuTexture.USAGE_RENDER_ATTACHMENT;
|
||||||
this.texture = GPU_DEVICE.createTexture(this.name,
|
|
||||||
|
this.texture = GPU_DEVICE.createTexture(
|
||||||
|
this.name,
|
||||||
usage,
|
usage,
|
||||||
this.textureFormat,
|
this.textureFormat,
|
||||||
viewWidth, viewHeight,
|
viewWidth, viewHeight,
|
||||||
/*depthOrLayers*/ 1, /*mipLevels*/ 1
|
/*depthOrLayers*/ 1, /*mipLevels*/ 1
|
||||||
);
|
);
|
||||||
this.textureView = GPU_DEVICE.createTextureView(this.texture);
|
this.textureView = GPU_DEVICE.createTextureView(this.texture);
|
||||||
|
|
||||||
@@ -156,7 +191,18 @@ public class BlazeTextureWrapper
|
|||||||
{
|
{
|
||||||
if (this.texture != null)
|
if (this.texture != null)
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
COMMAND_ENCODER.clearColorTexture(this.texture, clearArgbColor);
|
COMMAND_ENCODER.clearColorTexture(this.texture, clearArgbColor);
|
||||||
|
#else
|
||||||
|
Vector4f clearColor = new Vector4f(
|
||||||
|
// color values should be between 0.0 and 1.0
|
||||||
|
ColorUtil.getRed(clearArgbColor) / 255.0f,
|
||||||
|
ColorUtil.getGreen(clearArgbColor) / 255.0f,
|
||||||
|
ColorUtil.getBlue(clearArgbColor) / 255.0f,
|
||||||
|
ColorUtil.getAlpha(clearArgbColor) / 255.0f
|
||||||
|
);
|
||||||
|
COMMAND_ENCODER.clearColorTexture(this.texture, clearColor);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package com.seibel.distanthorizons.common.render.blaze.wrappers.texture;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_21_10
|
||||||
|
public interface IDhBlazeTexture {}
|
||||||
|
#else
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.textures.GpuSampler;
|
||||||
|
import com.mojang.blaze3d.textures.GpuTextureView;
|
||||||
|
|
||||||
|
public interface IDhBlazeTexture
|
||||||
|
{
|
||||||
|
|
||||||
|
GpuTextureView getTextureView();
|
||||||
|
GpuSampler getTextureSampler();
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
+10
-27
@@ -5,14 +5,10 @@ public class BlazeLodUniformBufferWrapper {}
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
import com.mojang.blaze3d.buffers.Std140Builder;
|
|
||||||
import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
|
||||||
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodBufferContainer;
|
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodBufferContainer;
|
||||||
import com.seibel.distanthorizons.core.util.math.Vec3f;
|
import com.seibel.distanthorizons.core.util.math.Vec3f;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.ILodContainerUniformBufferWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.ILodContainerUniformBufferWrapper;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
|
|
||||||
public class BlazeLodUniformBufferWrapper extends BlazeUniformBufferWrapper implements ILodContainerUniformBufferWrapper
|
public class BlazeLodUniformBufferWrapper extends BlazeUniformBufferWrapper implements ILodContainerUniformBufferWrapper
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -37,35 +33,22 @@ public class BlazeLodUniformBufferWrapper extends BlazeUniformBufferWrapper impl
|
|||||||
//region
|
//region
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createUniformData(LodBufferContainer bufferContainer)
|
public void tryUpload(LodBufferContainer bufferContainer)
|
||||||
{
|
|
||||||
Vec3f modelOffset = new Vec3f(
|
|
||||||
(float) (bufferContainer.minCornerBlockPos.getX()),
|
|
||||||
(float) (bufferContainer.minCornerBlockPos.getY()),
|
|
||||||
(float) (bufferContainer.minCornerBlockPos.getZ()));
|
|
||||||
|
|
||||||
// upload data //
|
|
||||||
|
|
||||||
int uniformBufferSize = new Std140SizeCalculator()
|
|
||||||
.putVec3() // uModelOffset
|
|
||||||
.get();
|
|
||||||
|
|
||||||
ByteBuffer buffer = this.getOrCreateBuffer(uniformBufferSize);
|
|
||||||
Std140Builder.intoBuffer(buffer)
|
|
||||||
.putVec3(modelOffset.x, modelOffset.y, modelOffset.z) // uModelOffset
|
|
||||||
.get();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tryUpload()
|
|
||||||
{
|
{
|
||||||
if (this.uploaded)
|
if (this.uploaded)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.upload();
|
Vec3f modelOffset = new Vec3f(
|
||||||
|
(float) (bufferContainer.minCornerBlockPos.getX()),
|
||||||
|
(float) (bufferContainer.minCornerBlockPos.getY()),
|
||||||
|
(float) (bufferContainer.minCornerBlockPos.getZ()));
|
||||||
|
|
||||||
|
// upload data //
|
||||||
|
this
|
||||||
|
.putVec3f(modelOffset.x, modelOffset.y, modelOffset.z) // uModelOffset
|
||||||
|
.finishAndUpload();
|
||||||
|
|
||||||
this.uploaded = true;
|
this.uploaded = true;
|
||||||
}
|
}
|
||||||
|
|||||||
+161
-47
@@ -7,17 +7,23 @@ public class BlazeUniformBufferWrapper {}
|
|||||||
|
|
||||||
import com.mojang.blaze3d.buffers.GpuBuffer;
|
import com.mojang.blaze3d.buffers.GpuBuffer;
|
||||||
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
||||||
|
import com.mojang.blaze3d.buffers.Std140Builder;
|
||||||
|
import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
|
||||||
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IUniformBufferWrapper;
|
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||||
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class BlazeUniformBufferWrapper implements IUniformBufferWrapper
|
public class BlazeUniformBufferWrapper implements AutoCloseable
|
||||||
{
|
{
|
||||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
@@ -27,11 +33,22 @@ public class BlazeUniformBufferWrapper implements IUniformBufferWrapper
|
|||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
private int cpuBufferSize = 0;
|
/** measured in bytes */
|
||||||
private int gpuBufferSize = 0;
|
private int bufferSize = 0;
|
||||||
|
|
||||||
private ByteBuffer cpuBuffer = null;
|
private ByteBuffer cpuBuffer = null;
|
||||||
public GpuBuffer gpuBuffer = null;
|
|
||||||
|
private GpuBuffer gpuBuffer = null;
|
||||||
|
public GpuBuffer getGpuBuffer() { return this.gpuBuffer; }
|
||||||
|
private GpuBufferSlice bufferSlice = null;
|
||||||
|
|
||||||
|
/** the element count the current CPU Buffer is sized for */
|
||||||
|
private int previousElementCount = 0;
|
||||||
|
/** how many elements are currently in flight (ie being added to the buffer right now) */
|
||||||
|
private int elementCount = 0;
|
||||||
|
/** used to resize the buffers dur first-time setup */
|
||||||
|
private final ArrayList<EUniformElement> uniformElementTypes = new ArrayList<>(0);
|
||||||
|
private Std140Builder uniformBufferBuilder = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -46,63 +63,136 @@ public class BlazeUniformBufferWrapper implements IUniformBufferWrapper
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//========//
|
//=================//
|
||||||
// render //
|
// element builder //
|
||||||
//========//
|
//=================//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
protected ByteBuffer getOrCreateBuffer(int size)
|
public BlazeUniformBufferWrapper putVec2f(float x, float y)
|
||||||
{
|
{
|
||||||
if (this.cpuBuffer == null
|
this.putElement(EUniformElement.VEC2f);
|
||||||
|| this.cpuBufferSize != size)
|
this.uniformBufferBuilder.putVec2(x,y);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public BlazeUniformBufferWrapper putVec3i(int x, int y, int z)
|
||||||
|
{
|
||||||
|
this.putElement(EUniformElement.VEC3i);
|
||||||
|
this.uniformBufferBuilder.putIVec3(x,y,z);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public BlazeUniformBufferWrapper putVec3f(float x, float y, float z)
|
||||||
|
{
|
||||||
|
this.putElement(EUniformElement.VEC3f);
|
||||||
|
this.uniformBufferBuilder.putVec3(x,y,z);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public BlazeUniformBufferWrapper putVec4f(float x, float y, float z, float w)
|
||||||
|
{
|
||||||
|
this.putElement(EUniformElement.VEC4f);
|
||||||
|
this.uniformBufferBuilder.putVec4(x,y,z,w);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public BlazeUniformBufferWrapper putMat4f(DhApiMat4f matrix)
|
||||||
|
{
|
||||||
|
this.putElement(EUniformElement.MAT4f);
|
||||||
|
this.uniformBufferBuilder.putMat4f(Mat4f.createJomlMatrix(matrix));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public BlazeUniformBufferWrapper putFloat(float f)
|
||||||
|
{
|
||||||
|
this.putElement(EUniformElement.FLOAT);
|
||||||
|
this.uniformBufferBuilder.putFloat(f);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public BlazeUniformBufferWrapper putInt(int i)
|
||||||
|
{
|
||||||
|
this.putElement(EUniformElement.INT);
|
||||||
|
this.uniformBufferBuilder.putInt(i);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
private void putElement(EUniformElement elementTypeEnum)
|
||||||
|
{
|
||||||
|
this.uniformElementTypes.add(elementTypeEnum);
|
||||||
|
|
||||||
|
boolean createNewBuilder = (this.elementCount == 0);
|
||||||
|
this.elementCount++;
|
||||||
|
if (this.elementCount > this.previousElementCount)
|
||||||
{
|
{
|
||||||
this.cpuBuffer = ByteBuffer.allocateDirect(size);
|
this.recreateCpuBuffer();
|
||||||
this.cpuBuffer.order(ByteOrder.nativeOrder());
|
createNewBuilder = true;
|
||||||
|
|
||||||
this.cpuBufferSize = size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.cpuBuffer;
|
if (createNewBuilder)
|
||||||
|
{
|
||||||
|
this.uniformBufferBuilder = Std140Builder.intoBuffer(this.cpuBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void recreateCpuBuffer()
|
||||||
|
{
|
||||||
|
ByteBuffer oldBuffer = this.cpuBuffer;
|
||||||
|
|
||||||
|
int size = calcBufferSize(this.uniformElementTypes);
|
||||||
|
this.cpuBuffer = MemoryUtil.memAlloc(size);
|
||||||
|
this.cpuBuffer.order(ByteOrder.nativeOrder());
|
||||||
|
|
||||||
|
if (oldBuffer != null)
|
||||||
|
{
|
||||||
|
oldBuffer.position(0);
|
||||||
|
this.cpuBuffer.put(oldBuffer);
|
||||||
|
MemoryUtil.memFree(oldBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.bufferSize = size;
|
||||||
|
this.previousElementCount = this.elementCount;
|
||||||
|
}
|
||||||
|
private static int calcBufferSize(ArrayList<EUniformElement> uniformElements)
|
||||||
|
{
|
||||||
|
Std140SizeCalculator calculator = new Std140SizeCalculator();
|
||||||
|
|
||||||
|
for (int i = 0; i < uniformElements.size(); i++)
|
||||||
|
{
|
||||||
|
EUniformElement element = uniformElements.get(i);
|
||||||
|
switch (element)
|
||||||
|
{
|
||||||
|
case VEC2f -> calculator.putVec2();
|
||||||
|
case VEC3i -> calculator.putIVec3();
|
||||||
|
case VEC3f -> calculator.putVec3();
|
||||||
|
case VEC4f -> calculator.putVec4();
|
||||||
|
case MAT4f -> calculator.putMat4f();
|
||||||
|
case INT -> calculator.putInt();
|
||||||
|
case FLOAT -> calculator.putFloat();
|
||||||
|
|
||||||
|
default -> throw new UnsupportedOperationException("No definition for element type ["+element.name()+"]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return calculator.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void upload() throws IllegalStateException
|
|
||||||
|
public void finishAndUpload()
|
||||||
{
|
{
|
||||||
if (this.cpuBuffer == null)
|
// re-create the GPU buffer if needed
|
||||||
|
GpuBuffer oldGpuBuffer = this.gpuBuffer;
|
||||||
|
this.gpuBuffer = BlazeUniformUtil.createBuffer(this.name, this.bufferSize, this.gpuBuffer);
|
||||||
|
|
||||||
|
boolean createNewBufferSlice = (this.bufferSlice == null || this.gpuBuffer != oldGpuBuffer);
|
||||||
|
if (createNewBufferSlice)
|
||||||
{
|
{
|
||||||
throw new IllegalStateException("Upload called before buffer was created");
|
this.bufferSlice = new GpuBufferSlice(this.gpuBuffer, 0, this.bufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.gpuBuffer == null
|
// upload to GPU
|
||||||
|| this.gpuBufferSize != this.cpuBufferSize)
|
this.cpuBuffer.position(0);
|
||||||
{
|
COMMAND_ENCODER.writeToBuffer(this.bufferSlice, this.cpuBuffer);
|
||||||
if (this.gpuBuffer != null)
|
|
||||||
{
|
|
||||||
this.gpuBuffer.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
int usage = GpuBuffer.USAGE_COPY_DST
|
|
||||||
| GpuBuffer.USAGE_VERTEX
|
|
||||||
| GpuBuffer.USAGE_UNIFORM;
|
|
||||||
this.gpuBuffer = GPU_DEVICE.createBuffer(this::getBufferName, usage, this.cpuBufferSize);
|
|
||||||
|
|
||||||
this.gpuBufferSize = this.cpuBufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
// clear the element tracking for next time
|
||||||
int byteSize = (this.cpuBuffer.limit() - this.cpuBuffer.position());
|
this.elementCount = 0;
|
||||||
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.gpuBuffer, /*offset*/0, byteSize);
|
this.uniformElementTypes.clear();
|
||||||
if (!bufferSlice.buffer().isClosed())
|
this.uniformBufferBuilder = null;
|
||||||
{
|
|
||||||
COMMAND_ENCODER.writeToBuffer(bufferSlice, this.cpuBuffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOGGER.warn("Uploading to buffer ["+this.name+"] failed due to already being closed");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private String getBufferName() { return this.name; }
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
@@ -120,11 +210,35 @@ public class BlazeUniformBufferWrapper implements IUniformBufferWrapper
|
|||||||
{
|
{
|
||||||
this.gpuBuffer.close();
|
this.gpuBuffer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.cpuBuffer != null)
|
||||||
|
{
|
||||||
|
MemoryUtil.memFree(this.cpuBuffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//================//
|
||||||
|
// helper classes //
|
||||||
|
//================//
|
||||||
|
//region
|
||||||
|
|
||||||
|
private enum EUniformElement
|
||||||
|
{
|
||||||
|
VEC2f,
|
||||||
|
VEC3f,
|
||||||
|
VEC3i,
|
||||||
|
VEC4f,
|
||||||
|
MAT4f,
|
||||||
|
INT,
|
||||||
|
FLOAT,
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
+13
-1
@@ -1,5 +1,7 @@
|
|||||||
package com.seibel.distanthorizons.common.render.openGl;
|
package com.seibel.distanthorizons.common.render.openGl;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderingApi;
|
||||||
|
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderingEngine;
|
||||||
import com.seibel.distanthorizons.common.render.openGl.generic.GlGenericObjectRenderer;
|
import com.seibel.distanthorizons.common.render.openGl.generic.GlGenericObjectRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.openGl.generic.GlGenericObjectVertexContainer;
|
import com.seibel.distanthorizons.common.render.openGl.generic.GlGenericObjectVertexContainer;
|
||||||
import com.seibel.distanthorizons.common.render.openGl.glObject.GlDummyUniformData;
|
import com.seibel.distanthorizons.common.render.openGl.glObject.GlDummyUniformData;
|
||||||
@@ -8,8 +10,8 @@ import com.seibel.distanthorizons.common.render.openGl.postProcessing.fade.GlDhF
|
|||||||
import com.seibel.distanthorizons.common.render.openGl.postProcessing.fade.GlVanillaFadeRenderer;
|
import com.seibel.distanthorizons.common.render.openGl.postProcessing.fade.GlVanillaFadeRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.openGl.postProcessing.fog.GlDhFogRenderer;
|
import com.seibel.distanthorizons.common.render.openGl.postProcessing.fog.GlDhFogRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.openGl.postProcessing.ssao.GlDhSSAORenderer;
|
import com.seibel.distanthorizons.common.render.openGl.postProcessing.ssao.GlDhSSAORenderer;
|
||||||
import com.seibel.distanthorizons.common.render.openGl.terrain.GlDhTerrainShaderProgram;
|
|
||||||
import com.seibel.distanthorizons.common.render.openGl.test.GlTestTriangleRenderer;
|
import com.seibel.distanthorizons.common.render.openGl.test.GlTestTriangleRenderer;
|
||||||
|
import com.seibel.distanthorizons.core.render.EDhRenderDepth;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.AbstractDebugWireframeRenderer;
|
import com.seibel.distanthorizons.core.render.renderer.AbstractDebugWireframeRenderer;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IDhGenericObjectVertexBufferContainer;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IDhGenericObjectVertexBufferContainer;
|
||||||
@@ -26,6 +28,16 @@ public class GlDhRenderApiDefinition extends AbstractDhRenderApiDefinition
|
|||||||
|
|
||||||
public String getApiName() { return "OpenGL"; }
|
public String getApiName() { return "OpenGL"; }
|
||||||
|
|
||||||
|
public EDhRenderDepth getRenderDepth()
|
||||||
|
{
|
||||||
|
// reversed Z shouldn't be supported on OpenGL due
|
||||||
|
// to that breaking Iris shaders
|
||||||
|
return EDhRenderDepth.FORWARD_Z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EDhApiRenderingApi getRenderApi() { return EDhApiRenderingApi.OPEN_GL; }
|
||||||
|
public boolean isNativeRenderer() { return true; }
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -75,6 +75,7 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
private static final DhApiRenderableBoxGroupShading DEFAULT_SHADING = DhApiRenderableBoxGroupShading.getUnshaded();
|
private static final DhApiRenderableBoxGroupShading DEFAULT_SHADING = DhApiRenderableBoxGroupShading.getUnshaded();
|
||||||
|
|
||||||
|
private static final DhApiBeforeGenericObjectRenderEvent.EventParam EVENT_PARAM = new DhApiBeforeGenericObjectRenderEvent.EventParam();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can be used to troubleshoot the renderer.
|
* Can be used to troubleshoot the renderer.
|
||||||
@@ -418,7 +419,7 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
this.init();
|
this.init();
|
||||||
|
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericRenderSetupEvent.class, renderEventParam);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericRenderSetupEvent.class, renderEventParam.apiCopy);
|
||||||
|
|
||||||
|
|
||||||
boolean renderWireframe = Config.Client.Advanced.Debugging.renderWireframe.get();
|
boolean renderWireframe = Config.Client.Advanced.Debugging.renderWireframe.get();
|
||||||
@@ -482,7 +483,8 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// allow API users to cancel this object's rendering
|
// allow API users to cancel this object's rendering
|
||||||
boolean cancelRendering = ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericObjectRenderEvent.class, new DhApiBeforeGenericObjectRenderEvent.EventParam(renderEventParam, boxGroup));
|
EVENT_PARAM.update(renderEventParam, boxGroup);
|
||||||
|
boolean cancelRendering = ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericObjectRenderEvent.class, EVENT_PARAM);
|
||||||
if (cancelRendering)
|
if (cancelRendering)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -529,7 +531,7 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
profiler.popPush("cleanup");
|
profiler.popPush("cleanup");
|
||||||
|
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericRenderCleanupEvent.class, renderEventParam);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericRenderCleanupEvent.class, renderEventParam.apiCopy);
|
||||||
|
|
||||||
if (renderWireframe)
|
if (renderWireframe)
|
||||||
{
|
{
|
||||||
|
|||||||
+17
-4
@@ -21,9 +21,9 @@ package com.seibel.distanthorizons.common.render.openGl.glObject;
|
|||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiGLErrorHandlingMode;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiGLErrorHandlingMode;
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiLoggerLevel;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderingApi;
|
||||||
|
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderingEngine;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.config.types.ConfigEntry;
|
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.jar.EPlatform;
|
import com.seibel.distanthorizons.core.jar.EPlatform;
|
||||||
@@ -32,6 +32,7 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
|||||||
import com.seibel.distanthorizons.core.util.objects.GLMessages.*;
|
import com.seibel.distanthorizons.core.util.objects.GLMessages.*;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IIrisAccessor;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IIrisAccessor;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
import org.lwjgl.opengl.GL;
|
import org.lwjgl.opengl.GL;
|
||||||
@@ -51,6 +52,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
public class GLProxy
|
public class GLProxy
|
||||||
{
|
{
|
||||||
private static final IIrisAccessor IRIS_ACCESSOR = ModAccessorInjector.INSTANCE.get(IIrisAccessor.class);
|
private static final IIrisAccessor IRIS_ACCESSOR = ModAccessorInjector.INSTANCE.get(IIrisAccessor.class);
|
||||||
|
private static final IMinecraftClientWrapper MC_CLIENT = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
||||||
|
private static final AbstractDhRenderApiDefinition RENDER_API_DEF = SingletonInjector.INSTANCE.get(AbstractDhRenderApiDefinition.class);
|
||||||
|
|
||||||
|
|
||||||
public static final DhLogger LOGGER;
|
public static final DhLogger LOGGER;
|
||||||
static
|
static
|
||||||
@@ -126,13 +130,22 @@ public class GLProxy
|
|||||||
|
|
||||||
private GLProxy() throws IllegalStateException
|
private GLProxy() throws IllegalStateException
|
||||||
{
|
{
|
||||||
|
if (RENDER_API_DEF.getRenderApi() != EDhApiRenderingApi.OPEN_GL)
|
||||||
|
{
|
||||||
|
throw new IllegalStateException("[" + GLProxy.class.getSimpleName() + "] was created with the wrong Rendering API ["+RENDER_API_DEF.getRenderApi()+"]!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// this must be created on minecraft's render context to work correctly
|
// this must be created on minecraft's render context to work correctly
|
||||||
if (GLFW.glfwGetCurrentContext() == 0L)
|
if (GLFW.glfwGetCurrentContext() == 0L)
|
||||||
{
|
{
|
||||||
throw new IllegalStateException(GLProxy.class.getSimpleName() + " was created outside the render thread!");
|
String message = "[" + GLProxy.class.getSimpleName() + "] was created outside the render thread!";
|
||||||
|
IllegalStateException exception = new IllegalStateException(message);
|
||||||
|
MC_CLIENT.crashMinecraft(message, exception);
|
||||||
|
throw exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.info("Creating " + GLProxy.class.getSimpleName() + "... If this is the last message you see there must have been an OpenGL error.");
|
LOGGER.info("Creating [" + GLProxy.class.getSimpleName() + "]... If this is the last message you see there must have been an OpenGL error.");
|
||||||
LOGGER.info("Lod Render OpenGL version [" + GL32.glGetString(GL32.GL_VERSION) + "].");
|
LOGGER.info("Lod Render OpenGL version [" + GL32.glGetString(GL32.GL_VERSION) + "].");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -9,9 +9,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.ILodCont
|
|||||||
*/
|
*/
|
||||||
public class GlDummyUniformData implements ILodContainerUniformBufferWrapper
|
public class GlDummyUniformData implements ILodContainerUniformBufferWrapper
|
||||||
{
|
{
|
||||||
@Override public void createUniformData(LodBufferContainer bufferContainer) { }
|
@Override public void tryUpload(LodBufferContainer bufferContainer) { }
|
||||||
@Override public void tryUpload() { }
|
|
||||||
@Override public void upload() { }
|
|
||||||
@Override public void close() { }
|
@Override public void close() { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-5
@@ -22,6 +22,7 @@ package com.seibel.distanthorizons.common.render.openGl.glObject.shader;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
|
||||||
import com.seibel.distanthorizons.api.objects.math.DhApiVec3i;
|
import com.seibel.distanthorizons.api.objects.math.DhApiVec3i;
|
||||||
import org.lwjgl.opengl.GL32;
|
import org.lwjgl.opengl.GL32;
|
||||||
import org.lwjgl.system.MemoryStack;
|
import org.lwjgl.system.MemoryStack;
|
||||||
@@ -187,20 +188,44 @@ public class GlShaderProgram
|
|||||||
|
|
||||||
/** Requires a bound ShaderProgram. */
|
/** Requires a bound ShaderProgram. */
|
||||||
public void setUniform(int location, DhApiVec3i value) { GL32.glUniform3i(location, value.x, value.y, value.z); }
|
public void setUniform(int location, DhApiVec3i value) { GL32.glUniform3i(location, value.x, value.y, value.z); }
|
||||||
/** @see GlShaderProgram#setUniform(int, Mat4f) */
|
/** @see GlShaderProgram#setUniform(int, DhApiMat4f) */
|
||||||
public void trySetUniform(int location, DhApiVec3i value) { if (location != -1) { this.setUniform(location, value); } }
|
public void trySetUniform(int location, DhApiVec3i value) { if (location != -1) { this.setUniform(location, value); } }
|
||||||
|
|
||||||
/** Requires a bound ShaderProgram. */
|
/** Requires a bound ShaderProgram. */
|
||||||
public void setUniform(int location, Mat4f value)
|
public void setUniform(int location, DhApiMat4f value)
|
||||||
{
|
{
|
||||||
try (MemoryStack stack = MemoryStack.stackPush())
|
try (MemoryStack stack = MemoryStack.stackPush())
|
||||||
{
|
{
|
||||||
FloatBuffer buffer = stack.mallocFloat(4 * 4);
|
FloatBuffer buffer = stack.mallocFloat(16);
|
||||||
value.store(buffer);
|
storeMatrixInBuffer(value, buffer);
|
||||||
GL32.glUniformMatrix4fv(location, false, buffer);
|
GL32.glUniformMatrix4fv(location, false, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** @see GlShaderProgram#setUniform(int, Mat4f) */
|
private static void storeMatrixInBuffer(DhApiMat4f matrix, FloatBuffer floatBuffer)
|
||||||
|
{
|
||||||
|
floatBuffer.put(bufferIndex(0, 0), matrix.m00);
|
||||||
|
floatBuffer.put(bufferIndex(0, 1), matrix.m01);
|
||||||
|
floatBuffer.put(bufferIndex(0, 2), matrix.m02);
|
||||||
|
floatBuffer.put(bufferIndex(0, 3), matrix.m03);
|
||||||
|
|
||||||
|
floatBuffer.put(bufferIndex(1, 0), matrix.m10);
|
||||||
|
floatBuffer.put(bufferIndex(1, 1), matrix.m11);
|
||||||
|
floatBuffer.put(bufferIndex(1, 2), matrix.m12);
|
||||||
|
floatBuffer.put(bufferIndex(1, 3), matrix.m13);
|
||||||
|
|
||||||
|
floatBuffer.put(bufferIndex(2, 0), matrix.m20);
|
||||||
|
floatBuffer.put(bufferIndex(2, 1), matrix.m21);
|
||||||
|
floatBuffer.put(bufferIndex(2, 2), matrix.m22);
|
||||||
|
floatBuffer.put(bufferIndex(2, 3), matrix.m23);
|
||||||
|
|
||||||
|
floatBuffer.put(bufferIndex(3, 0), matrix.m30);
|
||||||
|
floatBuffer.put(bufferIndex(3, 1), matrix.m31);
|
||||||
|
floatBuffer.put(bufferIndex(3, 2), matrix.m32);
|
||||||
|
floatBuffer.put(bufferIndex(3, 3), matrix.m33);
|
||||||
|
}
|
||||||
|
private static int bufferIndex(int xIndex, int zIndex) { return (zIndex * 4) + xIndex; }
|
||||||
|
|
||||||
|
/** @see GlShaderProgram#setUniform(int, DhApiMat4f) */
|
||||||
public void trySetUniform(int location, Mat4f value) { if (location != -1) { this.setUniform(location, value); } }
|
public void trySetUniform(int location, Mat4f value) { if (location != -1) { this.setUniform(location, value); } }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -132,7 +132,7 @@ public class GlDhApplyShader extends GlAbstractShaderRenderer
|
|||||||
}
|
}
|
||||||
private void renderToMcTexture()
|
private void renderToMcTexture()
|
||||||
{
|
{
|
||||||
int targetColorTextureId = MC_RENDER.getColorTextureId();
|
int targetColorTextureId = MC_RENDER.getGlColorTextureId();
|
||||||
if (targetColorTextureId == -1)
|
if (targetColorTextureId == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
+1
-1
@@ -136,7 +136,7 @@ public class GlDhFarFadeRenderer implements IDhFarFadeRenderer
|
|||||||
|
|
||||||
|
|
||||||
GlDhFarFadeShader.INSTANCE.frameBuffer = this.fadeFramebuffer;
|
GlDhFarFadeShader.INSTANCE.frameBuffer = this.fadeFramebuffer;
|
||||||
GlDhFarFadeShader.INSTANCE.setProjectionMatrix(renderParams.mcModelViewMatrix, renderParams.mcProjectionMatrix);
|
GlDhFarFadeShader.INSTANCE.setProjectionMatrix(renderParams);
|
||||||
GlDhFarFadeShader.INSTANCE.render(renderParams);
|
GlDhFarFadeShader.INSTANCE.render(renderParams);
|
||||||
|
|
||||||
GlDhFarFadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
|
GlDhFarFadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
|
||||||
|
|||||||
+4
-10
@@ -42,7 +42,7 @@ public class GlDhFarFadeShader extends GlAbstractShaderRenderer
|
|||||||
|
|
||||||
public int frameBuffer = -1;
|
public int frameBuffer = -1;
|
||||||
|
|
||||||
private Mat4f inverseDhMvmProjMatrix;
|
private DhApiMat4f inverseDhMvmProjMatrix;
|
||||||
|
|
||||||
|
|
||||||
// Uniforms
|
// Uniforms
|
||||||
@@ -110,15 +110,9 @@ public class GlDhFarFadeShader extends GlAbstractShaderRenderer
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProjectionMatrix(DhApiMat4f mcModelViewMatrix, DhApiMat4f mcProjectionMatrix)
|
public void setProjectionMatrix(RenderParams renderParams)
|
||||||
{
|
{
|
||||||
Mat4f dhProjectionMatrix = RenderUtil.createLodProjectionMatrix(mcProjectionMatrix);
|
this.inverseDhMvmProjMatrix = renderParams.dhInverseMvmProjectionMatrix;
|
||||||
Mat4f dhModelViewMatrix = RenderUtil.createLodModelViewMatrix(mcModelViewMatrix);
|
|
||||||
|
|
||||||
Mat4f inverseDhModelViewProjectionMatrix = new Mat4f(dhProjectionMatrix);
|
|
||||||
inverseDhModelViewProjectionMatrix.multiply(dhModelViewMatrix);
|
|
||||||
inverseDhModelViewProjectionMatrix.invert();
|
|
||||||
this.inverseDhMvmProjMatrix = inverseDhModelViewProjectionMatrix;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -153,7 +147,7 @@ public class GlDhFarFadeShader extends GlAbstractShaderRenderer
|
|||||||
GL32.glUniform1i(this.uDhDepthTexture, 0);
|
GL32.glUniform1i(this.uDhDepthTexture, 0);
|
||||||
|
|
||||||
GLMC.glActiveTexture(GL32.GL_TEXTURE1);
|
GLMC.glActiveTexture(GL32.GL_TEXTURE1);
|
||||||
GLMC.glBindTexture(MC_RENDER.getColorTextureId());
|
GLMC.glBindTexture(MC_RENDER.getGlColorTextureId());
|
||||||
GL32.glUniform1i(this.uMcColorTexture, 1);
|
GL32.glUniform1i(this.uMcColorTexture, 1);
|
||||||
|
|
||||||
GLMC.glActiveTexture(GL32.GL_TEXTURE2);
|
GLMC.glActiveTexture(GL32.GL_TEXTURE2);
|
||||||
|
|||||||
+7
-18
@@ -43,8 +43,8 @@ public class GlDhVanillaFadeShader extends GlAbstractShaderRenderer
|
|||||||
|
|
||||||
public int frameBuffer = -1;
|
public int frameBuffer = -1;
|
||||||
|
|
||||||
private Mat4f inverseMcMvmProjMatrix;
|
private DhApiMat4f inverseMcMvmProjMatrix;
|
||||||
private Mat4f inverseDhMvmProjMatrix;
|
private DhApiMat4f inverseDhMvmProjMatrix;
|
||||||
private float levelMaxHeight;
|
private float levelMaxHeight;
|
||||||
|
|
||||||
|
|
||||||
@@ -136,21 +136,10 @@ public class GlDhVanillaFadeShader extends GlAbstractShaderRenderer
|
|||||||
this.shader.setUniform(this.uOnlyRenderLods, Config.Client.Advanced.Debugging.lodOnlyMode.get());
|
this.shader.setUniform(this.uOnlyRenderLods, Config.Client.Advanced.Debugging.lodOnlyMode.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProjectionMatrix(DhApiMat4f mcModelViewMatrix, DhApiMat4f mcProjectionMatrix)
|
public void setProjectionMatrix(RenderParams renderParams)
|
||||||
{
|
{
|
||||||
Mat4f inverseMcModelViewProjectionMatrix = new Mat4f(mcProjectionMatrix);
|
this.inverseMcMvmProjMatrix = renderParams.mcInverseMvmProjectionMatrix;
|
||||||
inverseMcModelViewProjectionMatrix.multiply(mcModelViewMatrix);
|
this.inverseDhMvmProjMatrix = renderParams.dhInverseMvmProjectionMatrix;
|
||||||
inverseMcModelViewProjectionMatrix.invert();
|
|
||||||
this.inverseMcMvmProjMatrix = inverseMcModelViewProjectionMatrix;
|
|
||||||
|
|
||||||
|
|
||||||
Mat4f dhProjectionMatrix = RenderUtil.createLodProjectionMatrix(mcProjectionMatrix);
|
|
||||||
Mat4f dhModelViewMatrix = RenderUtil.createLodModelViewMatrix(mcModelViewMatrix);
|
|
||||||
|
|
||||||
Mat4f inverseDhModelViewProjectionMatrix = new Mat4f(dhProjectionMatrix);
|
|
||||||
inverseDhModelViewProjectionMatrix.multiply(dhModelViewMatrix);
|
|
||||||
inverseDhModelViewProjectionMatrix.invert();
|
|
||||||
this.inverseDhMvmProjMatrix = inverseDhModelViewProjectionMatrix;
|
|
||||||
}
|
}
|
||||||
public void setLevelMaxHeight(int levelMaxHeight) { this.levelMaxHeight = levelMaxHeight; }
|
public void setLevelMaxHeight(int levelMaxHeight) { this.levelMaxHeight = levelMaxHeight; }
|
||||||
|
|
||||||
@@ -185,7 +174,7 @@ public class GlDhVanillaFadeShader extends GlAbstractShaderRenderer
|
|||||||
GLMC.disableBlend();
|
GLMC.disableBlend();
|
||||||
|
|
||||||
GLMC.glActiveTexture(GL32.GL_TEXTURE0);
|
GLMC.glActiveTexture(GL32.GL_TEXTURE0);
|
||||||
GLMC.glBindTexture(MC_RENDER.getDepthTextureId());
|
GLMC.glBindTexture(MC_RENDER.getGlDepthTextureId());
|
||||||
GL32.glUniform1i(this.uMcDepthTexture, 0);
|
GL32.glUniform1i(this.uMcDepthTexture, 0);
|
||||||
|
|
||||||
GLMC.glActiveTexture(GL32.GL_TEXTURE1);
|
GLMC.glActiveTexture(GL32.GL_TEXTURE1);
|
||||||
@@ -193,7 +182,7 @@ public class GlDhVanillaFadeShader extends GlAbstractShaderRenderer
|
|||||||
GL32.glUniform1i(this.uDhDepthTexture, 1);
|
GL32.glUniform1i(this.uDhDepthTexture, 1);
|
||||||
|
|
||||||
GLMC.glActiveTexture(GL32.GL_TEXTURE2);
|
GLMC.glActiveTexture(GL32.GL_TEXTURE2);
|
||||||
GLMC.glBindTexture(MC_RENDER.getColorTextureId());
|
GLMC.glBindTexture(MC_RENDER.getGlColorTextureId());
|
||||||
GL32.glUniform1i(this.uCombinedMcDhColorTexture, 2);
|
GL32.glUniform1i(this.uCombinedMcDhColorTexture, 2);
|
||||||
|
|
||||||
GLMC.glActiveTexture(GL32.GL_TEXTURE3);
|
GLMC.glActiveTexture(GL32.GL_TEXTURE3);
|
||||||
|
|||||||
+2
-2
@@ -108,7 +108,7 @@ public class GlVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_TEXTURE_2D, MC_RENDER.getColorTextureId(), 0);
|
GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_TEXTURE_2D, MC_RENDER.getGlColorTextureId(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ public class GlVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
|
|
||||||
|
|
||||||
GlDhVanillaFadeShader.INSTANCE.frameBuffer = this.fadeFramebuffer;
|
GlDhVanillaFadeShader.INSTANCE.frameBuffer = this.fadeFramebuffer;
|
||||||
GlDhVanillaFadeShader.INSTANCE.setProjectionMatrix(renderParams.mcModelViewMatrix, renderParams.mcProjectionMatrix);
|
GlDhVanillaFadeShader.INSTANCE.setProjectionMatrix(renderParams);
|
||||||
GlDhVanillaFadeShader.INSTANCE.setLevelMaxHeight(renderParams.clientLevelWrapper.getMaxHeight());
|
GlDhVanillaFadeShader.INSTANCE.setLevelMaxHeight(renderParams.clientLevelWrapper.getMaxHeight());
|
||||||
GlDhVanillaFadeShader.INSTANCE.render(renderParams);
|
GlDhVanillaFadeShader.INSTANCE.render(renderParams);
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.common.render.openGl.postProcessing.fog;
|
package com.seibel.distanthorizons.common.render.openGl.postProcessing.fog;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiFogRenderParam;
|
||||||
import com.seibel.distanthorizons.common.render.openGl.glObject.GLState;
|
import com.seibel.distanthorizons.common.render.openGl.glObject.GLState;
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
@@ -108,7 +109,7 @@ public class GlDhFogRenderer implements IDhFogRenderer
|
|||||||
//region
|
//region
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(RenderParams renderParams)
|
public void render(RenderParams renderParams, DhApiFogRenderParam fogRenderParams)
|
||||||
{
|
{
|
||||||
// GLState needed in MC 1.16.5 probably due to MC not manually setting each GL state they need before the next rendering step
|
// GLState needed in MC 1.16.5 probably due to MC not manually setting each GL state they need before the next rendering step
|
||||||
try (GLState state = new GLState())
|
try (GLState state = new GLState())
|
||||||
@@ -126,7 +127,7 @@ public class GlDhFogRenderer implements IDhFogRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
GlDhFogShader.INSTANCE.frameBuffer = this.fogFramebuffer;
|
GlDhFogShader.INSTANCE.frameBuffer = this.fogFramebuffer;
|
||||||
GlDhFogShader.INSTANCE.setProjectionMatrix(renderParams.dhMvmProjMatrix);
|
GlDhFogShader.INSTANCE.prepUniformObjects(renderParams.dhMvmProjMatrix, fogRenderParams);
|
||||||
GlDhFogShader.INSTANCE.render(renderParams);
|
GlDhFogShader.INSTANCE.render(renderParams);
|
||||||
|
|
||||||
GlDhFogApplyShader.INSTANCE.fogTexture = this.fogTexture;
|
GlDhFogApplyShader.INSTANCE.fogTexture = this.fogTexture;
|
||||||
|
|||||||
+29
-67
@@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.common.render.openGl.postProcessing.fog;
|
package com.seibel.distanthorizons.common.render.openGl.postProcessing.fog;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogColorMode;
|
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection;
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection;
|
||||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
|
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiFogRenderParam;
|
||||||
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
|
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
|
||||||
import com.seibel.distanthorizons.common.render.openGl.GlDhMetaRenderer;
|
import com.seibel.distanthorizons.common.render.openGl.GlDhMetaRenderer;
|
||||||
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
|
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
|
||||||
@@ -37,8 +37,6 @@ import com.seibel.distanthorizons.core.util.math.Mat4f;
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||||
import org.lwjgl.opengl.GL32;
|
import org.lwjgl.opengl.GL32;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class GlDhFogShader extends GlAbstractShaderRenderer
|
public class GlDhFogShader extends GlAbstractShaderRenderer
|
||||||
{
|
{
|
||||||
public static final GlDhFogShader INSTANCE = new GlDhFogShader();
|
public static final GlDhFogShader INSTANCE = new GlDhFogShader();
|
||||||
@@ -51,6 +49,7 @@ public class GlDhFogShader extends GlAbstractShaderRenderer
|
|||||||
|
|
||||||
public int frameBuffer;
|
public int frameBuffer;
|
||||||
private Mat4f inverseMvmProjMatrix;
|
private Mat4f inverseMvmProjMatrix;
|
||||||
|
private DhApiFogRenderParam fogRenderParams;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -167,95 +166,58 @@ public class GlDhFogShader extends GlAbstractShaderRenderer
|
|||||||
{
|
{
|
||||||
int lodDrawDistance = Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius.get() * LodUtil.CHUNK_WIDTH;
|
int lodDrawDistance = Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius.get() * LodUtil.CHUNK_WIDTH;
|
||||||
|
|
||||||
|
this.shader.setUniform(this.uInvMvmProj, this.inverseMvmProjMatrix);
|
||||||
|
|
||||||
if (this.inverseMvmProjMatrix != null)
|
|
||||||
{
|
|
||||||
this.shader.setUniform(this.uInvMvmProj, this.inverseMvmProjMatrix);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Fog uniforms
|
// Fog uniforms
|
||||||
this.shader.setUniform(this.uFogColor, this.getFogColor(renderParams.partialTicks));
|
this.shader.setUniform(this.uFogColor, this.fogRenderParams.getFogColor());
|
||||||
this.shader.setUniform(this.uFogScale, 1.f / lodDrawDistance);
|
this.shader.setUniform(this.uFogScale, 1.f / lodDrawDistance);
|
||||||
this.shader.setUniform(this.uFogVerticalScale, 1.f / MC.getWrappedClientLevel().getMaxHeight());
|
this.shader.setUniform(this.uFogVerticalScale, 1.f / MC.getWrappedClientLevel().getMaxHeight());
|
||||||
// only used for debugging
|
this.shader.setUniform(this.uFogDebugMode, 0); // 0 = normal // 1 = render everything with fog color // 7 = use debug rendering
|
||||||
this.shader.setUniform(this.uFogDebugMode, 0); // 1 = render everything with fog color // 7 = use debug rendering
|
this.shader.setUniform(this.uFogFalloffType, this.fogRenderParams.getFarFogFalloff().value);
|
||||||
this.shader.setUniform(this.uFogFalloffType, Config.Client.Advanced.Graphics.Fog.farFogFalloff.get().value);
|
|
||||||
|
|
||||||
|
|
||||||
// fog config
|
// fog config
|
||||||
float farFogStart = Config.Client.Advanced.Graphics.Fog.farFogStart.get();
|
this.shader.setUniform(this.uFarFogStart, this.fogRenderParams.getFarFogStartPercent());
|
||||||
float farFogEnd = Config.Client.Advanced.Graphics.Fog.farFogEnd.get();
|
this.shader.setUniform(this.uFarFogLength, this.fogRenderParams.getFarFogEndPercent() - this.fogRenderParams.getFarFogStartPercent());
|
||||||
float farFogMin = Config.Client.Advanced.Graphics.Fog.farFogMin.get();
|
this.shader.setUniform(this.uFarFogMin, this.fogRenderParams.getFarFogMinThickness());
|
||||||
float farFogMax = Config.Client.Advanced.Graphics.Fog.farFogMax.get();
|
this.shader.setUniform(this.uFarFogRange, this.fogRenderParams.getFarFogMaxThickness() - this.fogRenderParams.getFarFogMinThickness());
|
||||||
float farFogDensity = Config.Client.Advanced.Graphics.Fog.farFogDensity.get();
|
this.shader.setUniform(this.uFarFogDensity, this.fogRenderParams.getFarFogDensity());
|
||||||
|
|
||||||
// override fog if underwater
|
|
||||||
if (MC_RENDER.isFogStateSpecial())
|
|
||||||
{
|
|
||||||
// hide everything behind fog
|
|
||||||
farFogStart = 0.0f;
|
|
||||||
farFogEnd = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.shader.setUniform(this.uFarFogStart, farFogStart);
|
|
||||||
this.shader.setUniform(this.uFarFogLength, farFogEnd - farFogStart);
|
|
||||||
this.shader.setUniform(this.uFarFogMin, farFogMin);
|
|
||||||
this.shader.setUniform(this.uFarFogRange, farFogMax - farFogMin);
|
|
||||||
this.shader.setUniform(this.uFarFogDensity, farFogDensity);
|
|
||||||
|
|
||||||
|
|
||||||
// height config
|
// height config
|
||||||
EDhApiHeightFogMixMode heightFogMixingMode = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMixMode.get();
|
EDhApiHeightFogMixMode heightFogMixingMode = this.fogRenderParams.getHeightFogMixingMode();
|
||||||
boolean heightFogEnabled = heightFogMixingMode != EDhApiHeightFogMixMode.SPHERICAL && heightFogMixingMode != EDhApiHeightFogMixMode.CYLINDRICAL;
|
boolean heightFogEnabled =
|
||||||
|
heightFogMixingMode != EDhApiHeightFogMixMode.SPHERICAL
|
||||||
|
&& heightFogMixingMode != EDhApiHeightFogMixMode.CYLINDRICAL;
|
||||||
boolean useSphericalFog = heightFogMixingMode == EDhApiHeightFogMixMode.SPHERICAL;
|
boolean useSphericalFog = heightFogMixingMode == EDhApiHeightFogMixMode.SPHERICAL;
|
||||||
EDhApiHeightFogDirection heightFogCameraDirection = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogDirection.get();
|
EDhApiHeightFogDirection heightFogDirection = this.fogRenderParams.getHeightFogDirection();
|
||||||
|
|
||||||
float heightFogStart = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogStart.get();
|
this.shader.setUniform(this.uHeightFogStart, this.fogRenderParams.getHeightFogStartPercent());
|
||||||
float heightFogEnd = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogEnd.get();
|
this.shader.setUniform(this.uHeightFogLength, this.fogRenderParams.getHeightFogEndPercent() - this.fogRenderParams.getHeightFogStartPercent());
|
||||||
float heightFogMin = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMin.get();
|
this.shader.setUniform(this.uHeightFogMin, this.fogRenderParams.getFarFogMinThickness());
|
||||||
float heightFogMax = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMax.get();
|
this.shader.setUniform(this.uHeightFogRange, this.fogRenderParams.getFarFogMaxThickness() - this.fogRenderParams.getFarFogMinThickness());
|
||||||
float heightFogDensity = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogDensity.get();
|
this.shader.setUniform(this.uHeightFogDensity, this.fogRenderParams.getFarFogDensity());
|
||||||
|
|
||||||
this.shader.setUniform(this.uHeightFogStart, heightFogStart);
|
|
||||||
this.shader.setUniform(this.uHeightFogLength, heightFogEnd - heightFogStart);
|
|
||||||
this.shader.setUniform(this.uHeightFogMin, heightFogMin);
|
|
||||||
this.shader.setUniform(this.uHeightFogRange, heightFogMax - heightFogMin);
|
|
||||||
this.shader.setUniform(this.uHeightFogDensity, heightFogDensity);
|
|
||||||
|
|
||||||
|
|
||||||
this.shader.setUniform(this.uHeightFogEnabled, heightFogEnabled);
|
this.shader.setUniform(this.uHeightFogEnabled, heightFogEnabled);
|
||||||
this.shader.setUniform(this.uHeightFogFalloffType, Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogFalloff.get().value);
|
this.shader.setUniform(this.uHeightFogFalloffType, this.fogRenderParams.getHeightFogFalloff().value);
|
||||||
this.shader.setUniform(this.uHeightFogBaseHeight, Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogBaseHeight.get());
|
this.shader.setUniform(this.uHeightFogBaseHeight, this.fogRenderParams.getHeightFogBaseHeight());
|
||||||
this.shader.setUniform(this.uHeightBasedOnCamera, heightFogCameraDirection.basedOnCamera);
|
this.shader.setUniform(this.uHeightBasedOnCamera, heightFogDirection.basedOnCamera);
|
||||||
this.shader.setUniform(this.uHeightFogAppliesUp, heightFogCameraDirection.fogAppliesUp);
|
this.shader.setUniform(this.uHeightFogAppliesUp, heightFogDirection.fogAppliesUp);
|
||||||
this.shader.setUniform(this.uHeightFogAppliesDown, heightFogCameraDirection.fogAppliesDown);
|
this.shader.setUniform(this.uHeightFogAppliesDown, heightFogDirection.fogAppliesDown);
|
||||||
this.shader.setUniform(this.uUseSphericalFog, useSphericalFog);
|
this.shader.setUniform(this.uUseSphericalFog, useSphericalFog);
|
||||||
this.shader.setUniform(this.uHeightFogMixingMode, heightFogMixingMode.value);
|
this.shader.setUniform(this.uHeightFogMixingMode, heightFogMixingMode.value);
|
||||||
this.shader.setUniform(this.uCameraBlockYPos, (float)MC_RENDER.getCameraExactPosition().y);
|
this.shader.setUniform(this.uCameraBlockYPos, (float)MC_RENDER.getCameraExactPosition().y);
|
||||||
|
|
||||||
}
|
}
|
||||||
private Color getFogColor(float partialTicks)
|
|
||||||
{
|
|
||||||
Color fogColor;
|
|
||||||
|
|
||||||
if (Config.Client.Advanced.Graphics.Fog.colorMode.get() == EDhApiFogColorMode.USE_SKY_COLOR)
|
|
||||||
{
|
|
||||||
fogColor = MC_RENDER.getSkyColor();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fogColor = MC_RENDER.getFogColor(partialTicks);
|
|
||||||
}
|
|
||||||
|
|
||||||
return fogColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProjectionMatrix(DhApiMat4f modelViewProjectionMatrix)
|
public void prepUniformObjects(DhApiMat4f modelViewProjectionMatrix, DhApiFogRenderParam fogRenderParams)
|
||||||
{
|
{
|
||||||
this.inverseMvmProjMatrix = new Mat4f(modelViewProjectionMatrix);
|
this.inverseMvmProjMatrix = new Mat4f(modelViewProjectionMatrix);
|
||||||
this.inverseMvmProjMatrix.invert();
|
this.inverseMvmProjMatrix.invert();
|
||||||
|
|
||||||
|
this.fogRenderParams = fogRenderParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|||||||
+10
-4
@@ -46,6 +46,11 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
|
|||||||
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
|
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
|
||||||
private static final IIrisAccessor IRIS_ACCESSOR = ModAccessorInjector.INSTANCE.get(IIrisAccessor.class);
|
private static final IIrisAccessor IRIS_ACCESSOR = ModAccessorInjector.INSTANCE.get(IIrisAccessor.class);
|
||||||
|
|
||||||
|
private static final Vec3f MODEL_POS = new Vec3f();
|
||||||
|
/** single event object used to reduce GC pressure */
|
||||||
|
private static final DhApiBeforeBufferRenderEvent.EventParam BEFORE_BUFFER_RENDER_EVENT_PARAM = new DhApiBeforeBufferRenderEvent.EventParam();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private boolean init = false;
|
private boolean init = false;
|
||||||
|
|
||||||
@@ -291,7 +296,7 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
|
|||||||
|
|
||||||
// needs to be triggered after DH attempts to set the GL state so that Iris
|
// needs to be triggered after DH attempts to set the GL state so that Iris
|
||||||
// can override it as needed
|
// can override it as needed
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam.apiCopy);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -324,15 +329,16 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
|
|||||||
// set uniforms and fire events
|
// set uniforms and fire events
|
||||||
{
|
{
|
||||||
Vec3d camPos = renderEventParam.exactCameraPosition;
|
Vec3d camPos = renderEventParam.exactCameraPosition;
|
||||||
Vec3f modelPos = new Vec3f(
|
MODEL_POS.set(
|
||||||
(float) (bufferContainer.minCornerBlockPos.getX() - camPos.x),
|
(float) (bufferContainer.minCornerBlockPos.getX() - camPos.x),
|
||||||
(float) (bufferContainer.minCornerBlockPos.getY() - camPos.y),
|
(float) (bufferContainer.minCornerBlockPos.getY() - camPos.y),
|
||||||
(float) (bufferContainer.minCornerBlockPos.getZ() - camPos.z));
|
(float) (bufferContainer.minCornerBlockPos.getZ() - camPos.z));
|
||||||
|
BEFORE_BUFFER_RENDER_EVENT_PARAM.update(renderEventParam, MODEL_POS);
|
||||||
|
|
||||||
GlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.bind();
|
GlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.bind();
|
||||||
GlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.setModelOffsetPos(modelPos);
|
GlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.setModelOffsetPos(MODEL_POS);
|
||||||
|
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeBufferRenderEvent.class, new DhApiBeforeBufferRenderEvent.EventParam(renderEventParam, modelPos));
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeBufferRenderEvent.class, BEFORE_BUFFER_RENDER_EVENT_PARAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
IVertexBufferWrapper[] vertexBuffers = (opaquePass ? bufferContainer.vboOpaqueWrappers : bufferContainer.vboTransparentWrappers);
|
IVertexBufferWrapper[] vertexBuffers = (opaquePass ? bufferContainer.vboOpaqueWrappers : bufferContainer.vboTransparentWrappers);
|
||||||
|
|||||||
+20
-9
@@ -19,11 +19,12 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers;
|
package com.seibel.distanthorizons.common.wrappers;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderingEngine;
|
||||||
import com.seibel.distanthorizons.api.interfaces.render.IDhApiCustomRenderObjectFactory;
|
import com.seibel.distanthorizons.api.interfaces.render.IDhApiCustomRenderObjectFactory;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.BlazeDhRenderApiDefinition;
|
import com.seibel.distanthorizons.common.render.blaze.BlazeDhRenderApiDefinition;
|
||||||
import com.seibel.distanthorizons.common.render.openGl.GlDhRenderApiDefinition;
|
import com.seibel.distanthorizons.common.render.openGl.GlDhRenderApiDefinition;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
|
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderingApi;
|
||||||
import com.seibel.distanthorizons.core.render.renderer.GenericRenderObjectFactory;
|
import com.seibel.distanthorizons.core.render.renderer.GenericRenderObjectFactory;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.classicConfig.ClassicConfigGUI;
|
import com.seibel.distanthorizons.common.wrappers.gui.classicConfig.ClassicConfigGUI;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.LangWrapper;
|
import com.seibel.distanthorizons.common.wrappers.gui.LangWrapper;
|
||||||
@@ -94,25 +95,25 @@ public class DependencySetup
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
EDhApiRenderApi renderingApiEnum = Config.Client.Advanced.Graphics.Experimental.renderingApi.get();
|
EDhApiRenderingEngine renderingApiEnum = Config.Client.Advanced.Graphics.Experimental.renderingEngine.get();
|
||||||
if (renderingApiEnum == EDhApiRenderApi.AUTO)
|
if (renderingApiEnum == EDhApiRenderingEngine.AUTO)
|
||||||
{
|
{
|
||||||
IVersionConstants versionConstants = SingletonInjector.INSTANCE.get(IVersionConstants.class);
|
IVersionConstants versionConstants = SingletonInjector.INSTANCE.get(IVersionConstants.class);
|
||||||
renderingApiEnum = versionConstants.getDefaultRenderingApi();
|
renderingApiEnum = versionConstants.getDefaultRenderingEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.info("Setting DH Rendering API to: ["+renderingApiEnum+"].");
|
LOGGER.info("Setting DH Rendering API to: ["+renderingApiEnum+"]...");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
boolean validApi;
|
boolean validApi;
|
||||||
AbstractDhRenderApiDefinition renderDefinition;
|
AbstractDhRenderApiDefinition renderDefinition;
|
||||||
if (renderingApiEnum == EDhApiRenderApi.OPEN_GL)
|
if (renderingApiEnum == EDhApiRenderingEngine.OPEN_GL)
|
||||||
{
|
{
|
||||||
validApi = true;
|
validApi = true;
|
||||||
renderDefinition = new GlDhRenderApiDefinition();
|
renderDefinition = new GlDhRenderApiDefinition();
|
||||||
}
|
}
|
||||||
else if (renderingApiEnum == EDhApiRenderApi.BLAZE_3D)
|
else if (renderingApiEnum == EDhApiRenderingEngine.BLAZE_3D)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_21_10
|
#if MC_VER <= MC_1_21_10
|
||||||
validApi = false;
|
validApi = false;
|
||||||
@@ -133,14 +134,24 @@ public class DependencySetup
|
|||||||
// crash if an invalid API is set
|
// crash if an invalid API is set
|
||||||
if (!validApi)
|
if (!validApi)
|
||||||
{
|
{
|
||||||
String message = "["+renderingApiEnum+"] is not supported on this version of Minecraft, reverting to ["+EDhApiRenderApi.AUTO+"].";
|
String message = "["+renderingApiEnum+"] is not supported on this version of Minecraft, reverting to ["+ EDhApiRenderingEngine.AUTO+"].";
|
||||||
|
LOGGER.fatal(message);
|
||||||
|
Config.Client.Advanced.Graphics.Experimental.renderingEngine.set(EDhApiRenderingEngine.AUTO);
|
||||||
|
throw new IllegalStateException(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// crash if the rendering API set doesn't match Minecraft's
|
||||||
|
EDhApiRenderingApi mcRenderApi = MinecraftRenderWrapper.INSTANCE.getMcRenderingApi();
|
||||||
|
if (mcRenderApi != renderDefinition.getRenderApi())
|
||||||
|
{
|
||||||
|
String message = "["+renderDefinition.getApiName()+"] cannot be used due to it's API ["+renderDefinition.getRenderApi().name()+"] not matching what Minecraft is currently set to use. Please either change Minecraft's rendering API or Distant Horizons'.";
|
||||||
LOGGER.fatal(message);
|
LOGGER.fatal(message);
|
||||||
Config.Client.Advanced.Graphics.Experimental.renderingApi.set(EDhApiRenderApi.AUTO);
|
|
||||||
throw new IllegalStateException(message);
|
throw new IllegalStateException(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
renderDefinition.bindRenderers();
|
renderDefinition.bindRenderers();
|
||||||
|
LOGGER.info("DH Rendering successfully bound to: ["+renderDefinition.getApiName()+"]...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+6
-4
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers;
|
package com.seibel.distanthorizons.common.wrappers;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderingEngine;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
||||||
|
|
||||||
public class VersionConstants implements IVersionConstants
|
public class VersionConstants implements IVersionConstants
|
||||||
@@ -98,6 +98,8 @@ public class VersionConstants implements IVersionConstants
|
|||||||
return "1.21.11";
|
return "1.21.11";
|
||||||
#elif MC_VER == MC_26_1_2
|
#elif MC_VER == MC_26_1_2
|
||||||
return "26.1.2";
|
return "26.1.2";
|
||||||
|
#elif MC_VER == MC_26_2_0
|
||||||
|
return "26.2.0";
|
||||||
#else
|
#else
|
||||||
ERROR MC version constant missing
|
ERROR MC version constant missing
|
||||||
#endif
|
#endif
|
||||||
@@ -105,12 +107,12 @@ public class VersionConstants implements IVersionConstants
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EDhApiRenderApi getDefaultRenderingApi()
|
public EDhApiRenderingEngine getDefaultRenderingEngine()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_21_11
|
#if MC_VER <= MC_1_21_11
|
||||||
return EDhApiRenderApi.OPEN_GL;
|
return EDhApiRenderingEngine.OPEN_GL;
|
||||||
#else
|
#else
|
||||||
return EDhApiRenderApi.BLAZE_3D;
|
return EDhApiRenderingEngine.BLAZE_3D;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -345,9 +345,9 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===========//
|
//=================//
|
||||||
// set color //
|
// static handlers //
|
||||||
//===========//
|
//=================//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -360,6 +360,8 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
|
|||||||
COLOR_BY_BLOCK_BIOME_PAIR.put(pair, colorInt);
|
COLOR_BY_BLOCK_BIOME_PAIR.put(pair, colorInt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clear() { COLOR_BY_BLOCK_BIOME_PAIR.clear(); }
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+82
-12
@@ -309,8 +309,18 @@ public class ClientBlockStateColorCache
|
|||||||
for (int i = 0; i < COLOR_RESOLUTION_DIRECTION_ORDER.length; i++)
|
for (int i = 0; i < COLOR_RESOLUTION_DIRECTION_ORDER.length; i++)
|
||||||
{
|
{
|
||||||
direction = COLOR_RESOLUTION_DIRECTION_ORDER[i];
|
direction = COLOR_RESOLUTION_DIRECTION_ORDER[i];
|
||||||
quads = this.getQuadsForDirection(direction);
|
try
|
||||||
if (quads != null && !quads.isEmpty()
|
{
|
||||||
|
quads = this.getQuadsForDirection(direction);
|
||||||
|
}
|
||||||
|
catch (Exception ignore)
|
||||||
|
{
|
||||||
|
// failing to get quads can happen in the block is invalid
|
||||||
|
// (i.e. AIR is somehow passed in)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quads != null
|
||||||
|
&& !quads.isEmpty()
|
||||||
&& !(
|
&& !(
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
this.blockState.getBlock() instanceof BlockRotatedPillar
|
this.blockState.getBlock() instanceof BlockRotatedPillar
|
||||||
@@ -328,7 +338,15 @@ public class ClientBlockStateColorCache
|
|||||||
|
|
||||||
if (quads == null || quads.isEmpty())
|
if (quads == null || quads.isEmpty())
|
||||||
{
|
{
|
||||||
quads = this.getUnculledQuads();
|
try
|
||||||
|
{
|
||||||
|
quads = this.getUnculledQuads();
|
||||||
|
}
|
||||||
|
catch (Exception ignore)
|
||||||
|
{
|
||||||
|
// failing to get quads can happen in the block is invalid
|
||||||
|
// (i.e. AIR is somehow passed in)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (quads != null
|
if (quads != null
|
||||||
@@ -406,6 +424,23 @@ public class ClientBlockStateColorCache
|
|||||||
|
|
||||||
this.isColorResolved = true;
|
this.isColorResolved = true;
|
||||||
}
|
}
|
||||||
|
catch (Exception resolveError)
|
||||||
|
{
|
||||||
|
LOGGER.warn("Failed to get color for block ["+this.blockStateWrapper.getSerialString()+"], error: ["+resolveError.getMessage()+"]. Attempting to use particle icon color...", resolveError);
|
||||||
|
|
||||||
|
this.needPostTinting = true;
|
||||||
|
this.tintIndex = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.baseColor = this.getParticleIconColor();
|
||||||
|
}
|
||||||
|
catch (Exception getParticleIconError)
|
||||||
|
{
|
||||||
|
LOGGER.warn("Failed to get particle icon color for block ["+this.blockStateWrapper.getSerialString()+"], error: ["+getParticleIconError.getMessage()+"], block will render as hot pink.", getParticleIconError);
|
||||||
|
this.baseColor = ColorUtil.HOT_PINK;
|
||||||
|
}
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
RESOLVE_LOCK.unlock();
|
RESOLVE_LOCK.unlock();
|
||||||
@@ -413,12 +448,16 @@ public class ClientBlockStateColorCache
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private List<BakedQuad> getUnculledQuads() { return this.getQuadsForDirection(null); }
|
private List<BakedQuad> getUnculledQuads() throws Exception { return this.getQuadsForDirection(null); }
|
||||||
|
/**
|
||||||
|
* throws Exception is to document that rarely MC will throw errors if this method
|
||||||
|
* is called on the wrong block (even though in that case it should just return null).
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
private List<BakedQuad> getQuadsForDirection(@Nullable EnumFacing direction)
|
private List<BakedQuad> getQuadsForDirection(@Nullable EnumFacing direction) throws Exception
|
||||||
#else
|
#else
|
||||||
private List<BakedQuad> getQuadsForDirection(@Nullable Direction direction)
|
private List<BakedQuad> getQuadsForDirection(@Nullable Direction direction) throws Exception
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
@@ -621,6 +660,15 @@ public class ClientBlockStateColorCache
|
|||||||
|
|
||||||
private int getParticleIconColor()
|
private int getParticleIconColor()
|
||||||
{
|
{
|
||||||
|
// Air can be null which will cause issues below,
|
||||||
|
// just use a static color, it shouldn't be rendered anyway.
|
||||||
|
// This is just to capture a rare bug state where we attempt
|
||||||
|
// to get air's color.
|
||||||
|
if (BlockStateWrapper.isAir(this.blockState))
|
||||||
|
{
|
||||||
|
return ColorUtil.INVISIBLE;
|
||||||
|
}
|
||||||
|
|
||||||
return calculateColorFromTexture(
|
return calculateColorFromTexture(
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(this.blockState),
|
Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(this.blockState),
|
||||||
@@ -641,7 +689,9 @@ public class ClientBlockStateColorCache
|
|||||||
//===============//
|
//===============//
|
||||||
//region
|
//region
|
||||||
|
|
||||||
public int getColor(BiomeWrapper biomeWrapper, FullDataSourceV2 fullDataSource, DhBlockPos blockPos)
|
public int getColor(
|
||||||
|
BiomeWrapper biomeWrapper, FullDataSourceV2 fullDataSource, DhBlockPos blockPos,
|
||||||
|
boolean allowApiOverride)
|
||||||
{
|
{
|
||||||
// only get the tint if the block needs to be tinted
|
// only get the tint if the block needs to be tinted
|
||||||
int tintColor = ClientBlockStateColorCache.INVALID_COLOR;
|
int tintColor = ClientBlockStateColorCache.INVALID_COLOR;
|
||||||
@@ -805,14 +855,17 @@ public class ClientBlockStateColorCache
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// only fire an API event if needed
|
// only fire the API event if allowed
|
||||||
// (this is done to reduce GC pressure and speed up color getting)
|
// (done to prevent infinite loops if called during by another color resolution event)
|
||||||
if (this.blockStateWrapper.allowApiColorOverride())
|
if (allowApiOverride
|
||||||
|
// if the API event is requested
|
||||||
|
// (this is done to reduce GC pressure and speed up color getting)
|
||||||
|
&& this.blockStateWrapper.allowApiColorOverride())
|
||||||
{
|
{
|
||||||
DhApiBlockColorOverrideEvent.EventParam eventParam = ColorOverrideEventParamGetter.get();
|
DhApiBlockColorOverrideEvent.EventParam eventParam = ColorOverrideEventParamGetter.get();
|
||||||
eventParam.update(
|
eventParam.update(
|
||||||
this.clientLevelWrapper,
|
this.clientLevelWrapper, fullDataSource,
|
||||||
this.blockStateWrapper, returnColor,
|
this.blockStateWrapper, biomeWrapper, returnColor,
|
||||||
blockPos.getX(), blockPos.getY(), blockPos.getZ()
|
blockPos.getX(), blockPos.getY(), blockPos.getZ()
|
||||||
);
|
);
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBlockColorOverrideEvent.class, eventParam);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBlockColorOverrideEvent.class, eventParam);
|
||||||
@@ -828,6 +881,23 @@ public class ClientBlockStateColorCache
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=========//
|
||||||
|
// cleanup //
|
||||||
|
//=========//
|
||||||
|
//region
|
||||||
|
|
||||||
|
public static void clearCachedTints()
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
#else
|
||||||
|
AbstractDhTintGetter.clear();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//================//
|
//================//
|
||||||
// helper classes //
|
// helper classes //
|
||||||
//================//
|
//================//
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.seibel.distanthorizons.common.wrappers.gui;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class DhScreenUtil
|
||||||
|
{
|
||||||
|
//================//
|
||||||
|
// helper methods //
|
||||||
|
//================//
|
||||||
|
//region
|
||||||
|
|
||||||
|
public static void setScreen(Screen screen)
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
Objects.requireNonNull(Minecraft.getMinecraft()).displayGuiScreen(screen);
|
||||||
|
#elif MC_VER <= MC_26_1_2
|
||||||
|
Objects.requireNonNull(Minecraft.getInstance()).setScreen(screen);
|
||||||
|
#else
|
||||||
|
Objects.requireNonNull(Minecraft.getInstance()).setScreenAndShow(screen);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+7
-1
@@ -16,8 +16,14 @@ public class LangWrapper implements ILangWrapper
|
|||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
return I18n.hasKey(str);
|
return I18n.hasKey(str);
|
||||||
#else
|
#elif MC_VER <= MC_26_1_2
|
||||||
return I18n.exists(str);
|
return I18n.exists(str);
|
||||||
|
#else
|
||||||
|
String translated = getLang(str);
|
||||||
|
return translated != null
|
||||||
|
// if this isn't translatable it will generally return
|
||||||
|
// the same string as was passed in
|
||||||
|
&& !translated.equalsIgnoreCase(str);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-5
@@ -43,6 +43,13 @@ public class MinecraftScreen
|
|||||||
return new ConfigScreenRenderer(parent, screen, translationName);
|
return new ConfigScreenRenderer(parent, screen, translationName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//=========//
|
||||||
|
// screens //
|
||||||
|
//=========//
|
||||||
|
//region
|
||||||
|
|
||||||
private static class ConfigScreenRenderer extends DhScreen
|
private static class ConfigScreenRenderer extends DhScreen
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
@@ -231,11 +238,7 @@ public class MinecraftScreen
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
this.screen.onClose(); // Close our screen
|
this.screen.onClose(); // Close our screen
|
||||||
#if MC_VER <= MC_1_12_2
|
DhScreenUtil.setScreen(this.parent); // Goto the parent screen
|
||||||
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); // Goto the parent screen
|
|
||||||
#else
|
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Goto the parent screen
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
#if MC_VER > MC_1_12_2
|
||||||
@@ -280,4 +283,8 @@ public class MinecraftScreen
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+62
-391
@@ -3,61 +3,41 @@ package com.seibel.distanthorizons.common.wrappers.gui.classicConfig;
|
|||||||
import java.util.AbstractMap;
|
import java.util.AbstractMap;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.DisallowSelectingViaConfigGui;
|
import com.seibel.distanthorizons.api.enums.config.DisallowSelectingViaConfigGui;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.DhScreen;
|
import com.seibel.distanthorizons.common.wrappers.gui.DhScreen;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.GuiHelper;
|
import com.seibel.distanthorizons.common.wrappers.gui.DhScreenUtil;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget;
|
import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.config.ConfigGuiInfo;
|
import com.seibel.distanthorizons.common.wrappers.gui.config.ConfigGuiInfo;
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper;
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
import com.seibel.distanthorizons.core.config.ConfigHandler;
|
import com.seibel.distanthorizons.core.config.ConfigHandler;
|
||||||
import com.seibel.distanthorizons.core.config.types.*;
|
import com.seibel.distanthorizons.core.config.types.*;
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.OnPressed;
|
|
||||||
#else
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.updater.ChangelogScreen;
|
import com.seibel.distanthorizons.common.wrappers.gui.updater.ChangelogScreen;
|
||||||
#endif
|
|
||||||
import com.seibel.distanthorizons.core.config.types.enums.EConfigCommentTextPosition;
|
|
||||||
import com.seibel.distanthorizons.core.config.types.enums.EConfigValidity;
|
import com.seibel.distanthorizons.core.config.types.enums.EConfigValidity;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.jar.updater.SelfUpdater;
|
import com.seibel.distanthorizons.core.jar.updater.SelfUpdater;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.util.AnnotationUtil;
|
import com.seibel.distanthorizons.core.util.AnnotationUtil;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.config.IConfigGui;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.config.ILangWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.config.ILangWrapper;
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
import net.minecraft.client.gui.*;
|
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.Style;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
#else
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.gui.Font;
|
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
import net.minecraft.client.gui.components.AbstractWidget;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
|
|
||||||
import net.minecraft.client.gui.components.EditBox;
|
import net.minecraft.client.gui.components.EditBox;
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
#endif
|
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
#elif MC_VER < MC_1_20_1
|
#if MC_VER < MC_1_20_1
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import net.minecraft.client.gui.GuiComponent;
|
import net.minecraft.client.gui.GuiComponent;
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
@@ -67,21 +47,16 @@ import net.minecraft.client.gui.GuiGraphicsExtractor;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER >= MC_1_17_1
|
#if MC_VER >= MC_1_17_1
|
||||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_10
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
#elif MC_VER <= MC_1_21_10
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
#else
|
#else
|
||||||
import net.minecraft.resources.Identifier;
|
import net.minecraft.resources.Identifier;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import com.mojang.blaze3d.platform.InputConstants;
|
import com.mojang.blaze3d.platform.InputConstants;
|
||||||
#endif
|
|
||||||
|
|
||||||
import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.*;
|
import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.*;
|
||||||
import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.Translatable;
|
import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.Translatable;
|
||||||
@@ -95,34 +70,21 @@ class DhConfigScreen extends DhScreen
|
|||||||
|
|
||||||
private static final MinecraftClientWrapper MC_CLIENT = MinecraftClientWrapper.INSTANCE;
|
private static final MinecraftClientWrapper MC_CLIENT = MinecraftClientWrapper.INSTANCE;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private final GuiScreen parent;
|
|
||||||
#else
|
|
||||||
private final Screen parent;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
private final Screen parent;
|
||||||
private final String category;
|
private final String category;
|
||||||
private ClassicConfigGUI.ConfigListWidget configListWidget;
|
private ClassicConfigGUI.ConfigListWidget configListWidget;
|
||||||
private boolean reload = false;
|
private boolean reload = false;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private GuiButton doneButton;
|
|
||||||
#else
|
|
||||||
private Button doneButton;
|
private Button doneButton;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=============//
|
//=============//
|
||||||
// constructor //
|
// constructor //
|
||||||
//=============//
|
//=============//
|
||||||
//region
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
protected DhConfigScreen(GuiScreen parent, String category)
|
|
||||||
#else
|
|
||||||
protected DhConfigScreen(Screen parent, String category)
|
protected DhConfigScreen(Screen parent, String category)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
super(Translatable(
|
super(Translatable(
|
||||||
LANG_WRAPPER.langExists(ModInfo.ID + ".config" + (category.isEmpty() ? "." + category : "") + ".title") ?
|
LANG_WRAPPER.langExists(ModInfo.ID + ".config" + (category.isEmpty() ? "." + category : "") + ".title") ?
|
||||||
@@ -133,50 +95,25 @@ class DhConfigScreen extends DhScreen
|
|||||||
this.category = category;
|
this.category = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===================//
|
|
||||||
// menu UI lifecycle //
|
|
||||||
//===================//
|
|
||||||
//region
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public void updateScreen() { super.updateScreen(); }
|
|
||||||
#else
|
|
||||||
public void tick() { super.tick(); }
|
public void tick() { super.tick(); }
|
||||||
#endif
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==================//
|
//==================//
|
||||||
// menu UI creation //
|
// menu UI creation //
|
||||||
//==================//
|
//==================//
|
||||||
//region
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public void initGui()
|
|
||||||
#else
|
|
||||||
protected void init()
|
protected void init()
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
super.initGui();
|
|
||||||
#else
|
|
||||||
super.init();
|
super.init();
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!this.reload)
|
if (!this.reload)
|
||||||
{
|
{
|
||||||
ConfigHandler.INSTANCE.configFileHandler.loadFromFile();
|
ConfigHandler.INSTANCE.configFileHandler.loadFromFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
// Changelog button
|
// Changelog button
|
||||||
if (Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get()
|
if (Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get()
|
||||||
// we only have changelogs for stable builds
|
// we only have changelogs for stable builds
|
||||||
@@ -204,7 +141,7 @@ class DhConfigScreen extends DhScreen
|
|||||||
ChangelogScreen changelogScreen = new ChangelogScreen(this);
|
ChangelogScreen changelogScreen = new ChangelogScreen(this);
|
||||||
if (changelogScreen.usable)
|
if (changelogScreen.usable)
|
||||||
{
|
{
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(changelogScreen);
|
DhScreenUtil.setScreen(changelogScreen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -215,7 +152,6 @@ class DhConfigScreen extends DhScreen
|
|||||||
Translatable(ModInfo.ID + ".updater.title")
|
Translatable(ModInfo.ID + ".updater.title")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// back button
|
// back button
|
||||||
@@ -225,11 +161,7 @@ class DhConfigScreen extends DhScreen
|
|||||||
(button) ->
|
(button) ->
|
||||||
{
|
{
|
||||||
ConfigHandler.INSTANCE.configFileHandler.loadFromFile();
|
ConfigHandler.INSTANCE.configFileHandler.loadFromFile();
|
||||||
#if MC_VER <= MC_1_12_2
|
DhScreenUtil.setScreen(this.parent);
|
||||||
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent);
|
|
||||||
#else
|
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
|
|
||||||
#endif
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// done/close button
|
// done/close button
|
||||||
@@ -240,30 +172,19 @@ class DhConfigScreen extends DhScreen
|
|||||||
(button) ->
|
(button) ->
|
||||||
{
|
{
|
||||||
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
|
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
|
||||||
#if MC_VER <= MC_1_12_2
|
DhScreenUtil.setScreen(this.parent);
|
||||||
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent);
|
|
||||||
#else
|
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
|
|
||||||
#endif
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.configListWidget = new ClassicConfigGUI.ConfigListWidget(this.mc, this.width * 2, this.height, 32, 32, 25);
|
|
||||||
#else
|
|
||||||
this.configListWidget = new ClassicConfigGUI.ConfigListWidget(this.minecraft, this.width * 2, this.height, 32, 32, 25);
|
this.configListWidget = new ClassicConfigGUI.ConfigListWidget(this.minecraft, this.width * 2, this.height, 32, 32, 25);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+
|
||||||
#elif MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+
|
|
||||||
if (this.minecraft != null && this.minecraft.level != null)
|
if (this.minecraft != null && this.minecraft.level != null)
|
||||||
{
|
{
|
||||||
this.configListWidget.setRenderBackground(false);
|
this.configListWidget.setRenderBackground(false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
this.addWidget(this.configListWidget);
|
this.addWidget(this.configListWidget);
|
||||||
#endif
|
|
||||||
|
|
||||||
for (AbstractConfigBase<?> configEntry : ConfigHandler.INSTANCE.configBaseList)
|
for (AbstractConfigBase<?> configEntry : ConfigHandler.INSTANCE.configBaseList)
|
||||||
{
|
{
|
||||||
@@ -426,35 +347,18 @@ class DhConfigScreen extends DhScreen
|
|||||||
private static void setupBooleanMenuOption(ConfigEntry<Boolean> booleanConfigEntry)
|
private static void setupBooleanMenuOption(ConfigEntry<Boolean> booleanConfigEntry)
|
||||||
{
|
{
|
||||||
// For boolean
|
// For boolean
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
Function<Object, ITextComponent> func = value -> Translatable("distanthorizons.general."+((Boolean) value ? "true" : "false")).setStyle(new Style().setColor((Boolean) value ? TextFormatting.GREEN : TextFormatting.RED));
|
|
||||||
#else
|
|
||||||
Function<Object, Component> func = value -> Translatable("distanthorizons.general." + ((Boolean) value ? "true" : "false")).withStyle((Boolean) value ? ChatFormatting.GREEN : ChatFormatting.RED);
|
Function<Object, Component> func = value -> Translatable("distanthorizons.general." + ((Boolean) value ? "true" : "false")).withStyle((Boolean) value ? ChatFormatting.GREEN : ChatFormatting.RED);
|
||||||
#endif
|
|
||||||
|
|
||||||
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) booleanConfigEntry.guiValue);
|
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) booleanConfigEntry.guiValue);
|
||||||
|
|
||||||
configGuiInfo.buttonOptionMap =
|
configGuiInfo.buttonOptionMap =
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
new AbstractMap.SimpleEntry<OnPressed, Function<Object, ITextComponent>>(
|
|
||||||
#else
|
|
||||||
new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(
|
new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(
|
||||||
#endif
|
|
||||||
(button) ->
|
(button) ->
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
button.enabled = !booleanConfigEntry.apiIsOverriding();
|
|
||||||
#else
|
|
||||||
button.active = !booleanConfigEntry.apiIsOverriding();
|
button.active = !booleanConfigEntry.apiIsOverriding();
|
||||||
#endif
|
|
||||||
|
|
||||||
booleanConfigEntry.uiSetWithoutSaving(!booleanConfigEntry.get());
|
booleanConfigEntry.uiSetWithoutSaving(!booleanConfigEntry.get());
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
button.displayString = func.apply(booleanConfigEntry.get()).getFormattedText();
|
|
||||||
#else
|
|
||||||
button.setMessage(func.apply(booleanConfigEntry.get()));
|
button.setMessage(func.apply(booleanConfigEntry.get()));
|
||||||
#endif
|
|
||||||
}, func);
|
}, func);
|
||||||
}
|
}
|
||||||
private static void setupEnumMenuOption(ConfigEntry<Enum<?>> enumConfigEntry, Class<? extends Enum<?>> enumClass)
|
private static void setupEnumMenuOption(ConfigEntry<Enum<?>> enumConfigEntry, Class<? extends Enum<?>> enumClass)
|
||||||
@@ -463,29 +367,20 @@ class DhConfigScreen extends DhScreen
|
|||||||
|
|
||||||
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) enumConfigEntry.guiValue);
|
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) enumConfigEntry.guiValue);
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
Function<Object, ITextComponent > getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString());
|
|
||||||
#else
|
|
||||||
Function<Object, Component> getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString());
|
Function<Object, Component> getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString());
|
||||||
#endif
|
|
||||||
|
|
||||||
configGuiInfo.buttonOptionMap =
|
configGuiInfo.buttonOptionMap =
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
new AbstractMap.SimpleEntry<OnPressed, Function<Object, ITextComponent>>(
|
|
||||||
#else
|
|
||||||
new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(
|
new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(
|
||||||
#endif
|
|
||||||
(button) ->
|
(button) ->
|
||||||
{
|
{
|
||||||
// get the currently selected enum and enum index
|
// get the currently selected enum and enum index
|
||||||
int startingIndex = enumList.indexOf(enumConfigEntry.get());
|
int startingIndex = enumList.indexOf(enumConfigEntry.get());
|
||||||
Enum<?> enumValue = enumList.get(startingIndex);
|
Enum<?> enumValue = enumList.get(startingIndex);
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
boolean shiftPressed =
|
||||||
boolean shiftPressed = GuiScreen.isShiftKeyDown();
|
InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_LEFT_SHIFT)
|
||||||
#else
|
|| InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_RIGHT_SHIFT);
|
||||||
boolean shiftPressed = InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_LEFT_SHIFT) || InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_RIGHT_SHIFT);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// move forward or backwards depending on if the shift key is pressed
|
// move forward or backwards depending on if the shift key is pressed
|
||||||
int index = shiftPressed ? startingIndex - 1 : startingIndex + 1;
|
int index = shiftPressed ? startingIndex - 1 : startingIndex + 1;
|
||||||
@@ -537,13 +432,9 @@ class DhConfigScreen extends DhScreen
|
|||||||
|
|
||||||
enumConfigEntry.uiSetWithoutSaving(enumValue);
|
enumConfigEntry.uiSetWithoutSaving(enumValue);
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
button.enabled = !enumConfigEntry.apiIsOverriding();
|
|
||||||
button.displayString = getEnumTranslatableFunc.apply(enumConfigEntry.get()).getFormattedText();
|
|
||||||
#else
|
|
||||||
button.active = !enumConfigEntry.apiIsOverriding();
|
button.active = !enumConfigEntry.apiIsOverriding();
|
||||||
|
|
||||||
button.setMessage(getEnumTranslatableFunc.apply(enumConfigEntry.get()));
|
button.setMessage(getEnumTranslatableFunc.apply(enumConfigEntry.get()));
|
||||||
#endif
|
|
||||||
}, getEnumTranslatableFunc);
|
}, getEnumTranslatableFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,18 +450,12 @@ class DhConfigScreen extends DhScreen
|
|||||||
//==============//
|
//==============//
|
||||||
// reset button //
|
// reset button //
|
||||||
//==============//
|
//==============//
|
||||||
//region
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif btnAction = (button) ->
|
Button.OnPress btnAction = (button) ->
|
||||||
{
|
{
|
||||||
configEntry.uiSetWithoutSaving(configEntry.getDefaultValue());
|
configEntry.uiSetWithoutSaving(configEntry.getDefaultValue());
|
||||||
this.reload = true;
|
this.reload = true;
|
||||||
|
DhScreenUtil.setScreen(this);
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
Objects.requireNonNull(this.mc).displayGuiScreen(ClassicConfigGUI.getScreen(this.parent, this.category));
|
|
||||||
#else
|
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int resetButtonPosX = this.width
|
int resetButtonPosX = this.width
|
||||||
@@ -578,60 +463,29 @@ class DhConfigScreen extends DhScreen
|
|||||||
- ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
- ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
||||||
int resetButtonPosZ = 0;
|
int resetButtonPosZ = 0;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif resetButton = MakeBtn(
|
Button resetButton = MakeBtn(
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
Translatable("distanthorizons.general.reset").setStyle(new Style().setColor(TextFormatting.RED)),
|
|
||||||
#else
|
|
||||||
Translatable("distanthorizons.general.reset").withStyle(ChatFormatting.RED),
|
Translatable("distanthorizons.general.reset").withStyle(ChatFormatting.RED),
|
||||||
#endif
|
|
||||||
resetButtonPosX, resetButtonPosZ,
|
resetButtonPosX, resetButtonPosZ,
|
||||||
ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_HEIGHT,
|
ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_HEIGHT,
|
||||||
btnAction);
|
btnAction);
|
||||||
|
|
||||||
|
if (configEntry.apiIsOverriding())
|
||||||
if (configEntry.mcVersionOverridePresent())
|
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
resetButton.enabled = false;
|
|
||||||
resetButton.displayString = Translatable("distanthorizons.general.unsupportedMcVersion").setStyle(new Style().setColor(TextFormatting.DARK_GRAY)).getFormattedText();
|
|
||||||
#else
|
|
||||||
resetButton.active = false;
|
|
||||||
resetButton.setMessage(Translatable("distanthorizons.general.unsupportedMcVersion").withStyle(ChatFormatting.DARK_GRAY));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (configEntry.apiIsOverriding())
|
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
resetButton.enabled = false;
|
|
||||||
resetButton.displayString = Translatable("distanthorizons.general.apiOverride").setStyle(new Style().setColor(TextFormatting.DARK_GRAY)).getFormattedText();
|
|
||||||
#else
|
|
||||||
resetButton.active = false;
|
resetButton.active = false;
|
||||||
resetButton.setMessage(Translatable("distanthorizons.general.apiOverride").withStyle(ChatFormatting.DARK_GRAY));
|
resetButton.setMessage(Translatable("distanthorizons.general.apiOverride").withStyle(ChatFormatting.DARK_GRAY));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
resetButton.enabled = true;
|
|
||||||
#else
|
|
||||||
resetButton.active = true;
|
resetButton.active = true;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==============//
|
//==============//
|
||||||
// option field //
|
// option field //
|
||||||
//==============//
|
//==============//
|
||||||
//region
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configEntry);
|
|
||||||
#else
|
|
||||||
Component textComponent = this.GetTranslatableTextComponentForConfig(configEntry);
|
Component textComponent = this.GetTranslatableTextComponentForConfig(configEntry);
|
||||||
#endif
|
|
||||||
|
|
||||||
int optionFieldPosX = this.width
|
int optionFieldPosX = this.width
|
||||||
- ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN
|
- ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN
|
||||||
@@ -643,40 +497,21 @@ class DhConfigScreen extends DhScreen
|
|||||||
if (configGuiInfo.buttonOptionMap != null)
|
if (configGuiInfo.buttonOptionMap != null)
|
||||||
{
|
{
|
||||||
// enum/multi option input button
|
// enum/multi option input button
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
Map.Entry<OnPressed, Function<Object,ITextComponent>> widget = configGuiInfo.buttonOptionMap;
|
|
||||||
#else
|
|
||||||
Map.Entry<Button.OnPress, Function<Object, Component>> widget = configGuiInfo.buttonOptionMap;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
Map.Entry<Button.OnPress, Function<Object, Component>> widget = configGuiInfo.buttonOptionMap;
|
||||||
if (configEntry.getType().isEnum())
|
if (configEntry.getType().isEnum())
|
||||||
{
|
{
|
||||||
widget.setValue((value) -> Translatable(TRANSLATION_PREFIX + "enum." + configEntry.getType().getSimpleName() + "." + configEntry.get().toString()));
|
widget.setValue((value) -> Translatable(TRANSLATION_PREFIX + "enum." + configEntry.getType().getSimpleName() + "." + configEntry.get().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GuiButton button = MakeBtn(
|
|
||||||
#else
|
|
||||||
Button button = MakeBtn(
|
Button button = MakeBtn(
|
||||||
#endif
|
|
||||||
widget.getValue().apply(configEntry.get()),
|
widget.getValue().apply(configEntry.get()),
|
||||||
optionFieldPosX, optionFieldPosZ,
|
optionFieldPosX, optionFieldPosZ,
|
||||||
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||||
widget.getKey());
|
widget.getKey());
|
||||||
|
|
||||||
|
|
||||||
// deactivate the button if the API is overriding it
|
// deactivate the button if the API is overriding it
|
||||||
// or the MC version doesn't support it
|
button.active = !configEntry.apiIsOverriding();
|
||||||
if (configEntry.mcVersionOverridePresent()
|
|
||||||
|| configEntry.apiIsOverriding())
|
|
||||||
{
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
button.enabled = false;
|
|
||||||
#else
|
|
||||||
button.active = false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.configListWidget.addButton(this, configEntry,
|
this.configListWidget.addButton(this, configEntry,
|
||||||
@@ -690,25 +525,16 @@ class DhConfigScreen extends DhScreen
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// text box input
|
// text box input
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
GuiTextField widget = new GuiTextField(0, this.fontRenderer,
|
|
||||||
optionFieldPosX, optionFieldPosZ,
|
|
||||||
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT);
|
|
||||||
widget.setMaxStringLength(3_000_000); // hopefully 3 million characters should be enough for any normal use-case, lol
|
|
||||||
widget.setText(String.valueOf(configEntry.get()));
|
|
||||||
#else
|
|
||||||
EditBox widget = new EditBox(this.font,
|
EditBox widget = new EditBox(this.font,
|
||||||
optionFieldPosX, optionFieldPosZ,
|
optionFieldPosX, optionFieldPosZ,
|
||||||
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||||
Translatable(""));
|
Translatable(""));
|
||||||
widget.setMaxLength(3_000_000); // hopefully 3 million characters should be enough for any normal use-case, lol
|
widget.setMaxLength(3_000_000); // hopefully 3 million characters should be enough for any normal use-case, lol
|
||||||
widget.insertText(String.valueOf(configEntry.get()));
|
widget.insertText(String.valueOf(configEntry.get()));
|
||||||
#endif
|
|
||||||
|
|
||||||
Predicate<String> processor = configGuiInfo.tooltipFunction.apply(widget, this.doneButton);
|
Predicate<String> processor = configGuiInfo.tooltipFunction.apply(widget, this.doneButton);
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_11
|
||||||
widget.setValidator(processor::test);
|
|
||||||
#elif MC_VER <= MC_1_21_11
|
|
||||||
widget.setFilter(processor);
|
widget.setFilter(processor);
|
||||||
#else
|
#else
|
||||||
widget.setResponder(processor::test);
|
widget.setResponder(processor::test);
|
||||||
@@ -718,8 +544,6 @@ class DhConfigScreen extends DhScreen
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -730,31 +554,18 @@ class DhConfigScreen extends DhScreen
|
|||||||
{
|
{
|
||||||
ConfigCategory configCategory = (ConfigCategory) configType;
|
ConfigCategory configCategory = (ConfigCategory) configType;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configCategory);
|
|
||||||
#else
|
|
||||||
Component textComponent = this.GetTranslatableTextComponentForConfig(configCategory);
|
Component textComponent = this.GetTranslatableTextComponentForConfig(configCategory);
|
||||||
#endif
|
|
||||||
|
|
||||||
int categoryPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
int categoryPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
||||||
int categoryPosZ = this.height - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT; // Note: the posZ value here seems to be ignored
|
int categoryPosZ = this.height - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT; // Note: the posZ value here seems to be ignored
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
Button widget = MakeBtn(textComponent,
|
||||||
GuiButton widget = MakeBtn(
|
|
||||||
#else
|
|
||||||
Button widget = MakeBtn(
|
|
||||||
#endif
|
|
||||||
textComponent,
|
|
||||||
categoryPosX, categoryPosZ,
|
categoryPosX, categoryPosZ,
|
||||||
ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||||
((button) ->
|
((button) ->
|
||||||
{
|
{
|
||||||
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
|
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
|
||||||
#if MC_VER <= MC_1_12_2
|
DhScreenUtil.setScreen(ClassicConfigGUI.getScreen(this, configCategory.getDestination()));
|
||||||
Objects.requireNonNull(this.mc).displayGuiScreen(ClassicConfigGUI.getScreen(this, configCategory.getDestination()));
|
|
||||||
#else
|
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(ClassicConfigGUI.getScreen(this, configCategory.getDestination()));
|
|
||||||
#endif
|
|
||||||
}));
|
}));
|
||||||
this.configListWidget.addButton(this, configType, widget, null, null, null);
|
this.configListWidget.addButton(this, configType, widget, null, null, null);
|
||||||
|
|
||||||
@@ -769,20 +580,11 @@ class DhConfigScreen extends DhScreen
|
|||||||
{
|
{
|
||||||
ConfigUIButton configUiButton = (ConfigUIButton) configType;
|
ConfigUIButton configUiButton = (ConfigUIButton) configType;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configUiButton);
|
|
||||||
#else
|
|
||||||
Component textComponent = this.GetTranslatableTextComponentForConfig(configUiButton);
|
Component textComponent = this.GetTranslatableTextComponentForConfig(configUiButton);
|
||||||
#endif
|
|
||||||
|
|
||||||
int buttonPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
int buttonPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
Button widget = MakeBtn(textComponent,
|
||||||
GuiButton widget = MakeBtn(
|
|
||||||
#else
|
|
||||||
Button widget = MakeBtn(
|
|
||||||
#endif
|
|
||||||
textComponent,
|
|
||||||
buttonPosX, this.height - 28,
|
buttonPosX, this.height - 28,
|
||||||
ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||||
(button) -> ((ConfigUIButton) configType).runAction());
|
(button) -> ((ConfigUIButton) configType).runAction());
|
||||||
@@ -799,11 +601,7 @@ class DhConfigScreen extends DhScreen
|
|||||||
{
|
{
|
||||||
ConfigUIComment configUiComment = (ConfigUIComment) configType;
|
ConfigUIComment configUiComment = (ConfigUIComment) configType;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configUiComment);
|
|
||||||
#else
|
|
||||||
Component textComponent = this.GetTranslatableTextComponentForConfig(configUiComment);
|
Component textComponent = this.GetTranslatableTextComponentForConfig(configUiComment);
|
||||||
#endif
|
|
||||||
if (configUiComment.parentConfigPath != null)
|
if (configUiComment.parentConfigPath != null)
|
||||||
{
|
{
|
||||||
textComponent = Translatable(TRANSLATION_PREFIX + configUiComment.parentConfigPath);
|
textComponent = Translatable(TRANSLATION_PREFIX + configUiComment.parentConfigPath);
|
||||||
@@ -819,13 +617,8 @@ class DhConfigScreen extends DhScreen
|
|||||||
private boolean tryCreateSpacer(AbstractConfigBase<?> configType)
|
private boolean tryCreateSpacer(AbstractConfigBase<?> configType)
|
||||||
{
|
{
|
||||||
if (configType instanceof ConfigUISpacer)
|
if (configType instanceof ConfigUISpacer)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
Button spacerButton = MakeBtn(Translatable("distanthorizons.general.spacer"),
|
||||||
GuiButton spacerButton = MakeBtn(
|
|
||||||
#else
|
|
||||||
Button spacerButton = MakeBtn(
|
|
||||||
#endif
|
|
||||||
Translatable("distanthorizons.general.spacer"),
|
|
||||||
10, 10, // having too small of a size causes division by 0 errors in older MC versions (IE 1.20.1)
|
10, 10, // having too small of a size causes division by 0 errors in older MC versions (IE 1.20.1)
|
||||||
1, 1,
|
1, 1,
|
||||||
(button) -> { });
|
(button) -> { });
|
||||||
@@ -850,36 +643,25 @@ class DhConfigScreen extends DhScreen
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
private ITextComponent GetTranslatableTextComponentForConfig(AbstractConfigBase<?> configType)
|
|
||||||
#else
|
|
||||||
private Component GetTranslatableTextComponentForConfig(AbstractConfigBase<?> configType)
|
private Component GetTranslatableTextComponentForConfig(AbstractConfigBase<?> configType)
|
||||||
#endif
|
|
||||||
{ return Translatable(TRANSLATION_PREFIX + configType.getNameAndCategory()); }
|
{ return Translatable(TRANSLATION_PREFIX + configType.getNameAndCategory()); }
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===========//
|
//===========//
|
||||||
// rendering //
|
// rendering //
|
||||||
//===========//
|
//===========//
|
||||||
//region
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_1
|
||||||
public void drawScreen(int mouseX, int mouseY, float delta)
|
|
||||||
#elif MC_VER < MC_1_20_1
|
|
||||||
public void render(PoseStack matrices, int mouseX, int mouseY, float delta)
|
public void render(PoseStack matrices, int mouseX, int mouseY, float delta)
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
||||||
#else
|
#else
|
||||||
public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_2 // 1.20.2 now enables this by default in the `this.list.render` function
|
||||||
this.drawDefaultBackground();
|
|
||||||
#elif MC_VER < MC_1_20_2 // 1.20.2 now enables this by default in the `this.list.render` function
|
|
||||||
this.renderBackground(matrices);
|
this.renderBackground(matrices);
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
super.render(matrices, mouseX, mouseY, delta);
|
super.render(matrices, mouseX, mouseY, delta);
|
||||||
@@ -888,9 +670,7 @@ class DhConfigScreen extends DhScreen
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Render buttons
|
// Render buttons
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_21_11
|
||||||
this.configListWidget.drawScreen(mouseX, mouseY, delta);
|
|
||||||
#elif MC_VER <= MC_1_21_11
|
|
||||||
this.configListWidget.render(matrices, mouseX, mouseY, delta);
|
this.configListWidget.render(matrices, mouseX, mouseY, delta);
|
||||||
#else
|
#else
|
||||||
this.configListWidget.extractRenderState(matrices, mouseX, mouseY, delta);
|
this.configListWidget.extractRenderState(matrices, mouseX, mouseY, delta);
|
||||||
@@ -898,74 +678,51 @@ class DhConfigScreen extends DhScreen
|
|||||||
|
|
||||||
|
|
||||||
// Render config title
|
// Render config title
|
||||||
this.DhDrawCenteredString(
|
this.DhDrawCenteredString(matrices, this.font, this.title,
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
matrices, this.font,
|
|
||||||
#endif
|
|
||||||
this.title,
|
|
||||||
this.width / 2, 15,
|
this.width / 2, 15,
|
||||||
#if MC_VER < MC_1_21_6
|
#if MC_VER < MC_1_21_6
|
||||||
0xFFFFFF // RGB white
|
0xFFFFFF // RGB white
|
||||||
#else
|
#else
|
||||||
0xFFFFFFFF // ARGB white
|
0xFFFFFFFF // ARGB white
|
||||||
#endif);
|
#endif );
|
||||||
|
|
||||||
|
|
||||||
// render DH version
|
// render DH version
|
||||||
this.DhDrawString(
|
this.DhDrawString(matrices, this.font, TextOrLiteral(ModInfo.VERSION), 2, this.height - 10,
|
||||||
#if MC_VER > MC_1_12_2
|
#if MC_VER < MC_1_21_6
|
||||||
matrices, this.font,
|
|
||||||
#endif
|
|
||||||
TextOrLiteral(ModInfo.VERSION), 2, this.height - 10,
|
|
||||||
#if MC_VER < MC_1_21_6
|
|
||||||
0xAAAAAA // RGB white
|
0xAAAAAA // RGB white
|
||||||
#else
|
#else
|
||||||
0xFFAAAAAA // ARGB white
|
0xFFAAAAAA // ARGB white
|
||||||
#endif);
|
#endif );
|
||||||
|
|
||||||
// If the update is pending, display this message to inform the user that it will apply when the game restarts
|
// If the update is pending, display this message to inform the user that it will apply when the game restarts
|
||||||
if (SelfUpdater.deleteOldJarOnJvmShutdown)
|
if (SelfUpdater.deleteOldJarOnJvmShutdown)
|
||||||
{
|
{
|
||||||
this.DhDrawString(
|
this.DhDrawString(matrices, this.font, Translatable(ModInfo.ID + ".updater.waitingForClose"), 4, this.height - 42,
|
||||||
#if MC_VER > MC_1_12_2
|
#if MC_VER < MC_1_21_6
|
||||||
matrices, this.font,
|
|
||||||
#endif
|
|
||||||
Translatable(ModInfo.ID + ".updater.waitingForClose"), 4, this.height - 42,
|
|
||||||
#if MC_VER < MC_1_21_6
|
|
||||||
0xFFFFFF // RGB white
|
0xFFFFFF // RGB white
|
||||||
#else
|
#else
|
||||||
0xFFFFFFFF // ARGB white
|
0xFFFFFFFF // ARGB white
|
||||||
#endif);
|
#endif );
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.renderTooltip(mouseX, mouseY, delta);
|
|
||||||
#else
|
|
||||||
this.renderTooltip(matrices, mouseX, mouseY, delta);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
this.renderTooltip(matrices, mouseX, mouseY, delta);
|
||||||
super.drawScreen(mouseX, mouseY, delta);
|
|
||||||
#elif MC_VER < MC_1_20_2
|
#if MC_VER < MC_1_20_2
|
||||||
super.render(matrices, mouseX, mouseY, delta);
|
super.render(matrices, mouseX, mouseY, delta);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER < MC_1_20_1
|
||||||
private void renderTooltip(int mouseX, int mouseY, float delta)
|
|
||||||
#elif MC_VER < MC_1_20_1
|
|
||||||
private void renderTooltip(PoseStack matrices, int mouseX, int mouseY, float delta)
|
private void renderTooltip(PoseStack matrices, int mouseX, int mouseY, float delta)
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
private void renderTooltip(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
private void renderTooltip(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
||||||
#else
|
#else
|
||||||
private void renderTooltip(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
private void renderTooltip(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
Gui hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY);
|
|
||||||
#else
|
|
||||||
AbstractWidget hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY);
|
AbstractWidget hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY);
|
||||||
#endif
|
|
||||||
if (hoveredWidget == null)
|
if (hoveredWidget == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -981,21 +738,14 @@ class DhConfigScreen extends DhScreen
|
|||||||
button.dhConfigType;
|
button.dhConfigType;
|
||||||
|
|
||||||
boolean apiOverrideActive = false;
|
boolean apiOverrideActive = false;
|
||||||
boolean unsupportedMcVersion = false;
|
|
||||||
if (configBase instanceof ConfigEntry)
|
if (configBase instanceof ConfigEntry)
|
||||||
{
|
{
|
||||||
apiOverrideActive = ((ConfigEntry<?>) configBase).apiIsOverriding();
|
apiOverrideActive = ((ConfigEntry<?>) configBase).apiIsOverriding();
|
||||||
unsupportedMcVersion = ((ConfigEntry<?>) configBase).mcVersionOverridePresent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String key = TRANSLATION_PREFIX + (configBase.category.isEmpty() ? "" : configBase.category + ".") + configBase.getName() + ".@tooltip";
|
String key = TRANSLATION_PREFIX + (configBase.category.isEmpty() ? "" : configBase.category + ".") + configBase.getName() + ".@tooltip";
|
||||||
|
|
||||||
if (unsupportedMcVersion)
|
if (apiOverrideActive)
|
||||||
{
|
|
||||||
key = "distanthorizons.general.unsupportedMcVersion.@tooltip";
|
|
||||||
}
|
|
||||||
else if (apiOverrideActive)
|
|
||||||
{
|
{
|
||||||
key = "distanthorizons.general.disabledByApi.@tooltip";
|
key = "distanthorizons.general.disabledByApi.@tooltip";
|
||||||
}
|
}
|
||||||
@@ -1004,116 +754,37 @@ class DhConfigScreen extends DhScreen
|
|||||||
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) configBase.guiValue);
|
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) configBase.guiValue);
|
||||||
if (configGuiInfo.errorMessage != null)
|
if (configGuiInfo.errorMessage != null)
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.DhRenderTooltip(configGuiInfo.errorMessage, mouseX, mouseY);
|
|
||||||
#else
|
|
||||||
this.DhRenderTooltip(matrices, this.font, configGuiInfo.errorMessage, mouseX, mouseY);
|
this.DhRenderTooltip(matrices, this.font, configGuiInfo.errorMessage, mouseX, mouseY);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
// display the tooltip if present
|
// display the tooltip if present
|
||||||
else if (LANG_WRAPPER.langExists(key))
|
else if (LANG_WRAPPER.langExists(key))
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
List<ITextComponent> list = new ArrayList<>();
|
|
||||||
#else
|
|
||||||
List<Component> list = new ArrayList<>();
|
List<Component> list = new ArrayList<>();
|
||||||
#endif
|
|
||||||
|
|
||||||
String lang = LANG_WRAPPER.getLang(key);
|
String lang = LANG_WRAPPER.getLang(key);
|
||||||
for (String langLine : lang.split("\n"))
|
for (String langLine : lang.split("\n"))
|
||||||
{
|
{
|
||||||
list.add(TextOrTranslatable(langLine));
|
list.add(TextOrTranslatable(langLine));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
this.DhRenderComponentTooltip(list, mouseX, mouseY);
|
|
||||||
#else
|
|
||||||
this.DhRenderComponentTooltip(matrices, this.font, list, mouseX, mouseY);
|
this.DhRenderComponentTooltip(matrices, this.font, list, mouseX, mouseY);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
@Override
|
|
||||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws java.io.IOException
|
|
||||||
{
|
|
||||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
|
|
||||||
if (mouseY >= this.configListWidget.top && mouseY <= this.configListWidget.bottom)
|
|
||||||
{
|
|
||||||
for (ClassicConfigGUI.DhButtonEntry entry : this.configListWidget.children)
|
|
||||||
{
|
|
||||||
if (entry.button instanceof GuiButton btn && btn.visible)
|
|
||||||
{
|
|
||||||
if (btn.mousePressed(this.mc, mouseX, mouseY))
|
|
||||||
{
|
|
||||||
btn.playPressSound(this.mc.getSoundHandler());
|
|
||||||
OnPressed handler = GuiHelper.HANDLER_BY_BUTTON.get(btn);
|
|
||||||
if (handler != null) handler.pressed(btn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (entry.button instanceof GuiTextField field && field.getVisible())
|
|
||||||
{
|
|
||||||
field.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entry.resetButton instanceof GuiButton reset && reset.visible)
|
|
||||||
{
|
|
||||||
if (reset.mousePressed(this.mc, mouseX, mouseY))
|
|
||||||
{
|
|
||||||
reset.playPressSound(this.mc.getSoundHandler());
|
|
||||||
OnPressed handler = GuiHelper.HANDLER_BY_BUTTON.get(reset);
|
|
||||||
if (handler != null) handler.pressed(reset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void keyTyped(char typedChar, int keyCode) throws java.io.IOException
|
|
||||||
{
|
|
||||||
super.keyTyped(typedChar, keyCode);
|
|
||||||
for (ClassicConfigGUI.DhButtonEntry entry : this.configListWidget.children)
|
|
||||||
{
|
|
||||||
if (entry.button instanceof GuiTextField field)
|
|
||||||
{
|
|
||||||
field.textboxKeyTyped(typedChar, keyCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMouseInput() throws java.io.IOException
|
|
||||||
{
|
|
||||||
super.handleMouseInput();
|
|
||||||
this.configListWidget.handleMouseInput();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==========//
|
//==========//
|
||||||
// shutdown //
|
// shutdown //
|
||||||
//==========//
|
//==========//
|
||||||
//region
|
|
||||||
/** When you close it, it goes to the previous screen and saves */
|
/** When you close it, it goes to the previous screen and saves */
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER <= MC_1_12_2
|
|
||||||
public void onGuiClosed()
|
|
||||||
#else
|
|
||||||
public void onClose()
|
public void onClose()
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
|
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
|
||||||
#if MC_VER > MC_1_12_2
|
DhScreenUtil.setScreen(this.parent);
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
|
|
||||||
#endif
|
|
||||||
ClassicConfigGUI.CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run());
|
ClassicConfigGUI.CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run());
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+161
-19
@@ -1,6 +1,6 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.gui.updater;
|
package com.seibel.distanthorizons.common.wrappers.gui.updater;
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.DhScreen;
|
import com.seibel.distanthorizons.common.wrappers.gui.DhScreen;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.gui.DhScreenUtil;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
|
||||||
@@ -8,19 +8,30 @@ import com.seibel.distanthorizons.coreapi.ModInfo;
|
|||||||
import com.seibel.distanthorizons.core.jar.installer.MarkdownFormatter;
|
import com.seibel.distanthorizons.core.jar.installer.MarkdownFormatter;
|
||||||
import com.seibel.distanthorizons.core.jar.installer.ModrinthGetter;
|
import com.seibel.distanthorizons.core.jar.installer.ModrinthGetter;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
import net.minecraft.client.gui.Gui;
|
||||||
|
import net.minecraft.client.gui.GuiListExtended;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
#else
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
import net.minecraft.client.gui.components.AbstractWidget;
|
import net.minecraft.client.gui.components.AbstractWidget;
|
||||||
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
|
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
#endif
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER >= MC_1_17_1
|
#if MC_VER >= MC_1_17_1
|
||||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER < MC_1_20_1
|
#if MC_VER <= MC_1_12_2
|
||||||
|
#elif MC_VER < MC_1_20_1
|
||||||
import net.minecraft.client.gui.GuiComponent;
|
import net.minecraft.client.gui.GuiComponent;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
@@ -44,14 +55,22 @@ public class ChangelogScreen extends DhScreen
|
|||||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
private GuiScreen parent;
|
||||||
|
#else
|
||||||
private Screen parent;
|
private Screen parent;
|
||||||
|
#endif
|
||||||
private String versionID;
|
private String versionID;
|
||||||
private List<String> changelog;
|
private List<String> changelog;
|
||||||
private TextArea changelogArea;
|
private TextArea changelogArea;
|
||||||
|
|
||||||
public boolean usable = false;
|
public boolean usable = false;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
public ChangelogScreen(GuiScreen parent)
|
||||||
|
#else
|
||||||
public ChangelogScreen(Screen parent)
|
public ChangelogScreen(Screen parent)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
this(parent, null);
|
this(parent, null);
|
||||||
|
|
||||||
@@ -86,7 +105,11 @@ public class ChangelogScreen extends DhScreen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
public ChangelogScreen(GuiScreen parent, String versionID)
|
||||||
|
#else
|
||||||
public ChangelogScreen(Screen parent, String versionID)
|
public ChangelogScreen(Screen parent, String versionID)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
super(Translatable(ModInfo.ID + ".updater.title"));
|
super(Translatable(ModInfo.ID + ".updater.title"));
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
@@ -142,9 +165,18 @@ public class ChangelogScreen extends DhScreen
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
public void initGui()
|
||||||
|
#else
|
||||||
protected void init()
|
protected void init()
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
super.initGui();
|
||||||
|
#else
|
||||||
super.init();
|
super.init();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!this.usable)
|
if (!this.usable)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -153,12 +185,19 @@ public class ChangelogScreen extends DhScreen
|
|||||||
|
|
||||||
this.addBtn( // Close
|
this.addBtn( // Close
|
||||||
MakeBtn(Translatable(ModInfo.ID + ".general.back"), 5, this.height - 25, 100, 20, (btn) -> {
|
MakeBtn(Translatable(ModInfo.ID + ".general.back"), 5, this.height - 25, 100, 20, (btn) -> {
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent);
|
||||||
|
#else
|
||||||
this.onClose();
|
this.onClose();
|
||||||
|
#endif
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
this.changelogArea = new TextArea(this.mc, this.width * 2, this.height, 32, 32, 10);
|
||||||
|
#else
|
||||||
this.changelogArea = new TextArea(this.minecraft, this.width * 2, this.height, 32, 32, 10);
|
this.changelogArea = new TextArea(this.minecraft, this.width * 2, this.height, 32, 32, 10);
|
||||||
|
#endif
|
||||||
for (int i = 0; i < this.changelog.size(); i++)
|
for (int i = 0; i < this.changelog.size(); i++)
|
||||||
{
|
{
|
||||||
this.changelogArea.addButton(TextOrLiteral(this.changelog.get(i)));
|
this.changelogArea.addButton(TextOrLiteral(this.changelog.get(i)));
|
||||||
@@ -168,7 +207,9 @@ public class ChangelogScreen extends DhScreen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER < MC_1_20_1
|
#if MC_VER <= MC_1_12_2
|
||||||
|
public void drawScreen(int mouseX, int mouseY, float delta)
|
||||||
|
#elif MC_VER < MC_1_20_1
|
||||||
public void render(PoseStack matrices, int mouseX, int mouseY, float delta)
|
public void render(PoseStack matrices, int mouseX, int mouseY, float delta)
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
||||||
@@ -176,7 +217,9 @@ public class ChangelogScreen extends DhScreen
|
|||||||
public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_20_2
|
#if MC_VER <= MC_1_12_2
|
||||||
|
this.drawDefaultBackground(); // Render background
|
||||||
|
#elif MC_VER < MC_1_20_2
|
||||||
this.renderBackground(matrices); // Render background
|
this.renderBackground(matrices); // Render background
|
||||||
#elif MC_VER < MC_1_21_6
|
#elif MC_VER < MC_1_21_6
|
||||||
this.renderBackground(matrices, mouseX, mouseY, delta); // Render background
|
this.renderBackground(matrices, mouseX, mouseY, delta); // Render background
|
||||||
@@ -200,7 +243,9 @@ public class ChangelogScreen extends DhScreen
|
|||||||
// This is a bit of a hack as we cannot scroll on this area
|
// This is a bit of a hack as we cannot scroll on this area
|
||||||
double scrollAmount = ((double) mouseY) / ((double) this.height) * 1.1 * maxScroll;
|
double scrollAmount = ((double) mouseY) / ((double) this.height) * 1.1 * maxScroll;
|
||||||
|
|
||||||
#if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
|
#if MC_VER <= MC_1_12_2
|
||||||
|
this.changelogArea.amountScrolled = (float)scrollAmount;
|
||||||
|
#elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1
|
||||||
this.changelogArea.setScrollAmount(scrollAmount);
|
this.changelogArea.setScrollAmount(scrollAmount);
|
||||||
#elif MC_VER <= MC_1_21_3
|
#elif MC_VER <= MC_1_21_3
|
||||||
this.changelogArea.scrollAmount = scrollAmount;
|
this.changelogArea.scrollAmount = scrollAmount;
|
||||||
@@ -208,9 +253,13 @@ public class ChangelogScreen extends DhScreen
|
|||||||
this.changelogArea.setScrollAmount(scrollAmount);
|
this.changelogArea.setScrollAmount(scrollAmount);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// render order matters, otherwise on
|
||||||
// render order matters, otherwise on 1.20.6+ the blurred background will render on top of the text
|
// 1.12.2- buttons won't render
|
||||||
#if MC_VER <= MC_1_21_11
|
// 1.20.6+ the blurred background will render on top of the text
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
this.changelogArea.drawScreen(mouseX, mouseY, delta); // Render the changelog
|
||||||
|
super.drawScreen(mouseX, mouseY, delta); // Render the buttons
|
||||||
|
#elif MC_VER <= MC_1_21_11
|
||||||
super.render(matrices, mouseX, mouseY, delta); // Render the buttons
|
super.render(matrices, mouseX, mouseY, delta); // Render the buttons
|
||||||
this.changelogArea.render(matrices, mouseX, mouseY, delta); // Render the changelog
|
this.changelogArea.render(matrices, mouseX, mouseY, delta); // Render the changelog
|
||||||
#else
|
#else
|
||||||
@@ -218,18 +267,45 @@ public class ChangelogScreen extends DhScreen
|
|||||||
this.changelogArea.extractRenderState(matrices, mouseX, mouseY, delta); // Render the changelog
|
this.changelogArea.extractRenderState(matrices, mouseX, mouseY, delta); // Render the changelog
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this.DhDrawCenteredString(matrices, this.font, this.title, this.width / 2, 15, 0xFFFFFF); // Render title
|
// Render title
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
this.DhDrawCenteredString(this.title, this.width / 2, 15, 0xFFFFFF);
|
||||||
|
#else
|
||||||
|
this.DhDrawCenteredString(matrices, this.font, this.title, this.width / 2, 15, 0xFFFFFF);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
@Override
|
||||||
|
public void onGuiClosed()
|
||||||
|
#else
|
||||||
@Override
|
@Override
|
||||||
public void onClose()
|
public void onClose()
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Goto the parent screen
|
// Go to the parent screen
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
// Handled by button to avoid recursive loop
|
||||||
|
#else
|
||||||
|
DhScreenUtil.setScreen(this.parent);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
public static class TextArea extends GuiListExtended
|
||||||
|
#else
|
||||||
public static class TextArea extends ContainerObjectSelectionList<ButtonEntry>
|
public static class TextArea extends ContainerObjectSelectionList<ButtonEntry>
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
public List<ButtonEntry> children = new ArrayList<>();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
FontRenderer textRenderer;
|
||||||
|
#else
|
||||||
Font textRenderer;
|
Font textRenderer;
|
||||||
|
#endif
|
||||||
|
|
||||||
public TextArea(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing)
|
public TextArea(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing)
|
||||||
{
|
{
|
||||||
@@ -238,63 +314,129 @@ public class ChangelogScreen extends DhScreen
|
|||||||
#else
|
#else
|
||||||
super(minecraftClient, canvasWidth, canvasHeight - (topMargin + botMargin), topMargin, itemSpacing);
|
super(minecraftClient, canvasWidth, canvasHeight - (topMargin + botMargin), topMargin, itemSpacing);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this.centerListVertically = false;
|
this.centerListVertically = false;
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
this.textRenderer = minecraftClient.fontRenderer;
|
||||||
|
#else
|
||||||
this.textRenderer = minecraftClient.font;
|
this.textRenderer = minecraftClient.font;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
public void addButton(ITextComponent text)
|
||||||
|
#else
|
||||||
public void addButton(Component text)
|
public void addButton(Component text)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
this.children.add(ButtonEntry.create(text));
|
||||||
|
#else
|
||||||
this.addEntry(ButtonEntry.create(text));
|
this.addEntry(ButtonEntry.create(text));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
public int getListWidth()
|
||||||
|
#else
|
||||||
public int getRowWidth()
|
public int getRowWidth()
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
return 10000;
|
return 10_000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
@Override
|
||||||
|
protected int getSize()
|
||||||
|
{
|
||||||
|
return this.children.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IGuiListEntry getListEntry(int index)
|
||||||
|
{
|
||||||
|
return this.children.get(index);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
public static class ButtonEntry implements GuiListExtended.IGuiListEntry
|
||||||
|
#else
|
||||||
public static class ButtonEntry extends ContainerObjectSelectionList.Entry<ButtonEntry>
|
public static class ButtonEntry extends ContainerObjectSelectionList.Entry<ButtonEntry>
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
private static final FontRenderer textRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||||
|
#else
|
||||||
private static final Font textRenderer = Minecraft.getInstance().font;
|
private static final Font textRenderer = Minecraft.getInstance().font;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
private final ITextComponent text;
|
||||||
|
#else
|
||||||
private final Component text;
|
private final Component text;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
private final List<Gui> children = new ArrayList<>();
|
||||||
|
#else
|
||||||
private final List<AbstractWidget> children = new ArrayList<>();
|
private final List<AbstractWidget> children = new ArrayList<>();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
private ButtonEntry(ITextComponent text) { this.text = text; }
|
||||||
|
#else
|
||||||
private ButtonEntry(Component text) { this.text = text; }
|
private ButtonEntry(Component text) { this.text = text; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
public static ButtonEntry create(ITextComponent text)
|
||||||
|
#else
|
||||||
public static ButtonEntry create(Component text)
|
public static ButtonEntry create(Component text)
|
||||||
|
#endif
|
||||||
{ return new ButtonEntry(text); }
|
{ return new ButtonEntry(text); }
|
||||||
|
|
||||||
#if MC_VER < MC_1_20_1
|
|
||||||
@Override
|
@Override
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float tickDelta)
|
||||||
|
{ textRenderer.drawString(text.getFormattedText(), 12, y + 5, 0xFFFFFF); }
|
||||||
|
#elif MC_VER < MC_1_20_1
|
||||||
public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta)
|
public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta)
|
||||||
{ GuiComponent.drawString(matrices, textRenderer, text, 12, y + 5, 0xFFFFFF); }
|
{ GuiComponent.drawString(matrices, textRenderer, text, 12, y + 5, 0xFFFFFF); }
|
||||||
#elif MC_VER < MC_1_21_9
|
#elif MC_VER < MC_1_21_9
|
||||||
@Override
|
|
||||||
public void render(GuiGraphics matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta)
|
public void render(GuiGraphics matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta)
|
||||||
{ matrices.drawString(textRenderer, this.text, 12, y + 5, 0xFFFFFF); }
|
{ matrices.drawString(textRenderer, this.text, 12, y + 5, 0xFFFFFF); }
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
@Override
|
|
||||||
public void renderContent(GuiGraphics matrices, int y, int x, boolean hovered, float tickDelta)
|
public void renderContent(GuiGraphics matrices, int y, int x, boolean hovered, float tickDelta)
|
||||||
{ matrices.drawString(textRenderer, this.text, 12, y + 5, 0xFFFFFF); }
|
{ matrices.drawString(textRenderer, this.text, 12, y + 5, 0xFFFFFF); }
|
||||||
#else
|
#else
|
||||||
@Override
|
|
||||||
public void extractContent(GuiGraphicsExtractor matrices, int y, int x, boolean hovered, float tickDelta)
|
public void extractContent(GuiGraphicsExtractor matrices, int y, int x, boolean hovered, float tickDelta)
|
||||||
{ matrices.text(textRenderer, this.text, 12, y + 5, 0xFFFFFF); }
|
{ matrices.text(textRenderer, this.text, 12, y + 5, 0xFFFFFF); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER > MC_1_12_2
|
||||||
@Override
|
@Override
|
||||||
public List<? extends GuiEventListener> children() { return this.children; }
|
public List<? extends GuiEventListener> children() { return this.children; }
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MC_VER >= MC_1_17_1
|
#if MC_VER >= MC_1_17_1
|
||||||
@Override
|
@Override
|
||||||
public List<? extends NarratableEntry> narratables() { return this.children; }
|
public List<? extends NarratableEntry> narratables() { return this.children; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
@Override
|
||||||
|
public void updatePosition(int slotIndex, int x, int y, float partialTicks) { }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY) { return false; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) { }
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+96
-20
@@ -1,7 +1,7 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.gui.updater;
|
package com.seibel.distanthorizons.common.wrappers.gui.updater;
|
||||||
#if MC_VER > MC_1_12_2
|
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.DhScreen;
|
import com.seibel.distanthorizons.common.wrappers.gui.DhScreen;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.gui.DhScreenUtil;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget;
|
import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget;
|
||||||
import com.seibel.distanthorizons.core.jar.ModJarInfo;
|
import com.seibel.distanthorizons.core.jar.ModJarInfo;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
@@ -10,10 +10,14 @@ import com.seibel.distanthorizons.core.config.Config;
|
|||||||
import com.seibel.distanthorizons.core.jar.installer.ModrinthGetter;
|
import com.seibel.distanthorizons.core.jar.installer.ModrinthGetter;
|
||||||
import com.seibel.distanthorizons.core.jar.updater.SelfUpdater;
|
import com.seibel.distanthorizons.core.jar.updater.SelfUpdater;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
#else
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MC_VER < MC_1_20_1
|
#if MC_VER <= MC_1_12_2
|
||||||
|
#elif MC_VER < MC_1_20_1
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
@@ -21,7 +25,9 @@ import net.minecraft.client.gui.GuiGraphics;
|
|||||||
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_10
|
#if MC_VER <= MC_1_12_2
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
#elif MC_VER <= MC_1_21_10
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
#else
|
#else
|
||||||
import net.minecraft.resources.Identifier;
|
import net.minecraft.resources.Identifier;
|
||||||
@@ -29,8 +35,6 @@ import net.minecraft.resources.Identifier;
|
|||||||
|
|
||||||
import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.*;
|
import static com.seibel.distanthorizons.common.wrappers.gui.GuiHelper.*;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The screen that pops up if the mod has an update.
|
* The screen that pops up if the mod has an update.
|
||||||
*
|
*
|
||||||
@@ -40,15 +44,26 @@ public class UpdateModScreen extends DhScreen
|
|||||||
{
|
{
|
||||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
private GuiScreen parent;
|
||||||
|
#else
|
||||||
private Screen parent;
|
private Screen parent;
|
||||||
|
#endif
|
||||||
private String newVersionID;
|
private String newVersionID;
|
||||||
|
|
||||||
private String currentVer;
|
private String currentVer;
|
||||||
private String nextVer;
|
private String nextVer;
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
private static final int logoButton_id = 100;
|
||||||
|
private static final int changelogButton_id = 101;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
public UpdateModScreen(GuiScreen parent, String newVersionID) throws IllegalArgumentException
|
||||||
|
#else
|
||||||
public UpdateModScreen(Screen parent, String newVersionID) throws IllegalArgumentException
|
public UpdateModScreen(Screen parent, String newVersionID) throws IllegalArgumentException
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
super(Translatable(ModInfo.ID + ".updater.title"));
|
super(Translatable(ModInfo.ID + ".updater.title"));
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
@@ -76,10 +91,17 @@ public class UpdateModScreen extends DhScreen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
public void initGui()
|
||||||
|
#else
|
||||||
protected void init()
|
protected void init()
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
super.initGui();
|
||||||
|
#else
|
||||||
super.init();
|
super.init();
|
||||||
|
#endif
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -87,6 +109,9 @@ public class UpdateModScreen extends DhScreen
|
|||||||
|
|
||||||
// Logo image
|
// Logo image
|
||||||
this.addBtn(new TexturedButtonWidget(
|
this.addBtn(new TexturedButtonWidget(
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
logoButton_id,
|
||||||
|
#endif
|
||||||
// Where the button is on the screen
|
// Where the button is on the screen
|
||||||
this.width / 2 - 95, this.height / 2 - 110,
|
this.width / 2 - 95, this.height / 2 - 110,
|
||||||
// Width and height of the button
|
// Width and height of the button
|
||||||
@@ -105,9 +130,15 @@ public class UpdateModScreen extends DhScreen
|
|||||||
195, 65,
|
195, 65,
|
||||||
// Create the button and tell it where to go
|
// Create the button and tell it where to go
|
||||||
// For now it goes to the client option by default
|
// For now it goes to the client option by default
|
||||||
|
#if MC_VER > MC_1_12_2
|
||||||
(buttonWidget) -> LOGGER.info("Nice, you found an Easter egg :)"),
|
(buttonWidget) -> LOGGER.info("Nice, you found an Easter egg :)"),
|
||||||
|
#endif
|
||||||
// Add a title to the button
|
// Add a title to the button
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
Translatable(ModInfo.ID + ".updater.title").getFormattedText(),
|
||||||
|
#else
|
||||||
Translatable(ModInfo.ID + ".updater.title"),
|
Translatable(ModInfo.ID + ".updater.title"),
|
||||||
|
#endif
|
||||||
// Dont render the background of the button
|
// Dont render the background of the button
|
||||||
false
|
false
|
||||||
));
|
));
|
||||||
@@ -120,6 +151,9 @@ public class UpdateModScreen extends DhScreen
|
|||||||
if (!ModInfo.IS_DEV_BUILD)
|
if (!ModInfo.IS_DEV_BUILD)
|
||||||
{
|
{
|
||||||
this.addBtn(new TexturedButtonWidget(
|
this.addBtn(new TexturedButtonWidget(
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
changelogButton_id,
|
||||||
|
#endif
|
||||||
// Where the button is on the screen
|
// Where the button is on the screen
|
||||||
this.width / 2 - 97, this.height / 2 + 8,
|
this.width / 2 - 97, this.height / 2 + 8,
|
||||||
// Width and height of the button
|
// Width and height of the button
|
||||||
@@ -137,9 +171,15 @@ public class UpdateModScreen extends DhScreen
|
|||||||
#endif
|
#endif
|
||||||
20, 20,
|
20, 20,
|
||||||
// Create the button and tell it where to go
|
// Create the button and tell it where to go
|
||||||
(buttonWidget) -> Objects.requireNonNull(this.minecraft).setScreen(new ChangelogScreen(this, this.newVersionID)),
|
#if MC_VER > MC_1_12_2
|
||||||
|
(buttonWidget) -> DhScreenUtil.setScreen(new ChangelogScreen(this, this.newVersionID)),
|
||||||
|
#endif
|
||||||
// Add a title to the button
|
// Add a title to the button
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
Translatable(ModInfo.ID + ".updater.title").getFormattedText()
|
||||||
|
#else
|
||||||
Translatable(ModInfo.ID + ".updater.title")
|
Translatable(ModInfo.ID + ".updater.title")
|
||||||
|
#endif
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,32 +187,50 @@ public class UpdateModScreen extends DhScreen
|
|||||||
this.addBtn( // Update
|
this.addBtn( // Update
|
||||||
MakeBtn(Translatable(ModInfo.ID + ".updater.update"), this.width / 2 - 75, this.height / 2 + 8, 150, 20, (btn) -> {
|
MakeBtn(Translatable(ModInfo.ID + ".updater.update"), this.width / 2 - 75, this.height / 2 + 8, 150, 20, (btn) -> {
|
||||||
SelfUpdater.updateMod();
|
SelfUpdater.updateMod();
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent);
|
||||||
|
#else
|
||||||
this.onClose();
|
this.onClose();
|
||||||
|
#endif
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
this.addBtn( // Silent update
|
this.addBtn( // Silent update
|
||||||
MakeBtn(Translatable(ModInfo.ID + ".updater.silent"), this.width / 2 - 75, this.height / 2 + 30, 150, 20, (btn) -> {
|
MakeBtn(Translatable(ModInfo.ID + ".updater.silent"), this.width / 2 - 75, this.height / 2 + 30, 150, 20, (btn) -> {
|
||||||
Config.Client.Advanced.AutoUpdater.enableSilentUpdates.set(true);
|
Config.Client.Advanced.AutoUpdater.enableSilentUpdates.set(true);
|
||||||
SelfUpdater.updateMod();
|
SelfUpdater.updateMod();
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent);
|
||||||
|
#else
|
||||||
this.onClose();
|
this.onClose();
|
||||||
|
#endif
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
this.addBtn( // Later (not now)
|
this.addBtn( // Later (not now)
|
||||||
MakeBtn(Translatable(ModInfo.ID + ".updater.later"), this.width / 2 + 2, this.height / 2 + 70, 100, 20, (btn) -> {
|
MakeBtn(Translatable(ModInfo.ID + ".updater.later"), this.width / 2 + 2, this.height / 2 + 70, 100, 20, (btn) -> {
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent);
|
||||||
|
#else
|
||||||
this.onClose();
|
this.onClose();
|
||||||
|
#endif
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
this.addBtn( // Never
|
this.addBtn( // Never
|
||||||
MakeBtn(Translatable(ModInfo.ID + ".updater.never"), this.width / 2 - 102, this.height / 2 + 70, 100, 20, (btn) -> {
|
MakeBtn(Translatable(ModInfo.ID + ".updater.never"), this.width / 2 - 102, this.height / 2 + 70, 100, 20, (btn) -> {
|
||||||
Config.Client.Advanced.AutoUpdater.enableAutoUpdater.set(false);
|
Config.Client.Advanced.AutoUpdater.enableAutoUpdater.set(false);
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent);
|
||||||
|
#else
|
||||||
this.onClose();
|
this.onClose();
|
||||||
|
#endif
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
#if MC_VER < MC_1_20_1
|
#if MC_VER <= MC_1_12_2
|
||||||
|
public void drawScreen(int mouseX, int mouseY, float delta)
|
||||||
|
#elif MC_VER < MC_1_20_1
|
||||||
public void render(PoseStack matrices, int mouseX, int mouseY, float delta)
|
public void render(PoseStack matrices, int mouseX, int mouseY, float delta)
|
||||||
#elif MC_VER <= MC_1_21_11
|
#elif MC_VER <= MC_1_21_11
|
||||||
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
||||||
@@ -180,7 +238,9 @@ public class UpdateModScreen extends DhScreen
|
|||||||
public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_20_2
|
#if MC_VER <= MC_1_12_2
|
||||||
|
this.drawDefaultBackground(); // Render background
|
||||||
|
#elif MC_VER < MC_1_20_2
|
||||||
this.renderBackground(matrices); // Render background
|
this.renderBackground(matrices); // Render background
|
||||||
#elif MC_VER < MC_1_21_6
|
#elif MC_VER < MC_1_21_6
|
||||||
this.renderBackground(matrices, mouseX, mouseY, delta); // Render background
|
this.renderBackground(matrices, mouseX, mouseY, delta); // Render background
|
||||||
@@ -188,15 +248,20 @@ public class UpdateModScreen extends DhScreen
|
|||||||
// background blur is already being rendered, rendering again causes the game to crash
|
// background blur is already being rendered, rendering again causes the game to crash
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_11
|
#if MC_VER <= MC_1_12_2
|
||||||
|
super.drawScreen(mouseX, mouseY, delta); // Render the buttons
|
||||||
|
#elif MC_VER <= MC_1_21_11
|
||||||
super.render(matrices, mouseX, mouseY, delta); // Render the buttons
|
super.render(matrices, mouseX, mouseY, delta); // Render the buttons
|
||||||
#else
|
#else
|
||||||
super.extractRenderState(matrices, mouseX, mouseY, delta);
|
super.extractRenderState(matrices, mouseX, mouseY, delta);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Render the text's
|
// Render the text's
|
||||||
this.DhDrawCenteredString(matrices, this.font,
|
this.DhDrawCenteredString(
|
||||||
Translatable(ModInfo.ID + ".updater.text1"),
|
#if MC_VER > MC_1_12_2
|
||||||
|
matrices, this.font,
|
||||||
|
#endif
|
||||||
|
Translatable(ModInfo.ID + ".updater.updateAvailable"),
|
||||||
this.width / 2, this.height / 2 - 35,
|
this.width / 2, this.height / 2 - 35,
|
||||||
#if MC_VER < MC_1_21_6
|
#if MC_VER < MC_1_21_6
|
||||||
0xFFFFFF // RGB
|
0xFFFFFF // RGB
|
||||||
@@ -204,8 +269,11 @@ public class UpdateModScreen extends DhScreen
|
|||||||
0xFFFFFFFF // ARGB
|
0xFFFFFFFF // ARGB
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
this.DhDrawCenteredString(matrices, this.font,
|
this.DhDrawCenteredString(
|
||||||
Translatable(ModInfo.ID + ".updater.text2", this.currentVer, this.nextVer),
|
#if MC_VER > MC_1_12_2
|
||||||
|
matrices, this.font,
|
||||||
|
#endif
|
||||||
|
Translatable(ModInfo.ID + ".updater.updateConfirmation", this.currentVer, this.nextVer),
|
||||||
this.width / 2, this.height / 2 - 20,
|
this.width / 2, this.height / 2 - 20,
|
||||||
#if MC_VER < MC_1_21_6
|
#if MC_VER < MC_1_21_6
|
||||||
0x52FD52 // RGB
|
0x52FD52 // RGB
|
||||||
@@ -216,10 +284,18 @@ public class UpdateModScreen extends DhScreen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
public void onGuiClosed()
|
||||||
|
#else
|
||||||
public void onClose()
|
public void onClose()
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Go to the parent screen
|
// Go to the parent screen
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
// Handled by button to avoid recursive loop
|
||||||
|
#else
|
||||||
|
DhScreenUtil.setScreen(this.parent); // Go to the parent screen
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
+6
-2
@@ -157,8 +157,10 @@ public class MinecraftGLWrapper
|
|||||||
GL32.glEnable(GL32.GL_BLEND);
|
GL32.glEnable(GL32.GL_BLEND);
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
#else
|
#elif MC_VER <= MC_26_1_2
|
||||||
GlStateManager._enableBlend();
|
GlStateManager._enableBlend();
|
||||||
|
#else
|
||||||
|
GlStateManager._enableBlend(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/** @see GL32#GL_BLEND */
|
/** @see GL32#GL_BLEND */
|
||||||
@@ -167,8 +169,10 @@ public class MinecraftGLWrapper
|
|||||||
GL32.glDisable(GL32.GL_BLEND);
|
GL32.glDisable(GL32.GL_BLEND);
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
GlStateManager.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
|
#elif MC_VER <= MC_26_1_2
|
||||||
|
GlStateManager._disableBlend();
|
||||||
#else
|
#else
|
||||||
GlStateManager._disableBlend();
|
GlStateManager._disableBlend(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+61
-12
@@ -20,13 +20,13 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.minecraft;
|
package com.seibel.distanthorizons.common.wrappers.minecraft;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.lang.invoke.MethodHandles;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
#if MC_VER > MC_1_12_2
|
||||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
import com.mojang.blaze3d.pipeline.RenderTarget;
|
||||||
import com.mojang.blaze3d.platform.NativeImage;
|
import com.mojang.blaze3d.platform.NativeImage;
|
||||||
#endif
|
#endif
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiLodShading;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiLodShading;
|
||||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||||
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
||||||
@@ -35,6 +35,7 @@ import com.seibel.distanthorizons.core.config.Config;
|
|||||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||||
import com.seibel.distanthorizons.core.enums.EDhDirection;
|
import com.seibel.distanthorizons.core.enums.EDhDirection;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderingApi;
|
||||||
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.ILightMapWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.ILightMapWrapper;
|
||||||
|
|
||||||
@@ -53,7 +54,6 @@ import org.joml.Vector3f;
|
|||||||
#else
|
#else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.AbstractOptifineAccessor;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IDimensionTypeWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IDimensionTypeWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||||
@@ -156,9 +156,12 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
#elif MC_VER <= MC_1_21_10
|
#elif MC_VER <= MC_1_21_10
|
||||||
Camera camera = MC.gameRenderer.getMainCamera();
|
Camera camera = MC.gameRenderer.getMainCamera();
|
||||||
return new Vec3f(camera.getLookVector().x(), camera.getLookVector().y(), camera.getLookVector().z());
|
return new Vec3f(camera.getLookVector().x(), camera.getLookVector().y(), camera.getLookVector().z());
|
||||||
#else
|
#elif MC_VER <= MC_26_1_2
|
||||||
Camera camera = MC.gameRenderer.getMainCamera();
|
Camera camera = MC.gameRenderer.getMainCamera();
|
||||||
return new Vec3f(camera.forwardVector().x(), camera.forwardVector().y(), camera.forwardVector().z());
|
return new Vec3f(camera.forwardVector().x(), camera.forwardVector().y(), camera.forwardVector().z());
|
||||||
|
#else
|
||||||
|
Camera camera = MC.gameRenderer.mainCamera();
|
||||||
|
return new Vec3f(camera.forwardVector().x(), camera.forwardVector().y(), camera.forwardVector().z());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,15 +205,18 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
RenderManager rm = MC.getRenderManager();
|
RenderManager rm = MC.getRenderManager();
|
||||||
return new Vec3d(rm.viewerPosX, rm.viewerPosY, rm.viewerPosZ);
|
return new Vec3d(rm.viewerPosX, rm.viewerPosY, rm.viewerPosZ);
|
||||||
#else
|
#elif MC_VER <= MC_26_1_2
|
||||||
Camera camera = MC.gameRenderer.getMainCamera();
|
Camera camera = MC.gameRenderer.getMainCamera();
|
||||||
|
#else
|
||||||
|
Camera camera = MC.gameRenderer.mainCamera();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_10
|
#if MC_VER <= MC_1_21_10
|
||||||
Vec3 projectedView = camera.getPosition();
|
Vec3 projectedView = camera.getPosition();
|
||||||
#else
|
#else
|
||||||
Vec3 projectedView = camera.position();
|
Vec3 projectedView = camera.position();
|
||||||
#endif
|
#endif
|
||||||
return new Vec3d(projectedView.x, projectedView.y, projectedView.z);
|
return new Vec3d(projectedView.x, projectedView.y, projectedView.z);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -298,20 +304,29 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
float darkenAmount;
|
float darkenAmount;
|
||||||
#if MC_VER <= MC_1_21_11
|
#if MC_VER <= MC_1_21_11
|
||||||
darkenAmount = MC.gameRenderer.getDarkenWorldAmount(MC.deltaTracker.getGameTimeDeltaPartialTick(true));
|
darkenAmount = MC.gameRenderer.getDarkenWorldAmount(MC.deltaTracker.getGameTimeDeltaPartialTick(true));
|
||||||
#else
|
#elif MC_VER <= MC_26_1_2
|
||||||
darkenAmount = MC.gameRenderer.getBossOverlayWorldDarkening(MC.deltaTracker.getGameTimeDeltaPartialTick(true));
|
darkenAmount = MC.gameRenderer.getBossOverlayWorldDarkening(MC.deltaTracker.getGameTimeDeltaPartialTick(true));
|
||||||
|
#else
|
||||||
|
darkenAmount = MC.gameRenderer.bossOverlayWorldDarkening(MC.deltaTracker.getGameTimeDeltaPartialTick(true));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
Camera camera = MC.gameRenderer.getMainCamera();
|
||||||
|
#else
|
||||||
|
Camera camera = MC.gameRenderer.mainCamera();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_21_11
|
#if MC_VER <= MC_1_21_11
|
||||||
Vector4f colorValues = mcFogRenderer.setupFog(
|
Vector4f colorValues = mcFogRenderer.setupFog(
|
||||||
MC.gameRenderer.getMainCamera(),
|
camera,
|
||||||
MC.options.getEffectiveRenderDistance(),
|
MC.options.getEffectiveRenderDistance(),
|
||||||
MC.deltaTracker,
|
MC.deltaTracker,
|
||||||
darkenAmount,
|
darkenAmount,
|
||||||
MC.level);
|
MC.level);
|
||||||
#else
|
#else
|
||||||
FogData fogData = mcFogRenderer.setupFog(
|
FogData fogData = mcFogRenderer.setupFog(
|
||||||
MC.gameRenderer.getMainCamera(),
|
camera,
|
||||||
MC.options.getEffectiveRenderDistance(),
|
MC.options.getEffectiveRenderDistance(),
|
||||||
MC.deltaTracker,
|
MC.deltaTracker,
|
||||||
darkenAmount,
|
darkenAmount,
|
||||||
@@ -390,7 +405,14 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if MC_VER > MC_1_12_2
|
#if MC_VER > MC_1_12_2
|
||||||
protected RenderTarget getRenderTarget() { return MC.getMainRenderTarget(); }
|
public RenderTarget getRenderTarget()
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
return MC.getMainRenderTarget();
|
||||||
|
#else
|
||||||
|
return MC.gameRenderer.mainRenderTarget();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -413,6 +435,30 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private EDhApiRenderingApi renderApi = null;
|
||||||
|
@Override
|
||||||
|
public EDhApiRenderingApi getMcRenderingApi()
|
||||||
|
{
|
||||||
|
if (this.renderApi != null)
|
||||||
|
{
|
||||||
|
return this.renderApi;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
this.renderApi = EDhApiRenderingApi.OPEN_GL;
|
||||||
|
#else
|
||||||
|
String backendName = RenderSystem
|
||||||
|
.getDevice()
|
||||||
|
.getDeviceInfo()
|
||||||
|
.backendName();
|
||||||
|
boolean isVulkan = backendName.equalsIgnoreCase("Vulkan");
|
||||||
|
this.renderApi = isVulkan ? EDhApiRenderingApi.VULKAN : EDhApiRenderingApi.OPEN_GL;
|
||||||
|
#endif
|
||||||
|
return this.renderApi;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTargetFramebuffer()
|
public int getTargetFramebuffer()
|
||||||
{
|
{
|
||||||
@@ -437,7 +483,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
public void clearTargetFrameBuffer() { this.finalLevelFrameBufferId = -1; }
|
public void clearTargetFrameBuffer() { this.finalLevelFrameBufferId = -1; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDepthTextureId()
|
public int getGlDepthTextureId()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
//1.12.2 is using renderbuffer instead of framebuffer for depth texture
|
//1.12.2 is using renderbuffer instead of framebuffer for depth texture
|
||||||
@@ -470,7 +516,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getColorTextureId()
|
public int getGlColorTextureId()
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
return MC.getFramebuffer().framebufferTexture;
|
return MC.getFramebuffer().framebufferTexture;
|
||||||
@@ -543,9 +589,12 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
|||||||
isBlind |= fluidState.is(FluidTags.WATER);
|
isBlind |= fluidState.is(FluidTags.WATER);
|
||||||
isBlind |= fluidState.is(FluidTags.LAVA);
|
isBlind |= fluidState.is(FluidTags.LAVA);
|
||||||
return isBlind;
|
return isBlind;
|
||||||
#else
|
#elif MC_VER <= MC_26_1_2
|
||||||
boolean isBlind = this.playerHasBlindingEffect();
|
boolean isBlind = this.playerHasBlindingEffect();
|
||||||
return MC.gameRenderer.getMainCamera().getFluidInCamera() != FogType.NONE || isBlind;
|
return MC.gameRenderer.getMainCamera().getFluidInCamera() != FogType.NONE || isBlind;
|
||||||
|
#else
|
||||||
|
boolean isBlind = this.playerHasBlindingEffect();
|
||||||
|
return MC.gameRenderer.mainCamera().getFluidInCamera() != FogType.NONE || isBlind;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+61
-9
@@ -1,26 +1,28 @@
|
|||||||
package com.seibel.distanthorizons.common.wrappers.world;
|
package com.seibel.distanthorizons.common.wrappers.world;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiLevelType;
|
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiLevelType;
|
||||||
|
import com.seibel.distanthorizons.api.interfaces.block.IDhApiBiomeWrapper;
|
||||||
|
import com.seibel.distanthorizons.api.interfaces.block.IDhApiBlockStateWrapper;
|
||||||
import com.seibel.distanthorizons.api.interfaces.render.IDhApiCustomRenderRegister;
|
import com.seibel.distanthorizons.api.interfaces.render.IDhApiCustomRenderRegister;
|
||||||
|
import com.seibel.distanthorizons.api.objects.DhApiResult;
|
||||||
|
import com.seibel.distanthorizons.api.objects.data.IDhApiFullDataSource;
|
||||||
import com.seibel.distanthorizons.common.wrappers.block.BiomeWrapper;
|
import com.seibel.distanthorizons.common.wrappers.block.BiomeWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper;
|
import com.seibel.distanthorizons.common.wrappers.block.BlockStateWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.block.ClientBlockStateColorCache;
|
import com.seibel.distanthorizons.common.wrappers.block.ClientBlockStateColorCache;
|
||||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
|
||||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper;
|
|
||||||
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
|
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
|
||||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||||
import com.seibel.distanthorizons.core.level.*;
|
import com.seibel.distanthorizons.core.level.*;
|
||||||
import com.seibel.distanthorizons.core.level.IServerKeyedClientLevel;
|
import com.seibel.distanthorizons.core.level.IServerKeyedClientLevel;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
|
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
|
||||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPosMutable;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IDimensionTypeWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IDimensionTypeWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
@@ -32,7 +34,6 @@ import net.minecraft.client.multiplayer.ClientLevel;
|
|||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
|
||||||
#endif
|
#endif
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
|
||||||
@@ -53,7 +54,6 @@ import java.util.function.Function;
|
|||||||
#elif MC_VER <= MC_1_20_4
|
#elif MC_VER <= MC_1_20_4
|
||||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||||
#else
|
#else
|
||||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
@@ -88,6 +88,10 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
private static final Minecraft MINECRAFT = Minecraft.getInstance();
|
private static final Minecraft MINECRAFT = Minecraft.getInstance();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
private static final ThreadLocal<DhBlockPosMutable> MUTABLE_BLOCK_POS_THREAD_LOCAL = ThreadLocal.withInitial(DhBlockPosMutable::new);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
private final WorldClient level;
|
private final WorldClient level;
|
||||||
private final ConcurrentHashMap<IBlockState, ClientBlockStateColorCache> blockColorCacheByBlockState = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<IBlockState, ClientBlockStateColorCache> blockColorCacheByBlockState = new ConcurrentHashMap<>();
|
||||||
@@ -255,7 +259,9 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
//region
|
//region
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBlockColor(DhBlockPos blockPos, IBiomeWrapper biome, FullDataSourceV2 fullDataSource, IBlockStateWrapper blockWrapper)
|
public int getBlockColor(
|
||||||
|
DhBlockPos blockWorldPos, IBiomeWrapper biome, FullDataSourceV2 fullDataSource, IBlockStateWrapper blockWrapper,
|
||||||
|
boolean allowApiOverride)
|
||||||
{
|
{
|
||||||
ClientBlockStateColorCache blockColorCache = this.blockColorCacheByBlockState.get(((BlockStateWrapper) blockWrapper).blockState);
|
ClientBlockStateColorCache blockColorCache = this.blockColorCacheByBlockState.get(((BlockStateWrapper) blockWrapper).blockState);
|
||||||
if (blockColorCache == null)
|
if (blockColorCache == null)
|
||||||
@@ -265,7 +271,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
this.createCachedBlockColorCacheFunc);
|
this.createCachedBlockColorCacheFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return blockColorCache.getColor((BiomeWrapper) biome, fullDataSource, blockPos);
|
return blockColorCache.getColor((BiomeWrapper) biome, fullDataSource, blockWorldPos, allowApiOverride);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -289,7 +295,14 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearBlockColorCache() { this.blockColorCacheByBlockState.clear(); }
|
public void clearBlockColorCache()
|
||||||
|
{
|
||||||
|
this.blockColorCacheByBlockState.clear();
|
||||||
|
|
||||||
|
// this technically only needs to be called once globally, but it's easier
|
||||||
|
// to handle here statically
|
||||||
|
ClientBlockStateColorCache.clearCachedTints();
|
||||||
|
}
|
||||||
|
|
||||||
private IDimensionTypeWrapper dimensionTypeWrapper = null;
|
private IDimensionTypeWrapper dimensionTypeWrapper = null;
|
||||||
@Override
|
@Override
|
||||||
@@ -448,6 +461,45 @@ public class ClientLevelWrapper implements IClientLevelWrapper
|
|||||||
return this.dhLevel.getSaveStructure().getSaveFolder(this);
|
return this.dhLevel.getSaveStructure().getSaveFolder(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DhApiResult<Color> getBlockColorPreApi(
|
||||||
|
IDhApiBlockStateWrapper blockStateWrapper,
|
||||||
|
IDhApiBiomeWrapper biomeWrapper,
|
||||||
|
int blockWorldPosX, int blockWorldPosY, int blockWorldPosZ,
|
||||||
|
IDhApiFullDataSource dataSource)
|
||||||
|
{
|
||||||
|
// cast to core objects //
|
||||||
|
//region
|
||||||
|
|
||||||
|
if(!(blockStateWrapper instanceof IBlockStateWrapper coreBlockStateWrapper))
|
||||||
|
{
|
||||||
|
return DhApiResult.createFail("Unable to cast ["+blockStateWrapper.getClass()+"] to ["+IBlockStateWrapper.class+"]");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!(biomeWrapper instanceof IBiomeWrapper coreBiomeWrapper))
|
||||||
|
{
|
||||||
|
return DhApiResult.createFail("Unable to cast ["+biomeWrapper.getClass()+"] to ["+IBiomeWrapper.class+"]");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!(dataSource instanceof FullDataSourceV2 coreDataSource))
|
||||||
|
{
|
||||||
|
return DhApiResult.createFail("Unable to cast ["+dataSource.getClass()+"] to ["+FullDataSourceV2.class+"]");
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// use a mutable thread local to reduce allocations slightly
|
||||||
|
DhBlockPosMutable blockWorldPos = MUTABLE_BLOCK_POS_THREAD_LOCAL.get();
|
||||||
|
blockWorldPos.setX(blockWorldPosX);
|
||||||
|
blockWorldPos.setY(blockWorldPosY);
|
||||||
|
blockWorldPos.setZ(blockWorldPosZ);
|
||||||
|
|
||||||
|
int color = this.getBlockColor(blockWorldPos, coreBiomeWrapper, coreDataSource, coreBlockStateWrapper, false);
|
||||||
|
return DhApiResult.createSuccess(ColorUtil.toColorObjARGB(color));
|
||||||
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+28
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.common.wrappers.world;
|
package com.seibel.distanthorizons.common.wrappers.world;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -26,21 +27,30 @@ import java.util.Map;
|
|||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiLevelType;
|
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiLevelType;
|
||||||
|
import com.seibel.distanthorizons.api.interfaces.block.IDhApiBiomeWrapper;
|
||||||
|
import com.seibel.distanthorizons.api.interfaces.block.IDhApiBlockStateWrapper;
|
||||||
import com.seibel.distanthorizons.api.interfaces.render.IDhApiCustomRenderRegister;
|
import com.seibel.distanthorizons.api.interfaces.render.IDhApiCustomRenderRegister;
|
||||||
|
import com.seibel.distanthorizons.api.objects.DhApiResult;
|
||||||
|
import com.seibel.distanthorizons.api.objects.data.IDhApiFullDataSource;
|
||||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||||
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
import com.seibel.distanthorizons.core.api.internal.SharedApi;
|
||||||
import com.seibel.distanthorizons.core.config.Config;
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
|
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
|
||||||
import com.seibel.distanthorizons.core.level.IDhLevel;
|
import com.seibel.distanthorizons.core.level.IDhLevel;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.network.messages.base.LevelInitMessage;
|
import com.seibel.distanthorizons.core.network.messages.base.LevelInitMessage;
|
||||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||||
|
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPosMutable;
|
||||||
import com.seibel.distanthorizons.core.world.EWorldEnvironment;
|
import com.seibel.distanthorizons.core.world.EWorldEnvironment;
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IServerLevelWrapper;
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
#else
|
#else
|
||||||
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
@@ -80,6 +90,7 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
|||||||
//==============//
|
//==============//
|
||||||
// constructors //
|
// constructors //
|
||||||
//==============//
|
//==============//
|
||||||
|
//region
|
||||||
|
|
||||||
public static ServerLevelWrapper getWrapper(#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif level)
|
public static ServerLevelWrapper getWrapper(#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif level)
|
||||||
{
|
{
|
||||||
@@ -104,11 +115,14 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
|||||||
this.KeyedLevelDimensionName = this.createKeyedLevelDimensionName();
|
this.KeyedLevelDimensionName = this.createKeyedLevelDimensionName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==================//
|
//==================//
|
||||||
// instance methods //
|
// instance methods //
|
||||||
//==================//
|
//==================//
|
||||||
|
//region
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File getMcSaveFolder()
|
public File getMcSaveFolder()
|
||||||
@@ -293,14 +307,28 @@ public class ServerLevelWrapper implements IServerLevelWrapper
|
|||||||
return this.dhLevel.getSaveStructure().getSaveFolder(this);
|
return this.dhLevel.getSaveStructure().getSaveFolder(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DhApiResult<Color> getBlockColorPreApi(
|
||||||
|
IDhApiBlockStateWrapper blockStateWrapper,
|
||||||
|
IDhApiBiomeWrapper biomeWrapper,
|
||||||
|
int blockWorldPosX, int blockWorldPosY, int blockWorldPosZ,
|
||||||
|
IDhApiFullDataSource dataSource)
|
||||||
|
{ return DhApiResult.createFail("["+ServerLevelWrapper.class.getSimpleName()+"]'s cannot get block colors, please use a ["+ClientLevelWrapper.class.getSimpleName()+"] instead."); }
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//================//
|
//================//
|
||||||
// base overrides //
|
// base overrides //
|
||||||
//================//
|
//================//
|
||||||
|
//region
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() { return "Wrapped{" + this.level.toString() + "@" + this.getDhIdentifier() + "}"; }
|
public String toString() { return "Wrapped{" + this.level.toString() + "@" + this.getDhIdentifier() + "}"; }
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-6
@@ -56,6 +56,7 @@ import java.util.concurrent.*;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
|
import net.minecraft.world.level.levelgen.Heightmap;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -672,12 +673,16 @@ public final class BatchGenerationEnvironment implements IBatchGeneratorEnvironm
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// throwIfThreadInterrupted();
|
// carvers heightmaps are needed by some world gen mods,
|
||||||
// // caves can generally be ignored since they aren't generally visible from far away
|
// otherwise unexpected issues may occur
|
||||||
// if (step == EDhApiWorldGenerationStep.CARVERS)
|
// (like trying to use an empty heightmap and walking out the bottom of
|
||||||
// {
|
// the world looking for a valid snow location).
|
||||||
// return;
|
throwIfThreadInterrupted();
|
||||||
// }
|
for (ChunkWrapper chunkWrapper : chunkWrappersToGenerate)
|
||||||
|
{
|
||||||
|
ChunkAccess chunk = chunkWrapper.getChunk();
|
||||||
|
Heightmap.primeHeightmaps(chunk, ChunkStatus.CARVERS.heightmapsAfter());
|
||||||
|
}
|
||||||
|
|
||||||
throwIfThreadInterrupted();
|
throwIfThreadInterrupted();
|
||||||
this.stepFeatures.generateGroup(genEvent.threadedParam, region, GetCutoutFrom(chunkWrappersToGenerate, EDhApiWorldGenerationStep.FEATURES));
|
this.stepFeatures.generateGroup(genEvent.threadedParam, region, GetCutoutFrom(chunkWrappersToGenerate, EDhApiWorldGenerationStep.FEATURES));
|
||||||
|
|||||||
+132
-39
@@ -31,6 +31,9 @@ import net.minecraft.world.WorldServer;
|
|||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraft.world.gen.ChunkProviderServer;
|
import net.minecraft.world.gen.ChunkProviderServer;
|
||||||
import net.minecraftforge.common.ForgeChunkManager;
|
import net.minecraftforge.common.ForgeChunkManager;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
||||||
|
import net.minecraft.world.storage.ThreadedFileIOBase;
|
||||||
#else
|
#else
|
||||||
import net.minecraft.server.level.ChunkHolder;
|
import net.minecraft.server.level.ChunkHolder;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
@@ -47,6 +50,7 @@ import net.minecraft.world.level.chunk.status.ChunkStatus;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.CompletionException;
|
import java.util.concurrent.CompletionException;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -91,7 +95,9 @@ public class InternalServerGenerator
|
|||||||
@Nullable
|
@Nullable
|
||||||
private final ChunkUpdateQueueManager updateManager;
|
private final ChunkUpdateQueueManager updateManager;
|
||||||
private final Timer chunkSaveIgnoreTimer = TimerUtil.CreateTimer("ChunkSaveIgnoreTimer");
|
private final Timer chunkSaveIgnoreTimer = TimerUtil.CreateTimer("ChunkSaveIgnoreTimer");
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
private static final java.util.concurrent.Semaphore chunkRequestSemaphore = new java.util.concurrent.Semaphore(20);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//=============//
|
//=============//
|
||||||
@@ -128,11 +134,29 @@ public class InternalServerGenerator
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
while (!isServerHealthy())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Don't submit request until server tps is healthy
|
||||||
|
Thread.sleep(50);
|
||||||
|
}
|
||||||
|
catch (InterruptedException e)
|
||||||
|
{
|
||||||
|
throw new CancellationException("Interrupted while waiting for server");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Iterator<ChunkPos> chunkPosIterator = ChunkPosGenStream.getIterator(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.widthInChunks, 0);
|
Iterator<ChunkPos> chunkPosIterator = ChunkPosGenStream.getIterator(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.widthInChunks, 0);
|
||||||
while (chunkPosIterator.hasNext())
|
while (chunkPosIterator.hasNext())
|
||||||
{
|
{
|
||||||
ChunkPos chunkPos = chunkPosIterator.next();
|
ChunkPos chunkPos = chunkPosIterator.next();
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
chunkRequestSemaphore.acquireUninterruptibly();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
CompletableFuture<Chunk> requestChunkFuture;
|
CompletableFuture<Chunk> requestChunkFuture;
|
||||||
#else
|
#else
|
||||||
@@ -145,6 +169,9 @@ public class InternalServerGenerator
|
|||||||
.whenCompleteAsync(
|
.whenCompleteAsync(
|
||||||
(chunk, throwable) ->
|
(chunk, throwable) ->
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
chunkRequestSemaphore.release();
|
||||||
|
#endif
|
||||||
// unwrap the CompletionException if necessary
|
// unwrap the CompletionException if necessary
|
||||||
Throwable actualThrowable = throwable;
|
Throwable actualThrowable = throwable;
|
||||||
while (actualThrowable instanceof CompletionException)
|
while (actualThrowable instanceof CompletionException)
|
||||||
@@ -155,9 +182,9 @@ public class InternalServerGenerator
|
|||||||
if (actualThrowable != null)
|
if (actualThrowable != null)
|
||||||
{
|
{
|
||||||
// ignore expected shutdown exceptions
|
// ignore expected shutdown exceptions
|
||||||
boolean isShutdownException =
|
boolean isShutdownException =
|
||||||
ExceptionUtil.isShutdownException(actualThrowable)
|
ExceptionUtil.isShutdownException(actualThrowable)
|
||||||
|| actualThrowable.getMessage().contains("Unloaded chunk");
|
|| actualThrowable.getMessage().contains("Unloaded chunk");
|
||||||
if (!isShutdownException)
|
if (!isShutdownException)
|
||||||
{
|
{
|
||||||
CHUNK_LOAD_LOGGER.warn("DistantHorizons: Couldn't load chunk [" + chunkPos + "] from server, error: [" + actualThrowable.getMessage() + "].", actualThrowable);
|
CHUNK_LOAD_LOGGER.warn("DistantHorizons: Couldn't load chunk [" + chunkPos + "] from server, error: [" + actualThrowable.getMessage() + "].", actualThrowable);
|
||||||
@@ -224,6 +251,9 @@ public class InternalServerGenerator
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
ArrayList<CompletableFuture<Void>> releaseFutures = new ArrayList<>();
|
ArrayList<CompletableFuture<Void>> releaseFutures = new ArrayList<>();
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
Set<Long> neighborIgnoreSet = new HashSet<>();
|
||||||
|
#endif
|
||||||
|
|
||||||
// release all chunks from the server to prevent out of memory issues
|
// 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);
|
Iterator<ChunkPos> chunkPosIterator = ChunkPosGenStream.getIterator(genEvent.minPos.getX(), genEvent.minPos.getZ(), genEvent.widthInChunks, 0);
|
||||||
@@ -231,7 +261,28 @@ public class InternalServerGenerator
|
|||||||
{
|
{
|
||||||
ChunkPos chunkPos = chunkPosIterator.next();
|
ChunkPos chunkPos = chunkPosIterator.next();
|
||||||
releaseFutures.add(this.releaseChunkFromServerAsync(this.params.mcServerLevel, chunkPos));
|
releaseFutures.add(this.releaseChunkFromServerAsync(this.params.mcServerLevel, chunkPos));
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
// collect unique neighbor positions for release and ignore removal
|
||||||
|
for (int dx = -1; dx <= 1; dx++)
|
||||||
|
{
|
||||||
|
for (int dz = -1; dz <= 1; dz++)
|
||||||
|
{
|
||||||
|
if (dx == 0 && dz == 0) continue;
|
||||||
|
neighborIgnoreSet.add(ChunkPos.asLong(chunkPos.x + dx, chunkPos.z + dz));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
// release neighbor chunks that were loaded in requestChunkFromServerAsync
|
||||||
|
for (long posLong : neighborIgnoreSet)
|
||||||
|
{
|
||||||
|
ChunkPos neighborPos = new ChunkPos(ChunkPos.getX(posLong), ChunkPos.getZ(posLong));
|
||||||
|
releaseFutures.add(this.releaseChunkFromServerAsync(this.params.mcServerLevel, neighborPos));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// wait for all release futures to finish to prevent an issue where DH queues
|
// wait for all release futures to finish to prevent an issue where DH queues
|
||||||
// tickets faster than MC can clear them out
|
// tickets faster than MC can clear them out
|
||||||
@@ -240,6 +291,45 @@ public class InternalServerGenerator
|
|||||||
CompletableFuture<Void> releaseFuture = releaseFutures.get(i);
|
CompletableFuture<Void> releaseFuture = releaseFutures.get(i);
|
||||||
releaseFuture.join();
|
releaseFuture.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tick after all unloads are queued
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
CompletableFuture<Void> tickFuture = new CompletableFuture<>();
|
||||||
|
this.params.mcServerLevel.getMinecraftServer().addScheduledTask(() ->
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ChunkProviderServer provider = this.params.mcServerLevel.getChunkProvider();
|
||||||
|
while (!provider.droppedChunks.isEmpty())
|
||||||
|
{
|
||||||
|
provider.tick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
tickFuture.complete(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tickFuture.join();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
for (long posLong : neighborIgnoreSet)
|
||||||
|
{
|
||||||
|
ChunkPos neighborPos = new ChunkPos(ChunkPos.getX(posLong), ChunkPos.getZ(posLong));
|
||||||
|
this.chunkSaveIgnoreTimer.schedule(new TimerTask()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (InternalServerGenerator.this.updateManager != null)
|
||||||
|
{
|
||||||
|
InternalServerGenerator.this.updateManager.removePosToIgnore(McObjectConverter.Convert(neighborPos));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, MS_TO_IGNORE_CHUNK_AFTER_COMPLETION);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void runValidation()
|
private void runValidation()
|
||||||
@@ -251,7 +341,7 @@ public class InternalServerGenerator
|
|||||||
throw new IllegalStateException("Internal server generation should be called from one of DH's world gen thread. Current thread: ["+Thread.currentThread().getName()+"]");
|
throw new IllegalStateException("Internal server generation should be called from one of DH's world gen thread. Current thread: ["+Thread.currentThread().getName()+"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MC_VER > MC_1_12_2
|
||||||
// C2ME present?
|
// C2ME present?
|
||||||
if (C2ME_ACCESSOR == null
|
if (C2ME_ACCESSOR == null
|
||||||
&& !c2meMissingWarningLogged)
|
&& !c2meMissingWarningLogged)
|
||||||
@@ -274,6 +364,7 @@ public class InternalServerGenerator
|
|||||||
|
|
||||||
LOGGER.warn(c2meWarning);
|
LOGGER.warn(c2meWarning);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
private CompletableFuture<Chunk> requestChunkFromServerAsync(ChunkPos chunkPos)
|
private CompletableFuture<Chunk> requestChunkFromServerAsync(ChunkPos chunkPos)
|
||||||
@@ -289,24 +380,25 @@ public class InternalServerGenerator
|
|||||||
{
|
{
|
||||||
this.updateManager.addPosToIgnore(McObjectConverter.Convert(chunkPos));
|
this.updateManager.addPosToIgnore(McObjectConverter.Convert(chunkPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
CompletableFuture<Chunk> future = new CompletableFuture<>();
|
CompletableFuture<Chunk> future = new CompletableFuture<>();
|
||||||
level.getMinecraftServer().addScheduledTask(() ->
|
level.getMinecraftServer().addScheduledTask(() ->
|
||||||
{
|
{
|
||||||
ChunkProviderServer provider = level.getChunkProvider();
|
ChunkProviderServer provider = level.getChunkProvider();
|
||||||
|
|
||||||
// load neighbors first so the target chunk can fully populate
|
// load neighbors first so the target chunk can fully populate
|
||||||
for (int i = -1; i <= 1; i++)
|
for (int dx = -1; dx <= 1; dx++)
|
||||||
{
|
{
|
||||||
for (int j = -1; j <= 1; j++)
|
for (int dz = -1; dz <= 1; dz++)
|
||||||
{
|
{
|
||||||
if (i != 0 || j != 0)
|
if (dx == 0 && dz == 0) continue;
|
||||||
|
if (this.updateManager != null)
|
||||||
{
|
{
|
||||||
if (this.updateManager != null)
|
this.updateManager.addPosToIgnore(new DhChunkPos(chunkPos.x + dx, chunkPos.z + dz));
|
||||||
{
|
}
|
||||||
this.updateManager.addPosToIgnore(new DhChunkPos(chunkPos.x + i, chunkPos.z + j));
|
if (provider.getLoadedChunk(chunkPos.x + dx, chunkPos.z + dz) == null)
|
||||||
}
|
{
|
||||||
provider.provideChunk(chunkPos.x + i, chunkPos.z + j);
|
provider.provideChunk(chunkPos.x + dx, chunkPos.z + dz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -380,32 +472,12 @@ public class InternalServerGenerator
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
for (int difX = -1; difX <= 1; difX++)
|
ChunkProviderServer provider = level.getChunkProvider();
|
||||||
|
|
||||||
|
Chunk chunk = provider.getLoadedChunk(chunkPos.x, chunkPos.z);
|
||||||
|
if (chunk != null)
|
||||||
{
|
{
|
||||||
for (int difZ = -1; difZ <= 1; difZ++)
|
provider.queueUnload(chunk);
|
||||||
{
|
|
||||||
if (difX != 0 || difZ != 0)
|
|
||||||
{
|
|
||||||
final int finalDifX = difX;
|
|
||||||
final int finalDifZ = difZ;
|
|
||||||
this.chunkSaveIgnoreTimer.schedule(new TimerTask()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if (InternalServerGenerator.this.updateManager != null)
|
|
||||||
{
|
|
||||||
InternalServerGenerator.this.updateManager.removePosToIgnore(
|
|
||||||
new DhChunkPos(
|
|
||||||
chunkPos.x + finalDifX,
|
|
||||||
chunkPos.z + finalDifZ
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, MS_TO_IGNORE_CHUNK_AFTER_COMPLETION);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#elif MC_VER < MC_1_21_5
|
#elif MC_VER < MC_1_21_5
|
||||||
int chunkLevel = 33; // 33 is equivalent to FULL Chunk
|
int chunkLevel = 33; // 33 is equivalent to FULL Chunk
|
||||||
@@ -428,7 +500,7 @@ public class InternalServerGenerator
|
|||||||
this.chunkSaveIgnoreTimer.schedule(new TimerTask()
|
this.chunkSaveIgnoreTimer.schedule(new TimerTask()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (InternalServerGenerator.this.updateManager != null)
|
if (InternalServerGenerator.this.updateManager != null)
|
||||||
{
|
{
|
||||||
@@ -452,4 +524,25 @@ public class InternalServerGenerator
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//======//
|
||||||
|
// misc //
|
||||||
|
//======//
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
private boolean isServerHealthy()
|
||||||
|
{
|
||||||
|
if(this.params.mcServerLevel.getMinecraftServer() == null) { return false; }
|
||||||
|
|
||||||
|
long[] ticks = this.params.mcServerLevel.getMinecraftServer().tickTimeArray;
|
||||||
|
long[] sorted = ticks.clone();
|
||||||
|
Arrays.sort(sorted);
|
||||||
|
|
||||||
|
int p99Index = (int)Math.ceil(0.99 * sorted.length) - 1;
|
||||||
|
double p99Ms = sorted[Math.max(0, p99Index)] * 1e-6;
|
||||||
|
double avgMs = Arrays.stream(sorted).average().orElse(0) * 1e-6;
|
||||||
|
|
||||||
|
return avgMs < 20.0 && p99Ms < 50.0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-7
@@ -94,7 +94,7 @@ public class DhLitWorldGenRegion extends WorldGenRegion
|
|||||||
public final int size;
|
public final int size;
|
||||||
|
|
||||||
private final DhChunkPos firstPos;
|
private final DhChunkPos firstPos;
|
||||||
private final List<ChunkAccess> cache;
|
private final List<ChunkAccess> chunkCacheList;
|
||||||
private final Long2ObjectOpenHashMap<ChunkAccess> chunkMap = new Long2ObjectOpenHashMap<ChunkAccess>();
|
private final Long2ObjectOpenHashMap<ChunkAccess> chunkMap = new Long2ObjectOpenHashMap<ChunkAccess>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,7 +158,7 @@ public class DhLitWorldGenRegion extends WorldGenRegion
|
|||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
this.lightEngine = lightEngine;
|
this.lightEngine = lightEngine;
|
||||||
this.writeRadius = writeRadius;
|
this.writeRadius = writeRadius;
|
||||||
this.cache = chunkList;
|
this.chunkCacheList = chunkList;
|
||||||
this.size = Mth.floor(Math.sqrt(chunkList.size()));
|
this.size = Mth.floor(Math.sqrt(chunkList.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,6 +294,24 @@ public class DhLitWorldGenRegion extends WorldGenRegion
|
|||||||
{
|
{
|
||||||
int chunkX = SectionPos.blockToSectionCoord(blockPos.getX());
|
int chunkX = SectionPos.blockToSectionCoord(blockPos.getX());
|
||||||
int chunkZ = SectionPos.blockToSectionCoord(blockPos.getZ());
|
int chunkZ = SectionPos.blockToSectionCoord(blockPos.getZ());
|
||||||
|
|
||||||
|
// No one should be trying to a block pos 1 million blocks
|
||||||
|
// above or below the world height.
|
||||||
|
// If that happens that likely means a mod is assuming DH populated the
|
||||||
|
// world/chunk in a certain way and that assumption isn't being met.
|
||||||
|
if (blockPos.getY() < -1_000_000
|
||||||
|
|| blockPos.getY() > 1_000_000)
|
||||||
|
{
|
||||||
|
// Throwing an exception here is done to break out of potential
|
||||||
|
// infinite loops where a mod attempts to walk down the level to find a specific block type.
|
||||||
|
// Example from WilderWild:
|
||||||
|
// https://github.com/FrozenBlock/WilderWild/blob/1eaaaa2179d837aac6ece002ff795eed665cd7b7/src/main/java/net/frozenblock/wilderwild/worldgen/impl/feature/SnowBlanketFeature.java#L95
|
||||||
|
throw new ArrayIndexOutOfBoundsException(
|
||||||
|
"Attempted to getBlockState outside the DH defined Y bounds [-1_000_000, 1_000_000]: ["+blockPos+"]. " +
|
||||||
|
"This is likely a mod compatibility issue, " +
|
||||||
|
"there is no reason to try getting a block this far outside the world during world gen.");
|
||||||
|
}
|
||||||
|
|
||||||
return this.getChunk(chunkX, chunkZ).getBlockState(blockPos);
|
return this.getChunk(chunkX, chunkZ).getBlockState(blockPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,8 +384,14 @@ public class DhLitWorldGenRegion extends WorldGenRegion
|
|||||||
*/
|
*/
|
||||||
private ChunkAccess getChunkAccess(int chunkX, int chunkZ, ChunkStatus chunkStatus, boolean returnNonNull)
|
private ChunkAccess getChunkAccess(int chunkX, int chunkZ, ChunkStatus chunkStatus, boolean returnNonNull)
|
||||||
{
|
{
|
||||||
ChunkAccess chunk = this.superHasChunk(chunkX, chunkZ) ? this.superGetChunk(chunkX, chunkZ) : null;
|
ChunkAccess chunk = null;
|
||||||
if (chunk != null && ChunkWrapper.getStatus(chunk).isOrAfter(chunkStatus))
|
if (this.dhHasChunk(chunkX, chunkZ))
|
||||||
|
{
|
||||||
|
chunk = this.dhGetChunk(chunkX, chunkZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chunk != null
|
||||||
|
&& ChunkWrapper.getStatus(chunk).isOrAfter(chunkStatus))
|
||||||
{
|
{
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
@@ -417,7 +441,7 @@ public class DhLitWorldGenRegion extends WorldGenRegion
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Use this instead of super.hasChunk() to bypass C2ME concurrency checks */
|
/** Use this instead of super.hasChunk() to bypass C2ME concurrency checks */
|
||||||
public boolean superHasChunk(int x, int z)
|
public boolean dhHasChunk(int x, int z)
|
||||||
{
|
{
|
||||||
int xOffset = x - this.firstPos.getX();
|
int xOffset = x - this.firstPos.getX();
|
||||||
int zOffset = z - this.firstPos.getZ();
|
int zOffset = z - this.firstPos.getZ();
|
||||||
@@ -426,11 +450,11 @@ public class DhLitWorldGenRegion extends WorldGenRegion
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Use this instead of super.getChunk() to bypass C2ME concurrency checks */
|
/** Use this instead of super.getChunk() to bypass C2ME concurrency checks */
|
||||||
private ChunkAccess superGetChunk(int x, int z)
|
private ChunkAccess dhGetChunk(int x, int z)
|
||||||
{
|
{
|
||||||
int xOffset = x - this.firstPos.getX();
|
int xOffset = x - this.firstPos.getX();
|
||||||
int zOffset = z - this.firstPos.getZ();
|
int zOffset = z - this.firstPos.getZ();
|
||||||
return this.cache.get(xOffset + zOffset * this.size);
|
return this.chunkCacheList.get(xOffset + zOffset * this.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
public net.minecraft.client.renderer.EntityRenderer getFOVModifier(FZ)F
|
public net.minecraft.client.renderer.EntityRenderer getFOVModifier(FZ)F
|
||||||
public net.minecraft.client.renderer.ActiveRenderInfo MODELVIEW
|
public net.minecraft.client.renderer.ActiveRenderInfo MODELVIEW
|
||||||
public net.minecraft.client.renderer.ActiveRenderInfo PROJECTION
|
public net.minecraft.client.renderer.ActiveRenderInfo PROJECTION
|
||||||
|
public net.minecraft.client.gui.GuiSlot amountScrolled
|
||||||
|
public net.minecraft.world.gen.ChunkProviderServer droppedChunks
|
||||||
@@ -4,7 +4,9 @@ Thanks for your interest in contributing to Distant Horizons!
|
|||||||
|
|
||||||
Check out the [Core Wiki](https://gitlab.com/jeseibel/distant-horizons-core/-/wikis/home) for a rough overview of Distant Horizon's project structure.
|
Check out the [Core Wiki](https://gitlab.com/jeseibel/distant-horizons-core/-/wikis/home) for a rough overview of Distant Horizon's project structure.
|
||||||
|
|
||||||
|
## Translations
|
||||||
|
|
||||||
|
See [translations.md](translations.md) for the Crowdin workflow.
|
||||||
|
|
||||||
## Submitting a merge request
|
## Submitting a merge request
|
||||||
|
|
||||||
|
|||||||
+1
-1
Submodule coreSubProjects updated: fd3a8f7ddf...9231a48998
@@ -0,0 +1,8 @@
|
|||||||
|
project_id_env: CROWDIN_PROJECT_ID
|
||||||
|
api_token_env: CROWDIN_PERSONAL_TOKEN
|
||||||
|
base_path: ./coreSubProjects/core/src/main/resources/assets/distanthorizons/lang
|
||||||
|
preserve_hierarchy: true
|
||||||
|
files:
|
||||||
|
- source: /en_us.json
|
||||||
|
translation: /%locale_with_underscore%.json
|
||||||
|
type: json
|
||||||
+5
-2
@@ -17,8 +17,11 @@ dependencies {
|
|||||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||||
|
|
||||||
// Fabric API (bundled as jar-in-jar so users don't need to install it separately)
|
// Fabric API (bundled as jar-in-jar so users don't need to install it separately)
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
|
modImplementation ("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}")
|
||||||
include "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
|
include ("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}") {
|
||||||
|
// including the gametest API can cause issues for other mods if included in our jar
|
||||||
|
exclude module: "fabric-gametest-api-v1"
|
||||||
|
}
|
||||||
|
|
||||||
// Mod Menu
|
// Mod Menu
|
||||||
addMod("com.terraformersmc:modmenu:${rootProject.modmenu_version}", rootProject.enable_mod_menu)
|
addMod("com.terraformersmc:modmenu:${rootProject.modmenu_version}", rootProject.enable_mod_menu)
|
||||||
|
|||||||
@@ -98,9 +98,6 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
private static final MinecraftClientWrapper MC = MinecraftClientWrapper.INSTANCE;
|
private static final MinecraftClientWrapper MC = MinecraftClientWrapper.INSTANCE;
|
||||||
private static final AbstractPluginPacketSender PACKET_SENDER = (AbstractPluginPacketSender) SingletonInjector.INSTANCE.get(IPluginPacketSender.class);
|
private static final AbstractPluginPacketSender PACKET_SENDER = (AbstractPluginPacketSender) SingletonInjector.INSTANCE.get(IPluginPacketSender.class);
|
||||||
|
|
||||||
@Deprecated // just use the static reference
|
|
||||||
private static final ClientApi clientApi = ClientApi.INSTANCE;
|
|
||||||
|
|
||||||
HashSet<Integer> previouslyPressKeyCodes = new HashSet<>();
|
HashSet<Integer> previouslyPressKeyCodes = new HashSet<>();
|
||||||
|
|
||||||
|
|
||||||
@@ -244,7 +241,7 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, renderContext.world());
|
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, renderContext.world());
|
||||||
|
|
||||||
|
|
||||||
this.clientApi.renderLods();
|
ClientApi.INSTANCE.renderLods();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -267,7 +264,7 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, renderContext.world());
|
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, renderContext.world());
|
||||||
|
|
||||||
|
|
||||||
this.clientApi.renderFadeOpaque();
|
ClientApi.INSTANCE.renderFadeOpaque();
|
||||||
});
|
});
|
||||||
|
|
||||||
WorldRenderEvents.AFTER_TRANSLUCENT.register((renderContext) ->
|
WorldRenderEvents.AFTER_TRANSLUCENT.register((renderContext) ->
|
||||||
@@ -297,7 +294,7 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
ClientApi.INSTANCE.renderDeferredLodsForShaders();
|
ClientApi.INSTANCE.renderDeferredLodsForShaders();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this.clientApi.renderFadeTransparent();
|
ClientApi.INSTANCE.renderFadeTransparent();
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -327,10 +324,11 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
|
|||||||
// FIXME: Use better hooks so it doesn't trigger key press events in text boxes
|
// FIXME: Use better hooks so it doesn't trigger key press events in text boxes
|
||||||
ClientTickEvents.END_CLIENT_TICK.register(client ->
|
ClientTickEvents.END_CLIENT_TICK.register(client ->
|
||||||
{
|
{
|
||||||
if (client.player != null && !(Minecraft.getInstance().screen instanceof TitleScreen))
|
// TODO
|
||||||
{
|
//if (client.player != null && !(Minecraft.getInstance().screen instanceof TitleScreen))
|
||||||
this.onKeyInput();
|
//{
|
||||||
}
|
// this.onKeyInput();
|
||||||
|
//}
|
||||||
});
|
});
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
package com.seibel.distanthorizons.fabric;
|
package com.seibel.distanthorizons.fabric;
|
||||||
|
|
||||||
import com.seibel.distanthorizons.api.DhApi;
|
import com.seibel.distanthorizons.api.DhApi;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBlockColorOverrideEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.*;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBlockStateWrapperCreatedEvent;
|
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiChunkProcessingEvent;
|
|
||||||
import com.seibel.distanthorizons.api.methods.events.DhApiEventRegister;
|
import com.seibel.distanthorizons.api.methods.events.DhApiEventRegister;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiLevelLoadEvent;
|
|
||||||
import com.seibel.distanthorizons.common.AbstractModInitializer;
|
import com.seibel.distanthorizons.common.AbstractModInitializer;
|
||||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||||
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
|
||||||
@@ -18,10 +15,7 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
|||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||||
import com.seibel.distanthorizons.fabric.testing.TestBlockWrapperCreatedEvent;
|
import com.seibel.distanthorizons.fabric.testing.*;
|
||||||
import com.seibel.distanthorizons.fabric.testing.TestChunkInputReplacerEvent;
|
|
||||||
import com.seibel.distanthorizons.fabric.testing.TestCustomColorEvent;
|
|
||||||
import com.seibel.distanthorizons.fabric.testing.TestWorldGenBindingEvent;
|
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||||
@@ -106,6 +100,12 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
|
|||||||
DhApi.events.bind(DhApiBlockColorOverrideEvent.class, new TestCustomColorEvent());
|
DhApi.events.bind(DhApiBlockColorOverrideEvent.class, new TestCustomColorEvent());
|
||||||
DhApi.events.bind(DhApiBlockStateWrapperCreatedEvent.class, new TestBlockWrapperCreatedEvent());
|
DhApi.events.bind(DhApiBlockStateWrapperCreatedEvent.class, new TestBlockWrapperCreatedEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test fog override
|
||||||
|
if (false)
|
||||||
|
{
|
||||||
|
DhApi.events.bind(DhApiBeforeFogRenderEvent.class, new TestFogRenderEvent());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
@@ -93,7 +93,10 @@ public class MixinChunkSectionsToRender
|
|||||||
@Inject(at = @At("HEAD"), method = "renderGroup", order = 800)
|
@Inject(at = @At("HEAD"), method = "renderGroup", order = 800)
|
||||||
private void renderDeferredLayerHead(ChunkSectionLayerGroup chunkSectionLayerGroup, GpuSampler gpuSampler, CallbackInfo ci)
|
private void renderDeferredLayerHead(ChunkSectionLayerGroup chunkSectionLayerGroup, GpuSampler gpuSampler, CallbackInfo ci)
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, Minecraft.getInstance().levelRenderer.level);
|
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, Minecraft.getInstance().levelRenderer.level);
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
ClientApi.RENDER_STATE.canRenderOrThrow();
|
ClientApi.RENDER_STATE.canRenderOrThrow();
|
||||||
|
|||||||
+13
@@ -29,8 +29,11 @@ public class MixinGameRenderer {}
|
|||||||
#else
|
#else
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||||
import net.minecraft.client.DeltaTracker;
|
import net.minecraft.client.DeltaTracker;
|
||||||
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.client.renderer.state.OptionsRenderState;
|
import net.minecraft.client.renderer.state.OptionsRenderState;
|
||||||
@@ -71,6 +74,16 @@ public class MixinGameRenderer
|
|||||||
final Matrix4f projectionMatrix,
|
final Matrix4f projectionMatrix,
|
||||||
final PoseStack poseStack)
|
final PoseStack poseStack)
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
|
#else
|
||||||
|
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, (ClientLevel)player.level());
|
||||||
|
|
||||||
|
ClientApi.RENDER_STATE.mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrix);
|
||||||
|
|
||||||
|
ClientApi.RENDER_STATE.partialTickTime = MinecraftRenderWrapper.INSTANCE.getPartialTickTime();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
ClientApi.RENDER_STATE.mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix);
|
ClientApi.RENDER_STATE.mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
@@ -94,8 +94,11 @@ import com.seibel.distanthorizons.core.logging.DhLogger;
|
|||||||
@Mixin(LevelRenderer.class)
|
@Mixin(LevelRenderer.class)
|
||||||
public class MixinLevelRenderer
|
public class MixinLevelRenderer
|
||||||
{
|
{
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
@Shadow
|
@Shadow
|
||||||
private ClientLevel level;
|
private ClientLevel level;
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
@@ -220,12 +223,14 @@ public class MixinLevelRenderer
|
|||||||
#if MC_VER <= MC_1_21_11
|
#if MC_VER <= MC_1_21_11
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
@Inject(at = @At("HEAD"), method = "prepareChunkRenders")
|
@Inject(at = @At("HEAD"), method = "prepareChunkRenders")
|
||||||
private void prepareChunkRenders(final Matrix4fc modelViewMatrix, CallbackInfoReturnable<ChunkSectionsToRender> callback)
|
private void prepareChunkRenders(final Matrix4fc modelViewMatrix, CallbackInfoReturnable<ChunkSectionsToRender> callback)
|
||||||
{
|
{
|
||||||
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, this.level);
|
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, this.level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "renderLevel")
|
@Inject(at = @At("HEAD"), method = "renderLevel")
|
||||||
public void renderLevel(
|
public void renderLevel(
|
||||||
final GraphicsResourceAllocator resourceAllocator, final DeltaTracker deltaTracker,
|
final GraphicsResourceAllocator resourceAllocator, final DeltaTracker deltaTracker,
|
||||||
@@ -241,6 +246,9 @@ public class MixinLevelRenderer
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|||||||
+14
-1
@@ -111,13 +111,26 @@ public class MixinLightTexture
|
|||||||
#elif MC_VER <= MC_1_21_10
|
#elif MC_VER <= MC_1_21_10
|
||||||
GlTexture glTexture = (GlTexture) this.texture;
|
GlTexture glTexture = (GlTexture) this.texture;
|
||||||
this.renderWrapper.setLightmapId(glTexture.glId(), clientLevel);
|
this.renderWrapper.setLightmapId(glTexture.glId(), clientLevel);
|
||||||
#else
|
#elif MC_VER <= MC_26_1_2
|
||||||
// both options are available since the renderer can be changed to either Blaze3D or OpenGL
|
// both options are available since the renderer can be changed to either Blaze3D or OpenGL
|
||||||
GlTexture glTexture = (GlTexture) this.texture;
|
GlTexture glTexture = (GlTexture) this.texture;
|
||||||
this.renderWrapper.setLightmapId(glTexture.glId(), clientLevel);
|
this.renderWrapper.setLightmapId(glTexture.glId(), clientLevel);
|
||||||
|
|
||||||
|
this.renderWrapper.setLightmapGpuTexture(this.texture, clientLevel);
|
||||||
|
#else
|
||||||
|
|
||||||
|
// this will only be used when using native GL rendering
|
||||||
|
if (this.texture instanceof GlTexture)
|
||||||
|
{
|
||||||
|
GlTexture glTexture = (GlTexture) this.texture;
|
||||||
|
this.renderWrapper.setLightmapId(glTexture.glId(), clientLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
// this will be used for Blaze3D OpenGL and Vulkan
|
||||||
this.renderWrapper.setLightmapGpuTexture(this.texture, clientLevel);
|
this.renderWrapper.setLightmapGpuTexture(this.texture, clientLevel);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+8
@@ -88,11 +88,19 @@ public abstract class MixinMinecraft
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MC_VER >= MC_1_20_2
|
#if MC_VER >= MC_1_20_2
|
||||||
|
#if MC_VER <= MC_26_1_2
|
||||||
@Redirect(
|
@Redirect(
|
||||||
method = "Lnet/minecraft/client/Minecraft;onGameLoadFinished(Lnet/minecraft/client/Minecraft$GameLoadCookie;)V",
|
method = "Lnet/minecraft/client/Minecraft;onGameLoadFinished(Lnet/minecraft/client/Minecraft$GameLoadCookie;)V",
|
||||||
at = @At(value = "INVOKE", target = "Ljava/lang/Runnable;run()V")
|
at = @At(value = "INVOKE", target = "Ljava/lang/Runnable;run()V")
|
||||||
)
|
)
|
||||||
private void buildInitialScreens(Runnable runnable)
|
private void buildInitialScreens(Runnable runnable)
|
||||||
|
#else
|
||||||
|
@Redirect(
|
||||||
|
method = "Lnet/minecraft/client/Minecraft;onGameLoadFinished(Lnet/minecraft/client/GameLoadCookie;)V",
|
||||||
|
at = @At(value = "INVOKE", target = "Ljava/lang/Runnable;run()V")
|
||||||
|
)
|
||||||
|
private void buildInitialScreens(Runnable runnable)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
DhUpdateScreenBase.tryShowUpdateScreenAndRunAutoUpdateStartup(runnable);
|
DhUpdateScreenBase.tryShowUpdateScreenAndRunAutoUpdateStartup(runnable);
|
||||||
runnable.run();
|
runnable.run();
|
||||||
|
|||||||
+2
-2
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.seibel.distanthorizons.fabric.mixins.client;
|
package com.seibel.distanthorizons.fabric.mixins.client;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.gui.DhScreenUtil;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.GetConfigScreen;
|
import com.seibel.distanthorizons.common.wrappers.gui.GetConfigScreen;
|
||||||
import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget;
|
import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget;
|
||||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
@@ -34,7 +35,6 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
#if MC_VER >= MC_1_20_6
|
#if MC_VER >= MC_1_20_6
|
||||||
@@ -147,7 +147,7 @@ public class MixinOptionsScreen extends Screen
|
|||||||
20, ICON_TEXTURE, 20, 40,
|
20, ICON_TEXTURE, 20, 40,
|
||||||
// Create the button and tell it where to go
|
// Create the button and tell it where to go
|
||||||
// For now it goes to the client option by default
|
// For now it goes to the client option by default
|
||||||
(buttonWidget) -> Objects.requireNonNull(this.minecraft).setScreen(GetConfigScreen.getScreen(this)),
|
(buttonWidget) -> DhScreenUtil.setScreen(GetConfigScreen.getScreen(this)),
|
||||||
// Add a title to the button
|
// Add a title to the button
|
||||||
#if MC_VER < MC_1_19_2
|
#if MC_VER < MC_1_19_2
|
||||||
new TranslatableComponent(ModInfo.ID + ".title"));
|
new TranslatableComponent(ModInfo.ID + ".title"));
|
||||||
|
|||||||
+24
-12
@@ -24,18 +24,19 @@ public abstract class MixinSharedConstants
|
|||||||
@Mutable
|
@Mutable
|
||||||
@Shadow @Final public static boolean IS_RUNNING_IN_IDE;
|
@Shadow @Final public static boolean IS_RUNNING_IN_IDE;
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private static final DhLogger DH_LOGGER = new DhLoggerBuilder().name("SharedConstants").build();
|
||||||
|
|
||||||
|
|
||||||
@Inject(method = "<clinit>", at = @At("TAIL"))
|
@Inject(method = "<clinit>", at = @At("TAIL"))
|
||||||
private static void setIsRunningInIde(CallbackInfo ci)
|
private static void setIsRunningInIde(CallbackInfo ci)
|
||||||
{
|
{
|
||||||
DhLogger logger = new DhLoggerBuilder().name("SharedConstants").build();
|
|
||||||
|
|
||||||
// setting IS_RUNNING_IN_IDE to true enables
|
// setting IS_RUNNING_IN_IDE to true enables
|
||||||
// additional validation on Mojang's side which
|
// additional validation on Mojang's side which
|
||||||
// helps catch errors when developing for Blaze3D
|
// helps catch errors when developing for Blaze3D
|
||||||
|
|
||||||
boolean irisPresent;
|
boolean brokenIrisVersionPresent = false;
|
||||||
#if MC_VER <= MC_1_21_11
|
#if MC_VER <= MC_1_21_11
|
||||||
IS_RUNNING_IN_IDE = ModInfo.IS_DEV_BUILD;
|
|
||||||
#else
|
#else
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -44,17 +45,28 @@ public abstract class MixinSharedConstants
|
|||||||
// Blaze3D validation is enabled (which is enabled by if
|
// Blaze3D validation is enabled (which is enabled by if
|
||||||
// IS_RUNNING_IN_IDE is true)
|
// IS_RUNNING_IN_IDE is true)
|
||||||
ModInfo.class.getClassLoader().loadClass("net.irisshaders.iris.api.v0.IrisApi");
|
ModInfo.class.getClassLoader().loadClass("net.irisshaders.iris.api.v0.IrisApi");
|
||||||
irisPresent = true;
|
brokenIrisVersionPresent = true;
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException ignore)
|
catch (ClassNotFoundException ignore) { }
|
||||||
{
|
|
||||||
irisPresent = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
IS_RUNNING_IN_IDE = ModInfo.IS_DEV_BUILD && !irisPresent;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
logger.info("Setting Minecraft's SharedConstants.IS_RUNNING_IN_IDE to ["+IS_RUNNING_IN_IDE+"]");
|
boolean wilderWildPresent = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Wilder Wild will refuse to launch if
|
||||||
|
// "IS_RUNNING_IN_IDE" is true
|
||||||
|
// not sure why
|
||||||
|
ModInfo.class.getClassLoader().loadClass("net.frozenblock.wilderwild.WilderWild");
|
||||||
|
wilderWildPresent = true;
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException ignore) { }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
IS_RUNNING_IN_IDE = ModInfo.IS_DEV_BUILD
|
||||||
|
&& !brokenIrisVersionPresent
|
||||||
|
&& !wilderWildPresent;
|
||||||
|
DH_LOGGER.info("DH is setting Minecraft's SharedConstants.IS_RUNNING_IN_IDE to ["+IS_RUNNING_IN_IDE+"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+39
-2
@@ -1,13 +1,19 @@
|
|||||||
package com.seibel.distanthorizons.fabric.testing;
|
package com.seibel.distanthorizons.fabric.testing;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.DhApi;
|
||||||
|
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiLevelType;
|
||||||
|
import com.seibel.distanthorizons.api.interfaces.block.IDhApiBlockStateWrapper;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBlockColorOverrideEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBlockColorOverrideEvent;
|
||||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam;
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiEventParam;
|
||||||
|
import com.seibel.distanthorizons.api.objects.DhApiResult;
|
||||||
|
import com.seibel.distanthorizons.common.wrappers.WrapperFactory;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||||
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see TestBlockWrapperCreatedEvent
|
* @see TestBlockWrapperCreatedEvent
|
||||||
@@ -19,14 +25,15 @@ public class TestCustomColorEvent extends DhApiBlockColorOverrideEvent
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void blockStateWrapperCreated(DhApiEventParam<EventParam> event)
|
public void onBlockColorOverridden(DhApiEventParam<EventParam> event)
|
||||||
{
|
{
|
||||||
EventParam eventParam = event.value;
|
EventParam eventParam = event.value;
|
||||||
|
|
||||||
//randomDatapointColors(eventParam);
|
//randomDatapointColors(eventParam);
|
||||||
//randomPerBlockColors(eventParam);
|
//randomPerBlockColors(eventParam);
|
||||||
//blackWhitePositionStripe(eventParam);
|
//blackWhitePositionStripe(eventParam);
|
||||||
positionRainbow(eventParam);
|
useWaterTint(eventParam);
|
||||||
|
//positionRainbow(eventParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** each datapoint has a random color */
|
/** each datapoint has a random color */
|
||||||
@@ -58,6 +65,36 @@ public class TestCustomColorEvent extends DhApiBlockColorOverrideEvent
|
|||||||
eventParam.setColor(r,g,b);
|
eventParam.setColor(r,g,b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** every block will be rendered using water's color */
|
||||||
|
private void useWaterTint(EventParam eventParam)
|
||||||
|
{
|
||||||
|
IDhApiBlockStateWrapper blockWrapper;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String blockNamespace = "minecraft:water"; // everything is a shade of blue (except swamps)
|
||||||
|
//String blockNamespace = "minecraft:oak_leaves"; // alternative example using oak leaves (everything is a shade of green)
|
||||||
|
blockWrapper = DhApi.Delayed.wrapperFactory.getDefaultBlockStateWrapper(blockNamespace, eventParam.getLevelWrapper());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
blockWrapper = eventParam.getBlockStateWrapper();
|
||||||
|
}
|
||||||
|
|
||||||
|
DhApiResult<Color> result = eventParam.getLevelWrapper().getBlockColorPreApi(
|
||||||
|
blockWrapper,
|
||||||
|
eventParam.getBiomeWrapper(),
|
||||||
|
eventParam.getBlockPosX(), eventParam.getBlockPosY(), eventParam.getBlockPosZ(),
|
||||||
|
eventParam.getDataSource()
|
||||||
|
);
|
||||||
|
if (!result.success)
|
||||||
|
{
|
||||||
|
// shouldn't happen, but just in case
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
eventParam.setColor(result.payload.getRed(), result.payload.getGreen(), result.payload.getBlue());
|
||||||
|
}
|
||||||
|
|
||||||
private void blackWhitePositionStripe(EventParam eventParam)
|
private void blackWhitePositionStripe(EventParam eventParam)
|
||||||
{
|
{
|
||||||
// black-white stripes
|
// black-white stripes
|
||||||
|
|||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
package com.seibel.distanthorizons.fabric.testing;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeFogRenderEvent;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiCancelableEventParam;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiFogRenderParam;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiMutableFogRenderParam;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
|
|
||||||
|
public class TestFogRenderEvent extends DhApiBeforeFogRenderEvent
|
||||||
|
{
|
||||||
|
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||||
|
|
||||||
|
private static final float INCREMENT_PER_SECOND = 0.25f;
|
||||||
|
|
||||||
|
|
||||||
|
private float lastFar = 1;
|
||||||
|
private long lastUpdateTime = System.nanoTime();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeRender(DhApiCancelableEventParam<EventParam> event)
|
||||||
|
{
|
||||||
|
EventParam eventParam = event.value;
|
||||||
|
DhApiFogRenderParam originalParms = eventParam.getOriginalFogRenderParam();
|
||||||
|
DhApiMutableFogRenderParam mutableParms = eventParam.getFogRenderParam();
|
||||||
|
|
||||||
|
long currentTime = System.nanoTime();
|
||||||
|
float deltaSeconds = (currentTime - this.lastUpdateTime) / 1_000_000_000f;
|
||||||
|
this.lastUpdateTime = currentTime;
|
||||||
|
|
||||||
|
this.lastFar += INCREMENT_PER_SECOND * deltaSeconds;
|
||||||
|
if (this.lastFar >= originalParms.getFarFogEndPercent())
|
||||||
|
{
|
||||||
|
this.lastFar = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
mutableParms.setFarFogStartPercent(this.lastFar);
|
||||||
|
mutableParms.setFarFogEndPercent(this.lastFar + 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+5
-5
@@ -27,20 +27,20 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IIrisAccess
|
|||||||
import net.coderbot.iris.Iris;
|
import net.coderbot.iris.Iris;
|
||||||
import net.irisshaders.iris.api.v0.IrisApi;
|
import net.irisshaders.iris.api.v0.IrisApi;
|
||||||
#else
|
#else
|
||||||
import net.irisshaders.iris.Iris;
|
//import net.irisshaders.iris.Iris;
|
||||||
import net.irisshaders.iris.api.v0.IrisApi;
|
//import net.irisshaders.iris.api.v0.IrisApi;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public class IrisAccessor implements IIrisAccessor
|
public class IrisAccessor implements IIrisAccessor
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public String getModName() { return Iris.MODID; }
|
public String getModName() { return /*Iris.MODID;*/ ""; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isShaderPackInUse() { return IrisApi.getInstance().isShaderPackInUse(); }
|
public boolean isShaderPackInUse() { return false;/*IrisApi.getInstance().isShaderPackInUse();*/ }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRenderingShadowPass() { return IrisApi.getInstance().isRenderingShadowPass(); }
|
public boolean isRenderingShadowPass() { return false;/*IrisApi.getInstance().isRenderingShadowPass();*/ }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ org.gradle.caching=true
|
|||||||
mod_name=DistantHorizons
|
mod_name=DistantHorizons
|
||||||
api_name=DistantHorizonsApi
|
api_name=DistantHorizonsApi
|
||||||
mod_version=3.0.4-b-dev
|
mod_version=3.0.4-b-dev
|
||||||
api_version=6.1.1
|
api_version=7.0.0
|
||||||
maven_group=com.seibel.distanthorizons
|
maven_group=com.seibel.distanthorizons
|
||||||
mod_readable_name=Distant Horizons
|
mod_readable_name=Distant Horizons
|
||||||
mod_id=distanthorizons
|
mod_id=distanthorizons
|
||||||
|
|||||||
+4
-4
@@ -23,12 +23,12 @@ public class NeoforgeMinecraftRenderWrapper extends MinecraftRenderWrapper
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDepthTextureId()
|
public int getGlDepthTextureId()
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_21_9
|
#if MC_VER < MC_1_21_9
|
||||||
// no special handling required,
|
// no special handling required,
|
||||||
// both neo/fabric uses the same back end objects
|
// both neo/fabric uses the same back end objects
|
||||||
return super.getDepthTextureId();
|
return super.getGlDepthTextureId();
|
||||||
#else
|
#else
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -50,12 +50,12 @@ public class NeoforgeMinecraftRenderWrapper extends MinecraftRenderWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColorTextureId()
|
public int getGlColorTextureId()
|
||||||
{
|
{
|
||||||
#if MC_VER < MC_1_21_9
|
#if MC_VER < MC_1_21_9
|
||||||
// no special handling required,
|
// no special handling required,
|
||||||
// both neo/fabric uses the same back end objects
|
// both neo/fabric uses the same back end objects
|
||||||
return super.getColorTextureId();
|
return super.getGlColorTextureId();
|
||||||
#else
|
#else
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
Translations are managed via Crowdin: https://crowdin.com/project/distant-horizons
|
||||||
|
|
||||||
|
## How to help:
|
||||||
|
1. Create a Crowdin account
|
||||||
|
2. Join the project
|
||||||
|
3. Translate strings from `en_us.json`.
|
||||||
|
|
||||||
|
## Notes:
|
||||||
|
- Keys ending with `@tooltip` are tooltips.
|
||||||
|
- Keep formatting codes intact, IE: `§`, `%s`, `%d`, `%1$s`.
|
||||||
|
- For newlines, utilize **Shift + Enter** instead of `\n`.
|
||||||
|
- Do not edit non-English files in pull requests.
|
||||||
|
|
||||||
|
## To pull translations into the repo
|
||||||
|
- Downlod the [Crowdin CLI](https://github.com/crowdin/crowdin-cli/releases)
|
||||||
|
- Run `crowdin download --export-only-approved --skip-untranslated-files` in the project root.
|
||||||
@@ -27,7 +27,8 @@ fabric_api_version=0.92.6+1.20.1
|
|||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
# iris - needs 1.7.4+ to support the DH API
|
# iris - needs 1.7.4+ to support the DH API
|
||||||
fabric_incompatibility_list={ "iris": "<=1.7.4" }
|
# vertigo - prevents DH from seeing the full chunk, causing holes
|
||||||
|
fabric_incompatibility_list={ "iris": "<=1.7.4", "vertigo": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ fabric_api_version=0.90.4+1.20.2
|
|||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
# iris - needs 1.7.4+ to support the DH API
|
# iris - needs 1.7.4+ to support the DH API
|
||||||
fabric_incompatibility_list={ "iris": "<=1.7.4" }
|
# vertigo - prevents DH from seeing the full chunk, causing holes
|
||||||
|
fabric_incompatibility_list={ "iris": "<=1.7.4", "vertigo": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ fabric_api_version=0.91.2+1.20.4
|
|||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
# iris - needs 1.7.4+ to support the DH API
|
# iris - needs 1.7.4+ to support the DH API
|
||||||
fabric_incompatibility_list={ "iris": "<=1.7.4" }
|
# vertigo - prevents DH from seeing the full chunk, causing holes
|
||||||
|
fabric_incompatibility_list={ "iris": "<=1.7.4", "vertigo": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ fabric_api_version=0.97.8+1.20.6
|
|||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
# iris - needs 1.7.4+ to support the DH API
|
# iris - needs 1.7.4+ to support the DH API
|
||||||
fabric_incompatibility_list={ "iris": "<=1.7.4" }
|
# vertigo - prevents DH from seeing the full chunk, causing holes
|
||||||
|
fabric_incompatibility_list={ "iris": "<=1.7.4", "vertigo": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ fabric_api_version=0.116.11+1.21.1
|
|||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
# iris - needs 1.7.4+ to support the DH API
|
# iris - needs 1.7.4+ to support the DH API
|
||||||
fabric_incompatibility_list={ "iris": "<=1.7.4" }
|
# vertigo - prevents DH from seeing the full chunk, causing holes
|
||||||
|
fabric_incompatibility_list={ "iris": "<=1.7.4", "vertigo": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ fabric_api_version=0.138.4+1.21.10
|
|||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
fabric_incompatibility_list={ }
|
# vertigo - prevents DH from seeing the full chunk, causing holes
|
||||||
|
fabric_incompatibility_list={ "vertigo": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ fabric_api_version=0.139.4+1.21.11
|
|||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
fabric_incompatibility_list={ }
|
# vertigo - prevents DH from seeing the full chunk, causing holes
|
||||||
|
fabric_incompatibility_list={ "vertigo": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ fabric_api_version=0.110.0+1.21.3
|
|||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
# fabric-api 0.110.0 fixed a bug in MC 1.21.3 with the rendering API DH relied on
|
# fabric-api 0.110.0 fixed a bug in MC 1.21.3 with the rendering API DH relied on
|
||||||
fabric_incompatibility_list={ "fabric-api": "<0.110.0" }
|
# vertigo - prevents DH from seeing the full chunk, causing holes
|
||||||
|
fabric_incompatibility_list={ "fabric-api": "<0.110.0", "vertigo": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ fabric_api_version=0.110.5+1.21.4
|
|||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
fabric_incompatibility_list={ }
|
# vertigo - prevents DH from seeing the full chunk, causing holes
|
||||||
|
fabric_incompatibility_list={ "vertigo": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ fabric_api_version=0.119.5+1.21.5
|
|||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
# Iris - some versions of 1.8.11 nightly builds may not work, but the ones after 2025-03-30 should
|
# Iris - some versions of 1.8.11 nightly builds may not work, but the ones after 2025-03-30 should
|
||||||
fabric_incompatibility_list={ "iris": "<=1.8.10" }
|
# vertigo - prevents DH from seeing the full chunk, causing holes
|
||||||
|
fabric_incompatibility_list={ "iris": "<=1.8.10", "vertigo": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ fabric_api_version=0.127.0+1.21.6
|
|||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
fabric_incompatibility_list={ }
|
# vertigo - prevents DH from seeing the full chunk, causing holes
|
||||||
|
fabric_incompatibility_list={ "vertigo": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ fabric_api_version=0.133.4+1.21.8
|
|||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
fabric_incompatibility_list={ }
|
# vertigo - prevents DH from seeing the full chunk, causing holes
|
||||||
|
fabric_incompatibility_list={ "vertigo": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ fabric_api_version=0.134.0+1.21.9
|
|||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
fabric_incompatibility_list={ }
|
# vertigo - prevents DH from seeing the full chunk, causing holes
|
||||||
|
fabric_incompatibility_list={ "vertigo": "*" }
|
||||||
fabric_recommend_list={}
|
fabric_recommend_list={}
|
||||||
|
|
||||||
# Fabric mod run
|
# Fabric mod run
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
java_version=25
|
java_version=25
|
||||||
minecraft_version=26.1.2
|
minecraft_version=26.1.2
|
||||||
parchment_version=1.21:2024.07.28
|
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.1", "26.1.2"]
|
||||||
compatible_minecraft_versions=["26.1.0", "26.1.2"]
|
|
||||||
accessWidenerVersion=26_1
|
accessWidenerVersion=26_1
|
||||||
builds_for=fabric,neoforge
|
builds_for=fabric,neoforge
|
||||||
# forge is broken due to gradle/build script issues
|
# forge is broken due to gradle/build script issues
|
||||||
@@ -16,44 +15,45 @@ lwjgl_version=3.4.1
|
|||||||
|
|
||||||
# Fabric loader
|
# Fabric loader
|
||||||
fabric_loader_version=0.18.5
|
fabric_loader_version=0.18.5
|
||||||
fabric_api_version=0.145.4+26.1.2
|
fabric_api_version=0.149.1+26.1.2
|
||||||
modmenu_version=18.0.0-alpha.8
|
modmenu_version=18.0.0-alpha.8
|
||||||
starlight_version_fabric=
|
starlight_version_fabric=
|
||||||
phosphor_version_fabric=
|
phosphor_version_fabric=
|
||||||
lithium_version=
|
lithium_version=
|
||||||
sodium_version=mc26.1.1-0.8.9-fabric
|
sodium_version=mc26.1.1-0.8.9-fabric
|
||||||
iris_version=1.10.9+26.1-fabric
|
iris_version=1.10.9+26.1-fabric
|
||||||
bclib_version=
|
bclib_version=
|
||||||
immersive_portals_version=
|
immersive_portals_version=
|
||||||
canvas_version=
|
canvas_version=
|
||||||
|
|
||||||
|
# vertigo - prevents DH from seeing the full chunk, causing holes
|
||||||
|
fabric_incompatibility_list={ "vertigo": "*" }
|
||||||
|
fabric_recommend_list={}
|
||||||
|
|
||||||
fabric_incompatibility_list={ }
|
# Fabric mod run
|
||||||
fabric_recommend_list={}
|
# 0 = Don't enable and don't run
|
||||||
|
# 1 = Can be referenced in code but doesn't run
|
||||||
# Fabric mod run
|
# 2 = Can be referenced in code and runs in client
|
||||||
# 0 = Don't enable and don't run
|
enable_mod_menu=2
|
||||||
# 1 = Can be referenced in code but doesn't run
|
enable_starlight=0
|
||||||
# 2 = Can be referenced in code and runs in client
|
enable_phosphor=0
|
||||||
enable_mod_menu=2
|
enable_sodium=1
|
||||||
enable_starlight=0
|
enable_lithium=0
|
||||||
enable_phosphor=0
|
enable_iris=1
|
||||||
enable_sodium=1
|
enable_bclib=0
|
||||||
enable_lithium=0
|
enable_immersive_portals=0
|
||||||
enable_iris=1
|
enable_canvas=0
|
||||||
enable_bclib=0
|
|
||||||
enable_immersive_portals=0
|
|
||||||
enable_canvas=0
|
|
||||||
|
|
||||||
# NeoForge loader
|
# NeoForge loader
|
||||||
forge_version=
|
forge_version=
|
||||||
neoforge_version=15-beta
|
neoforge_version=15-beta
|
||||||
neoforge_version_range=[*,)
|
neoforge_version_range=[*,)
|
||||||
|
|
||||||
# NeoForge mod versions
|
# NeoForge mod versions
|
||||||
neo_iris_version=1.10.9+26.1-neoforge
|
neo_iris_version=1.10.9+26.1-neoforge
|
||||||
|
|
||||||
# (Neo)Forge mod run
|
# (Neo)Forge mod run
|
||||||
# 0 = Don't enable and don't run
|
# 0 = Don't enable and don't run
|
||||||
# 1 = Can be referenced in code but doesn't run
|
# 1 = Can be referenced in code but doesn't run
|
||||||
# 2 = Can be referenced in code and runs in client
|
# 2 = Can be referenced in code and runs in client
|
||||||
neo_enable_iris=1
|
neo_enable_iris=1
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
# 26.2.0 version
|
||||||
|
java_version=25
|
||||||
|
minecraft_version=26.2-snapshot-7
|
||||||
|
parchment_version=1.21:2024.07.28
|
||||||
|
compatible_minecraft_versions=["26.2.0","26.2-alpha.7"]
|
||||||
|
accessWidenerVersion=26_1
|
||||||
|
builds_for=fabric
|
||||||
|
#,neoforge
|
||||||
|
# forge is broken due to gradle/build script issues
|
||||||
|
|
||||||
|
# Netty
|
||||||
|
netty_version=4.1.97.Final
|
||||||
|
|
||||||
|
# LWJGL
|
||||||
|
lwjgl_version=3.4.1
|
||||||
|
|
||||||
|
# Fabric loader
|
||||||
|
fabric_loader_version=0.18.5
|
||||||
|
fabric_api_version=0.149.0+26.2
|
||||||
|
modmenu_version=
|
||||||
|
starlight_version_fabric=
|
||||||
|
phosphor_version_fabric=
|
||||||
|
lithium_version=
|
||||||
|
sodium_version=
|
||||||
|
iris_version=
|
||||||
|
bclib_version=
|
||||||
|
immersive_portals_version=
|
||||||
|
canvas_version=
|
||||||
|
|
||||||
|
# vertigo - prevents DH from seeing the full chunk, causing holes
|
||||||
|
fabric_incompatibility_list={ "vertigo": "*" }
|
||||||
|
fabric_recommend_list={}
|
||||||
|
|
||||||
|
# Fabric mod run
|
||||||
|
# 0 = Don't enable and don't run
|
||||||
|
# 1 = Can be referenced in code but doesn't run
|
||||||
|
# 2 = Can be referenced in code and runs in client
|
||||||
|
enable_mod_menu=0
|
||||||
|
enable_starlight=0
|
||||||
|
enable_phosphor=0
|
||||||
|
enable_sodium=0
|
||||||
|
enable_lithium=0
|
||||||
|
enable_iris=0
|
||||||
|
enable_bclib=0
|
||||||
|
enable_immersive_portals=0
|
||||||
|
enable_canvas=0
|
||||||
|
|
||||||
|
# NeoForge loader
|
||||||
|
forge_version=
|
||||||
|
neoforge_version=15-beta
|
||||||
|
neoforge_version_range=[*,)
|
||||||
|
|
||||||
|
# NeoForge mod versions
|
||||||
|
neo_iris_version=
|
||||||
|
|
||||||
|
# (Neo)Forge mod run
|
||||||
|
# 0 = Don't enable and don't run
|
||||||
|
# 1 = Can be referenced in code but doesn't run
|
||||||
|
# 2 = Can be referenced in code and runs in client
|
||||||
|
neo_enable_iris=0
|
||||||
Reference in New Issue
Block a user