BTA and Indev tests
Fix BTA throwing exception when attempting to apply LWJGL frame patch
This commit is contained in:
parent
7e662a411e
commit
304d09d3b3
4 changed files with 101 additions and 25 deletions
|
@ -109,6 +109,7 @@ public class LegacyTweak extends Tweak {
|
||||||
if(main == null) {
|
if(main == null) {
|
||||||
minecraft.methods.add(main = getMain());
|
minecraft.methods.add(main = getMain());
|
||||||
} else {
|
} else {
|
||||||
|
// Try to patch main instead of replacing. Issues with BTA
|
||||||
minecraft.methods.remove(main);
|
minecraft.methods.remove(main);
|
||||||
minecraft.methods.add(main = getMain());
|
minecraft.methods.add(main = getMain());
|
||||||
}
|
}
|
||||||
|
@ -1204,7 +1205,12 @@ public class LegacyTweak extends Tweak {
|
||||||
insns.add(new VarInsnNode(ALOAD, appletIndex));
|
insns.add(new VarInsnNode(ALOAD, appletIndex));
|
||||||
insns.add(new FieldInsnNode(GETFIELD, minecraftApplet.name, mcField, mcDesc));
|
insns.add(new FieldInsnNode(GETFIELD, minecraftApplet.name, mcField, mcDesc));
|
||||||
} else {
|
} else {
|
||||||
insns.add(getNewMinecraftImpl(minecraft, null));
|
InsnList constructor = getNewMinecraftImpl(minecraft, null);
|
||||||
|
if(constructor != null) {
|
||||||
|
insns.add(constructor);
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException("Unexpected constructor!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
insns.add(new VarInsnNode(ASTORE, mcIndex));
|
insns.add(new VarInsnNode(ASTORE, mcIndex));
|
||||||
if(width != null && height != null) {
|
if(width != null && height != null) {
|
||||||
|
@ -1286,6 +1292,9 @@ public class LegacyTweak extends Tweak {
|
||||||
AbstractInsnNode[] insns2 = fill(insn, 6);
|
AbstractInsnNode[] insns2 = fill(insn, 6);
|
||||||
if(compareInsn(insns2[1], PUTFIELD, minecraftApplet.name, mcField, mcDesc)
|
if(compareInsn(insns2[1], PUTFIELD, minecraftApplet.name, mcField, mcDesc)
|
||||||
&& compareInsn(insns2[0], INVOKESPECIAL, null, "<init>")) {
|
&& compareInsn(insns2[0], INVOKESPECIAL, null, "<init>")) {
|
||||||
|
MethodInsnNode invoke = (MethodInsnNode) insns2[0];
|
||||||
|
InsnList constructor = getNewMinecraftImpl(source.getClass(invoke.owner), canvasField);
|
||||||
|
if(constructor != null) {
|
||||||
InsnList insns = new InsnList();
|
InsnList insns = new InsnList();
|
||||||
insns.add(new VarInsnNode(ALOAD, 0));
|
insns.add(new VarInsnNode(ALOAD, 0));
|
||||||
insns.add(new FieldInsnNode(GETFIELD, minecraftApplet.name, canvasField, "Ljava/awt/Canvas;"));
|
insns.add(new FieldInsnNode(GETFIELD, minecraftApplet.name, canvasField, "Ljava/awt/Canvas;"));
|
||||||
|
@ -1296,8 +1305,7 @@ public class LegacyTweak extends Tweak {
|
||||||
insns.add(new MethodInsnNode(INVOKESPECIAL, "java/awt/Dimension", "<init>", "(II)V"));
|
insns.add(new MethodInsnNode(INVOKESPECIAL, "java/awt/Dimension", "<init>", "(II)V"));
|
||||||
insns.add(new MethodInsnNode(INVOKEVIRTUAL, "java/awt/Canvas", "setPreferredSize", "(Ljava/awt/Dimension;)V"));
|
insns.add(new MethodInsnNode(INVOKEVIRTUAL, "java/awt/Canvas", "setPreferredSize", "(Ljava/awt/Dimension;)V"));
|
||||||
init.instructions.insert(insns2[1], insns);
|
init.instructions.insert(insns2[1], insns);
|
||||||
MethodInsnNode invoke = (MethodInsnNode) insns2[0];
|
init.instructions.insertBefore(insns2[1], constructor);
|
||||||
init.instructions.insertBefore(insns2[1], getNewMinecraftImpl(source.getClass(invoke.owner), canvasField));
|
|
||||||
IdentifyCall call = new IdentifyCall(invoke);
|
IdentifyCall call = new IdentifyCall(invoke);
|
||||||
AbstractInsnNode newInsn = call.getArgument(0)[0].getPrevious();
|
AbstractInsnNode newInsn = call.getArgument(0)[0].getPrevious();
|
||||||
if(newInsn.getOpcode() == NEW) {
|
if(newInsn.getOpcode() == NEW) {
|
||||||
|
@ -1307,6 +1315,7 @@ public class LegacyTweak extends Tweak {
|
||||||
remove(init.instructions, arg);
|
remove(init.instructions, arg);
|
||||||
}
|
}
|
||||||
init.instructions.remove(invoke);
|
init.instructions.remove(invoke);
|
||||||
|
}
|
||||||
insn = insns2[1];
|
insn = insns2[1];
|
||||||
}
|
}
|
||||||
if(compareInsn(insns2[0], ALOAD, 0)
|
if(compareInsn(insns2[0], ALOAD, 0)
|
||||||
|
@ -1437,13 +1446,15 @@ public class LegacyTweak extends Tweak {
|
||||||
} else if(i == 1) {
|
} else if(i == 1) {
|
||||||
insns.add(intInsn(launch.height.get()));
|
insns.add(intInsn(launch.height.get()));
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Unexpected constructor: " + init.desc);
|
return null;
|
||||||
|
// throw new IllegalStateException("Unexpected constructor: " + init.desc);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
} else if(desc.equals("Z")) {
|
} else if(desc.equals("Z")) {
|
||||||
insns.add(booleanInsn(launch.fullscreen.get()));
|
insns.add(booleanInsn(launch.fullscreen.get()));
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Unexpected constructor: " + init.desc);
|
return null;
|
||||||
|
// throw new IllegalStateException("Unexpected constructor: " + init.desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
insns.add(new MethodInsnNode(INVOKESPECIAL, minecraftImpl.name, "<init>", init.desc));
|
insns.add(new MethodInsnNode(INVOKESPECIAL, minecraftImpl.name, "<init>", init.desc));
|
||||||
|
|
30
src/test/java/org/mcphackers/launchwrapper/test/BTATest.java
Normal file
30
src/test/java/org/mcphackers/launchwrapper/test/BTATest.java
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package org.mcphackers.launchwrapper.test;
|
||||||
|
|
||||||
|
import org.mcphackers.launchwrapper.LaunchConfig;
|
||||||
|
import org.mcphackers.launchwrapper.tweak.LegacyTweak;
|
||||||
|
import org.mcphackers.launchwrapper.tweak.Tweak;
|
||||||
|
import org.mcphackers.launchwrapper.util.ClassNodeSource;
|
||||||
|
|
||||||
|
public class BTATest extends TweakTest {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String jarName() {
|
||||||
|
return "bta.jar";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String jarUrl() {
|
||||||
|
return "https://github.com/Better-than-Adventure/bta-download-repo/releases/download/v1.7.7.0_02/bta.jar";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Tweak getTweak(ClassNodeSource source, LaunchConfig config) {
|
||||||
|
return new LegacyTweak(source, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TestFeatureBuilder getTests() {
|
||||||
|
return new TestFeatureBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package org.mcphackers.launchwrapper.test;
|
||||||
|
|
||||||
|
import org.mcphackers.launchwrapper.LaunchConfig;
|
||||||
|
import org.mcphackers.launchwrapper.tweak.LegacyTweak;
|
||||||
|
import org.mcphackers.launchwrapper.tweak.Tweak;
|
||||||
|
import org.mcphackers.launchwrapper.util.ClassNodeSource;
|
||||||
|
|
||||||
|
public class IndevTest extends TweakTest {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String jarName() {
|
||||||
|
return "in-20100223.jar";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String jarUrl() {
|
||||||
|
return "http://files.betacraft.uk/launcher/assets/versions/in-20100223.jar";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Tweak getTweak(ClassNodeSource source, LaunchConfig config) {
|
||||||
|
return new LegacyTweak(source, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TestFeatureBuilder getTests() {
|
||||||
|
return new TestFeatureBuilder()
|
||||||
|
.tweakInfoList("Indev launch", "Indev save patch", "Set default width and height",
|
||||||
|
"Fullscreen init patch", "Replaced icon", "Replaced fullscreen", "Replaced width",
|
||||||
|
"Replaced height", "Shutdown patch", "Options load fix",
|
||||||
|
"Replaced title", "Replaced gameDir", "Removed canvas null check",
|
||||||
|
"Set fullscreen", "Added main");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -30,6 +30,6 @@ public class InfdevTest extends TweakTest {
|
||||||
"Replaced height", "Shutdown patch", "SoundManager shutdown",
|
"Replaced height", "Shutdown patch", "SoundManager shutdown",
|
||||||
"Options load fix", "Replaced canvas getWidth", "Replaced canvas getHeight",
|
"Options load fix", "Replaced canvas getWidth", "Replaced canvas getHeight",
|
||||||
"Replaced title", "Replaced gameDir", "Removed canvas null check", "Set fullscreen",
|
"Replaced title", "Replaced gameDir", "Removed canvas null check", "Set fullscreen",
|
||||||
"Set default width and height", "Added main");
|
"Added main");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue