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

I've been trying to code a simple potion hud, but whenever I draw the string for the potion name, it always messes up the potion status textures. Do you guys know why?

 

 

CODE --> github.com/Runner55/Gems/blob/master/com/camp/overlay/PotionEffectHUD.java

 

Thanks in advance! I really appreciate it :)

Can you further describe the problem and/or include a photo? Do you mean that the string and the icon is not matching up based on the screen width / height? If so, use ScaledResolution (I'm pretty sure you must use this rather than just finding the center of the screen and drawing from there, but I could be wrong):

@SubscribeEvent
public void renderOverlay(RenderGameOverlayEvent.Post event)
{
    ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
    int posX = scaledresolution.getScaledWidth() / 2 + SOME INTEGER; //Get the center of the screen width and add from there
    int posY = scaledresolution.getScaledHeight() / 2 + SOME INTEGER; //Get the center of the screen height and add from there

    this.drawString(mc.fontRendererObj, "SOME STRING", posX, posY, 0xFFFFFF);
    //Render as you please
}

 

Make sure you use the post subclass for RenderGameOverlayEvent to avoid rendering HUD issues:

@SubscribeEvent
public void renderOverlay(RenderGameOverlayEvent.Post event)
{
    //Check element type, if cancelable, etc.
}

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Hi

 

Probably your rendering is changing the opengl graphics flags or perhaps changing the bound texture.

 

Changing the time (event) that you render the element might help; you might also be able to save/restore the settings, or to call a vanilla method to set the rendering settings back.

 

I think the best way to track this down is to set a breakpoint in your hud render code, see where it's being called from, then try to figure out which rendering settings your code is messing with.  The forge code just before calling your render code, and just after, might also give you clues.

 

-TGG

  • Author

Hi! Thank you for your quick responses. I've updated my method to be RenderGameOverlayEvent.Post and draw from the center of the screen, and I've used your suggestions to help fix my issue. Thank you all for your help ;)

 

Guest
This topic is now closed to further replies.

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.