Agravaine Posted August 24, 2015 Posted August 24, 2015 Hello. I changed the maximum health of the player, but there was a problem: After the death of the player or rejoining is not saved! Help me please. IAttributeInstance healthAttribute = player.getEntityAttribute(SharedMonsterAttributes.maxHealth); AttributeModifier moras = new AttributeModifier(UUID.fromString("B9766C51-9566-4402-BC1F-2EE2A276D836"), "Moras Health Boost", abilities[i], 0).setSaved(true); healthAttribute.removeModifier(moras); healthAttribute.applyModifier(moras); Quote
UberAffe Posted August 25, 2015 Posted August 25, 2015 Take a look here: https://gist.github.com/Choonster/b435956191898d34c7f8 I'm not very familiar with using attributes but it looks like you are applying the change wrong. Quote Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
Failender Posted August 25, 2015 Posted August 25, 2015 One solution is to save the amount of hp the player should have and reasign it in EntityConstruct event, since there is a new EntityPlayer created every time the player dies Quote
Choonster Posted August 25, 2015 Posted August 25, 2015 Take a look here: https://gist.github.com/Choonster/b435956191898d34c7f8 I'm not very familiar with using attributes but it looks like you are applying the change wrong. That code is designed to apply modifiers from an equipment ItemStack (held item or equipped armour). If you're applying a modifier from some other mechanic, that's not the way to do it. Saved modifiers only save when the Entity is written to NBT (generally when saving the world). When a player respawns, a new EntityPlayer is created (without copying the attribute NBT) and PlayerEvent.Clone is fired; you should be able to use this event to reapply the modifiers. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Failender Posted August 25, 2015 Posted August 25, 2015 CloneEvent is enabled in 1.7? Damn I thought it was 1.8 only good to know 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.