Heal signs do not account for custom max health values
ImDarkLaw opened this issue ยท 3 comments
Type of bug
Other unexpected behaviour
/ess dump all
output
https://essentialsx.net/dump.html?id=4d77c9610f5d470ab46f0142b21415fd
Error log (if applicable)
No response
Bug description
The onSignInteract method inside the SignHeal class responsible for handling interactions with heal signs, currently, sets the player's health to 20 without considering potential increases in amount of health due to the generic max health attribute.
Steps to reproduce
Suggested course of action to reproduce this behavior:
- Ensure heal signs are enabled in the config:
enabledSigns:
- heal
- Create a heal sign by placing a sign and typing "[Heal]" on the first line.
- Use
/attribute @p minecraft:generic.max_health base set 40
to change our base maximum health value, in this case, doubling it to 40. - Right click on the sign and notice that our health is set back to 20 and the health buff removed.
Expected behaviour
One would expect that onSignInteract the player's health would be set to the maximum amount respecting modified maximum health values.
Actual behaviour
Upon interacting with a heal sign, health value is being set to 20 no matter what, without accounting for an increased amount of hearts.
Additional Information
No response
Interesting how this is fixed in the /heal
but not here. Good catch!
Yes, it seems like there's already a solution in the /heal
command implementation.
I'm currently in the process of implementing a quick fix for the SignHeal class to address this.
The proposed solution involves retrieving the player's maximum health attribute and setting their health accordingly, instead of the hardcoded 20 value. I've shared the implementation details in this pastebin. Let me know your thoughts and i can proceed to submit a PR.
Something like that should be fine. Doesn't hurt to open a PR so more users can test.
I will note that this may require a version check for feature / API not present in old versions of the game - but aside from that this fix is fairly straightforward (set the proper health, not just 20).