Fix crash when saving path to file player skin

This commit is contained in:
Moulberry committed 2025-02-11 19:34:07 +08:00
1 parent 89201e682c
commit 297db34bab
2 files changed
+6 -6

No files matched your search

@@ -31,10 +31,10 @@ public class FilePlayerSkin {
}
}
private PlayerSkin playerSkin = null;
private final Path pathToSkin;
private transient PlayerSkin playerSkin = null;
private final String pathToSkin;
public FilePlayerSkin(Path pathToSkin) {
public FilePlayerSkin(String pathToSkin) {
this.pathToSkin = pathToSkin;
}
@@ -43,7 +43,8 @@ public class FilePlayerSkin {
return this.playerSkin;
}
try (InputStream inputStream = Files.newInputStream(this.pathToSkin)) {
Path path = Path.of(this.pathToSkin);
try (InputStream inputStream = Files.newInputStream(path)) {
NativeImage nativeImage = NativeImage.read(inputStream);
// We determine the type using the alpha of the pixel at 54, 20
@@ -153,9 +153,8 @@ public class SelectedEntityPopup {
"Skin Texture", "png");
future.thenAccept(pathStr -> {
if (pathStr != null) {
Path path = Path.of(pathStr);
editorState.skinOverride.remove(entity.getUUID());
editorState.skinOverrideFromFile.put(entity.getUUID(), new FilePlayerSkin(path));
editorState.skinOverrideFromFile.put(entity.getUUID(), new FilePlayerSkin(pathStr));
}
});
}