This repository has been archived by the owner on Aug 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use IMixinConfigPlugin#postApply to substitute JEID config for mine
* As there is no way within the mixin framework to alter the target method at runtime, this is the best way I have found to apply this.
- Loading branch information
Showing
7 changed files
with
73 additions
and
21 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
65 changes: 65 additions & 0 deletions
65
src/main/java/uk/bobbytables/jeidsi/core/init/InitPlugin.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,65 @@ | ||
package uk.bobbytables.jeidsi.core.init; | ||
|
||
import org.spongepowered.asm.lib.Opcodes; | ||
import org.spongepowered.asm.lib.tree.AbstractInsnNode; | ||
import org.spongepowered.asm.lib.tree.ClassNode; | ||
import org.spongepowered.asm.lib.tree.LdcInsnNode; | ||
import org.spongepowered.asm.lib.tree.MethodNode; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import static uk.bobbytables.jeidsi.core.JEIDsILoadingPlugin.LOGGER; | ||
|
||
public class InitPlugin implements IMixinConfigPlugin { | ||
@Override | ||
public void onLoad(String mixinPackage) { | ||
} | ||
|
||
@Override | ||
public String getRefMapperConfig() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) { | ||
} | ||
|
||
@Override | ||
public List<String> getMixins() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
} | ||
|
||
@Override | ||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
for (MethodNode methodNode : targetClass.methods) { | ||
Iterator<AbstractInsnNode> insnNodeIterator = methodNode.instructions.iterator(); | ||
while (insnNodeIterator.hasNext()) { | ||
AbstractInsnNode abstractInsnNode = insnNodeIterator.next(); | ||
|
||
if (abstractInsnNode.getOpcode() != Opcodes.LDC) continue; | ||
|
||
LdcInsnNode ldcInsnNode = (LdcInsnNode) abstractInsnNode; | ||
if (ldcInsnNode.cst.equals("mixins.jeid.modsupport.json")) { | ||
LOGGER.info("JEID modsupport init method found: {}", methodNode.name); | ||
LOGGER.info("Substituting our config at instruction {}", methodNode.instructions.indexOf(ldcInsnNode)); | ||
ldcInsnNode.cst = "mixins.jeidsi.jeidmodsupport.json"; | ||
return; | ||
} | ||
} | ||
} | ||
LOGGER.error("JEIDsI has not got a veto over JEID's mod support, report to JEIDsI"); | ||
} | ||
} |
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
14 changes: 0 additions & 14 deletions
14
src/main/java/uk/bobbytables/jeidsi/core/init/mixins/MixinLoaderLate.java
This file was deleted.
Oops, something went wrong.
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