Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8] Potion Effect rendering names and pictures


Ytt
 Share

Recommended Posts

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 :)

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.