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

Alright, so I am trying to render some text onto the player HUD. It renders just fine, except the position changes when I go into fullscreen from a windowed screen.

 

Windowed:

 

Fullscreen:

 

Here is where I render it:

@SubscribeEvent
public void onRenderHUD(RenderGameOverlayEvent event) {
	Minecraft mc = Minecraft.getMinecraft();

	ExtendedPlayer props = ExtendedPlayer.get(mc.thePlayer);

	if(event.isCancelable() || event.type != ElementType.EXPERIENCE) {
		return;
	}

	int xPos = event.resolution.getScaledWidth() / 2 + 6;
	int yPos = event.resolution.getScaledHeight() / 2 - 6;

	mc.fontRendererObj.drawString(I18n.format(props.getCurrentWeight() + "/" + props.getMaxWeight(), new Object[0]), xPos, yPos, (props.isOverEncumbered() ? Color.RED.darker().getRGB() : 4210752));
}

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

  • Author

Bump

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Bruh... Width = x, height = y.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

I posted this and realized my mistake then changed it. :P I'll change the post though as to not confuse. xD

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

For the y-axis, resolutionScaled.getScaledHeight() is always the bottom of the screen, and the vanilla hotbar slots are 18 pixels tall, so (height - 18 - fontHeight) will put text right above them (vertically). Dividing it by 2 will put you relative to the center of the screen, which you don't want if you are trying to stay relative to the hotbar.

 

Horizontally, resolutionScaled.getScaledWidth() / 2 will always be relative to the center, with your text flowing to the right. This should be fine, subtracting some amount to move it further left above the hotbar.

 

It looks like you have a HUGE difference in screen resolution between those 2 images, btw, though the positions shown in either image still don't look right for the values you have in your code.

 

One thing to note: RenderGameOverlayEvent has both a Pre and a Post - choose Pre if you want to cancel the event, or Post if you just want to render, e.g.:

@SubscribeEvent
public void onRenderExperienceBar(RenderGameOverlayEvent.Post event) {
if (event.type != RenderGameOverlayEvent.ElementType.EXPERIENCE) {
	return; // limit the rendering to one ElementType, otherwise it will render LOTS of times each frame
}
// do your rendering here
}

  • Author

Seems my problem was not using the Post of RenderGameOverlayEvent. :P Thank you coolAlias!

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

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.