mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-19 10:49:19 +00:00
Get Ready for Forge 1.13
This commit is contained in:
1 parent
bfd1b41ecc
commit
d789119c8f
9 files changed
+111
-10
No files matched your search
@@ -49,15 +49,15 @@ public class FakeSkinBuffer implements net.minecraft.client.renderer.IImageBuffe
|
||||
image.fillArea(0 * ratio, 32 * ratio, 64 * ratio, 32 * ratio);
|
||||
|
||||
//Right Leg -> Left Leg
|
||||
image.copyArea( 4 * ratio, 16 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Top
|
||||
image.copyArea( 8 * ratio, 16 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Bottom
|
||||
image.copyArea( 4 * ratio, 16 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Top
|
||||
image.copyArea( 8 * ratio, 16 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Bottom
|
||||
image.copyArea( 0 * ratio, 20 * ratio, 24 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Right
|
||||
image.copyArea( 4 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Front
|
||||
image.copyArea( 8 * ratio, 20 * ratio, 8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Left
|
||||
image.copyArea(12 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Back
|
||||
//Right Arm -> Left Arm
|
||||
image.copyArea(44 * ratio, 16 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Top
|
||||
image.copyArea(48 * ratio, 16 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Bottom
|
||||
image.copyArea(44 * ratio, 16 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Top
|
||||
image.copyArea(48 * ratio, 16 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Bottom
|
||||
image.copyArea(40 * ratio, 20 * ratio, 0 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Right
|
||||
image.copyArea(44 * ratio, 20 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Front
|
||||
image.copyArea(48 * ratio, 20 * ratio,-16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Left
|
||||
|
||||
@@ -3,7 +3,9 @@ package customskinloader.forge;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.Name;
|
||||
|
||||
@Name("CustomSkinLoader")
|
||||
public class ForgePlugin implements IFMLLoadingPlugin {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
||||
import customskinloader.forge.transformer.*;
|
||||
import customskinloader.forge.transformer.PlayerTabTransformer.ScoreObjectiveTransformer;
|
||||
import customskinloader.forge.transformer.SkinManagerTransformer.*;
|
||||
import customskinloader.forge.transformer.SpectatorMenuTransformer.PlayerMenuObjectTransformer;
|
||||
@@ -39,7 +40,9 @@ public class TransformerManager implements IClassTransformer {
|
||||
new LoadProfileTexturesTransformer(),
|
||||
new LoadSkinFromCacheTransformer(),
|
||||
new ScoreObjectiveTransformer(),
|
||||
new PlayerMenuObjectTransformer()};
|
||||
new PlayerMenuObjectTransformer(),
|
||||
new FakeSkinManagerTransformer.InitTransformer()
|
||||
};
|
||||
private Map<String, Map<String, IMethodTransformer>> map;
|
||||
public TransformerManager(){
|
||||
map = new HashMap<String, Map<String, IMethodTransformer>>();
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package customskinloader.forge.remapper;
|
||||
|
||||
import org.objectweb.asm.commons.ClassRemapper;
|
||||
import org.objectweb.asm.commons.Remapper;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
// https://github.com/NekoCaffeine/Alchemy/blob/rebirth/src/main/java/index/alchemy/util/ASMHelper.java#L652-L672
|
||||
public class ClassNameRemapper extends Remapper {
|
||||
|
||||
private final String srcName, newName;
|
||||
|
||||
public ClassNameRemapper(String srcName, String newName) {
|
||||
this.srcName = srcName;
|
||||
this.newName = newName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String map(String typeName) {
|
||||
return srcName.equals(typeName) ? newName : super.map(typeName);
|
||||
}
|
||||
|
||||
public static void remapClassName(ClassNode cn, String srcName, String newName) {
|
||||
cn.accept(new ClassRemapper(null, new ClassNameRemapper(srcName, newName)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package customskinloader.forge.remapper;
|
||||
|
||||
import org.objectweb.asm.commons.ClassRemapper;
|
||||
import org.objectweb.asm.commons.Remapper;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
// https://github.com/NekoCaffeine/Alchemy/blob/rebirth/src/main/java/index/alchemy/util/ASMHelper.java#L652-L672
|
||||
public class MethodNameRemapper extends Remapper {
|
||||
|
||||
private final String owner, srcName, newName;
|
||||
|
||||
public MethodNameRemapper(String owner, String srcName, String newName) {
|
||||
this.owner = owner;
|
||||
this.srcName = srcName;
|
||||
this.newName = newName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mapMethodName(String owner, String name, String desc) {
|
||||
return this.owner.equals(owner) && srcName.equals(name) ? newName : super.map(name);
|
||||
}
|
||||
|
||||
public static void remapMethodName(ClassNode cn, String owner, String srcName, String newName) {
|
||||
cn.accept(new ClassRemapper(null, new MethodNameRemapper(owner, srcName, newName)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package customskinloader.forge.transformer;
|
||||
|
||||
import customskinloader.forge.remapper.ClassNameRemapper;
|
||||
import customskinloader.forge.TransformerManager.IMethodTransformer;
|
||||
import customskinloader.forge.TransformerManager.TransformTarget;
|
||||
import customskinloader.forge.remapper.MethodNameRemapper;
|
||||
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
||||
import org.objectweb.asm.commons.ClassRemapper;
|
||||
import org.objectweb.asm.tree.*;
|
||||
|
||||
/**
|
||||
* Transformer of FakeSkinManager for 1.13
|
||||
*/
|
||||
public class FakeSkinManagerTransformer {
|
||||
private static boolean needTransform = false;
|
||||
private static boolean needInit = true;
|
||||
private final static String TARGET_CLASS = "net/minecraft/client/renderer/ThreadDownloadImageData";
|
||||
private final static String NEW_TARGET_CLASS = "net/minecraft/client/renderer/texture/ThreadDownloadImageData";
|
||||
private final static String CALLBACK_CLASS = "net/minecraft/client/resources/SkinManager$SkinAvailableCallback";
|
||||
|
||||
private static void init() {
|
||||
if (!needInit) return;
|
||||
needTransform = TARGET_CLASS == FMLDeobfuscatingRemapper.INSTANCE.unmap(TARGET_CLASS);
|
||||
needInit = false;
|
||||
}
|
||||
|
||||
@TransformTarget(className = "customskinloader.fake.FakeSkinManager",
|
||||
methodNames = {"<init>"},
|
||||
desc = "(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V")
|
||||
public static class InitTransformer implements IMethodTransformer {
|
||||
@Override
|
||||
public void transform(ClassNode cn, MethodNode mn) {
|
||||
init();
|
||||
if (!needTransform) return;
|
||||
ClassNameRemapper.remapClassName(cn, TARGET_CLASS, NEW_TARGET_CLASS);
|
||||
MethodNameRemapper.remapMethodName(cn, CALLBACK_CLASS, "func_180521_a", "onSkinTextureAvailable");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package customskinloader.forge.transformer;
|
||||
|
||||
import java.util.ListIterator;
|
||||
|
||||
import customskinloader.forge.TransformerManager;
|
||||
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
@@ -22,7 +24,7 @@ public class SpectatorMenuTransformer {
|
||||
public void transform(ClassNode cn, MethodNode mn) {
|
||||
InsnList il=mn.instructions;
|
||||
ListIterator<AbstractInsnNode> li=il.iterator();
|
||||
|
||||
|
||||
boolean flag=false;
|
||||
while(li.hasNext()) {
|
||||
AbstractInsnNode ain=li.next();
|
||||
@@ -30,8 +32,11 @@ public class SpectatorMenuTransformer {
|
||||
continue;
|
||||
|
||||
MethodInsnNode min = (MethodInsnNode)ain;
|
||||
if(min.owner.equals("net/minecraft/client/entity/AbstractClientPlayer"))//Fix 1.13
|
||||
String deobfName = FMLDeobfuscatingRemapper.INSTANCE.map(min.owner);
|
||||
if(!deobfName.equals("net/minecraft/client/entity/AbstractClientPlayer")) {//Fix 1.13
|
||||
TransformerManager.logger.info("InvokeStatic to " + deobfName + " in PlayerMenuObject will be ignored.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!flag) {
|
||||
//First InvokeStatic
|
||||
@@ -46,6 +51,6 @@ public class SpectatorMenuTransformer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,7 @@ You could not earn money with this mod excluding modpack.
|
||||
Including some codes from
|
||||
- [AsteriskTeam/TabIconHackForge](http://git.oschina.net/AsteriskTeam/TabIconHackForge) (GPLv3)
|
||||
- [RecursiveG/UniSkinMod](https://github.com/RecursiveG/UniSkinMod) (GPLv3)
|
||||
- [NekoCaffeine/Alchemy](https://github.com/NekoCaffeine/Alchemy) (WTFPL)
|
||||
|
||||
Copyright(C) 2013-2018 JLChnToZ xfl03
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
name=CustomSkinLoader
|
||||
group=customskinloader
|
||||
version=14.9
|
||||
version=14.10
|
||||
dev_version=
|
||||
#RELEASE: snapshot=0
|
||||
snapshot=0
|
||||
snapshot=1
|
||||
Reference in new issue
Block a user