add DhApiBeforeFogRenderEvent

This commit is contained in:
James Seibel
2026-05-22 09:37:12 -05:00
parent b8c90985ce
commit 0b297b4cd7
5 changed files with 111 additions and 151 deletions
@@ -24,9 +24,8 @@ public class BlazeDhFogRenderer {}
#else #else
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogColorMode;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode; import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiFogRenderParam;
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer; import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer; import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper; import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
@@ -50,8 +49,6 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhFo
import java.awt.*; import java.awt.*;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.util.OptionalDouble;
import java.util.OptionalInt;
import com.mojang.blaze3d.buffers.GpuBuffer; import com.mojang.blaze3d.buffers.GpuBuffer;
import com.mojang.blaze3d.buffers.GpuBufferSlice; import com.mojang.blaze3d.buffers.GpuBufferSlice;
@@ -61,7 +58,6 @@ import com.mojang.blaze3d.pipeline.BlendFunction;
import com.mojang.blaze3d.pipeline.RenderPipeline; import com.mojang.blaze3d.pipeline.RenderPipeline;
import com.mojang.blaze3d.systems.CommandEncoder; import com.mojang.blaze3d.systems.CommandEncoder;
import com.mojang.blaze3d.systems.GpuDevice; import com.mojang.blaze3d.systems.GpuDevice;
import com.mojang.blaze3d.systems.RenderPass;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
#if MC_VER <= MC_26_1_2 #if MC_VER <= MC_26_1_2
@@ -168,7 +164,7 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
//region //region
@Override @Override
public void render(RenderParams renderParams) public void render(RenderParams renderParams, DhApiFogRenderParam fogRenderParams)
{ {
this.tryInit(); this.tryInit();
@@ -229,48 +225,19 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
// create data // // create data //
int lodDrawDistance = Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius.get() * LodUtil.CHUNK_WIDTH; int lodDrawDistance = Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius.get() * LodUtil.CHUNK_WIDTH;
Mat4f inverseMvmProjMatrix = new Mat4f(renderParams.dhMvmProjMatrix); Mat4f inverseMvmProjMatrix = new Mat4f(renderParams.dhMvmProjMatrix);
inverseMvmProjMatrix.invert(); inverseMvmProjMatrix.invert();
if (renderParams.dhMvmProjMatrix == null) EDhApiHeightFogMixMode heightFogMixingMode = fogRenderParams.getHeightFogMixingMode();
{ boolean heightFogEnabled =
return; heightFogMixingMode != EDhApiHeightFogMixMode.SPHERICAL
} && heightFogMixingMode != EDhApiHeightFogMixMode.CYLINDRICAL;
Color fogColor = this.getFogColor(renderParams.partialTicks);
// fog config
float farFogStart = Config.Client.Advanced.Graphics.Fog.farFogStart.get();
float farFogEnd = Config.Client.Advanced.Graphics.Fog.farFogEnd.get();
float farFogMin = Config.Client.Advanced.Graphics.Fog.farFogMin.get();
float farFogMax = Config.Client.Advanced.Graphics.Fog.farFogMax.get();
float farFogDensity = Config.Client.Advanced.Graphics.Fog.farFogDensity.get();
// override fog if underwater
if (MC_RENDER.isFogStateSpecial())
{
// hide everything behind fog
farFogStart = 0.0f;
farFogEnd = 0.0f;
}
// height config
EDhApiHeightFogMixMode heightFogMixingMode = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMixMode.get();
boolean heightFogEnabled = heightFogMixingMode != EDhApiHeightFogMixMode.SPHERICAL && heightFogMixingMode != EDhApiHeightFogMixMode.CYLINDRICAL;
boolean useSphericalFog = heightFogMixingMode == EDhApiHeightFogMixMode.SPHERICAL; boolean useSphericalFog = heightFogMixingMode == EDhApiHeightFogMixMode.SPHERICAL;
EDhApiHeightFogDirection heightFogCameraDirection = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogDirection.get();
float heightFogStart = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogStart.get(); Color fogColor = fogRenderParams.getFogColor();
float heightFogEnd = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogEnd.get();
float heightFogMin = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMin.get();
float heightFogMax = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMax.get();
float heightFogDensity = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogDensity.get();
// upload data // // upload data //
@@ -287,31 +254,30 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
fogColor.getAlpha() / 255.0f) // uFogColor fogColor.getAlpha() / 255.0f) // uFogColor
.putFloat(1.f / lodDrawDistance) //uFogScale .putFloat(1.f / lodDrawDistance) //uFogScale
.putFloat(1.f / MC.getWrappedClientLevel().getMaxHeight()) //uFogVerticalScale .putFloat(1.f / MC.getWrappedClientLevel().getMaxHeight()) //uFogVerticalScale
// only used for debugging .putInt(0) //uFogDebugMode // 0 = normal // 1 = render everything with fog color // 7 = use debug rendering
.putInt(0) //uFogDebugMode // 1 = render everything with fog color // 7 = use debug rendering .putInt(fogRenderParams.getFarFogFalloff().value) //uFogFalloffType
.putInt(Config.Client.Advanced.Graphics.Fog.farFogFalloff.get().value) //uFogFalloffType
// fog config // fog config
.putFloat(farFogStart) // uFarFogStart .putFloat(fogRenderParams.getFarFogStartPercent()) // uFarFogStart
.putFloat(farFogEnd - farFogStart) // uFarFogLength .putFloat(fogRenderParams.getFarFogEndPercent() - fogRenderParams.getFarFogStartPercent()) // uFarFogLength
.putFloat(farFogMin) // uFarFogMin .putFloat(fogRenderParams.getFarFogMinThickness()) // uFarFogMin
.putFloat(farFogMax - farFogMin) // uFarFogRange .putFloat(fogRenderParams.getFarFogMaxThickness() - fogRenderParams.getFarFogMinThickness()) // uFarFogRange
.putFloat(farFogDensity) // uFarFogDensity .putFloat(fogRenderParams.getFarFogDensity()) // uFarFogDensity
// height fog config // height fog config
.putFloat(heightFogStart) // uHeightFogStart .putFloat(fogRenderParams.getHeightFogStartPercent()) // uHeightFogStart
.putFloat(heightFogEnd - heightFogStart) // uHeightFogLength .putFloat(fogRenderParams.getHeightFogEndPercent() - fogRenderParams.getHeightFogStartPercent()) // uHeightFogLength
.putFloat(heightFogMin) // uHeightFogMin .putFloat(fogRenderParams.getHeightFogMinThickness()) // uHeightFogMin
.putFloat(heightFogMax - heightFogMin) // uHeightFogRange .putFloat(fogRenderParams.getHeightFogMaxThickness() - fogRenderParams.getHeightFogMinThickness()) // uHeightFogRange
.putFloat(heightFogDensity) // uHeightFogDensity .putFloat(fogRenderParams.getHeightFogDensity()) // uHeightFogDensity
// ?? // ??
.putInt(heightFogEnabled ? 1 : 0) // uHeightFogEnabled .putInt(heightFogEnabled ? 1 : 0) // uHeightFogEnabled
.putInt(Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogFalloff.get().value) // uHeightFogFalloffType .putInt(fogRenderParams.getHeightFogFalloff().value) // uHeightFogFalloffType
.putInt(heightFogCameraDirection.basedOnCamera ? 1 : 0) // uHeightBasedOnCamera .putInt(fogRenderParams.getHeightFogDirection().basedOnCamera ? 1 : 0) // uHeightBasedOnCamera
.putFloat(Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogBaseHeight.get()) // uHeightFogBaseHeight .putFloat(fogRenderParams.getHeightFogBaseHeight()) // uHeightFogBaseHeight
.putInt(heightFogCameraDirection.fogAppliesUp ? 1 : 0) // uHeightFogAppliesUp .putInt(fogRenderParams.getHeightFogDirection().fogAppliesUp ? 1 : 0) // uHeightFogAppliesUp
.putInt(heightFogCameraDirection.fogAppliesDown ? 1 : 0) // uHeightFogAppliesDown .putInt(fogRenderParams.getHeightFogDirection().fogAppliesDown ? 1 : 0) // uHeightFogAppliesDown
.putInt(useSphericalFog ? 1 : 0) // uUseSphericalFog .putInt(useSphericalFog ? 1 : 0) // uUseSphericalFog
.putInt(heightFogMixingMode.value) // uHeightFogMixingMode .putInt(heightFogMixingMode.value) // uHeightFogMixingMode
.putFloat((float)MC_RENDER.getCameraExactPosition().y) // uCameraBlockYPos .putFloat((float)MC_RENDER.getCameraExactPosition().y) // uCameraBlockYPos
@@ -335,21 +301,7 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
} }
private Color getFogColor(float partialTicks)
{
Color fogColor;
if (Config.Client.Advanced.Graphics.Fog.colorMode.get() == EDhApiFogColorMode.USE_SKY_COLOR)
{
fogColor = MC_RENDER.getSkyColor();
}
else
{
fogColor = MC_RENDER.getFogColor(partialTicks);
}
return fogColor;
}
private void renderFogToTexture() private void renderFogToTexture()
{ {
@@ -19,6 +19,7 @@
package com.seibel.distanthorizons.common.render.openGl.postProcessing.fog; package com.seibel.distanthorizons.common.render.openGl.postProcessing.fog;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiFogRenderParam;
import com.seibel.distanthorizons.common.render.openGl.glObject.GLState; import com.seibel.distanthorizons.common.render.openGl.glObject.GLState;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper; import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
@@ -108,7 +109,7 @@ public class GlDhFogRenderer implements IDhFogRenderer
//region //region
@Override @Override
public void render(RenderParams renderParams) public void render(RenderParams renderParams, DhApiFogRenderParam fogRenderParams)
{ {
// GLState needed in MC 1.16.5 probably due to MC not manually setting each GL state they need before the next rendering step // GLState needed in MC 1.16.5 probably due to MC not manually setting each GL state they need before the next rendering step
try (GLState state = new GLState()) try (GLState state = new GLState())
@@ -126,7 +127,7 @@ public class GlDhFogRenderer implements IDhFogRenderer
} }
GlDhFogShader.INSTANCE.frameBuffer = this.fogFramebuffer; GlDhFogShader.INSTANCE.frameBuffer = this.fogFramebuffer;
GlDhFogShader.INSTANCE.setProjectionMatrix(renderParams.dhMvmProjMatrix); GlDhFogShader.INSTANCE.prepUniformObjects(renderParams.dhMvmProjMatrix, fogRenderParams);
GlDhFogShader.INSTANCE.render(renderParams); GlDhFogShader.INSTANCE.render(renderParams);
GlDhFogApplyShader.INSTANCE.fogTexture = this.fogTexture; GlDhFogApplyShader.INSTANCE.fogTexture = this.fogTexture;
@@ -19,9 +19,9 @@
package com.seibel.distanthorizons.common.render.openGl.postProcessing.fog; package com.seibel.distanthorizons.common.render.openGl.postProcessing.fog;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogColorMode;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection; import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode; import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiFogRenderParam;
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f; import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
import com.seibel.distanthorizons.common.render.openGl.GlDhMetaRenderer; import com.seibel.distanthorizons.common.render.openGl.GlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram; import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
@@ -37,8 +37,6 @@ import com.seibel.distanthorizons.core.util.math.Mat4f;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import org.lwjgl.opengl.GL32; import org.lwjgl.opengl.GL32;
import java.awt.*;
public class GlDhFogShader extends GlAbstractShaderRenderer public class GlDhFogShader extends GlAbstractShaderRenderer
{ {
public static final GlDhFogShader INSTANCE = new GlDhFogShader(); public static final GlDhFogShader INSTANCE = new GlDhFogShader();
@@ -51,6 +49,7 @@ public class GlDhFogShader extends GlAbstractShaderRenderer
public int frameBuffer; public int frameBuffer;
private Mat4f inverseMvmProjMatrix; private Mat4f inverseMvmProjMatrix;
private DhApiFogRenderParam fogRenderParams;
@@ -167,95 +166,58 @@ public class GlDhFogShader extends GlAbstractShaderRenderer
{ {
int lodDrawDistance = Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius.get() * LodUtil.CHUNK_WIDTH; int lodDrawDistance = Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius.get() * LodUtil.CHUNK_WIDTH;
this.shader.setUniform(this.uInvMvmProj, this.inverseMvmProjMatrix);
if (this.inverseMvmProjMatrix != null)
{
this.shader.setUniform(this.uInvMvmProj, this.inverseMvmProjMatrix);
}
// Fog uniforms // Fog uniforms
this.shader.setUniform(this.uFogColor, this.getFogColor(renderParams.partialTicks)); this.shader.setUniform(this.uFogColor, this.fogRenderParams.getFogColor());
this.shader.setUniform(this.uFogScale, 1.f / lodDrawDistance); this.shader.setUniform(this.uFogScale, 1.f / lodDrawDistance);
this.shader.setUniform(this.uFogVerticalScale, 1.f / MC.getWrappedClientLevel().getMaxHeight()); this.shader.setUniform(this.uFogVerticalScale, 1.f / MC.getWrappedClientLevel().getMaxHeight());
// only used for debugging this.shader.setUniform(this.uFogDebugMode, 0); // 0 = normal // 1 = render everything with fog color // 7 = use debug rendering
this.shader.setUniform(this.uFogDebugMode, 0); // 1 = render everything with fog color // 7 = use debug rendering this.shader.setUniform(this.uFogFalloffType, this.fogRenderParams.getFarFogFalloff().value);
this.shader.setUniform(this.uFogFalloffType, Config.Client.Advanced.Graphics.Fog.farFogFalloff.get().value);
// fog config // fog config
float farFogStart = Config.Client.Advanced.Graphics.Fog.farFogStart.get(); this.shader.setUniform(this.uFarFogStart, this.fogRenderParams.getFarFogStartPercent());
float farFogEnd = Config.Client.Advanced.Graphics.Fog.farFogEnd.get(); this.shader.setUniform(this.uFarFogLength, this.fogRenderParams.getFarFogEndPercent() - this.fogRenderParams.getFarFogStartPercent());
float farFogMin = Config.Client.Advanced.Graphics.Fog.farFogMin.get(); this.shader.setUniform(this.uFarFogMin, this.fogRenderParams.getFarFogMinThickness());
float farFogMax = Config.Client.Advanced.Graphics.Fog.farFogMax.get(); this.shader.setUniform(this.uFarFogRange, this.fogRenderParams.getFarFogMaxThickness() - this.fogRenderParams.getFarFogMinThickness());
float farFogDensity = Config.Client.Advanced.Graphics.Fog.farFogDensity.get(); this.shader.setUniform(this.uFarFogDensity, this.fogRenderParams.getFarFogDensity());
// override fog if underwater
if (MC_RENDER.isFogStateSpecial())
{
// hide everything behind fog
farFogStart = 0.0f;
farFogEnd = 0.0f;
}
this.shader.setUniform(this.uFarFogStart, farFogStart);
this.shader.setUniform(this.uFarFogLength, farFogEnd - farFogStart);
this.shader.setUniform(this.uFarFogMin, farFogMin);
this.shader.setUniform(this.uFarFogRange, farFogMax - farFogMin);
this.shader.setUniform(this.uFarFogDensity, farFogDensity);
// height config // height config
EDhApiHeightFogMixMode heightFogMixingMode = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMixMode.get(); EDhApiHeightFogMixMode heightFogMixingMode = this.fogRenderParams.getHeightFogMixingMode();
boolean heightFogEnabled = heightFogMixingMode != EDhApiHeightFogMixMode.SPHERICAL && heightFogMixingMode != EDhApiHeightFogMixMode.CYLINDRICAL; boolean heightFogEnabled =
heightFogMixingMode != EDhApiHeightFogMixMode.SPHERICAL
&& heightFogMixingMode != EDhApiHeightFogMixMode.CYLINDRICAL;
boolean useSphericalFog = heightFogMixingMode == EDhApiHeightFogMixMode.SPHERICAL; boolean useSphericalFog = heightFogMixingMode == EDhApiHeightFogMixMode.SPHERICAL;
EDhApiHeightFogDirection heightFogCameraDirection = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogDirection.get(); EDhApiHeightFogDirection heightFogDirection = this.fogRenderParams.getHeightFogDirection();
float heightFogStart = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogStart.get(); this.shader.setUniform(this.uHeightFogStart, this.fogRenderParams.getHeightFogStartPercent());
float heightFogEnd = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogEnd.get(); this.shader.setUniform(this.uHeightFogLength, this.fogRenderParams.getHeightFogEndPercent() - this.fogRenderParams.getHeightFogStartPercent());
float heightFogMin = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMin.get(); this.shader.setUniform(this.uHeightFogMin, this.fogRenderParams.getFarFogMinThickness());
float heightFogMax = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogMax.get(); this.shader.setUniform(this.uHeightFogRange, this.fogRenderParams.getFarFogMaxThickness() - this.fogRenderParams.getFarFogMinThickness());
float heightFogDensity = Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogDensity.get(); this.shader.setUniform(this.uHeightFogDensity, this.fogRenderParams.getFarFogDensity());
this.shader.setUniform(this.uHeightFogStart, heightFogStart);
this.shader.setUniform(this.uHeightFogLength, heightFogEnd - heightFogStart);
this.shader.setUniform(this.uHeightFogMin, heightFogMin);
this.shader.setUniform(this.uHeightFogRange, heightFogMax - heightFogMin);
this.shader.setUniform(this.uHeightFogDensity, heightFogDensity);
this.shader.setUniform(this.uHeightFogEnabled, heightFogEnabled); this.shader.setUniform(this.uHeightFogEnabled, heightFogEnabled);
this.shader.setUniform(this.uHeightFogFalloffType, Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogFalloff.get().value); this.shader.setUniform(this.uHeightFogFalloffType, this.fogRenderParams.getHeightFogFalloff().value);
this.shader.setUniform(this.uHeightFogBaseHeight, Config.Client.Advanced.Graphics.Fog.HeightFog.heightFogBaseHeight.get()); this.shader.setUniform(this.uHeightFogBaseHeight, this.fogRenderParams.getHeightFogBaseHeight());
this.shader.setUniform(this.uHeightBasedOnCamera, heightFogCameraDirection.basedOnCamera); this.shader.setUniform(this.uHeightBasedOnCamera, heightFogDirection.basedOnCamera);
this.shader.setUniform(this.uHeightFogAppliesUp, heightFogCameraDirection.fogAppliesUp); this.shader.setUniform(this.uHeightFogAppliesUp, heightFogDirection.fogAppliesUp);
this.shader.setUniform(this.uHeightFogAppliesDown, heightFogCameraDirection.fogAppliesDown); this.shader.setUniform(this.uHeightFogAppliesDown, heightFogDirection.fogAppliesDown);
this.shader.setUniform(this.uUseSphericalFog, useSphericalFog); this.shader.setUniform(this.uUseSphericalFog, useSphericalFog);
this.shader.setUniform(this.uHeightFogMixingMode, heightFogMixingMode.value); this.shader.setUniform(this.uHeightFogMixingMode, heightFogMixingMode.value);
this.shader.setUniform(this.uCameraBlockYPos, (float)MC_RENDER.getCameraExactPosition().y); this.shader.setUniform(this.uCameraBlockYPos, (float)MC_RENDER.getCameraExactPosition().y);
} }
private Color getFogColor(float partialTicks)
{
Color fogColor;
if (Config.Client.Advanced.Graphics.Fog.colorMode.get() == EDhApiFogColorMode.USE_SKY_COLOR)
{
fogColor = MC_RENDER.getSkyColor();
}
else
{
fogColor = MC_RENDER.getFogColor(partialTicks);
}
return fogColor;
}
public void setProjectionMatrix(DhApiMat4f modelViewProjectionMatrix) public void prepUniformObjects(DhApiMat4f modelViewProjectionMatrix, DhApiFogRenderParam fogRenderParams)
{ {
this.inverseMvmProjMatrix = new Mat4f(modelViewProjectionMatrix); this.inverseMvmProjMatrix = new Mat4f(modelViewProjectionMatrix);
this.inverseMvmProjMatrix.invert(); this.inverseMvmProjMatrix.invert();
this.fogRenderParams = fogRenderParams;
} }
//endregion //endregion
@@ -1,11 +1,8 @@
package com.seibel.distanthorizons.fabric; package com.seibel.distanthorizons.fabric;
import com.seibel.distanthorizons.api.DhApi; import com.seibel.distanthorizons.api.DhApi;
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBlockColorOverrideEvent; import com.seibel.distanthorizons.api.methods.events.abstractEvents.*;
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBlockStateWrapperCreatedEvent;
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiChunkProcessingEvent;
import com.seibel.distanthorizons.api.methods.events.DhApiEventRegister; import com.seibel.distanthorizons.api.methods.events.DhApiEventRegister;
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiLevelLoadEvent;
import com.seibel.distanthorizons.common.AbstractModInitializer; import com.seibel.distanthorizons.common.AbstractModInitializer;
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper; import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
@@ -18,10 +15,7 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender; import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
import com.seibel.distanthorizons.fabric.testing.TestBlockWrapperCreatedEvent; import com.seibel.distanthorizons.fabric.testing.*;
import com.seibel.distanthorizons.fabric.testing.TestChunkInputReplacerEvent;
import com.seibel.distanthorizons.fabric.testing.TestCustomColorEvent;
import com.seibel.distanthorizons.fabric.testing.TestWorldGenBindingEvent;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
@@ -106,6 +100,12 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
DhApi.events.bind(DhApiBlockColorOverrideEvent.class, new TestCustomColorEvent()); DhApi.events.bind(DhApiBlockColorOverrideEvent.class, new TestCustomColorEvent());
DhApi.events.bind(DhApiBlockStateWrapperCreatedEvent.class, new TestBlockWrapperCreatedEvent()); DhApi.events.bind(DhApiBlockStateWrapperCreatedEvent.class, new TestBlockWrapperCreatedEvent());
} }
// test fog override
if (false)
{
DhApi.events.bind(DhApiBeforeFogRenderEvent.class, new TestFogRenderEvent());
}
} }
@@ -0,0 +1,45 @@
package com.seibel.distanthorizons.fabric.testing;
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeFogRenderEvent;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiCancelableEventParam;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiFogRenderParam;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiMutableFogRenderParam;
import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
public class TestFogRenderEvent extends DhApiBeforeFogRenderEvent
{
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
private static final float INCREMENT_PER_SECOND = 0.25f;
private float lastFar = 1;
private long lastUpdateTime = System.nanoTime();
@Override
public void beforeRender(DhApiCancelableEventParam<EventParam> event)
{
EventParam eventParam = event.value;
DhApiFogRenderParam originalParms = eventParam.getOriginalFogRenderParam();
DhApiMutableFogRenderParam mutableParms = eventParam.getFogRenderParam();
long currentTime = System.nanoTime();
float deltaSeconds = (currentTime - this.lastUpdateTime) / 1_000_000_000f;
this.lastUpdateTime = currentTime;
this.lastFar += INCREMENT_PER_SECOND * deltaSeconds;
if (this.lastFar >= originalParms.getFarFogMaxThickness())
{
this.lastFar = 0.0f;
}
mutableParms.setFarFogStartPercent(this.lastFar);
mutableParms.setFarFogEndPercent(this.lastFar + 0.5f);
}
}