Fix incorrect HUD z index for sub layers ()

Fixes 
This commit is contained in:
modmuss 2025-02-11 16:41:40 +00:00 committed by GitHub
parent 6de41552f4
commit 0d31b09f50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions
fabric-rendering-v1/src/client/java/net/fabricmc/fabric
impl/client/rendering
mixin/client/rendering

View file

@ -22,6 +22,8 @@ import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.LayeredDrawer;
import net.minecraft.client.render.RenderTickCounter;
import net.fabricmc.fabric.mixin.client.rendering.LayeredDrawerAccessor;
/**
* A layer that wraps another layered drawer that can be added to {@link net.fabricmc.fabric.api.client.rendering.v1.LayeredDrawerWrapper LayeredDrawerWrapper}.
*
@ -30,11 +32,15 @@ import net.minecraft.client.render.RenderTickCounter;
* @param delegate the layered drawer to wrap
* @param shouldRender a boolean supplier that determines if the layer should render
*/
public record SubLayer(LayeredDrawer delegate, BooleanSupplier shouldRender) implements LayeredDrawer.Layer {
public record SubLayer(LayeredDrawer delegate, BooleanSupplier shouldRender, LayeredDrawerAccessor layeredDrawerAccessor) implements LayeredDrawer.Layer {
public SubLayer(LayeredDrawer delegate, BooleanSupplier shouldRender) {
this(delegate, shouldRender, (LayeredDrawerAccessor) delegate);
}
@Override
public void render(DrawContext context, RenderTickCounter tickCounter) {
if (shouldRender.getAsBoolean()) {
delegate.render(context, tickCounter);
layeredDrawerAccessor.invokeRenderInternal(context, tickCounter);
}
}
}

View file

@ -20,11 +20,17 @@ import java.util.List;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.LayeredDrawer;
import net.minecraft.client.render.RenderTickCounter;
@Mixin(LayeredDrawer.class)
public interface LayeredDrawerAccessor {
@Accessor
List<LayeredDrawer.Layer> getLayers();
@Invoker("renderInternal")
void invokeRenderInternal(DrawContext context, RenderTickCounter tickCounter);
}