Jump to content

HUD with textures


neosatan

Recommended Posts

Hi,

 

New to modding, so I will have tons of questions. As I am trying to learn from existing code, sometimes It's too much to me to properly interprete code. I hope that my questions are trivial, and someone will help a newbe.

 

I want to do a mod that will give some new HUD features (basically will give more FPS-ish HUD features), and I would rather that drawing string on HUD draw a textures. I seen that in thaumcraft there are some textures on HUD (vis/taint level when googles of revealing on). I want to display some HUD features when item is worn or in quickItem bar, but detecting item is kinda easy. For now I don't know how to implement drawing textures on HUD.

I would like to draw textures from a custom file, and I also don't know where to put that file or how to define that texture.

 

Can anyone help?

Link to comment
Share on other sites

Hello.

 

I'm not sure about adding a new texture on the HUD, but I did manage to place a string/text on the screen.

 

Follow the Ticking example on the wiki. This a very handy thing to know/have if you want to add things that require constant updates. Once you have that ready, add this in the onRenderTick() Method:

 

FMLClientHandler.instance().getClient().fontRenderer.drawStringWithShadow(displayText(String), x(int), y(int), color(int));

 

Bare in mind this could be tidied up, but this was just from a quick test I've just done a few minutes ago. Obviously, don't forget to change the displayText(String) to a string and x,y & color to a number. For example:

FMLClientHandler.instance().getClient().fontRenderer.drawStringWithShadow("Hello World!", 0, 0, 16777215));

 

There is also a drawString method with the same parameters, just that it displays the text with no shadow.

 

The color parameter is an Integer and I'm uncertain how that works (although I am going to find out). However, I did find (somewhere buried deep in the files and I can't remember where) this value: 16777215 and this seems to give the same white color as the other texts

 

The Color parameter is the Hex color value (eg FF0000) converted into Decimal.

 

For the textures look how Minecraft displays the GUI elements (Inventory bar, health bar etc). I know things can be difficult with all over the unnamed variables (var1..var2), but if you're using Eclipse you can just highlight the variable name and all off the references highlight also so you can just follow where the variables lead. Sometimes you might see a named variable, which is a nice treat.

 

I hope this helps. Any questions just ask.

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.



×
×
  • Create New...

Important Information

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