From 67e56957e777096c4c628633c2047d19b0789243 Mon Sep 17 00:00:00 2001 From: Alexander Xia Date: Sun, 11 Feb 2018 12:44:41 +0800 Subject: [PATCH] Fix Spectator Menu --- .../customskinloader/CustomSkinLoader.java | 6 +++++- Common/source/customskinloader/Logger.java | 2 +- .../fake/FakeClientPlayer.java | 5 ++++- .../forge/SpectatorMenuTransformer.java | 21 +++++++++++++++---- README.md | 2 +- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Common/source/customskinloader/CustomSkinLoader.java b/Common/source/customskinloader/CustomSkinLoader.java index 81767c5..83530c2 100644 --- a/Common/source/customskinloader/CustomSkinLoader.java +++ b/Common/source/customskinloader/CustomSkinLoader.java @@ -21,7 +21,7 @@ import customskinloader.utils.MinecraftUtil; /** * Custom skin loader mod for Minecraft. - * @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2016 + * @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2018 * @version @MOD_FULL_VERSION@ */ public class CustomSkinLoader { @@ -105,6 +105,10 @@ public class CustomSkinLoader { }catch(Exception e){ logger.warning("Exception occurs while loading."); logger.warning(e); + if(e.getCause()!=null) { + logger.warning("Caused By:"); + logger.warning(e.getCause()); + } } if(profile==null) continue; diff --git a/Common/source/customskinloader/Logger.java b/Common/source/customskinloader/Logger.java index da61104..dfe3e90 100644 --- a/Common/source/customskinloader/Logger.java +++ b/Common/source/customskinloader/Logger.java @@ -85,7 +85,7 @@ public class Logger { public void warning(String msg){ log(Level.WARNING,msg); } - public void warning(Exception e){ + public void warning(Throwable e){ log(Level.WARNING,"Exception: "+e.toString()); StackTraceElement[] stes=e.getStackTrace(); for(StackTraceElement ste : stes){ diff --git a/Common/source/customskinloader/fake/FakeClientPlayer.java b/Common/source/customskinloader/fake/FakeClientPlayer.java index b7eb78d..16ab2f5 100644 --- a/Common/source/customskinloader/fake/FakeClientPlayer.java +++ b/Common/source/customskinloader/fake/FakeClientPlayer.java @@ -34,7 +34,10 @@ public class FakeClientPlayer { skinman.loadProfileTextures(offlineProfile, new LegacyBuffer(resourceLocationIn), false); } - return (ThreadDownloadImageData)ito; + if(ito instanceof ThreadDownloadImageData) + return (ThreadDownloadImageData)ito; + else + return null; } public static ResourceLocation getLocationSkin(String username) diff --git a/Forge/source/customskinloader/forge/SpectatorMenuTransformer.java b/Forge/source/customskinloader/forge/SpectatorMenuTransformer.java index 45f8a55..a41ffb6 100644 --- a/Forge/source/customskinloader/forge/SpectatorMenuTransformer.java +++ b/Forge/source/customskinloader/forge/SpectatorMenuTransformer.java @@ -22,12 +22,25 @@ public class SpectatorMenuTransformer { public void transform(ClassNode cn, MethodNode mn) { InsnList il=mn.instructions; ListIterator li=il.iterator(); + + boolean flag=false; while(li.hasNext()) { - AbstractInsnNode nn=li.next(); - if(nn.getOpcode()!=Opcodes.INVOKESTATIC) + AbstractInsnNode ain=li.next(); + if(ain.getOpcode()!=Opcodes.INVOKESTATIC) continue; - MethodInsnNode min=(MethodInsnNode)nn; - min.owner="customskinloader/fake/FakeClientPlayer"; + //MethodInsnNode min=(MethodInsnNode)nn; + //min.owner="customskinloader/fake/FakeClientPlayer"; + if(!flag) { + //First InvokeStatic + il.set(ain, new MethodInsnNode(Opcodes.INVOKESTATIC,"customskinloader/fake/FakeClientPlayer","getLocationSkin", + "(Ljava/lang/String;)Lnet/minecraft/util/ResourceLocation;",false)); + flag=true; + }else { + //Second InvokeStatic + il.set(ain, new MethodInsnNode(Opcodes.INVOKESTATIC,"customskinloader/fake/FakeClientPlayer","getDownloadImageSkin", + "(Lnet/minecraft/util/ResourceLocation;Ljava/lang/String;)Lnet/minecraft/client/renderer/ThreadDownloadImageData;",false)); + break; + } } } diff --git a/README.md b/README.md index 187c5ab..fddc9b5 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ Including some code from - [AsteriskTeam/TabIconHackForge](http://git.oschina.net/AsteriskTeam/TabIconHackForge) (GPLv3) - [RecursiveG/UniSkinMod](https://github.com/RecursiveG/UniSkinMod) (GPLv3) -Copyright(C) 2013-2017 JLChnToZ xfl03 +Copyright(C) 2013-2018 JLChnToZ xfl03 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.