From 50e29823d79919788339e63a903a605ca0512b1f Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Tue, 27 Dec 2016 01:57:58 -0500 Subject: [PATCH] put skin cache back in the skins folder and clear the internal cache when needed. --- .../com/voxelmodpack/hdskins/HDSkinManager.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java index 61c67eb9..3018b976 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/HDSkinManager.java @@ -127,7 +127,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener { String skinDir = type.toString().toLowerCase() + "s/"; final ResourceLocation skin = new ResourceLocation("hdskins", skinDir + texture.getHash()); - File file2 = new File(LiteLoader.getAssetsDirectory(), "hd" + skinDir + "/" + texture.getHash().substring(0, 2) + "/" + texture.getHash()); + File file2 = new File(LiteLoader.getAssetsDirectory(), "skins/" + skinDir + texture.getHash().substring(0, 2) + "/" + texture.getHash()); final IImageBuffer imagebufferdownload = type == Type.SKIN ? new ImageBufferDownloadHD() : null; ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(file2, texture.getUrl(), DefaultPlayerSkin.getDefaultSkinLegacy(), @@ -164,7 +164,7 @@ public final class HDSkinManager implements IResourceManagerReloadListener { } private Map loadProfileData(final GameProfile profile) { - return getProfileData(profile).orElseGet(() -> { + return getProfileData(profile).orElseGet(() -> { String uuid = UUIDTypeAdapter.fromUUID(profile.getId()); @@ -176,9 +176,9 @@ public final class HDSkinManager implements IResourceManagerReloadListener { builder.put(type, new HDProfileTexture(url, hash, null)); } - Map textures = builder.build(); - this.profileTextures.put(profile.getId(), textures); - return textures; + Map textures = builder.build(); + this.profileTextures.put(profile.getId(), textures); + return textures; }); } @@ -252,6 +252,12 @@ public final class HDSkinManager implements IResourceManagerReloadListener { try { FileUtils.deleteDirectory(new File(LiteLoader.getAssetsDirectory(), "skins")); + TextureManager textures = Minecraft.getMinecraft().getTextureManager(); + INSTANCE.skinCache.values().stream() + .flatMap(m -> m.values().stream()) + .forEach(textures::deleteTexture); + INSTANCE.skinCache.clear(); + INSTANCE.profileTextures.clear(); } catch (IOException var1) { var1.printStackTrace(); }