diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java
index 23e635044..c39e8a69b 100644
--- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java
+++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java
@@ -24,7 +24,10 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrappe
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
import net.minecraft.resources.ResourceLocation;
+import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.Blocks;
+import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import org.apache.logging.log4j.Logger;
@@ -85,6 +88,8 @@ public class BlockStateWrapper implements IBlockStateWrapper
* Should be between {@link IBlockStateWrapper#FULLY_OPAQUE} and {@link IBlockStateWrapper#FULLY_OPAQUE}
*/
private int opacity = -1;
+ /** used by the Iris shader mod to determine how each LOD should be rendered */
+ private byte irisBlockMaterialId = 0;
@@ -116,7 +121,8 @@ public class BlockStateWrapper implements IBlockStateWrapper
{
this.blockState = blockState;
this.serialString = this.serialize(levelWrapper);
- LOGGER.trace("Created BlockStateWrapper ["+this.serialString+"] for ["+blockState+"]");
+ this.irisBlockMaterialId = this.calculateIrisBlockMaterialId();
+ LOGGER.trace("Created BlockStateWrapper ["+this.serialString+"] for ["+blockState+"] with material ID ["+this.irisBlockMaterialId+"]");
}
@@ -274,6 +280,9 @@ public class BlockStateWrapper implements IBlockStateWrapper
#endif
}
+ @Override
+ public byte getIrisBlockMaterialId() { return this.irisBlockMaterialId; }
+
@Override
public String toString() { return this.getSerialString(); }
@@ -457,4 +466,111 @@ public class BlockStateWrapper implements IBlockStateWrapper
+ //==============//
+ // Iris methods //
+ //==============//
+
+ private byte calculateIrisBlockMaterialId()
+ {
+ if (this.blockState == null)
+ {
+ return 0;
+ }
+
+
+ String serialString = this.getSerialString();
+ if (this.blockState.is(BlockTags.LEAVES))
+ {
+ return 1;
+ }
+ else if (serialString.contains("water") && this.isLiquid())
+ {
+ return 12;
+ }
+ else if (this.blockState.getSoundType() == SoundType.WOOD
+ #if MC_VER >= MC_1_19_2
+ || this.blockState.getSoundType() == SoundType.CHERRY_WOOD
+ #endif
+ )
+ {
+ return 3;
+ }
+ else if (this.blockState.getSoundType() == SoundType.METAL
+ #if MC_VER >= MC_1_19_2
+ || this.blockState.getSoundType() == SoundType.COPPER
+ #endif
+ #if MC_VER >= MC_1_20_4
+ || this.blockState.getSoundType() == SoundType.COPPER_BULB
+ || this.blockState.getSoundType() == SoundType.COPPER_GRATE
+ #endif
+ )
+ {
+ return 4;
+ }
+ else if (
+ #if MC_VER >= MC_1_18_2
+ this.blockState.is(BlockTags.DIRT)
+ #else
+ state.is(Blocks.DIRT)
+ || state.is(Blocks.PODZOL)
+ || state.is(Blocks.COARSE_DIRT)
+ || state.is(Blocks.GRASS_BLOCK)
+ #endif
+ )
+ {
+ return 5;
+ }
+ else if (this.blockState.is(Blocks.LAVA))
+ {
+ return 6;
+ }
+ #if MC_VER >= MC_1_17_1
+ else if (this.blockState.getSoundType() == SoundType.DEEPSLATE
+ || this.blockState.getSoundType() == SoundType.DEEPSLATE_BRICKS
+ || this.blockState.getSoundType() == SoundType.DEEPSLATE_TILES
+ || this.blockState.getSoundType() == SoundType.POLISHED_DEEPSLATE)
+ {
+ return 7;
+ }
+ #endif
+ else if (this.blockState.getSoundType() == SoundType.SNOW
+ #if MC_VER >= MC_1_17_1
+ || this.blockState.getSoundType() == SoundType.POWDER_SNOW
+ #endif
+ )
+ {
+ return 8;
+ }
+ else if (this.blockState.is(BlockTags.SAND))
+ {
+ return 9;
+ }
+ else if (
+ #if MC_VER >= MC_1_18_2
+ this.blockState.is(BlockTags.TERRACOTTA)
+ #else
+ serialString.contains("terracotta")
+ #endif
+ )
+ {
+ return 10;
+ }
+ else if (this.blockState.is(BlockTags.BASE_STONE_NETHER))
+ {
+ return 11;
+ }
+ else if (serialString.contains("stone"))
+ {
+ return 2;
+ }
+ else if (this.blockState.getLightEmission() > 0)
+ {
+ return 15;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
}
diff --git a/coreSubProjects b/coreSubProjects
index 1c90270eb..0efa4c3de 160000
--- a/coreSubProjects
+++ b/coreSubProjects
@@ -1 +1 @@
-Subproject commit 1c90270eb61e65354af86ea07b5c2db6914196fe
+Subproject commit 0efa4c3de33b0d2650e0bb99f2e42add066adf6a
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 2fd788b6a..218f4cd5e 100644
--- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java
+++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java
@@ -47,7 +47,6 @@ import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.TitleScreen;
-import java.nio.FloatBuffer;
import java.util.HashSet;
import net.minecraft.client.multiplayer.ClientLevel;
@@ -181,9 +180,6 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
// render event //
//==============//
- //Define this in the MixinLevelRenderer so that it works with sodium without any changes to the code
- // TODO: If all else is fine, can we remove these commented code
- // Client Render Level
WorldRenderEvents.AFTER_SETUP.register((renderContext) ->
{
this.clientApi.renderLods(ClientLevelWrapper.getWrapper(renderContext.world()),
@@ -206,6 +202,14 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy
#endif
}
});
+
+ WorldRenderEvents.AFTER_TRANSLUCENT.register((renderContext) ->
+ {
+ this.clientApi.renderDeferredLods(ClientLevelWrapper.getWrapper(renderContext.world()),
+ McObjectConverter.Convert(renderContext.matrixStack().last().pose()),
+ McObjectConverter.Convert(renderContext.projectionMatrix()),
+ renderContext.tickDelta());
+ });
// Debug keyboard event
// FIXME: Use better hooks so it doesn't trigger key press events in text boxes
diff --git a/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinLevelRenderer.java b/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinLevelRenderer.java
index f6223c099..558696d27 100644
--- a/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinLevelRenderer.java
+++ b/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinLevelRenderer.java
@@ -35,40 +35,29 @@ import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.api.internal.ClientApi;
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
-import net.minecraft.client.Camera;
import net.minecraft.client.multiplayer.ClientLevel;
-import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LevelRenderer;
-import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.RenderType;
-import net.minecraft.world.level.lighting.LevelLightEngine;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import java.nio.FloatBuffer;
-
#if MC_VER < MC_1_17_1
import org.lwjgl.opengl.GL15;
#endif
/**
- * This class is used to mix in my rendering code
+ * This class is used to mix in DH's rendering code
* before Minecraft starts rendering blocks.
* If this wasn't done, and we used Forge's
* render last event, the LODs would render on top
* of the normal terrain.
*
* This is also the mixin for rendering the clouds
- *
- * @author coolGi
- * @author James Seibel
- * @version 12-31-2021
*/
@Mixin(LevelRenderer.class)
public class MixinLevelRenderer
@@ -92,13 +81,15 @@ public class MixinLevelRenderer
public void renderClouds(PoseStack poseStack, Matrix4f projectionMatrix, float partialTicks, double cameraX, double cameraY, double cameraZ, CallbackInfo ci)
#endif
{
+ // FIXME this is only called when clouds are enabled and vanilla render distance is far enough
+ // not having the parital ticks doesn't appear to be critical currently, but might cause weird issues down the line
+
// get the partial ticks since renderBlockLayer doesn't
// have access to them
previousPartialTicks = partialTicks;
}
- // TODO: Can we move this to forge's client proxy similarly to how fabric does it
#if MC_VER < MC_1_17_1
@Inject(at = @At("HEAD"),
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDD)V",
@@ -142,7 +133,7 @@ public class MixinLevelRenderer
// only render before solid blocks
if (renderType.equals(RenderType.solid()))
{
- ClientApi.INSTANCE.renderLods(ClientLevelWrapper.getWrapper(level), mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
+ ClientApi.INSTANCE.renderLods(ClientLevelWrapper.getWrapper(this.level), mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
// experimental proof-of-concept option
if (Config.Client.Advanced.Graphics.AdvancedGraphics.seamlessOverdraw.get())
@@ -157,6 +148,10 @@ public class MixinLevelRenderer
projectionMatrix.set(matrixFloatArray);
#endif
}
+ }
+ else if (renderType.equals(RenderType.translucent()))
+ {
+ ClientApi.INSTANCE.renderDeferredLods(ClientLevelWrapper.getWrapper(this.level), mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
}
if (Config.Client.Advanced.Debugging.lodOnlyMode.get())
diff --git a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinLevelRenderer.java b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinLevelRenderer.java
index 6c54ed6db..ad7ca6cbc 100644
--- a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinLevelRenderer.java
+++ b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinLevelRenderer.java
@@ -51,17 +51,13 @@ import org.lwjgl.opengl.GL15;
/**
- * This class is used to mix in my rendering code
+ * This class is used to mix in DH's rendering code
* before Minecraft starts rendering blocks.
* If this wasn't done, and we used Forge's
* render last event, the LODs would render on top
* of the normal terrain.
*
* This is also the mixin for rendering the clouds
- *
- * @author coolGi
- * @author James Seibel
- * @version 12-31-2021
*/
@Mixin(LevelRenderer.class)
public class MixinLevelRenderer
@@ -88,6 +84,9 @@ public class MixinLevelRenderer
public void renderClouds(PoseStack poseStack, Matrix4f projectionMatrix, float partialTicks, double cameraX, double cameraY, double cameraZ, CallbackInfo ci)
#endif
{
+ // FIXME this is only called when clouds are enabled and vanilla render distance is far enough
+ // not having the partial ticks doesn't appear to be critical currently, but might cause weird issues down the line
+
// get the partial ticks since renderBlockLayer doesn't
// have access to them
previousPartialTicks = partialTicks;
@@ -138,7 +137,7 @@ public class MixinLevelRenderer
// only render before solid blocks
if (renderType.equals(RenderType.solid()))
{
- ClientApi.INSTANCE.renderLods(ClientLevelWrapper.getWrapper(level), mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
+ ClientApi.INSTANCE.renderOpaqueLods(ClientLevelWrapper.getWrapper(level), mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
// experimental proof-of-concept option
if (Config.Client.Advanced.Graphics.AdvancedGraphics.seamlessOverdraw.get())
@@ -153,6 +152,10 @@ public class MixinLevelRenderer
projectionMatrix.set(matrixFloatArray);
#endif
}
+ }
+ else if (renderType.equals(RenderType.translucent()))
+ {
+ ClientApi.INSTANCE.renderTranslucentLods(ClientLevelWrapper.getWrapper(level), mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
}
if (Config.Client.Advanced.Debugging.lodOnlyMode.get())