Posted January 28, 20205 yr 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? @SubscribeEvent public static void respawnPlayer(PlayerEvent.PlayerRespawnEvent event) { player.getAttribute(SharedMonsterAttributes.MAX_HEALTH).removeModifier(TestMaxHealthUUID); player.getAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(new AttributeModifier(TestMaxHealthUUID, "TestMaxHealth", 2.0f - 1.0f, AttributeModifier.Operation.MULTIPLY_TOTAL)); player.setHealth(40.0f); LOGGER.debug("change to: " + player.getHealth() + " / " + player.getMaxHealth()); } Edited January 29, 20205 yr by kyazuki
January 28, 20205 yr Author I want to set max health to 40.0f as default value. So I don't use effects of potions and equipments. The game renders 20 hearts. So the client knows my modified max health, didn't it? Edited January 28, 20205 yr by kyazuki
January 28, 20205 yr Author 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 January 28, 20205 yr by kyazuki
January 28, 20205 yr Author Sorry, I said 20 hearts as max health(include gray hearts)... Edited January 28, 20205 yr by kyazuki
January 28, 20205 yr Author I checked by debugger. setHealth method works in Server Thread. Should I check methods in Render Thread? I don't know the method which health synced to the server.
January 29, 20205 yr Author Hmm... I can't find the method to sync. Can you tell me methods which I should check using the debugger? Edited January 29, 20205 yr by kyazuki
January 29, 20205 yr Author I was mistaken about isRemote method. I reduced their max health in Render Thread( if(isRemote()) ). Thank you very much! Could you answer to this topic? Edited January 29, 20205 yr by kyazuki
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.