fix skilltree wiping on death
This commit is contained in:
+1
-1
@@ -48,7 +48,7 @@ mod_name=Fretux's Skill Engine
|
|||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=All Rights Reserved
|
mod_license=All Rights Reserved
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=1.2.9
|
mod_version=1.3.0
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
|||||||
@@ -35,11 +35,16 @@ public class SkillEnginePlayerEvents {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onClone(PlayerEvent.Clone event) {
|
public static void onClone(PlayerEvent.Clone event) {
|
||||||
if (event.getEntity() instanceof ServerPlayer newPlayer && event.getOriginal() instanceof ServerPlayer oldPlayer) {
|
if (event.getEntity() instanceof ServerPlayer newPlayer && event.getOriginal() instanceof ServerPlayer oldPlayer) {
|
||||||
|
oldPlayer.reviveCaps();
|
||||||
|
try {
|
||||||
oldPlayer.getCapability(SkillEngineCapabilities.PLAYER_SKILLS).ifPresent(oldData ->
|
oldPlayer.getCapability(SkillEngineCapabilities.PLAYER_SKILLS).ifPresent(oldData ->
|
||||||
newPlayer.getCapability(SkillEngineCapabilities.PLAYER_SKILLS).ifPresent(newData -> {
|
newPlayer.getCapability(SkillEngineCapabilities.PLAYER_SKILLS).ifPresent(newData ->
|
||||||
newData.load(oldData.save());
|
newData.load(oldData.save())
|
||||||
})
|
)
|
||||||
);
|
);
|
||||||
|
} finally {
|
||||||
|
oldPlayer.invalidateCaps();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user