#Improvement for F7/M7 HP Bars

1 messages · Page 1 of 1 (latest)

sturdy trench
#

The current way Skytils grabs HP of withers is by grabbing the HP from the vanilla bossbar Hypixel sends to the client, which is based on a invisible wither that has a static unrelated health value, and from my understanding this bossbar data isn't being sent when your out of radius, which causes the bossbar to go invisible and the HP display to not show at times, it also sometimes doesn't update for a few seconds. This the case even if you enable "Boss Bar Fix" feature, which has the description "Attempts to stop bossbars from disappearing."

There's a possible workaround for this which I tested and it works. The way the workaround works is that we grab the HP value from the actual EntityWither which extends EntityLivingBase and implements IBossDisplayData, which both have the methods getHealth and getMaxHealth that don't depend on the BossBarSetEvent.

Unfortunately this workaround will not work for other bossbars that are not related to HP, for example the crystal hollows event bossbars like 2X Powder, cause there's no actual entity for those it is just the invisible wither, for those the issue needs to be fixed on server side, but I am not sure if that is possible, since they would likely need to spawn another invisible wither for each player and make it follow the players. However, with the upcoming Mod API, maybe a way to talk to the server to grab the current Crystal Hollows (and Dwarven Mines) event might be added for that as well.

The feature itself is also wrongly named "Show Necron's HP", after the F7 revamp it should be named "Show Wither Lord's HP" since it works (except when it disappears) for all the wither lords not just Necron.

Due to the discord message limit I will add my example code to the next message, do note that I copied this from my own workaround and had to change some stuff in notepad and I didn't test compiling it.

#

Forgot to say but theres also another bug where it shows the HP as 0.3% when the Wither Lords die. This caused by the fact that Hypixel sets the health to 1 (out of the max health of 300) when they die, resulting in 0.3% HP.

To fix this we need to check if the health is 1 manually and then return 0.

Heres my example code:

/**
 * Grabs the HP of Maxor in percentage, returning 0 if dead or -1 if we can't find the wither entity. (just as an example, this should work for others if you just change the .contains("Maxor") part to for example check for Necron instead).
 **/
float getMaxorHpPercentage() {
    for (Entity entity : Minecraft.getMinecraft().theWorld.loadedEntityList) { // Iterate over all entities (might be costly to do it each tick so maybe this needs to be saved to a variable (and then cleared carefully later to not create memory leaks) when we find the entity of the wither lords for the first time?)
        if (entity instanceof EntityWither) { // Make sure we are checking the actual EntityWither cause theres also an EntityArmorStand with the Wither Lord's name
            if (entity.getName().contains("Maxor")) { // Make sure we aren't fooled by the invisible/dinnerbone withers
                EntityWither maxor = (EntityWither) entity; // Safe cast since we checked instanceof before
                float hp = maxor.getHealth();
                return hp == 1 ? dead : (hp / maxor.getMaxHealth()) * 100; // Returns health percentage or 0 if dead (Hypixel sets the HP to 1 instead of 0 when they are dead which causes the percentage to be 0.3% normally otherwise).
            }
        }
    }
    return -1;
}
shut jetty
#

skytils is written in kotlin, not java

brittle glen
#

I ain't readin all that

sturdy trench
sturdy trench
sturdy trench
# sturdy trench Then don't reply, simple as that.

Unless you want to add anything to the conversation or you are going to make a Pull Request but your only excuse is that my example is in Java, sure I can give an example in Kotlin. I would make one myself but my understanding of the Forge BossBar API isn't complete and my workaround that I use currently just displays health as a Skytils GuiElement on the screen. I opened this in hopes maybe some other contributor experienced with the Forge BossBar API would make a proper fix that overrides vanilla bossbar with the correct HP values without the need of a new GuiElement.

shut jetty