fix skilltree wiping on death

This commit is contained in:
2026-04-07 08:46:10 +02:00
parent 0386027e99
commit 66f7f76e01
2 changed files with 11 additions and 6 deletions
+1 -1
View File
@@ -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.getCapability(SkillEngineCapabilities.PLAYER_SKILLS).ifPresent(oldData -> oldPlayer.reviveCaps();
newPlayer.getCapability(SkillEngineCapabilities.PLAYER_SKILLS).ifPresent(newData -> { try {
newData.load(oldData.save()); oldPlayer.getCapability(SkillEngineCapabilities.PLAYER_SKILLS).ifPresent(oldData ->
}) newPlayer.getCapability(SkillEngineCapabilities.PLAYER_SKILLS).ifPresent(newData ->
); newData.load(oldData.save())
)
);
} finally {
oldPlayer.invalidateCaps();
}
} }
} }