Compare commits

...

6 Commits

Author SHA1 Message Date
James Seibel 64d8f7ee2d update blaze 3d api use 2026-05-11 22:00:07 -05:00
James Seibel d8b3aee9dc temp disable forgix 2026-05-11 22:00:07 -05:00
James Seibel fce94fa4bf update screen mixin update 2026-05-11 22:00:07 -05:00
James Seibel 254d671629 basic mixin updates 2026-05-11 21:58:33 -05:00
James Seibel e66e7e627a disable mod compat code 2026-05-11 21:55:30 -05:00
James Seibel 1f1024251b up version number 3.0.3 -> 3.0.4 2026-05-04 07:41:48 -05:00
32 changed files with 413 additions and 125 deletions
+1
View File
@@ -3,6 +3,7 @@ plugins {
id 'io.github.pacifistmc.forgix' version '2.+'
}
if (false) // TODO vulkan don't run if there is only one mod loader
forgix {
autoRun = true
@@ -70,10 +70,16 @@ public class DhUpdateScreenBase
try
{
MC.setScreen(new UpdateModScreen(
UpdateModScreen updateScreen = new UpdateModScreen(
new TitleScreen(false),
versionId
));
);
#if MC_VER <= MC_26_1_2
MC.setScreen(updateScreen);
#else
MC.setScreenAndShow(updateScreen);
#endif
}
catch (Exception e)
{
@@ -71,9 +71,12 @@ public class MixinVanillaFogCommon
#elif MC_VER <= MC_1_21_10
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
Entity entity = camera.getEntity();
#else
#elif MC_VER <= MC_26_1_2
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
Entity entity = camera.entity();
#else
Camera camera = Minecraft.getInstance().gameRenderer.mainCamera();
Entity entity = camera.entity();
#endif
@@ -10,6 +10,7 @@ import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterCo
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.wrappers.texture.BlazeTextureWrapper;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.render.RenderParams;
import com.seibel.distanthorizons.coreapi.util.ColorUtil;
@@ -86,7 +87,7 @@ public class BlazeDhMetaRenderer implements IDhMetaRenderer
@Override
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);
}
@@ -40,6 +40,7 @@ import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
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.BlazeTextureWrapper;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.render.RenderParams;
@@ -151,7 +152,7 @@ public class BlazeDhFarFadeRenderer implements IDhFarFadeRenderer
// textures
this.dhFadeColorTextureWrapper.tryCreateOrResize();
this.mcColorTextureViewWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getColorTexture());
this.mcColorTextureViewWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getColorTexture());
this.dhFadeDepthTextureWrapper.tryCreateOrResize();
@@ -23,19 +23,7 @@ package com.seibel.distanthorizons.common.render.blaze.postProcessing;
public class BlazeDhFogRenderer {}
#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;
@@ -62,6 +50,24 @@ import java.nio.ByteOrder;
import java.util.OptionalDouble;
import java.util.OptionalInt;
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.systems.CommandEncoder;
import com.mojang.blaze3d.systems.GpuDevice;
import com.mojang.blaze3d.systems.RenderPass;
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.
*/
@@ -109,11 +115,16 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
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(
"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"
);
@@ -23,19 +23,7 @@ package com.seibel.distanthorizons.common.render.blaze.postProcessing;
public class BlazeDhSsaoRenderer {}
#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.apply.BlazeDhApplyRenderer;
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
@@ -56,6 +44,25 @@ import java.nio.ByteOrder;
import java.util.OptionalDouble;
import java.util.OptionalInt;
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.BlendFactor;
import com.mojang.blaze3d.systems.CommandEncoder;
import com.mojang.blaze3d.systems.GpuDevice;
import com.mojang.blaze3d.systems.RenderPass;
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. */
public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
{
@@ -101,9 +108,17 @@ public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
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(
"ssao_apply_to_dh",
new BlendFunction(SourceFactor.ZERO, DestFactor.SRC_ALPHA, SourceFactor.ZERO, DestFactor.ONE),
blendFunc,
"apply/blaze/vert", "ssao/blaze/apply",
/*uniforms*/ new String[] { "applyFragUniformBlock" }
);
@@ -43,6 +43,7 @@ import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
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.BlazeTextureWrapper;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.logging.DhLogger;
@@ -164,8 +165,8 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
this.fadeColorTextureWrapper.tryCreateOrResize();
this.fadeDepthTextureWrapper.tryCreateOrResize();
this.mcDepthTextureWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getDepthTexture());
this.mcColorTextureWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getColorTexture());
this.mcDepthTextureWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getDepthTexture());
this.mcColorTextureWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getColorTexture());
{
@@ -198,11 +199,8 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
Mat4f inverseMcMvmProjMatrix = inverseMcModelViewProjectionMatrix;
Mat4f dhProjectionMatrix = RenderUtil.createLodProjectionMatrix(renderParams.mcProjectionMatrix);
Mat4f dhModelViewMatrix = RenderUtil.createLodModelViewMatrix(renderParams.mcModelViewMatrix);
Mat4f inverseDhModelViewProjectionMatrix = new Mat4f(dhProjectionMatrix);
inverseDhModelViewProjectionMatrix.multiply(dhModelViewMatrix);
Mat4f inverseDhModelViewProjectionMatrix = new Mat4f(renderParams.dhProjectionMatrix);
inverseDhModelViewProjectionMatrix.multiply(renderParams.dhModelViewMatrix);
inverseDhModelViewProjectionMatrix.invert();
Mat4f inverseDhMvmProjMatrix = inverseDhModelViewProjectionMatrix;
@@ -37,6 +37,7 @@ import com.mojang.blaze3d.vertex.VertexFormat;
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPipelineBuilderWrapper;
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.DhLoggerBuilder;
import com.seibel.distanthorizons.core.render.RenderParams;
@@ -164,8 +165,8 @@ public class BlazeDhTestTriangleRenderer implements IDhTestTriangleRenderer
{
this.tryInit();
this.mcColorTextureViewWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getColorTexture());
this.mcDepthTextureViewWrapper.tryWrap(Minecraft.getInstance().getMainRenderTarget().getDepthTexture());
this.mcColorTextureViewWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getColorTexture());
this.mcDepthTextureViewWrapper.tryWrap(MinecraftRenderWrapper.INSTANCE.getRenderTarget().getDepthTexture());
try (RenderPass renderPass = COMMAND_ENCODER.createRenderPass(
this::getRenderPassName,
@@ -5,6 +5,7 @@ public class BlazeDhVertexFormatUtil {}
#else
import com.mojang.blaze3d.GpuFormat;
import com.mojang.blaze3d.vertex.VertexFormatElement;
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi;
import com.seibel.distanthorizons.core.config.Config;
@@ -70,7 +71,7 @@ public class BlazeDhVertexFormatUtil
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);
#else
#elif MC_VER <= MC_26_1_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);
@@ -83,6 +84,20 @@ public class BlazeDhVertexFormatUtil
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);
#else
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
#endif
}
catch (Exception e)
@@ -6,8 +6,8 @@ public class RenderPipelineBuilderWrapper {}
#else
import com.mojang.blaze3d.pipeline.BlendFunction;
import com.mojang.blaze3d.pipeline.RenderPipeline;
import com.mojang.blaze3d.GpuFormat;
import com.mojang.blaze3d.pipeline.*;
import com.mojang.blaze3d.platform.PolygonMode;
import com.mojang.blaze3d.shaders.UniformType;
import com.mojang.blaze3d.vertex.VertexFormat;
@@ -16,13 +16,12 @@ import net.minecraft.resources.Identifier;
#if MC_VER <= MC_1_21_11
import com.mojang.blaze3d.platform.DepthTestFunction;
#else
import com.mojang.blaze3d.pipeline.ColorTargetState;
import com.mojang.blaze3d.pipeline.DepthStencilState;
import com.mojang.blaze3d.platform.CompareOp;
#endif
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Optional;
public class RenderPipelineBuilderWrapper
@@ -130,15 +129,27 @@ public class RenderPipelineBuilderWrapper
return this;
}
private final ArrayList<String> samplerNames = new ArrayList<>();
public RenderPipelineBuilderWrapper withSampler(String name) throws IllegalArgumentException
{
#if MC_VER <= MC_26_1_2
this.blazePipelineBuilder.withSampler(name);
#else
samplerNames.add(name);
#endif
return this;
}
private final ArrayList<String> uniformBufferNames = new ArrayList<>();
public RenderPipelineBuilderWrapper withUniformBuffer(String name) throws IllegalArgumentException
{
#if MC_VER <= MC_26_1_2
this.blazePipelineBuilder.withUniform(name, UniformType.UNIFORM_BUFFER);
#else
uniformBufferNames.add(name);
#endif
return this;
}
@@ -282,6 +293,31 @@ public class RenderPipelineBuilderWrapper
this.blazePipelineBuilder.withVertexFormat(vertexFormat, blazeVertexMode);
}
// 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();
}
@@ -5,11 +5,6 @@ public class BlazeTextureWrapper {}
#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.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
@@ -18,6 +13,17 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRen
import java.util.OptionalDouble;
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;
#endif
public class BlazeTextureWrapper
{
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
@@ -29,7 +35,11 @@ public class BlazeTextureWrapper
public final String name;
#if MC_VER <= MC_26_1_2
public final TextureFormat textureFormat;
#else
public final GpuFormat textureFormat;
#endif
public GpuTexture texture = null;
public GpuTextureView textureView = null;
@@ -45,10 +55,27 @@ public class BlazeTextureWrapper
//==============//
//region
public static BlazeTextureWrapper createDepth(String name) { return new BlazeTextureWrapper(name, TextureFormat.DEPTH32); }
public static BlazeTextureWrapper createColor(String name) { return new BlazeTextureWrapper(name, TextureFormat.RGBA8); }
public static BlazeTextureWrapper createDepth(String name)
{
#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.textureFormat = textureFormat;
@@ -116,11 +143,13 @@ public class BlazeTextureWrapper
| GpuTexture.USAGE_TEXTURE_BINDING
| GpuTexture.USAGE_COPY_SRC
| GpuTexture.USAGE_RENDER_ATTACHMENT;
this.texture = GPU_DEVICE.createTexture(this.name,
this.texture = GPU_DEVICE.createTexture(
this.name,
usage,
this.textureFormat,
viewWidth, viewHeight,
/*depthOrLayers*/ 1, /*mipLevels*/ 1
/*depthOrLayers*/ 1, /*mipLevels*/ 1
);
this.textureView = GPU_DEVICE.createTextureView(this.texture);
@@ -126,6 +126,8 @@ public class GLProxy
private GLProxy() throws IllegalStateException
{
// TODO vulkan complain if created when MC is running on vulkan
// this must be created on minecraft's render context to work correctly
if (GLFW.glfwGetCurrentContext() == 0L)
{
@@ -95,6 +95,8 @@ public class VersionConstants implements IVersionConstants
return "1.21.11";
#elif MC_VER == MC_26_1_2
return "26.1.2";
#elif MC_VER == MC_26_2_0
return "26.2.0";
#else
ERROR MC version constant missing
#endif
@@ -0,0 +1,28 @@
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 showScreen(Screen screen)
{
#if MC_VER <= MC_26_1_2
Objects.requireNonNull(Minecraft.getInstance()).setScreen(screen);
#else
Objects.requireNonNull(Minecraft.getInstance()).setScreenAndShow(screen);
#endif
}
//endregion
}
@@ -24,10 +24,19 @@ import java.util.*;
public class MinecraftScreen
{
//
// helper methods
//
public static Screen getScreen(Screen parent, AbstractScreen screen, String translationName)
{
return new ConfigScreenRenderer(parent, screen, translationName);
}
{ return new ConfigScreenRenderer(parent, screen, translationName); }
//=========//
// screens //
//=========//
//region
private static class ConfigScreenRenderer extends DhScreen
{
@@ -152,7 +161,7 @@ public class MinecraftScreen
public void onClose()
{
this.screen.onClose(); // Close our screen
Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Goto the parent screen
DhScreenUtil.showScreen(this.parent); // Goto the parent screen
}
@Override
@@ -180,4 +189,8 @@ public class MinecraftScreen
}
//endregion
}
@@ -3,16 +3,15 @@ package com.seibel.distanthorizons.common.wrappers.gui.classicConfig;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import com.seibel.distanthorizons.api.enums.config.DisallowSelectingViaConfigGui;
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.config.ConfigGuiInfo;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper;
@@ -21,27 +20,20 @@ import com.seibel.distanthorizons.core.config.ConfigHandler;
import com.seibel.distanthorizons.core.config.types.*;
import com.seibel.distanthorizons.common.wrappers.gui.updater.ChangelogScreen;
import com.seibel.distanthorizons.core.config.types.enums.EConfigCommentTextPosition;
import com.seibel.distanthorizons.core.config.types.enums.EConfigValidity;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.jar.updater.SelfUpdater;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
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.coreapi.ModInfo;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.components.AbstractWidget;
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.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import com.seibel.distanthorizons.core.logging.DhLogger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -55,7 +47,6 @@ import net.minecraft.client.gui.GuiGraphicsExtractor;
#endif
#if MC_VER >= MC_1_17_1
import net.minecraft.client.gui.narration.NarratableEntry;
#endif
#if MC_VER <= MC_1_21_10
@@ -92,6 +83,7 @@ class DhConfigScreen extends DhScreen
//=============//
// constructor //
//=============//
//region
protected DhConfigScreen(Screen parent, String category)
{
@@ -104,15 +96,25 @@ class DhConfigScreen extends DhScreen
this.category = category;
}
//endregion
//=============//
// tick update //
//=============//
//region
@Override
public void tick() { super.tick(); }
//endregion
//==================//
// menu UI creation //
//==================//
//region
@Override
protected void init()
@@ -150,7 +152,7 @@ class DhConfigScreen extends DhScreen
ChangelogScreen changelogScreen = new ChangelogScreen(this);
if (changelogScreen.usable)
{
Objects.requireNonNull(this.minecraft).setScreen(changelogScreen);
DhScreenUtil.showScreen(changelogScreen);
}
else
{
@@ -170,7 +172,7 @@ class DhConfigScreen extends DhScreen
(button) ->
{
ConfigHandler.INSTANCE.configFileHandler.loadFromFile();
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
DhScreenUtil.showScreen(this.parent);
}));
// done/close button
@@ -181,7 +183,7 @@ class DhConfigScreen extends DhScreen
(button) ->
{
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
DhScreenUtil.showScreen(this.parent);
}));
this.configListWidget = new ClassicConfigGUI.ConfigListWidget(this.minecraft, this.width * 2, this.height, 32, 32, 25);
@@ -464,7 +466,7 @@ class DhConfigScreen extends DhScreen
{
configEntry.uiSetWithoutSaving(configEntry.getDefaultValue());
this.reload = true;
Objects.requireNonNull(this.minecraft).setScreen(this);
DhScreenUtil.showScreen(this);
};
int resetButtonPosX = this.width
@@ -574,7 +576,7 @@ class DhConfigScreen extends DhScreen
((button) ->
{
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
Objects.requireNonNull(this.minecraft).setScreen(ClassicConfigGUI.getScreen(this, configCategory.getDestination()));
DhScreenUtil.showScreen(ClassicConfigGUI.getScreen(this, configCategory.getDestination()));
}));
this.configListWidget.addButton(this, configType, widget, null, null, null);
@@ -655,11 +657,14 @@ class DhConfigScreen extends DhScreen
private Component GetTranslatableTextComponentForConfig(AbstractConfigBase<?> configType)
{ return Translatable(TRANSLATION_PREFIX + configType.getNameAndCategory()); }
//endregion
//===========//
// rendering //
//===========//
//region
@Override
#if MC_VER < MC_1_20_1
@@ -779,21 +784,27 @@ class DhConfigScreen extends DhScreen
}
}
//endregion
//==========//
// shutdown //
//==========//
//region
/** When you close it, it goes to the previous screen and saves */
@Override
public void onClose()
{
ConfigHandler.INSTANCE.configFileHandler.saveToFile();
Objects.requireNonNull(this.minecraft).setScreen(this.parent);
DhScreenUtil.showScreen(this.parent);
ClassicConfigGUI.CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run());
}
//endregion
}
@@ -1,6 +1,7 @@
package com.seibel.distanthorizons.common.wrappers.gui.updater;
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.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
@@ -222,10 +223,7 @@ public class ChangelogScreen extends DhScreen
}
@Override
public void onClose()
{
Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Goto the parent screen
}
public void onClose() { DhScreenUtil.showScreen(this.parent); }
public static class TextArea extends ContainerObjectSelectionList<ButtonEntry>
{
@@ -2,6 +2,7 @@ package com.seibel.distanthorizons.common.wrappers.gui.updater;
import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch;
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.core.jar.ModJarInfo;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
@@ -137,7 +138,7 @@ public class UpdateModScreen extends DhScreen
#endif
20, 20,
// Create the button and tell it where to go
(buttonWidget) -> Objects.requireNonNull(this.minecraft).setScreen(new ChangelogScreen(this, this.newVersionID)),
(buttonWidget) -> DhScreenUtil.showScreen(new ChangelogScreen(this, this.newVersionID)),
// Add a title to the button
Translatable(ModInfo.ID + ".updater.title")
));
@@ -218,7 +219,7 @@ public class UpdateModScreen extends DhScreen
@Override
public void onClose()
{
Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Go to the parent screen
DhScreenUtil.showScreen(this.parent); // Go to the parent screen
}
}
@@ -136,9 +136,12 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
#if MC_VER <= MC_1_21_10
Camera camera = MC.gameRenderer.getMainCamera();
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();
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
}
@@ -170,7 +173,12 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
@Override
public Vec3d getCameraExactPosition()
{
#if MC_VER <= MC_26_1_2
Camera camera = MC.gameRenderer.getMainCamera();
#else
Camera camera = MC.gameRenderer.mainCamera();
#endif
#if MC_VER <= MC_1_21_10
Vec3 projectedView = camera.getPosition();
#else
@@ -263,20 +271,29 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
float darkenAmount;
#if MC_VER <= MC_1_21_11
darkenAmount = MC.gameRenderer.getDarkenWorldAmount(MC.deltaTracker.getGameTimeDeltaPartialTick(true));
#else
#elif MC_VER <= MC_26_1_2
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
#if MC_VER <= MC_1_21_11
Vector4f colorValues = mcFogRenderer.setupFog(
MC.gameRenderer.getMainCamera(),
camera,
MC.options.getEffectiveRenderDistance(),
MC.deltaTracker,
darkenAmount,
MC.level);
#else
FogData fogData = mcFogRenderer.setupFog(
MC.gameRenderer.getMainCamera(),
camera,
MC.options.getEffectiveRenderDistance(),
MC.deltaTracker,
darkenAmount,
@@ -342,7 +359,14 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
#endif
}
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
}
@Override
public boolean mcRendersToFrameBuffer()
@@ -415,6 +439,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
}
#endif
}
// TODO vulkan deprecate(?) and add method to get color texture
@Override
public int getColorTextureId()
{
@@ -479,9 +504,12 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
isBlind |= fluidState.is(FluidTags.WATER);
isBlind |= fluidState.is(FluidTags.LAVA);
return isBlind;
#else
#elif MC_VER <= MC_26_1_2
boolean isBlind = this.playerHasBlindingEffect();
return MC.gameRenderer.getMainCamera().getFluidInCamera() != FogType.NONE || isBlind;
#else
boolean isBlind = this.playerHasBlindingEffect();
return MC.gameRenderer.mainCamera().getFluidInCamera() != FogType.NONE || isBlind;
#endif
}
@@ -327,10 +327,11 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
// FIXME: Use better hooks so it doesn't trigger key press events in text boxes
ClientTickEvents.END_CLIENT_TICK.register(client ->
{
if (client.player != null && !(Minecraft.getInstance().screen instanceof TitleScreen))
{
this.onKeyInput();
}
// TODO
//if (client.player != null && !(Minecraft.getInstance().screen instanceof TitleScreen))
//{
// this.onKeyInput();
//}
});
//endregion
@@ -93,7 +93,10 @@ public class MixinChunkSectionsToRender
@Inject(at = @At("HEAD"), method = "renderGroup", order = 800)
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);
#else
#endif
ClientApi.RENDER_STATE.canRenderOrThrow();
@@ -29,8 +29,11 @@ public class MixinGameRenderer {}
#else
import com.mojang.blaze3d.vertex.PoseStack;
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 net.minecraft.client.DeltaTracker;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.state.OptionsRenderState;
@@ -71,6 +74,16 @@ public class MixinGameRenderer
final Matrix4f projectionMatrix,
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);
}
}
@@ -94,8 +94,11 @@ import com.seibel.distanthorizons.core.logging.DhLogger;
@Mixin(LevelRenderer.class)
public class MixinLevelRenderer
{
#if MC_VER <= MC_26_1_2
@Shadow
private ClientLevel level;
#else
#endif
@Unique
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
@@ -220,12 +223,14 @@ public class MixinLevelRenderer
#if MC_VER <= MC_1_21_11
#else
#if MC_VER <= MC_26_1_2
@Inject(at = @At("HEAD"), method = "prepareChunkRenders")
private void prepareChunkRenders(final Matrix4fc modelViewMatrix, CallbackInfoReturnable<ChunkSectionsToRender> callback)
{
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, this.level);
}
@Inject(at = @At("HEAD"), method = "renderLevel")
public void renderLevel(
final GraphicsResourceAllocator resourceAllocator, final DeltaTracker deltaTracker,
@@ -241,6 +246,9 @@ public class MixinLevelRenderer
}
#else
#endif
#endif
//endregion
@@ -112,9 +112,10 @@ public class MixinLightTexture
GlTexture glTexture = (GlTexture) this.texture;
this.renderWrapper.setLightmapId(glTexture.glId(), clientLevel);
#else
// both options are available since the renderer can be changed to either Blaze3D or OpenGL
GlTexture glTexture = (GlTexture) this.texture;
this.renderWrapper.setLightmapId(glTexture.glId(), clientLevel);
// TODO vulkan
//// both options are available since the renderer can be changed to either Blaze3D or OpenGL
//GlTexture glTexture = (GlTexture) this.texture;
//this.renderWrapper.setLightmapId(glTexture.glId(), clientLevel);
this.renderWrapper.setLightmapGpuTexture(this.texture, clientLevel);
#endif
@@ -87,17 +87,18 @@ public abstract class MixinMinecraft
}
#endif
#if MC_VER >= MC_1_20_2
@Redirect(
method = "Lnet/minecraft/client/Minecraft;onGameLoadFinished(Lnet/minecraft/client/Minecraft$GameLoadCookie;)V",
at = @At(value = "INVOKE", target = "Ljava/lang/Runnable;run()V")
)
private void buildInitialScreens(Runnable runnable)
{
DhUpdateScreenBase.tryShowUpdateScreenAndRunAutoUpdateStartup(runnable);
runnable.run();
}
#endif
// TODO vulkan
//#if MC_VER >= MC_1_20_2
//@Redirect(
// method = "Lnet/minecraft/client/Minecraft;onGameLoadFinished(Lnet/minecraft/client/Minecraft$GameLoadCookie;)V",
// at = @At(value = "INVOKE", target = "Ljava/lang/Runnable;run()V")
//)
//private void buildInitialScreens(Runnable runnable)
//{
// DhUpdateScreenBase.tryShowUpdateScreenAndRunAutoUpdateStartup(runnable);
// runnable.run();
//}
//#endif
@Inject(at = @At("HEAD"), method = "updateLevelInEngines")
public void updateLevelInEngines(ClientLevel level, CallbackInfo ci)
@@ -19,6 +19,7 @@
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.TexturedButtonWidget;
import com.seibel.distanthorizons.coreapi.ModInfo;
@@ -147,7 +148,7 @@ public class MixinOptionsScreen extends Screen
20, ICON_TEXTURE, 20, 40,
// Create the button and tell it where to go
// For now it goes to the client option by default
(buttonWidget) -> Objects.requireNonNull(this.minecraft).setScreen(GetConfigScreen.getScreen(this)),
(buttonWidget) -> DhScreenUtil.showScreen(GetConfigScreen.getScreen(this)),
// Add a title to the button
#if MC_VER < MC_1_19_2
new TranslatableComponent(ModInfo.ID + ".title"));
@@ -20,17 +20,17 @@
package com.seibel.distanthorizons.fabric.wrappers.config;
import com.seibel.distanthorizons.common.wrappers.gui.GetConfigScreen;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
//import com.terraformersmc.modmenu.api.ConfigScreenFactory;
//import com.terraformersmc.modmenu.api.ModMenuApi;
/** For making the config show up in modmenu */
public class ModMenuIntegration implements ModMenuApi
public class ModMenuIntegration //implements ModMenuApi
{
// For the custom config code
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory()
{
return parent -> GetConfigScreen.getScreen(parent);
}
//@Override
//public ConfigScreenFactory<?> getModConfigScreenFactory()
//{
// return parent -> GetConfigScreen.getScreen(parent);
//}
}
@@ -27,20 +27,20 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IIrisAccess
import net.coderbot.iris.Iris;
import net.irisshaders.iris.api.v0.IrisApi;
#else
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.api.v0.IrisApi;
//import net.irisshaders.iris.Iris;
//import net.irisshaders.iris.api.v0.IrisApi;
#endif
public class IrisAccessor implements IIrisAccessor
{
@Override
public String getModName() { return Iris.MODID; }
public String getModName() { return /*Iris.MODID;*/ ""; }
@Override
public boolean isShaderPackInUse() { return IrisApi.getInstance().isShaderPackInUse(); }
public boolean isShaderPackInUse() { return false;/*IrisApi.getInstance().isShaderPackInUse();*/ }
@Override
public boolean isRenderingShadowPass() { return IrisApi.getInstance().isRenderingShadowPass(); }
public boolean isRenderingShadowPass() { return false;/*IrisApi.getInstance().isRenderingShadowPass();*/ }
}
+2 -2
View File
@@ -6,7 +6,7 @@ org.gradle.caching=true
# Mod Info
mod_name=DistantHorizons
api_name=DistantHorizonsApi
mod_version=3.0.3-b
mod_version=3.0.4-b-dev
api_version=6.1.1
maven_group=com.seibel.distanthorizons
mod_readable_name=Distant Horizons
@@ -47,7 +47,7 @@ versionStr=
# This defines what MC version Intellij will use for the preprocessor
# and what version is used automatically by build and run commands
mcVer=26.1.2
mcVer=26.2.0
# Defines the maximum amount of memory Minecraft is allowed when run in a development environment
minecraftMemoryJavaArg=-Xmx6G
+60
View File
@@ -0,0 +1,60 @@
# 26.2.0 version
java_version=25
minecraft_version=26.2-snapshot-5
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.2.0","26.2-alpha.5"]
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.147.1+26.2
modmenu_version=
starlight_version_fabric=
phosphor_version_fabric=
lithium_version=
sodium_version=
iris_version=
bclib_version=
immersive_portals_version=
canvas_version=
fabric_incompatibility_list={ }
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