kyazuki Posted January 23, 2020 Posted January 23, 2020 (edited) I want to set player's max health to 20.0. I have managed to increase health by 10.0. But every time this function is called, the player's health keeps increase. How do max health set? public static void setPlayerHealth(PlayerEntity player) { player.getAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(new AttributeModifier("MaxHealth", 10.0f, AttributeModifier.Operation.ADDITION)); player.setHealth(20.0f); } Edited January 24, 2020 by kyazuki Quote
kyazuki Posted January 24, 2020 Author Posted January 24, 2020 I want to call this function when player logins first or every time player dies. Quote
kyazuki Posted January 24, 2020 Author Posted January 24, 2020 Yes, I call this function on those events. But those events happens not only once, health keeps increase. Quote
kyazuki Posted January 24, 2020 Author Posted January 24, 2020 I gradually decrease max health on PlayerTickEvent. If a player dies, reset his max health to 20 hearts. But this cord increases max health every time he dies. How do I reset his max health? Quote
kyazuki Posted January 24, 2020 Author Posted January 24, 2020 I didn't know removeModifier method... It works! Thanks!! Quote
Recommended Posts
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.