Jump to content

I Want to Create Health Bars


Justin_Perry

Recommended Posts

Create an screen overlay.

Subscribe to RenderGameOverlayEvent and do your rendering.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

19 hours ago, DavidM said:

Create an screen overlay.

Subscribe to RenderGameOverlayEvent and do your rendering.

I have created a basic gui that displays text on the screen. How should I go about getting an entities health when the player hovers over them? If not hover, how can I make health permanently show?

Link to comment
Share on other sites

9 hours ago, Justin_Perry said:

I have created a basic gui that displays text on the screen. How should I go about getting an entities health when the player hovers over them? If not hover, how can I make health permanently show?

That’s not what they meant, 

You can subscribe to the RenderLivingEvent and render your health bars there. There already a mod that does this https://minecraft.curseforge.com/projects/neat

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

I thought you meant to create a custom health bar for the player...

 

10 hours ago, Justin_Perry said:

I have created a basic gui that displays text on the screen. How should I go about getting an entities health when the player hovers over them? If not hover, how can I make health permanently show?

You are being rather vague.

If you meant to create a health bar that hovers on each EntityLiving, subscribe to RenderLivingEvent.

If you want to show the health of the mob the player is looking at as a screen overlay (like WAILA and DamageIndicator), do a ray trace to detect the entity the player is looking at and display its health on the GUI you've created.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

14 hours ago, Cadiboo said:

That’s not what they meant, 

You can subscribe to the RenderLivingEvent and render your health bars there. There already a mod that does this https://minecraft.curseforge.com/projects/neat

Thank you for your useless comment. I am not asking for code as you can clearly see, so I will reply to whoever is attempting to assist me when I get past a certain stage asking for more clarification and guidance. I am taking guidance and putting my spin on it. I understand there are mods that do this, I am attempting to make one big mod for my friends and I,  instead of downloading many mods that others have created. I have a friend who particularly does not like mods simply because they do not blend well and that is what I am here to accomplish. I appreciate your assistance, however, it is anything but. Have a great day.

Link to comment
Share on other sites

13 hours ago, DavidM said:

I thought you meant to create a custom health bar for the player...

 

You are being rather vague.

If you meant to create a health bar that hovers on each EntityLiving, subscribe to RenderLivingEvent.

If you want to show the health of the mob the player is looking at as a screen overlay (like WAILA and DamageIndicator), do a ray trace to detect the entity the player is looking at and display its health on the GUI you've created.

Sorry for being so vague, I am just trying to accomplish one thing with the easiest route. I think avoiding ray tracing is the way to go. I particularly like constant health bar or hearts above the entities while in range. I am looking into RenderLivingEvent. Thank you

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.