Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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.

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

 

  • 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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.