Change how much health a heart represents?

I am attempting to create a plugin that reworks damage to be more like Diablo III.

it works best if a players base health is more like 200 rather than 20.
It’s simple enough to add health to a player, however, it adds hearts to the players GUI. which really start to clutter up the screen since a heart only represents 2 health.

My question is if it’s possible to change how much health each heart represents.

If anyone has a better way to do this, I would love to hear any ideas you guys might have.

Yessir! Do your calculations and number management where needed. When someone gets damaged, whether you cancel it outright and handle it- or if you interject; you want to set the health of the player to the scale at which you would like each one to display.

100 for example. In this case we have a base hearts of 10 that fit on the row. 100/10=10 each heart can evenly be worth 10hp in your combat system.

customHp=100 (base health)
customHp-10 (player got damaged)
customHp=90 (health after damage)
playerHp=customHp/10=9 (final health scaling to vanilla)

Here we now how the value 9, which represents our health scaled to vanilla Minecraft. You should have rare cases in which scaling doesn’t go as planned, but for the most part if you pick your values right, it’s pretty simple.

So… after a few days of testing and more testing, I got health scaling to work in the API:

It’s implemented in both stable-5, stable-6, and bleeding (no changes to the API).

The way it works is exactly as you’d expect in that the following will function (if you use it as a command):

    private static CommandSpec getHealthCommand() {
        return CommandSpec.builder()
            .executor((src, args) -> {
                if (!(src instanceof Player)) {
                    return CommandResult.empty();
                final Player player = (Player) src;
                player.offer(Keys.HEALTH_SCALE, 20D);
                player.offer(Keys.MAX_HEALTH, 100D);
                player.offer(Keys.HEALTH, 100D);
                return CommandResult.success();

This would set the player to scale to 20 health (10 hearts), and then of course, damage is still done as normal. The advantage with this is that the client now ONLY receives the understanding that the health is 20 (not aware of the 100 actual health on the server). This plays really nicely with mods as well.

Note: If you set the health scale before setting the new max health/health, the client won’t notice the change (no damage taken technically). If you raise the health scale, the hearts will automatically update. Likewise, if you have health boost attribute modifiers (like potion effects or armor), it will show the health boost in that circumstance as the true modifier of the health.