Jump to content

Question about healthbar rendering [1.12.2]


theishiopian

Recommended Posts

I am trying to make an overlay of the vanilla health bar that changes the color of the first two hearts on the bar. The render works fine, and renders my hearts over the vanilla ones no problem. The trouble is that vanilla hearts tend to shake up and down under various conditions, and these movements are hardcoded and can't be accessed. The solution taken by tinkers construct appears to be to render their own health bar, which is something I'd like to avoid. Is there some way of masking out shapes underneath my render, IE erasing anything on the HUD behind my icons? Or perhaps some way of getting the shake that I don't see? I really REALLY don't want to cancel the vanilla render and make my own health bar if it can be at all avoided, as that would be a compatibility nightmare for other mods that do the same. Is there a decently efficient way to use reflection to get a reference to the field in GUIIngame that stores the y offset for each heart? I hesitate to do that since reflection tends to be rather intensive.

 

 

Link to comment
Share on other sites

1 hour ago, theishiopian said:

Is there a decently efficient way to use reflection to get a reference to the field in GUIIngame that stores the y offset for each heart? I hesitate to do that since reflection tends to be rather intensive. 

No but it doesn't seem like their motion is random. There are no calls to rand.next... You can replicate the math it all seems to be focused on the updateCounter field which is accessible

Minecraft.getInstance().ingameGUI.getUpdateCounter()

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

11 minutes ago, theishiopian said:

I did see a call to rand.nextInt(), Ill find it when I get home. It may turn out to be extraneous though, in which case I'll use the update counter.

There is a single one unfortunately but it only happens when the health is less than or equal to 4(2 hearts). Which I assume you won't influence you too much and they also apply a seed to the random before rendering the health so it should always result in the same value.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

29 minutes ago, theishiopian said:

Since by default my effect really kicks in at 4 hearts, it unfortunately does influence me. However, the seed does help, where does it come from? I'm not at my dev environment currently so I can't find it myself.

It's based on the update counter multiplied by 312871.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

2 minutes ago, theishiopian said:

Ah, perfect. so If i get the update counter and multiply, the seed should give me the same number? or will the update counter have updated by the time my code calls?

Should all work fine.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

3 minutes ago, theishiopian said:

@Animefan8888 I tried setting the seed, but it doesn't seem to work at all. I think I'm going to rethink my effect, the health rendering section is a mess of obfuscated fields that make no sense.

Did you copy all of the positioning code?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.