Posted December 10, 20222 yr Hi, I am on an issue currently, I am rendering the screen gui as well as the tooltips. However they do not align. Moreover, even when I align them on screen and then try to open the screen on my other monitor which has a different resolution, it removes every alignment. Here is the Menu constructor, with the slots positions : public RingInfuserMenu(int windowId, Inventory inv, BlockEntity be, ContainerData data) { super(AlcaMenuTypes.RING_INFUSER_MENU.get(), windowId); checkContainerSize(inv, 4); this.be = (RingInfuserBlockEntity) be; this.level = inv.player.level; this.data = data; // Forge Inv this.be.getCapability(ForgeCapabilities.ITEM_HANDLER).ifPresent(handler -> { this.addSlot(new RingInfuserRingSlot(handler, 0, 20, 31)); this.addSlot(new RingInfuserInfuserSlot(handler, 1, 65, 75)); this.addSlot(new GenericFuelSlot(handler, 2, 95, 75)); this.addSlot(new GenericOutput(handler, 3, 140, 31)); }); addDataSlots(data); // Player Inv for (int row = 0 ; row < 3 ; row++) { for (int col = 0 ; col < 9 ; col++) { this.addSlot(new Slot(inv, col + row * 9 + 9, 8 + col * 18, 84 + (row * 18))); } } // Player HotBar for (int col = 0 ; col < 9 ; col++) { this.addSlot(new Slot(inv, col, 8 + col * 18, 142)); } } And the Screen RenderBg method : @Override protected void renderBg(PoseStack poseStack, float pTick, int pMouseX, int pMouseY) { RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); RenderSystem.setShaderTexture(0, INFUSER_GUI); this.imageWidth = 176; this.imageHeight = 201; int x = (width - imageWidth) / 2; int y = (height - imageHeight) / 2; this.blit(poseStack, x, y, 0, 0, imageWidth, imageHeight); this.blit(poseStack, x + 38, y + 24, 0, 201, this.menu.getInfuseProgressionScaled(), 35); this.blit(poseStack, x + 85, y + 73 - this.menu.getHeatProgressionScaled(), 100, 211 - this.menu.getHeatProgressionScaled(), 21, this.menu.getHeatProgressionScaled()); GlStateManager._enableBlend(); GlStateManager._blendFunc(GlStateManager.SourceFactor.SRC_ALPHA.value, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA.value); this.blit(poseStack, x + 79, y + 61 - this.menu.getEssenceLevel(), 121 + this.menu.getEssenceOffset(), 246 - this.menu.getEssenceLevel(), 18, this.menu.getEssenceLevel()); GlStateManager._disableBlend(); } Thanks for your help Edited December 10, 20222 yr by Somnn
December 10, 20222 yr 12 hours ago, Somnn said: I am rendering the screen gui as well as the tooltips. However they do not align. What doesn't align? That's not really clear. Also, provide the entire classes and not just a snippet. In addition, provide the sizes of the textures you are attempting to render as well.
December 12, 20222 yr Author The real places of the slots are not where they should be according to the texture. Here is a screenshot, if it makes it more understandable. The texture I am attempting to render is 256x256 px, but the part I want to render is 176x201px And here is the full Screen class : public class RingInfuserScreen extends AbstractContainerScreen<RingInfuserMenu> { private static final ResourceLocation INFUSER_GUI = new ResourceLocation(Alcamod.MODID, "textures/gui/ring_infuser.png"); public RingInfuserScreen(RingInfuserMenu menu, Inventory inv, Component component) { super(menu, inv, component); } @Override protected void init() { super.init(); } @Override protected void renderBg(PoseStack poseStack, float pTick, int pMouseX, int pMouseY) { RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); RenderSystem.setShaderTexture(0, INFUSER_GUI); this.imageWidth = 176; this.imageHeight = 201; int x = (width - imageWidth) / 2; int y = (height - imageHeight) / 2; this.blit(poseStack, x, y, 0, 0, imageWidth, imageHeight); this.blit(poseStack, x + 38, y + 24, 0, 201, this.menu.getInfuseProgressionScaled(), 35); this.blit(poseStack, x + 85, y + 73 - this.menu.getHeatProgressionScaled(), 100, 211 - this.menu.getHeatProgressionScaled(), 21, this.menu.getHeatProgressionScaled()); GlStateManager._enableBlend(); GlStateManager._blendFunc(GlStateManager.SourceFactor.SRC_ALPHA.value, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA.value); this.blit(poseStack, x + 79, y + 61 - this.menu.getEssenceLevel(), 121 + this.menu.getEssenceOffset(), 246 - this.menu.getEssenceLevel(), 18, this.menu.getEssenceLevel()); GlStateManager._disableBlend(); } @Override public void render(PoseStack pPoseStack, int pMouseX, int pMouseY, float pPartialTick) { renderBackground(pPoseStack); super.render(pPoseStack, pMouseX, pMouseY, pPartialTick); renderTooltip(pPoseStack, pMouseX, pMouseY); } }
December 12, 20222 yr Set the `imageWidth` and `imageHeight` in the constructor. Additionally, use leftPos and topPos instead of calculating the x and y manually.
December 12, 20222 yr Author Fixed it thanks for your help ! I will just need to make some adjustments with the titles but it will be ok.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.