Jump to content

[1.19.2] need help on block entity screen rendering with tooltips


Somnn

Recommended Posts

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 by Somnn
Link to comment
Share on other sites

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);
	}
	
}

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.