Skip to content
This repository has been archived by the owner on Jan 3, 2020. It is now read-only.

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursiveG committed Apr 27, 2015
1 parent 3494187 commit 1373935
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 317 deletions.
49 changes: 1 addition & 48 deletions src/main/java/org/devinprogress/uniskinmod/AsmTransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,10 @@
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.*;

/**
* Transformers for authlib-1.5.17 and MC1.8
*/
public class AsmTransformer extends BaseAsmTransformer {
private static final String INVOKE_TARGET_CLASS=UniSkinMod.class.getName().replace(".","/");

public AsmTransformer(){
/*hookMethod("com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository","findProfilesByNames","findProfilesByNames",
"([Ljava/lang/String;Lcom/mojang/authlib/Agent;Lcom/mojang/authlib/ProfileLookupCallback;)V",
new findProfilesByNamesTransformer());
hookMethod("com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService","fillGameProfile","fillGameProfile",
"(Lcom/mojang/authlib/GameProfile;Z)Lcom/mojang/authlib/GameProfile;",
new fillGameProfileTransformer());
*/

hookMethod("net.minecraft.client.network.NetworkPlayerInfo","<init>","<init>",
"(Lnet/minecraft/network/play/server/S38PacketPlayerListItem$AddPlayerData;)V",
new NetworkPlayerInfoTransformer());
Expand All @@ -37,7 +26,7 @@ public AsmTransformer(){
private class NetworkPlayerInfoTransformer implements IMethodTransformer{
@Override
public void transform(MethodNode mn, String srgName, boolean devEnv, String classObfName) {
final String FIELD_NAME=devEnv?"gameProfile":"field_178867_a";
final String FIELD_NAME=devEnv?"gameProfile":"a"; //field_178867_a
AbstractInsnNode n= getInsnPutField(mn, FIELD_NAME, 1);
mn.instructions.insertBefore(n, new MethodInsnNode(Opcodes.INVOKESTATIC,INVOKE_TARGET_CLASS,
"fillGameProfile","(Lcom/mojang/authlib/GameProfile;)Lcom/mojang/authlib/GameProfile;",false));
Expand All @@ -64,42 +53,6 @@ public void transform(MethodNode mn, String srgName, boolean devEnv, String clas
}
}

private class findProfilesByNamesTransformer implements IMethodTransformer{
@Override
public void transform(MethodNode mn, String srgName, boolean devEnv, String classObfName) {
AbstractInsnNode n=getNthInsnNode(mn, Opcodes.CHECKCAST,2).getNext();
mn.instructions.insertBefore(n,new VarInsnNode(Opcodes.ALOAD,7));
mn.instructions.insertBefore(n,new MethodInsnNode(Opcodes.INVOKESTATIC,INVOKE_TARGET_CLASS,
"fillMissionProfile","(Lcom/mojang/authlib/yggdrasil/response/ProfileSearchResultsResponse;Ljava/util/List;)Lcom/mojang/authlib/yggdrasil/response/ProfileSearchResultsResponse;",false));
}
}

private class fillGameProfileTransformer implements IMethodTransformer{
@Override
public void transform(MethodNode mn, String srgName, boolean devEnv, String classObfName) {
AbstractInsnNode n=getNthInsnNode(mn,Opcodes.ALOAD,3);
LabelNode label=new LabelNode();
LabelNode label2=new LabelNode();
mn.instructions.insertBefore(n,new VarInsnNode(Opcodes.ALOAD,1));
mn.instructions.insertBefore(n,new MethodInsnNode(Opcodes.INVOKESTATIC,INVOKE_TARGET_CLASS,
"isOnlinePlayer","(Lcom/mojang/authlib/GameProfile;)Z",false));
mn.instructions.insertBefore(n,new JumpInsnNode(Opcodes.IFEQ,label));

n=getNthInsnNode(mn,Opcodes.ASTORE,3);
mn.instructions.insertBefore(n,new JumpInsnNode(Opcodes.GOTO,label2));
mn.instructions.insertBefore(n,label);
mn.instructions.insertBefore(n,new InsnNode(Opcodes.ACONST_NULL));
mn.instructions.insertBefore(n,label2);

n=getNthInsnNode(mn,Opcodes.ALOAD,6);
mn.instructions.insertBefore(n,new VarInsnNode(Opcodes.ALOAD,1));
mn.instructions.insertBefore(n,new VarInsnNode(Opcodes.ALOAD,4));
mn.instructions.insertBefore(n,new MethodInsnNode(Opcodes.INVOKESTATIC,INVOKE_TARGET_CLASS,
"fillResponse","(Lcom/mojang/authlib/GameProfile;Lcom/mojang/authlib/yggdrasil/response/MinecraftProfilePropertiesResponse;)Lcom/mojang/authlib/yggdrasil/response/MinecraftProfilePropertiesResponse;",false));
mn.instructions.insertBefore(n,new VarInsnNode(Opcodes.ASTORE,4));
}
}

/** Bypass the Signature Verification */
private class getTexturesTransformer implements IMethodTransformer{
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class MojangTexturePayload {
public MojangTexturePayload(String playerName){
isPublic=true;
profileName=playerName;
profileId=UniSkinMod.getOfflineUUID(playerName);
profileId= getOfflineUUID(playerName);
textures=new HashMap<MinecraftProfileTexture.Type, MinecraftProfileTexture>();

}
Expand All @@ -39,6 +39,10 @@ public static MojangTexturePayload fromProperty(Property property){
return gson.fromJson(e, MojangTexturePayload.class);
}

public static UUID getOfflineUUID(String name){
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
}

public Property toProperty(){
String j = gson.toJson(this);
String b64 = Base64.encodeBase64String(j.getBytes(Charsets.UTF_8));
Expand Down
190 changes: 0 additions & 190 deletions src/main/java/org/devinprogress/uniskinmod/ProfileResponseBuilder.java

This file was deleted.

16 changes: 4 additions & 12 deletions src/main/java/org/devinprogress/uniskinmod/UniSkinApiProfile.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
package org.devinprogress.uniskinmod;

import com.google.common.base.Charsets;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.gson.Gson;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.Minecraft;
import org.apache.commons.io.IOUtils;

Expand All @@ -15,11 +10,8 @@
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
* Created by recursiveg on 15-4-26.
*/
/** Universal Skin API */
public class UniSkinApiProfile {

private class ProfileJSON{
Expand Down Expand Up @@ -74,14 +66,14 @@ private UniSkinApiProfile(String name, String root){
model=m;
skin=URL_TEXTURE_FMT.replace("{root}",root).replace("{texture_hash}",json.skins.get(m));
hasProfile=true;
UniSkinMod.log.info("Player Skin Selected: %s %s %s",name,model,json.skins.get(m));
UniSkinMod.log.info(String.format("Player Skin Selected: %s %s %s",name,model,json.skins.get(m)));
break;
}
}
if(json.cape!=null&&json.cape.length()>3){
cape=URL_TEXTURE_FMT.replace("{root}",root).replace("{texture_hash}",json.cape);
hasProfile=true;
UniSkinMod.log.info("Player Cape Selected: %s %s",name,json.cape);
UniSkinMod.log.info(String.format("Player Cape Selected: %s %s",name,json.cape));
}
update=json.last_update;
}
Expand All @@ -97,4 +89,4 @@ public String getModel(){
public long lastUpdate(){
return update;
}
}
}
Loading

0 comments on commit 1373935

Please sign in to comment.