Jump to content

[Solved][1.12.1] Translating a model on the hud


wesserboy

Recommended Posts

I am working on a mod that adds some overlays to the game, and for one of them I wanted to render an entity on the hud, but I'm having some problems positioning it where I want it.

I am using the RenderGameOverlayEvent.Post event to render it to the hud.

When I don't apply any translations it appears in the top left of the screen, which makes sense.

Since I want it to show up in the bottom left, I would assume I have to translate it by the height of the screen (I assumed was Minecraft.getMinecraft().displayHeight).

However this doesn't work, I have to divide it by 2 to get it to show up at the bottom. I am very confused by this behavior.

Then if I make the game fullscreen, the model disappears.

 

I assume there is some kind of scaling going on here, but I have no idea how to reliably calculate the amount I want to translate the model down by.

 

The translation I am currently using is:

GlStateManager.translate(25F, mc.displayHeight / 2F - 10, 50F);

which somehow works on the default window size.

The entire class can be found here:

https://github.com/wesserboy/Overlays-MC-/blob/master/src/main/java/com/wesserboy/overlays/renderers/BowAimHelp.java

 

Anyone know how I can render the model in the bottom left of the hud, independent of the window size?

Edited by wesserboy
Adding a [Solved] tag to the title

I made the Mob Particles mod, you can check it out here: http://www.minecraftforum.net/topic/2709242-172-forge-mob-particles/

Link to comment
Share on other sites

I have figured it out, it was indeed a scaling issue.

After looking at the event class I noticed it supplies you with a resolution.

I solved it by getting the scaled height form the event:

event.getResolution().getScaledHeight_double()

 

I made the Mob Particles mod, you can check it out here: http://www.minecraftforum.net/topic/2709242-172-forge-mob-particles/

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.