From 6ffdf2aafbd6229f4857bcf7df1e30ebba2c3ea2 Mon Sep 17 00:00:00 2001 From: Alexander Xia Date: Mon, 2 Jul 2018 00:15:03 +0800 Subject: [PATCH] Fix Spectator Menu totally --- .../source/customskinloader/fake/FakeClientPlayer.java | 10 +++++++--- .../source/customskinloader/fake/FakeSkinManager.java | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Common/source/customskinloader/fake/FakeClientPlayer.java b/Common/source/customskinloader/fake/FakeClientPlayer.java index f088761..38ec80e 100644 --- a/Common/source/customskinloader/fake/FakeClientPlayer.java +++ b/Common/source/customskinloader/fake/FakeClientPlayer.java @@ -1,7 +1,9 @@ package customskinloader.fake; +import java.util.Map; import java.util.UUID; +import com.google.common.collect.Maps; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; @@ -52,7 +54,9 @@ public class FakeClientPlayer { return new ResourceLocation("skins/legacy-" + StringUtils.stripControlCodes(username)); } - private static class LegacyBuffer implements SkinAvailableCallback { + public static Map textureCache = Maps.newHashMap(); + + public static class LegacyBuffer implements SkinAvailableCallback { ResourceLocation resourceLocationIn; boolean loaded = false; @@ -68,7 +72,8 @@ public class FakeClientPlayer { TextureManager textman = Minecraft.getMinecraft().getTextureManager(); ITextureObject ito = textman.getTexture(location); - + if (ito == null) + ito = textureCache.get(location); if (ito == null) return; @@ -76,7 +81,6 @@ public class FakeClientPlayer { textman.loadTexture(resourceLocationIn, ito); CustomSkinLoader.logger.debug("Legacy Texture (" + resourceLocationIn + ") Loaded as " + ito.toString() + " (" + location + ")"); - //textman.bindTexture(resourceLocationIn); } } diff --git a/Common/source/customskinloader/fake/FakeSkinManager.java b/Common/source/customskinloader/fake/FakeSkinManager.java index f8bcff9..71f0367 100644 --- a/Common/source/customskinloader/fake/FakeSkinManager.java +++ b/Common/source/customskinloader/fake/FakeSkinManager.java @@ -50,6 +50,8 @@ public class FakeSkinManager{ else{ ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(info.cacheFile, info.url, DefaultPlayerSkin.getDefaultSkinLegacy(), new BaseBuffer(skinAvailableCallback, textureType, resourcelocation, profileTexture)); + if(skinAvailableCallback instanceof FakeClientPlayer.LegacyBuffer)//Cache for client player + FakeClientPlayer.textureCache.put(resourcelocation,threaddownloadimagedata); this.textureManager.loadTexture(resourcelocation, threaddownloadimagedata); } return resourcelocation;