Skip to content

Fix: Mana bar render & regen bugs#569

Merged
cptflavio merged 3 commits into
mainfrom
wout/fix-mana-bar
Mar 4, 2026
Merged

Fix: Mana bar render & regen bugs#569
cptflavio merged 3 commits into
mainfrom
wout/fix-mana-bar

Conversation

@cptflavio

Copy link
Copy Markdown
Contributor
  • Mana bar renders correctly now when mana is not multiple of 10. Used to dip below the bar frame.
  • Mana regenerates after increasing max mana. This didnt happen when you had full mana, and increased the max.

Closes #509

@cptflavio cptflavio closed this Feb 8, 2026
@cptflavio cptflavio reopened this Feb 8, 2026
@cptflavio

cptflavio commented Feb 8, 2026

Copy link
Copy Markdown
Contributor Author

The multiple resource render is not a perfect solution, and should be re-done.
It used to render additional resources towards the left of the first, causing them to render off-screen, and outside the bounding box generated for them. This flips the direction of placement depending on position of screen.

A better solution would be to remove the anchoring change within the bounding box, and make the bounding box more tight around the resource bars (currently there is some room on the right side). The resource bars can always start placement from top-left of their combined bounding box, as this increases when adding more resources.
This would require the combined bounding box to also scale with max resource size: increasing length when length of longest bar increases.

event.updateTriggers(TriggerTracker.forEntity((Entity) holder));
}

void onMaxCharged() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be called onMaxChanged :) ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering, does anything need to be done to reduce the amount of mana if the max amount goes down?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about this, but with testing, reducing max works fine. The extra is just cut off, and it doesn't need to fill up (full for larger amount is also full for smaller amount)

@cptflavio cptflavio Feb 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the name: No, dont think so, as this gets called when the resource is full, the check for max change is within this method.
(If max changes, but the resource is not fully charged, there was no problem.)

Perhaps this isnt needed, and the check could be instantly done. I dont know if comparing current charge vs max is faster than old max vs new max?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any code calling this when the value is full - this is a new method only called when the attribute is changed, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, youre right!

@cptflavio cptflavio merged commit 48cff8d into main Mar 4, 2026
2 checks passed
@cptflavio cptflavio deleted the wout/fix-mana-bar branch March 4, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mana Bar Weirdness

2 participants