From 6ee0ba55188ab2ccc95bdcfe0ed64e2bd34ab725 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Tue, 6 Aug 2013 16:45:02 +0200 Subject: [PATCH] Taught AlphaVanillaTweakInjector about com.mojang --- build.gradle | 2 +- .../injector/AlphaVanillaTweakInjector.java | 26 +++++++++++++++---- .../injector/IndevVanillaTweakInjector.java | 4 --- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 94a3382..c00ab46 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ repositories { group = 'net.minecraft' archivesBaseName = 'launchwrapper' -version = '1.5' +version = '1.6' dependencies { compile 'net.sf.jopt-simple:jopt-simple:4.5' diff --git a/src/main/java/net/minecraft/launchwrapper/injector/AlphaVanillaTweakInjector.java b/src/main/java/net/minecraft/launchwrapper/injector/AlphaVanillaTweakInjector.java index e30ebba..24d4e38 100644 --- a/src/main/java/net/minecraft/launchwrapper/injector/AlphaVanillaTweakInjector.java +++ b/src/main/java/net/minecraft/launchwrapper/injector/AlphaVanillaTweakInjector.java @@ -1,9 +1,7 @@ package net.minecraft.launchwrapper.injector; -import net.minecraft.launchwrapper.AlphaVanillaTweaker; import net.minecraft.launchwrapper.IClassTransformer; import net.minecraft.launchwrapper.Launch; -import net.minecraft.launchwrapper.VanillaTweaker; import javax.swing.*; import java.applet.Applet; @@ -17,7 +15,8 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Modifier; import java.net.MalformedURLException; import java.net.URL; -import java.util.*; +import java.util.HashMap; +import java.util.Map; public class AlphaVanillaTweakInjector implements IClassTransformer { public AlphaVanillaTweakInjector() { @@ -29,7 +28,14 @@ public class AlphaVanillaTweakInjector implements IClassTransformer { } public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { - Class clazz = getaClass("net.minecraft.client.MinecraftApplet"); + Class clazz; + + try { + clazz = getaClass("net.minecraft.client.MinecraftApplet"); + } catch (ClassNotFoundException ignored) { + clazz = getaClass("com.mojang.minecraft.MinecraftApplet"); + } + System.out.println("AlphaVanillaTweakInjector.class.getClassLoader() = " + AlphaVanillaTweakInjector.class.getClassLoader()); Constructor constructor = clazz.getConstructor(); Object object = constructor.newInstance(); @@ -37,7 +43,7 @@ public class AlphaVanillaTweakInjector implements IClassTransformer { for (Field field : clazz.getDeclaredFields()) { String name = field.getType().getName(); - if (!name.contains("awt") && !name.contains("java")) { + if (!name.contains("awt") && !name.contains("java") && !name.equals("long")) { System.out.println("Found likely Minecraft candidate: " + field); Field fileField = getWorkingDirField(name); @@ -107,6 +113,16 @@ public class AlphaVanillaTweakInjector implements IClassTransformer { return null; } + @Override + public URL getCodeBase() { + try { + return new URL("http://www.minecraft.net/game/"); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + return null; + } + @Override public String getParameter(String paramName) { if (params.containsKey(paramName)) { diff --git a/src/main/java/net/minecraft/launchwrapper/injector/IndevVanillaTweakInjector.java b/src/main/java/net/minecraft/launchwrapper/injector/IndevVanillaTweakInjector.java index 710dc1c..dbeb4cb 100644 --- a/src/main/java/net/minecraft/launchwrapper/injector/IndevVanillaTweakInjector.java +++ b/src/main/java/net/minecraft/launchwrapper/injector/IndevVanillaTweakInjector.java @@ -23,10 +23,6 @@ public class IndevVanillaTweakInjector implements IClassTransformer { return null; } - if (name.equals("net.minecraft.client.d")) { - String beep = name.toLowerCase(); - } - final ClassNode classNode = new ClassNode(); final ClassReader classReader = new ClassReader(bytes); classReader.accept(classNode, ClassReader.EXPAND_FRAMES);