diff --git a/build.gradle b/build.gradle index af874eef2..f5ad7ba1b 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { // add the mod loaders to the end of the jar diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/DhUpdateScreenBase.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/DhUpdateScreenBase.java index 8e43d67a7..300a29f1d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/DhUpdateScreenBase.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/DhUpdateScreenBase.java @@ -1,6 +1,7 @@ package com.seibel.distanthorizons.common.commonMixins; 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.core.config.Config; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; @@ -81,12 +82,12 @@ public class DhUpdateScreenBase try { #if MC_VER <= MC_1_12_2 - MC.displayGuiScreen(new UpdateModScreen( - new GuiMainMenu(), + DhScreenUtil.showScreen(new UpdateModScreen( + new TitleScreen(false), versionId )); #else - MC.setScreen(new UpdateModScreen( + DhScreenUtil.showScreen(new UpdateModScreen( new TitleScreen(false), versionId )); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java index 291fdcc62..985a2465f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/MixinVanillaFogCommon.java @@ -72,9 +72,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 #if MC_VER <= MC_1_12_2 diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhMetaRenderer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhMetaRenderer.java index d5f47624c..723acb7f9 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhMetaRenderer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/BlazeDhMetaRenderer.java @@ -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); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhFarFadeRenderer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhFarFadeRenderer.java index 5839e9800..fe79b0a57 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhFarFadeRenderer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhFarFadeRenderer.java @@ -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(); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhFogRenderer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhFogRenderer.java index a91025ae2..693d6da42 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhFogRenderer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhFogRenderer.java @@ -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" ); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhSsaoRenderer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhSsaoRenderer.java index b7b80ee0d..7555ce4c5 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhSsaoRenderer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeDhSsaoRenderer.java @@ -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" } ); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeVanillaFadeRenderer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeVanillaFadeRenderer.java index 73b3d4aa7..b8118add6 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeVanillaFadeRenderer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/postProcessing/BlazeVanillaFadeRenderer.java @@ -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; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/test/BlazeDhTestTriangleRenderer.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/test/BlazeDhTestTriangleRenderer.java index 4d86c4def..dfc440ca8 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/test/BlazeDhTestTriangleRenderer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/test/BlazeDhTestTriangleRenderer.java @@ -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, diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/util/BlazeDhVertexFormatUtil.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/util/BlazeDhVertexFormatUtil.java index d36a5305d..146a46c03 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/util/BlazeDhVertexFormatUtil.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/util/BlazeDhVertexFormatUtil.java @@ -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) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/wrappers/RenderPipelineBuilderWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/wrappers/RenderPipelineBuilderWrapper.java index 0885bc195..97f76f84f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/wrappers/RenderPipelineBuilderWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/wrappers/RenderPipelineBuilderWrapper.java @@ -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 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 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(); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/wrappers/texture/BlazeTextureWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/wrappers/texture/BlazeTextureWrapper.java index 30b09744f..1908a4a04 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/wrappers/texture/BlazeTextureWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/blaze/wrappers/texture/BlazeTextureWrapper.java @@ -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); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/GLProxy.java b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/GLProxy.java index 49c577f8e..aad3e218f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/GLProxy.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/render/openGl/glObject/GLProxy.java @@ -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) { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/VersionConstants.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/VersionConstants.java index efd96f845..a6fd7a450 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/VersionConstants.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/VersionConstants.java @@ -98,6 +98,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 diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreenUtil.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreenUtil.java new file mode 100644 index 000000000..5ef482c21 --- /dev/null +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/DhScreenUtil.java @@ -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 + + + +} diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java index 2da926ba0..cd44a28f3 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/MinecraftScreen.java @@ -43,6 +43,13 @@ public class MinecraftScreen return new ConfigScreenRenderer(parent, screen, translationName); } + + + //=========// + // screens // + //=========// + //region + private static class ConfigScreenRenderer extends DhScreen { #if MC_VER <= MC_1_12_2 @@ -231,11 +238,7 @@ public class MinecraftScreen #endif { this.screen.onClose(); // Close our screen - #if MC_VER <= MC_1_12_2 - Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); // Goto the parent screen - #else - Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Goto the parent screen - #endif + DhScreenUtil.showScreen(this.parent); // Goto the parent screen } #if MC_VER > MC_1_12_2 @@ -280,4 +283,8 @@ public class MinecraftScreen #endif } + //endregion + + + } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java index 5c725fa9a..c5c4a110a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java @@ -12,13 +12,15 @@ 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.*; +import com.seibel.distanthorizons.common.wrappers.gui.DhScreen; +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; import com.seibel.distanthorizons.core.config.Config; 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; @@ -28,15 +30,8 @@ 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.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.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Button; @@ -45,13 +40,12 @@ 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; -#endif import com.seibel.distanthorizons.core.logging.DhLogger; import org.jetbrains.annotations.NotNull; 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 net.minecraft.client.gui.GuiComponent; #elif MC_VER <= MC_1_21_11 @@ -64,18 +58,14 @@ import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.client.gui.narration.NarratableEntry; #endif -#if MC_VER <= MC_1_12_2 -import net.minecraft.util.ResourceLocation; -#elif MC_VER <= MC_1_21_10 +#if MC_VER <= MC_1_21_10 import net.minecraft.resources.ResourceLocation; #else import net.minecraft.resources.Identifier; #endif import org.lwjgl.glfw.GLFW; -#if MC_VER > MC_1_12_2 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.Translatable; @@ -89,38 +79,21 @@ class DhConfigScreen extends DhScreen private static final MinecraftClientWrapper MC_CLIENT = MinecraftClientWrapper.INSTANCE; - #if MC_VER <= MC_1_12_2 - private static final int changelogButton_id = 101; - #endif - #if MC_VER <= MC_1_12_2 - private final GuiScreen parent; - #else private final Screen parent; - #endif - private final String category; private ClassicConfigGUI.ConfigListWidget configListWidget; private boolean reload = false; - #if MC_VER <= MC_1_12_2 - private GuiButton doneButton; - #else private Button doneButton; - #endif //=============// // constructor // //=============// - //region - #if MC_VER <= MC_1_12_2 - protected DhConfigScreen(GuiScreen parent, String category) - #else protected DhConfigScreen(Screen parent, String category) - #endif { super(Translatable( LANG_WRAPPER.langExists(ModInfo.ID + ".config" + (category.isEmpty() ? "." + category : "") + ".title") ? @@ -131,44 +104,20 @@ class DhConfigScreen extends DhScreen this.category = category; } - //endregion - - - //===================// - // menu UI lifecycle // - //===================// - //region - @Override - #if MC_VER <= MC_1_12_2 - public void updateScreen() { super.updateScreen(); } - #else public void tick() { super.tick(); } - #endif - //endregion - - - + + //==================// // menu UI creation // //==================// - //region @Override - #if MC_VER <= MC_1_12_2 - public void initGui() - #else protected void init() - #endif { - #if MC_VER <= MC_1_12_2 - super.initGui(); - #else super.init(); - #endif - if (!this.reload) { ConfigHandler.INSTANCE.configFileHandler.loadFromFile(); @@ -180,9 +129,6 @@ class DhConfigScreen extends DhScreen && !ModInfo.IS_DEV_BUILD) { this.addBtn(new TexturedButtonWidget( - #if MC_VER <= MC_1_12_2 - changelogButton_id, - #endif // Where the button is on the screen this.width - 28, this.height - 28, // Width and height of the button @@ -200,7 +146,6 @@ class DhConfigScreen extends DhScreen #endif 20, 20, // Create the button and tell it where to go - #if MC_VER > MC_1_12_2 (buttonWidget) -> { ChangelogScreen changelogScreen = new ChangelogScreen(this); if (changelogScreen.usable) @@ -212,13 +157,8 @@ class DhConfigScreen extends DhScreen LOGGER.warn("Changelog was not able to open"); } }, - #endif // 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") - #endif )); } @@ -230,11 +170,7 @@ class DhConfigScreen extends DhScreen (button) -> { ConfigHandler.INSTANCE.configFileHandler.loadFromFile(); - #if MC_VER <= MC_1_12_2 - Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); - #else Objects.requireNonNull(this.minecraft).setScreen(this.parent); - #endif })); // done/close button @@ -245,30 +181,19 @@ class DhConfigScreen extends DhScreen (button) -> { ConfigHandler.INSTANCE.configFileHandler.saveToFile(); - #if MC_VER <= MC_1_12_2 - 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); - #endif - #if MC_VER <= MC_1_12_2 - #elif MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+ + #if MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+ if (this.minecraft != null && this.minecraft.level != null) { this.configListWidget.setRenderBackground(false); } #endif - #if MC_VER > MC_1_12_2 this.addWidget(this.configListWidget); - #endif for (AbstractConfigBase configEntry : ConfigHandler.INSTANCE.configBaseList) { @@ -431,35 +356,18 @@ class DhConfigScreen extends DhScreen private static void setupBooleanMenuOption(ConfigEntry booleanConfigEntry) { // For boolean - #if MC_VER <= MC_1_12_2 - Function func = value -> Translatable("distanthorizons.general."+((Boolean) value ? "true" : "false")).setStyle(new Style().setColor((Boolean) value ? TextFormatting.GREEN : TextFormatting.RED)); - #else Function func = value -> Translatable("distanthorizons.general." + ((Boolean) value ? "true" : "false")).withStyle((Boolean) value ? ChatFormatting.GREEN : ChatFormatting.RED); - #endif final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) booleanConfigEntry.guiValue); configGuiInfo.buttonOptionMap = - #if MC_VER <= MC_1_12_2 - new AbstractMap.SimpleEntry>( - #else new AbstractMap.SimpleEntry>( - #endif (button) -> { - #if MC_VER <= MC_1_12_2 - button.enabled = !booleanConfigEntry.apiIsOverriding(); - #else button.active = !booleanConfigEntry.apiIsOverriding(); - #endif - + 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())); - #endif }, func); } private static void setupEnumMenuOption(ConfigEntry> enumConfigEntry, Class> enumClass) @@ -468,29 +376,20 @@ class DhConfigScreen extends DhScreen final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) enumConfigEntry.guiValue); - #if MC_VER <= MC_1_12_2 - Function getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString()); - #else Function getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString()); - #endif - configGuiInfo.buttonOptionMap = - #if MC_VER <= MC_1_12_2 - new AbstractMap.SimpleEntry>( - #else new AbstractMap.SimpleEntry>( - #endif (button) -> { // get the currently selected enum and enum index int startingIndex = enumList.indexOf(enumConfigEntry.get()); Enum enumValue = enumList.get(startingIndex); - #if MC_VER <= MC_1_12_2 - boolean shiftPressed = GuiScreen.isShiftKeyDown(); - #else - boolean shiftPressed = InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_LEFT_SHIFT) || InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_RIGHT_SHIFT); - #endif + boolean shiftPressed = + InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_LEFT_SHIFT) + || InputConstants.isKeyDown(MC_CLIENT.getGlfwWindowId(), GLFW.GLFW_KEY_RIGHT_SHIFT); + + // move forward or backwards depending on if the shift key is pressed int index = shiftPressed ? startingIndex - 1 : startingIndex + 1; @@ -542,13 +441,9 @@ class DhConfigScreen extends DhScreen 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.setMessage(getEnumTranslatableFunc.apply(enumConfigEntry.get())); - #endif }, getEnumTranslatableFunc); } @@ -564,12 +459,12 @@ class DhConfigScreen extends DhScreen //==============// // 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()); this.reload = true; + Objects.requireNonNull(this.minecraft).setScreen(this); }; int resetButtonPosX = this.width @@ -577,60 +472,29 @@ class DhConfigScreen extends DhScreen - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN; int resetButtonPosZ = 0; - #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif resetButton = MakeBtn( - #if MC_VER <= MC_1_12_2 - Translatable("distanthorizons.general.reset").setStyle(new Style().setColor(TextFormatting.RED)), - #else + Button resetButton = MakeBtn( Translatable("distanthorizons.general.reset").withStyle(ChatFormatting.RED), - #endif resetButtonPosX, resetButtonPosZ, ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_HEIGHT, btnAction); - - if (configEntry.mcVersionOverridePresent()) + if (configEntry.apiIsOverriding()) { - #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.setMessage(Translatable("distanthorizons.general.apiOverride").withStyle(ChatFormatting.DARK_GRAY)); - #endif } else { - #if MC_VER <= MC_1_12_2 - resetButton.enabled = true; - #else resetButton.active = true; - #endif } - //endregion - - + //==============// // option field // //==============// - //region - #if MC_VER <= MC_1_12_2 - ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configEntry); - #else Component textComponent = this.GetTranslatableTextComponentForConfig(configEntry); - #endif int optionFieldPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN @@ -642,40 +506,21 @@ class DhConfigScreen extends DhScreen if (configGuiInfo.buttonOptionMap != null) { // enum/multi option input button - #if MC_VER <= MC_1_12_2 - Map.Entry> widget = configGuiInfo.buttonOptionMap; - #else - Map.Entry> widget = configGuiInfo.buttonOptionMap; - #endif + Map.Entry> widget = configGuiInfo.buttonOptionMap; if (configEntry.getType().isEnum()) { 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( - #endif widget.getValue().apply(configEntry.get()), optionFieldPosX, optionFieldPosZ, ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, widget.getKey()); - // deactivate the button if the API is overriding it - // or the MC version doesn't support it - if (configEntry.mcVersionOverridePresent() - || configEntry.apiIsOverriding()) - { - #if MC_VER <= MC_1_12_2 - button.enabled = false; - #else - button.active = false; - #endif - } - + button.active = !configEntry.apiIsOverriding(); this.configListWidget.addButton(this, configEntry, @@ -689,25 +534,16 @@ class DhConfigScreen extends DhScreen else { // 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, optionFieldPosX, optionFieldPosZ, ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, Translatable("")); widget.setMaxLength(3_000_000); // hopefully 3 million characters should be enough for any normal use-case, lol widget.insertText(String.valueOf(configEntry.get())); - #endif Predicate processor = configGuiInfo.tooltipFunction.apply(widget, this.doneButton); - #if MC_VER <= MC_1_12_2 - widget.setValidator(processor::test); - #elif MC_VER <= MC_1_21_11 + #if MC_VER <= MC_1_21_11 widget.setFilter(processor); #else widget.setResponder(processor::test); @@ -717,8 +553,6 @@ class DhConfigScreen extends DhScreen return true; } - - //endregion } return false; @@ -729,31 +563,18 @@ class DhConfigScreen extends DhScreen { ConfigCategory configCategory = (ConfigCategory) configType; - #if MC_VER <= MC_1_12_2 - ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configCategory); - #else Component textComponent = this.GetTranslatableTextComponentForConfig(configCategory); - #endif 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 - #if MC_VER <= MC_1_12_2 - GuiButton widget = MakeBtn( - #else - Button widget = MakeBtn( - #endif - textComponent, + Button widget = MakeBtn(textComponent, categoryPosX, categoryPosZ, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, ((button) -> { ConfigHandler.INSTANCE.configFileHandler.saveToFile(); - #if MC_VER <= MC_1_12_2 - 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); @@ -768,20 +589,11 @@ class DhConfigScreen extends DhScreen { ConfigUIButton configUiButton = (ConfigUIButton) configType; - #if MC_VER <= MC_1_12_2 - ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configUiButton); - #else Component textComponent = this.GetTranslatableTextComponentForConfig(configUiButton); - #endif int buttonPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN; - #if MC_VER <= MC_1_12_2 - GuiButton widget = MakeBtn( - #else - Button widget = MakeBtn( - #endif - textComponent, + Button widget = MakeBtn(textComponent, buttonPosX, this.height - 28, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT, (button) -> ((ConfigUIButton) configType).runAction()); @@ -798,11 +610,7 @@ class DhConfigScreen extends DhScreen { ConfigUIComment configUiComment = (ConfigUIComment) configType; - #if MC_VER <= MC_1_12_2 - ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configUiComment); - #else Component textComponent = this.GetTranslatableTextComponentForConfig(configUiComment); - #endif if (configUiComment.parentConfigPath != null) { textComponent = Translatable(TRANSLATION_PREFIX + configUiComment.parentConfigPath); @@ -818,13 +626,8 @@ class DhConfigScreen extends DhScreen private boolean tryCreateSpacer(AbstractConfigBase configType) { if (configType instanceof ConfigUISpacer) - { - #if MC_VER <= MC_1_12_2 - GuiButton spacerButton = MakeBtn( - #else - Button spacerButton = MakeBtn( - #endif - Translatable("distanthorizons.general.spacer"), + { + Button spacerButton = MakeBtn(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) 1, 1, (button) -> { }); @@ -849,36 +652,25 @@ class DhConfigScreen extends DhScreen return false; } - #if MC_VER <= MC_1_12_2 - private ITextComponent GetTranslatableTextComponentForConfig(AbstractConfigBase configType) - #else private Component GetTranslatableTextComponentForConfig(AbstractConfigBase configType) - #endif { return Translatable(TRANSLATION_PREFIX + configType.getNameAndCategory()); } - //endregion - //===========// // rendering // //===========// - //region @Override - #if MC_VER <= MC_1_12_2 - public void drawScreen(int mouseX, int mouseY, float delta) - #elif MC_VER < MC_1_20_1 +#if MC_VER < MC_1_20_1 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) - #else +#else public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta) #endif { - #if MC_VER <= MC_1_12_2 - this.drawDefaultBackground(); - #elif MC_VER < MC_1_20_2 // 1.20.2 now enables this by default in the `this.list.render` function + #if MC_VER < MC_1_20_2 // 1.20.2 now enables this by default in the `this.list.render` function this.renderBackground(matrices); #elif MC_VER <= MC_1_21_11 super.render(matrices, mouseX, mouseY, delta); @@ -887,9 +679,7 @@ class DhConfigScreen extends DhScreen #endif // Render buttons - #if MC_VER <= MC_1_12_2 - this.configListWidget.drawScreen(mouseX, mouseY, delta); - #elif MC_VER <= MC_1_21_11 + #if MC_VER <= MC_1_21_11 this.configListWidget.render(matrices, mouseX, mouseY, delta); #else this.configListWidget.extractRenderState(matrices, mouseX, mouseY, delta); @@ -897,74 +687,51 @@ class DhConfigScreen extends DhScreen // Render config title - this.DhDrawCenteredString( - #if MC_VER > MC_1_12_2 - matrices, this.font, - #endif - this.title, + this.DhDrawCenteredString(matrices, this.font, this.title, this.width / 2, 15, - #if MC_VER < MC_1_21_6 + #if MC_VER < MC_1_21_6 0xFFFFFF // RGB white - #else - 0xFFFFFFFF // ARGB white - #endif); + #else + 0xFFFFFFFF // ARGB white + #endif ); // render DH version - this.DhDrawString( - #if MC_VER > MC_1_12_2 - matrices, this.font, - #endif - TextOrLiteral(ModInfo.VERSION), 2, this.height - 10, - #if MC_VER < MC_1_21_6 + this.DhDrawString(matrices, this.font, TextOrLiteral(ModInfo.VERSION), 2, this.height - 10, + #if MC_VER < MC_1_21_6 0xAAAAAA // RGB white - #else - 0xFFAAAAAA // ARGB white - #endif); + #else + 0xFFAAAAAA // ARGB white + #endif ); // If the update is pending, display this message to inform the user that it will apply when the game restarts if (SelfUpdater.deleteOldJarOnJvmShutdown) { - this.DhDrawString( - #if MC_VER > MC_1_12_2 - matrices, this.font, - #endif - Translatable(ModInfo.ID + ".updater.waitingForClose"), 4, this.height - 42, - #if MC_VER < MC_1_21_6 + this.DhDrawString(matrices, this.font, Translatable(ModInfo.ID + ".updater.waitingForClose"), 4, this.height - 42, + #if MC_VER < MC_1_21_6 0xFFFFFF // RGB white - #else - 0xFFFFFFFF // ARGB white - #endif); + #else + 0xFFFFFFFF // ARGB white + #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 - super.drawScreen(mouseX, mouseY, delta); - #elif MC_VER < MC_1_20_2 + this.renderTooltip(matrices, mouseX, mouseY, delta); + + #if MC_VER < MC_1_20_2 super.render(matrices, mouseX, mouseY, delta); #endif } - #if MC_VER <= MC_1_12_2 - private void renderTooltip(int mouseX, int mouseY, float delta) - #elif MC_VER < MC_1_20_1 + #if MC_VER < MC_1_20_1 private void renderTooltip(PoseStack matrices, int mouseX, int mouseY, float delta) #elif MC_VER <= MC_1_21_11 private void renderTooltip(GuiGraphics matrices, int mouseX, int mouseY, float delta) - #else +#else private void renderTooltip(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta) #endif { - #if MC_VER <= MC_1_12_2 - Gui hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY); - #else AbstractWidget hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY); - #endif if (hoveredWidget == null) { return; @@ -980,21 +747,14 @@ class DhConfigScreen extends DhScreen button.dhConfigType; boolean apiOverrideActive = false; - boolean unsupportedMcVersion = false; if (configBase instanceof ConfigEntry) { apiOverrideActive = ((ConfigEntry) configBase).apiIsOverriding(); - unsupportedMcVersion = ((ConfigEntry) configBase).mcVersionOverridePresent(); } - String key = TRANSLATION_PREFIX + (configBase.category.isEmpty() ? "" : configBase.category + ".") + configBase.getName() + ".@tooltip"; - if (unsupportedMcVersion) - { - key = "distanthorizons.general.unsupportedMcVersion.@tooltip"; - } - else if (apiOverrideActive) + if (apiOverrideActive) { key = "distanthorizons.general.disabledByApi.@tooltip"; } @@ -1003,136 +763,37 @@ class DhConfigScreen extends DhScreen final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) configBase.guiValue); 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); - #endif } // display the tooltip if present else if (LANG_WRAPPER.langExists(key)) { - #if MC_VER <= MC_1_12_2 - List list = new ArrayList<>(); - #else List list = new ArrayList<>(); - #endif - String lang = LANG_WRAPPER.getLang(key); for (String langLine : lang.split("\n")) { 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); - #endif } } - #if MC_VER <= MC_1_12_2 - @Override - protected void actionPerformed(GuiButton button) - { - super.actionPerformed(button); - if(button.id == changelogButton_id) - { - ChangelogScreen changelogScreen = new ChangelogScreen(this); - if (changelogScreen.usable) - { - Minecraft.getMinecraft().displayGuiScreen(changelogScreen); - } - else - { - LOGGER.warn("Changelog was not able to open"); - } - } - } - - @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 // //==========// - //region + /** When you close it, it goes to the previous screen and saves */ @Override - #if MC_VER <= MC_1_12_2 - public void onGuiClosed() - #else public void onClose() - #endif { ConfigHandler.INSTANCE.configFileHandler.saveToFile(); - #if MC_VER <= MC_1_12_2 - // Handled by button to avoid recursive loop - #else Objects.requireNonNull(this.minecraft).setScreen(this.parent); - #endif + ClassicConfigGUI.CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run()); } - //endregion } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java index 6e203480c..d67700173 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java @@ -1,6 +1,6 @@ package com.seibel.distanthorizons.common.wrappers.gui.updater; import com.seibel.distanthorizons.common.wrappers.gui.DhScreen; -import com.seibel.distanthorizons.common.wrappers.gui.classicConfig.ClassicConfigGUI; +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; @@ -275,10 +275,11 @@ public class ChangelogScreen extends DhScreen #endif } - @Override #if MC_VER <= MC_1_12_2 + @Override public void onGuiClosed() #else + @Override public void onClose() #endif { @@ -286,7 +287,7 @@ public class ChangelogScreen extends DhScreen #if MC_VER <= MC_1_12_2 // Handled by button to avoid recursive loop #else - Objects.requireNonNull(this.minecraft).setScreen(this.parent); + DhScreenUtil.showScreen(this.parent); #endif } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java index 26e68a166..6ec14a0ff 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java @@ -1,6 +1,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; @@ -173,7 +174,7 @@ public class UpdateModScreen extends DhScreen 20, 20, // Create the button and tell it where to go #if MC_VER > MC_1_12_2 - (buttonWidget) -> Objects.requireNonNull(this.minecraft).setScreen(new ChangelogScreen(this, this.newVersionID)), + (buttonWidget) -> DhScreenUtil.showScreen(new ChangelogScreen(this, this.newVersionID)), #endif // Add a title to the button #if MC_VER <= MC_1_12_2 @@ -295,7 +296,7 @@ public class UpdateModScreen extends DhScreen #if MC_VER <= MC_1_12_2 // Handled by button to avoid recursive loop #else - Objects.requireNonNull(this.minecraft).setScreen(this.parent); + DhScreenUtil.showScreen(this.parent); // Go to the parent screen #endif } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java index b3e34ef94..209571a88 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftRenderWrapper.java @@ -156,9 +156,12 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper #elif 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 } @@ -202,8 +205,12 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper #if MC_VER <= MC_1_12_2 RenderManager rm = MC.getRenderManager(); return new Vec3d(rm.viewerPosX, rm.viewerPosY, rm.viewerPosZ); - #else + #elif 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 @@ -298,20 +305,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, @@ -390,7 +406,14 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper } #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 @Override @@ -469,6 +492,7 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper } #endif } + // TODO vulkan deprecate(?) and add method to get color texture @Override public int getColorTextureId() { @@ -543,9 +567,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 } diff --git a/coreSubProjects b/coreSubProjects index d1f0325f8..2dd5b82be 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit d1f0325f875911056d3f12f02d7e1346042750f0 +Subproject commit 2dd5b82be3619c5b4afdba96701e5d3cb2751679 diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java index e7ebac4a0..052d173eb 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java @@ -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 diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinChunkSectionsToRender.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinChunkSectionsToRender.java index 4c9791bdc..7fef4483e 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinChunkSectionsToRender.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinChunkSectionsToRender.java @@ -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(); diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinGameRenderer.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinGameRenderer.java index efd9c3a89..ecb4a9697 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinGameRenderer.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinGameRenderer.java @@ -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); } } diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java index 4fe893927..7b1f7dd5b 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java @@ -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 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 diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLightTexture.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLightTexture.java index 203052ddc..e37a026c5 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLightTexture.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLightTexture.java @@ -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 diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinMinecraft.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinMinecraft.java index 71f9e4a84..5dc71a446 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinMinecraft.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinMinecraft.java @@ -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) diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinOptionsScreen.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinOptionsScreen.java index 60652a9d8..0d3615055 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinOptionsScreen.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinOptionsScreen.java @@ -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")); diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/config/ModMenuIntegration.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/config/ModMenuIntegration.java index 281493952..742aad75c 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/config/ModMenuIntegration.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/config/ModMenuIntegration.java @@ -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); + //} } diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/IrisAccessor.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/IrisAccessor.java index 40790483d..c20d9cc0c 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/IrisAccessor.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/IrisAccessor.java @@ -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();*/ } } diff --git a/gradle.properties b/gradle.properties index 31c530cab..90fd6504d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -48,7 +48,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 diff --git a/versionProperties/26.2.0.properties b/versionProperties/26.2.0.properties new file mode 100644 index 000000000..b177059e3 --- /dev/null +++ b/versionProperties/26.2.0.properties @@ -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