-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
108 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/org/mcphackers/launchwrapper/tweak/LegacyLauncherTweak.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.mcphackers.launchwrapper.tweak; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.mcphackers.launchwrapper.LaunchConfig; | ||
import org.mcphackers.launchwrapper.target.LaunchTarget; | ||
import org.mcphackers.launchwrapper.tweak.injection.Injection; | ||
import org.mcphackers.launchwrapper.tweak.injection.forge.ForgeFix; | ||
|
||
public class LegacyLauncherTweak extends Tweak { | ||
|
||
protected Tweak baseTweak; | ||
|
||
public LegacyLauncherTweak(LaunchConfig config, Tweak tweak) { | ||
super(config); | ||
baseTweak = tweak; | ||
} | ||
|
||
@Override | ||
public List<Injection> getInjections() { | ||
List<Injection> injections = new ArrayList<Injection>(); | ||
injections.addAll(baseTweak.getInjections()); | ||
injections.add(new ForgeFix()); | ||
return injections; | ||
} | ||
|
||
@Override | ||
public List<Tweaker> getTweakers() { | ||
return baseTweak.getTweakers(); | ||
} | ||
|
||
@Override | ||
public LaunchTarget getLaunchTarget() { | ||
return baseTweak.getLaunchTarget(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
src/main/java/org/mcphackers/launchwrapper/tweak/injection/forge/ForgeClassLoader.java
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
src/main/java/org/mcphackers/launchwrapper/tweak/injection/forge/ForgeFix.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.mcphackers.launchwrapper.tweak.injection.forge; | ||
|
||
import static org.mcphackers.launchwrapper.util.asm.InsnHelper.*; | ||
import static org.objectweb.asm.Opcodes.*; | ||
|
||
import org.mcphackers.launchwrapper.LaunchConfig; | ||
import org.mcphackers.launchwrapper.tweak.injection.Injection; | ||
import org.mcphackers.launchwrapper.util.ClassNodeSource; | ||
import org.mcphackers.launchwrapper.util.asm.NodeHelper; | ||
import org.objectweb.asm.tree.AbstractInsnNode; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.objectweb.asm.tree.MethodInsnNode; | ||
import org.objectweb.asm.tree.MethodNode; | ||
|
||
public class ForgeFix implements Injection { | ||
|
||
public String name() { | ||
return "Forge patch"; | ||
} | ||
|
||
public boolean required() { | ||
return false; | ||
} | ||
|
||
public boolean apply(ClassNodeSource source, LaunchConfig config) { | ||
ClassNode eventSubscriptionTransformer = source.getClass("net/minecraftforge/fml/common/asm/transformers/EventSubscriptionTransformer"); | ||
if (eventSubscriptionTransformer == null) { | ||
return false; | ||
} | ||
MethodNode buildEvents = NodeHelper.getMethod(eventSubscriptionTransformer, "buildEvents", "(Lorg/objectweb/asm/tree/ClassNode;)Z"); | ||
if (buildEvents == null) { | ||
return false; | ||
} | ||
for (AbstractInsnNode insn = getFirst(buildEvents.instructions); insn != null; insn = nextInsn(insn)) { | ||
if (compareInsn(insn, GETFIELD, "org/objectweb/asm/tree/ClassNode", "superName", "Ljava/lang/String;") && | ||
compareInsn(nextInsn(insn), INVOKESTATIC, "org/objectweb/asm/Type", "getType", "(Ljava/lang/String;)Lorg/objectweb/asm/Type;")) { | ||
// Forge incorrectly uses getType here. getObjectType makes it compatible with asm 9.7+ | ||
buildEvents.instructions.set(nextInsn(insn), new MethodInsnNode(INVOKESTATIC, "org/objectweb/asm/Type", "getObjectType", "(Ljava/lang/String;)Lorg/objectweb/asm/Type;")); | ||
break; | ||
} | ||
} | ||
source.overrideClass(eventSubscriptionTransformer); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters