mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-18 09:09:05 +00:00
Add debug output
This commit is contained in:
1 parent
4369ddf43e
commit
8cdabb762d
4 files changed
+17
-24
No files matched your search
@@ -24,6 +24,7 @@ import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class FakeSkinManager{
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ minecraft {
|
||||
replace '@MOD_VERSION@', rootProject.ext.config.version
|
||||
replace '@MOD_FULL_VERSION@', project.version
|
||||
replaceIn 'CustomSkinLoader.java'
|
||||
replaceIn 'FMLMod.java'
|
||||
replaceIn 'ForgeMod.java'
|
||||
}
|
||||
|
||||
task mergeSource { doLast {
|
||||
|
||||
@@ -1,37 +1,22 @@
|
||||
package customskinloader.fake;
|
||||
package customskinloader.forge;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.fake.FakeSkinManager;
|
||||
import customskinloader.utils.HttpTextureUtil;
|
||||
import customskinloader.utils.HttpTextureUtil.HttpTextureInfo;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IImageBuffer;
|
||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class FakeSkinManager extends SkinManager {
|
||||
public class ForgeSkinManager extends SkinManager {
|
||||
private FakeSkinManager fakeManager;//Fake Skin Manager
|
||||
|
||||
public FakeSkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) {
|
||||
public ForgeSkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) {
|
||||
super(textureManagerInstance, skinCacheDirectory, sessionService);
|
||||
this.fakeManager=new FakeSkinManager(textureManagerInstance,skinCacheDirectory,sessionService);
|
||||
}
|
||||
|
||||
@@ -31,22 +31,29 @@ public class TransformerManager implements IClassTransformer {
|
||||
public TransformerManager(){
|
||||
map = new HashMap<String, Map<String, IMethodTransformer>>();
|
||||
for(IMethodTransformer t:TRANFORMERS){
|
||||
if(!t.getClass().isAnnotationPresent(TransformTarget.class))
|
||||
FMLRelaunchLog.info("[CSL DEBUG] REGISTERING TRANSFORMER %s",t.getClass().getName());
|
||||
if(!t.getClass().isAnnotationPresent(TransformTarget.class)){
|
||||
FMLRelaunchLog.info("[CSL DEBUG] ERROR occurs while parsing Annotation.");
|
||||
continue;
|
||||
}
|
||||
addMethodTransformer(t.getClass().getAnnotation(TransformTarget.class),t);
|
||||
}
|
||||
}
|
||||
private void addMethodTransformer(TransformTarget target, IMethodTransformer transformer) {
|
||||
if (!map.containsKey(target.className()))
|
||||
map.put(target.className(), new HashMap<String, IMethodTransformer>());
|
||||
for(String methodName:target.methodNames())
|
||||
for(String methodName:target.methodNames()){
|
||||
map.get(target.className()).put(methodName + target.desc(), transformer);
|
||||
FMLRelaunchLog.info("[CSL DEBUG] REGISTERING METHOD %s(%s)",target.className(),methodName + target.desc());
|
||||
}
|
||||
}
|
||||
|
||||
//From: https://github.com/RecursiveG/UniSkinMod/blob/1.9.4/src/main/java/org/devinprogress/uniskinmod/coremod/BaseAsmTransformer.java
|
||||
@Override
|
||||
public byte[] transform(String obfClassName, String className, byte[] bytes) {
|
||||
FMLRelaunchLog.info("[CSL DEBUG] CLASS %s will be ignored", className);
|
||||
if (!map.containsKey(className)) return bytes;
|
||||
FMLRelaunchLog.info("[CSL DEBUG] CLASS %s will be transformed", className);
|
||||
Map<String, IMethodTransformer> transMap = map.get(className);
|
||||
|
||||
ClassReader cr = new ClassReader(bytes);
|
||||
@@ -61,11 +68,11 @@ public class TransformerManager implements IClassTransformer {
|
||||
String methodDesc = FMLDeobfuscatingRemapper.INSTANCE.mapMethodDesc(mn.desc);
|
||||
if (transMap.containsKey(methodName + methodDesc)) {
|
||||
try {
|
||||
FMLRelaunchLog.info("Transforming method %s in class %s(%s)", methodName + methodDesc, obfClassName, className);
|
||||
FMLRelaunchLog.info("[CSL DEBUG] Transforming method %s in class %s(%s)", methodName + methodDesc, obfClassName, className);
|
||||
transMap.get(methodName + methodDesc).transform(mn);
|
||||
FMLRelaunchLog.info("Successfully transformed method %s in class %s(%s)", methodName + methodDesc, obfClassName, className);
|
||||
FMLRelaunchLog.info("[CSL DEBUG] Successfully transformed method %s in class %s(%s)", methodName + methodDesc, obfClassName, className);
|
||||
} catch (Exception e) {
|
||||
FMLRelaunchLog.warning("An error happened when transforming method %s in class %s(%s). The whole class was not modified.", methodName + methodDesc, obfClassName, className);
|
||||
FMLRelaunchLog.warning("[CSL DEBUG] An error happened when transforming method %s in class %s(%s). The whole class was not modified.", methodName + methodDesc, obfClassName, className);
|
||||
e.printStackTrace();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user