#When do attributes from armor items get applied to the player on connect?

1 messages · Page 1 of 1 (latest)

arctic loom
#

A project I am working on has custom armor that, aside from standard armor, armor toughness, knockback resist, also modifies the player's max health when equipped. When the player disconnects with HP above the vanilla 20 while having that armor item equipped, their next login sees their HP reset to 20 despite the extra hearts showing up on their health bar.

It seems like the game on player connect is either setting any player's HP > 20 to 20, or the armor attribute modifiers are not immediately applied when they connect. Ideally, I aim for the correct HP to be set on login, but I can't seem to figure out the way to go about it. Any insight or pointers is appreciated.

icy roost
#

player connects
when transitioning from configuration phase to play phase, a ServerPlayerEntity is created
player's profile is loaded from cache or looked up
player's data is loaded from the savehandler into a NbtCompound
the nbt is applied to the ServerPlayerEntity via readNbt

current HP is saved in writeNbt/writeCustomDataToNbt, max HP is not. bonuses are added which increases max HP from the max 20

#

you can probably mixin to TAIL of PlayerEntity#readCustomDataFromNbt and setHealth again from the nbt. that should be after the inventory is loaded in

arctic loom
#

thank you. I'll try it and lyk

brisk nacelle