__on_player_respawns() event uses player data from point of death.
poombus opened this issue ยท 4 comments
If I were to do something like...
__on_player_respawns(player) -> (print(player~'pos'));
Once I actually do respawn, it'll print the coords of where the player dies instead of where they respawn.
Is this intentional, or is there some work-around I haven't figured out?
That may be also why __on_player_respawns(player) -> modify(player, 'health', 1e10)
does not respawn the player with full health, even when max health is increased via an item, for example /give @p minecraft:nether_star{AttributeModifiers:[{AttributeName:"generic.maxHealth",Name:"generic.maxHealth",Amount:980,Operation:0,UUIDLeast:-7369916,UUIDMost:6276875,Slot:"offhand"}]} 1
.
well. its better to have the event handled right before it happens rather than just after, since you can't go back in time, but you can defer execution of the callback to the end of the tick. Consider
on_respawn(player) -> print('player respawns at:'+pos(p)+' from '+p~'dimension')
versus:
on_respawn(player) -> schedule(0, _(outer(player)) -> print('player respawns at:'+pos(p)+' from '+p~'dimension') )
This way you can either control player state from before the event and after the event.
I consider this a sign of a poor documentation. Also going back from the end is also considered a 'respawn' event.