Fabric Screen Layers - Screen Layer Management for Fabric
Fabric Screen Layers implements multi-level interface display functionality in Minecraft, similar to the GuiScreenLayering system from Minecraft Forge. Using mixin technology, this tool allows overlaying various screens on top of each other, creating complex interface compositions.
Main Features
To add a new screen on top of an existing one:
ScreenLayerManager.pushLayer(new CustomScreen());
To remove the current screen:
ScreenLayerManager.popLayer();
To completely clear all screens:
ScreenLayerManager.clearLayers();
Important Working Features
When working with element positioning on the screen or their scaling, be sure to use the ScreenLayerManager.getFarPlane() method. This ensures proper compatibility with other modifications using the layer system.
Implementation example:
RenderSystem.clear(GL_DEPTH_BUFFER_BIT, Minecraft.ON_OSX);
Matrix4f matrix4f = new Matrix4f().setOrtho(0.0F, (float) width, (float) height, 0.0F, 100.0F, ScreenLayerManager.getFarPlane());
RenderSystem.setProjectionMatrix(matrix4f);
PoseStack posestack = RenderSystem.getModelViewStack();
posestack.setIdentity();
posestack.translate(0.0D, 0.0D, 1000.0F - ScreenLayerManager.getFarPlane());