Respect shader render layer overrides (#1293)

This commit is contained in:
Jason Mitchell authored and GitHub committed 2026-01-23 16:43:01 -08:00
1 parent 2f2fc22df3
commit f79774df65
10 files changed
+98 -67

No files matched your search

@@ -1,10 +1,9 @@
package net.coderbot.iris.block_rendering;
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
import com.gtnewhorizons.angelica.rendering.celeritas.BlockRenderLayer;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
@@ -36,33 +35,37 @@ public class BlockMaterialMapping {
return blockMatches;
}
public static Map<Block, RenderLayer> createBlockTypeMap(Map<NamespacedId, BlockRenderType> blockPropertiesMap) {
Map<Block, RenderLayer> blockTypeIds = new Reference2ReferenceOpenHashMap<>();
public static Map<Block, BlockRenderLayer> createBlockTypeMap(Map<NamespacedId, BlockRenderType> blockPropertiesMap) {
Map<Block, BlockRenderLayer> blockTypeIds = new Reference2ReferenceOpenHashMap<>();
blockPropertiesMap.forEach((id, blockType) -> {
ResourceLocation resourceLocation = new ResourceLocation(id.getNamespace(), id.getName());
final ResourceLocation resourceLocation = new ResourceLocation(id.getNamespace(), id.getName());
final Block block = Block.getBlockFromName(resourceLocation.toString());
Block block = Block.getBlockFromName(resourceLocation.toString());
if (block == null || block == Blocks.air) {
return;
}
blockTypeIds.put(block, convertBlockToRenderType(blockType));
final BlockRenderLayer layer = convertBlockToRenderLayer(blockType);
if (layer != null) {
blockTypeIds.put(block, layer);
}
});
return blockTypeIds;
}
private static RenderLayer convertBlockToRenderType(BlockRenderType type) {
private static BlockRenderLayer convertBlockToRenderLayer(BlockRenderType type) {
if (type == null) {
return null;
}
return switch (type) {
// Everything renders in cutout or translucent in 1.7.10
case SOLID, CUTOUT, CUTOUT_MIPPED -> RenderLayer.cutout();
// case SOLID -> RenderLayer.solid();
// case CUTOUT_MIPPED -> RenderLayer.cutoutMipped();
case TRANSLUCENT -> RenderLayer.translucent();
default -> null;
};
return switch (type) {
case SOLID -> BlockRenderLayer.SOLID;
case CUTOUT -> BlockRenderLayer.CUTOUT;
case CUTOUT_MIPPED -> BlockRenderLayer.CUTOUT_MIPPED;
case TRANSLUCENT -> BlockRenderLayer.TRANSLUCENT;
};
}
/**
@@ -1,6 +1,6 @@
package net.coderbot.iris.block_rendering;
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
import com.gtnewhorizons.angelica.rendering.celeritas.BlockRenderLayer;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntFunction;
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
@@ -18,7 +18,7 @@ public class BlockRenderingSettings {
@Getter
private boolean reloadRequired;
private Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches;
private Map<Block, RenderLayer> blockTypeIds;
private Map<Block, BlockRenderLayer> blockTypeIds;
private Object2IntFunction<NamespacedId> entityIds;
private Object2IntFunction<NamespacedId> itemIds;
private float ambientOcclusionLevel;
@@ -55,7 +55,7 @@ public class BlockRenderingSettings {
}
@Nullable
public Map<Block, RenderLayer> getBlockTypeIds() {
public Map<Block, BlockRenderLayer> getBlockTypeIds() {
return blockTypeIds;
}
@@ -74,7 +74,7 @@ public class BlockRenderingSettings {
this.blockMetaMatches = blockMetaIds;
}
public void setBlockTypeIds(Map<Block, RenderLayer> blockTypeIds) {
public void setBlockTypeIds(Map<Block, BlockRenderLayer> blockTypeIds) {
if (this.blockTypeIds != null && this.blockTypeIds.equals(blockTypeIds)) {
return;
}
@@ -1,5 +1,6 @@
package net.coderbot.iris.celeritas;
import com.gtnewhorizons.angelica.rendering.celeritas.BlockRenderLayer;
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProvider;
import com.gtnewhorizons.angelica.rendering.celeritas.iris.IrisExtendedChunkVertexType;
import net.coderbot.iris.Iris;
@@ -11,7 +12,6 @@ import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
import org.embeddedt.embeddium.impl.render.chunk.shader.ChunkShaderInterface;
import org.embeddedt.embeddium.impl.render.chunk.terrain.TerrainRenderPass;
import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexType;
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
@@ -61,7 +61,7 @@ public class IrisCeleritasShaderProvider implements IrisShaderProvider {
@Override
@Nullable
public Map<Block, RenderLayer> getBlockTypeIds() {
public Map<Block, BlockRenderLayer> getBlockTypeIds() {
return BlockRenderingSettings.INSTANCE.getBlockTypeIds();
}
@@ -3,9 +3,9 @@ package net.coderbot.iris.pipeline;
import com.gtnewhorizons.angelica.compat.mojang.Camera;
import com.gtnewhorizons.angelica.compat.mojang.GameModeUtil;
import com.gtnewhorizons.angelica.compat.mojang.InteractionHand;
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.rendering.RenderingState;
import com.gtnewhorizons.angelica.rendering.celeritas.BlockRenderLayer;
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
import net.coderbot.iris.layer.GbufferPrograms;
import net.irisshaders.iris.api.v0.IrisApi;
@@ -81,14 +81,12 @@ public class HandRenderer {
public boolean isHandTranslucent(InteractionHand hand) {
ItemStack heldItem = hand.getItemInHand(Minecraft.getMinecraft().thePlayer);
if (heldItem == null) {
return false;
}
Item item = heldItem.getItem();
if (heldItem == null) return false;
final Item item = heldItem.getItem();
if (item instanceof ItemBlock itemBlock) {
Map<Block, RenderLayer> blockTypeIds = BlockRenderingSettings.INSTANCE.getBlockTypeIds();
return blockTypeIds != null && blockTypeIds.get(itemBlock.field_150939_a) == RenderLayer.translucent();
final Map<Block, BlockRenderLayer> blockTypeIds = BlockRenderingSettings.INSTANCE.getBlockTypeIds();
return blockTypeIds != null && blockTypeIds.get(itemBlock.field_150939_a) == BlockRenderLayer.TRANSLUCENT;
}
return false;