Jump to content

(Solved)[1.15.2]setHealth method don't work as I expected


Recommended Posts

This cord set max health to 40.0f as I expected, but setHealth don't work.

Logger always says "Change to: 40.0 / 40.0" only in Server Thread.

I think setHealth calls only in Server Thread.

How do I fix?

  public static void respawnPlayer(PlayerEvent.PlayerRespawnEvent event) {
    player.getAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(new AttributeModifier(TestMaxHealthUUID, "TestMaxHealth", 2.0f - 1.0f, AttributeModifier.Operation.MULTIPLY_TOTAL));
    LOGGER.debug("change to: " + player.getHealth() + " / " + player.getMaxHealth());
Edited by kyazuki
Link to comment
Share on other sites

applyModifier works, but setHealth didn't works.


My mod gradually reduces the max health from 40.0 to 10.0.

Then, the player whose max health is 10.0 is killed.

I want to reset the player's max health to 40.0.

So, I calls my method when the player dies.

The method reset their max healths as I expected.

However, setHealth doesn't work in the client.

Health is same value before they die(ex. 10.0 / 40.0), but LOGGER says 40.0 / 40.0 in Server Thread.

Client's health isn't synced to Server's health.

Edited by kyazuki
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.

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.