Hi there, I am trying to add an image to the screen when the inventory is opened. So far, I've been able to get the image working (using RenderSystem and blit()), but it always appears behind the inventory (in other words, if you put one over the other, only the inventory will show). I have tried to use RenderSystem.depthFunc(519); (or depthFunc()) to set the image in front, but it still is displayed behind. (Also, just a heads up, the code doesn't bind the image to the mouse like I thought it would, but that is just for testing).
Clearly, I'm missing something here. What function allows an image to be rendered in front of the inventory?
Thanks, and if you see this then have a nice day
My code so far:
public static ResourceLocation LOCK = new ResourceLocation(ExampleMod.MOD_ID, "textures/gui/lock-opaque.png");
@SubscribeEvent
public static void onGuiRender(RenderGuiOverlayEvent.Post event) {
if (Minecraft.getInstance().player != null && Minecraft.getInstance().screen instanceof InventoryScreen) {
renderOverlay(event.getPoseStack(), (int) Minecraft.getInstance().mouseHandler.xpos(), (int) Minecraft.getInstance().mouseHandler.ypos());
}
}
public static void renderOverlay(PoseStack poseStack, int x, int y) {
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderSystem.setShaderTexture(0, LOCK);
RenderSystem.enableDepthTest();
RenderSystem.depthFunc(519);
blit(poseStack, x, y, 0, 0, 16, 16, 16, 16);
RenderSystem.depthFunc(515);
RenderSystem.disableDepthTest();
}