Fix dark AE2 cables when shaders enabled (#2223)

This commit is contained in:
Ancalagon authored and GitHub committed 2026-10-08 23:27:24 -07:00
1 parent bfb66d84ee
commit 1946c2ad65
3 files changed
+35 -2

No files matched your search

@@ -3,11 +3,16 @@ package com.gtnewhorizons.angelica.rendering;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
import com.gtnewhorizons.angelica.api.ThreadSafeISBRHFactory;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.IBlockAccess;
public final class IsbrhDispatch {
@@ -38,6 +43,7 @@ public final class IsbrhDispatch {
private static final class PerThread {
int gen = -1;
int worldRenderDepth;
ISimpleBlockRenderingHandler[] byId = new ISimpleBlockRenderingHandler[0];
final Reference2ObjectOpenHashMap<Class<?>, ISimpleBlockRenderingHandler> byClass = new Reference2ObjectOpenHashMap<>();
}
@@ -46,6 +52,28 @@ public final class IsbrhDispatch {
private IsbrhDispatch() {}
public static boolean isRenderingWorldBlock() {
return PER_THREAD.get().worldRenderDepth != 0;
}
public static boolean renderWorldBlock(ISimpleBlockRenderingHandler handler, RenderBlocks renderer,
IBlockAccess world, int x, int y, int z, Block block, int modelId) {
final PerThread state = PER_THREAD.get();
final int previousDepth = state.worldRenderDepth;
state.worldRenderDepth = previousDepth + 1;
try {
final Tessellator tessellator = TessellatorManager.get();
// Avoid stale lightmap values for ISBRHs that don't set brightness
if (((StateAwareTessellator) tessellator).angelica$isCeleritasMeshing()
&& !tessellator.hasBrightness) {
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
}
return handler.renderWorldBlock(world, x, y, z, block, modelId, renderer);
} finally {
state.worldRenderDepth = previousDepth;
}
}
public static ISimpleBlockRenderingHandler resolve(Map<Integer, ISimpleBlockRenderingHandler> map, int modelId) {
return resolve(map, modelId, Thread.currentThread() == GLStateManager.getMainThread());
}
@@ -6,6 +6,7 @@ import com.gtnewhorizons.angelica.common.BlockError;
import com.gtnewhorizons.angelica.experimental.surround.Surround;
import com.gtnewhorizons.angelica.loading.AngelicaClientTweaker;
import com.gtnewhorizons.angelica.proxy.ClientProxy;
import com.gtnewhorizons.angelica.rendering.IsbrhDispatch;
import com.gtnewhorizons.angelica.rendering.StateAwareTessellator;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local;
@@ -133,7 +134,11 @@ public abstract class MixinRenderBlocks implements ExtCeleritasRenderBlocks {
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;getMixedBrightnessForBlock(Lnet/minecraft/world/IBlockAccess;III)I"),
require = 1)
private int angelica$skipDiscardedBrightness(Block block, IBlockAccess world, int x, int y, int z, @Local(ordinal = 0) Tessellator tessellator) {
return this.applyingCeleritasAO && ((StateAwareTessellator) tessellator).angelica$isCeleritasMeshing() ? 0 : block.getMixedBrightnessForBlock(world, x, y, z);
final boolean discard = this.applyingCeleritasAO && this.isRenderingByType
&& ((Object) this).getClass() == RenderBlocks.class
&& !IsbrhDispatch.isRenderingWorldBlock()
&& ((StateAwareTessellator) tessellator).angelica$isCeleritasMeshing();
return discard ? 0 : block.getMixedBrightnessForBlock(world, x, y, z);
}
@Override
@@ -33,7 +33,7 @@ public class MixinRenderingRegistry implements IRenderingRegistryExt {
@Overwrite
public boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId) {
ISimpleBlockRenderingHandler h = IsbrhDispatch.resolve(this.blockRenderers, modelId);
return h != null && h.renderWorldBlock(world, x, y, z, block, modelId, renderer);
return h != null && IsbrhDispatch.renderWorldBlock(h, renderer, world, x, y, z, block, modelId);
}
@Surround(method = { "renderInventoryBlock", "renderItemAsFull3DBlock" }, at = @At(value="INVOKE", target="Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;"))