Changes

Update to 1.18
Line 53: Line 53:  
By default, the capability data does not persist on death. In order to change this, the data has to be manually copied when the player entity is cloned during the respawn process.
 
By default, the capability data does not persist on death. In order to change this, the data has to be manually copied when the player entity is cloned during the respawn process.
   −
This can be done by handling the <code><nowiki>PlayerEvent$Clone</nowiki></code> event, reading the data from the original entity, and assigning it to the new entity. In this event, the <code>wasDead</code> field can be used to distinguish between respawning after death, and returning from the End. This is important because the data will already exist when returning from the End, so care has to be taken to not duplicate values in this case.
+
This can be done by handling the <code><nowiki>PlayerEvent$Clone</nowiki></code> event, reading the data from the original entity, and assigning it to the new entity. In this event, the <code>#isWasDeath</code> method can be used to distinguish between respawning after death, and returning from the End. This is important because the data will already exist when returning from the End, so care has to be taken to not duplicate values in this case.
       
[[Category:Data Storage]]
 
[[Category:Data Storage]]