aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle.kts1
-rw-r--r--gradle.properties3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/init/OneConfigInit.java9
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/mixin/VigilantMixin.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/plugin/LoadingPlugin.java14
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java9
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/ClassTransformer.java48
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/ITransformer.java15
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/tweakers/NanoVGGLConfigTransformer.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/tweakers/VigilantTransformer.java202
-rw-r--r--src/main/resources/mixins.oneconfig.json1
11 files changed, 222 insertions, 90 deletions
diff --git a/build.gradle.kts b/build.gradle.kts
index e9d942f..9361919 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -47,6 +47,7 @@ loom {
launchConfigs.named("client") {
property("fml.coreMods.load", "cc.polyfrost.oneconfig.internal.plugin.LoadingPlugin")
property("mixin.debug.export", "true")
+ property("debugBytecode", "true")
}
}
if (project.platform.isForge) {
diff --git a/gradle.properties b/gradle.properties
index 8471818..d4390fc 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,8 +1,7 @@
mod_name = OneConfig
mod_id = oneconfig
-mod_version = 0.1.0-alpha4
+mod_version = 0.1.0-alpha7
-loom.platform = forge
essential.defaults.loom=0
org.gradle.daemon=true
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/init/OneConfigInit.java b/src/main/java/cc/polyfrost/oneconfig/internal/init/OneConfigInit.java
index 438c60e..3d924ac 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/init/OneConfigInit.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/init/OneConfigInit.java
@@ -4,18 +4,9 @@ import net.minecraft.launchwrapper.Launch;
import org.spongepowered.asm.launch.MixinBootstrap;
import org.spongepowered.asm.mixin.Mixins;
-/**
- * Initializes the OneConfig mod.
- * <p><b>MUST BE CALLED VIA AN ITWEAKER / FMLLOADINGPLUGIN FOR 1.12 AND BELOW, OR A PRELAUNCH TWEAKER FOR 1.14+ FABRIC.</b></p>
- */
@SuppressWarnings("unused")
public class OneConfigInit {
- /**
- * Initializes the OneConfig mod.
- *
- * @param args The arguments passed to the mod.
- */
public static void initialize(String[] args) {
Launch.blackboard.put("oneconfig.initialized", true);
MixinBootstrap.init();
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/mixin/VigilantMixin.java b/src/main/java/cc/polyfrost/oneconfig/internal/mixin/VigilantMixin.java
new file mode 100644
index 0000000..662293c
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/mixin/VigilantMixin.java
@@ -0,0 +1,8 @@
+package cc.polyfrost.oneconfig.internal.mixin;
+
+import gg.essential.vigilance.Vigilant;
+import org.spongepowered.asm.mixin.Mixin;
+
+@Mixin(Vigilant.class)
+public class VigilantMixin {
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/LoadingPlugin.java b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/LoadingPlugin.java
index b819f24..825dab8 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/LoadingPlugin.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/LoadingPlugin.java
@@ -1,15 +1,15 @@
package cc.polyfrost.oneconfig.internal.plugin;
import cc.polyfrost.oneconfig.internal.init.OneConfigInit;
+import cc.polyfrost.oneconfig.internal.plugin.asm.ClassTransformer;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.launchwrapper.LaunchClassLoader;
-import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Set;
-public class LoadingPlugin implements IFMLLoadingPlugin {
+public class LoadingPlugin {
/**
* Taken from LWJGLTwoPointFive under The Unlicense
@@ -22,31 +22,29 @@ public class LoadingPlugin implements IFMLLoadingPlugin {
Set<String> exceptions = (Set<String>) f_exceptions.get(Launch.classLoader);
exceptions.remove("org.lwjgl.");
OneConfigInit.initialize(new String[]{});
+ Launch.blackboard.put("oneconfig.init.initialized", true);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
- @Override
public String[] getASMTransformerClass() {
- return new String[]{"cc.polyfrost.oneconfig.internal.plugin.asm.ClassTransformer"};
+ Launch.blackboard.put("oneconfig.init.registered_transformer", true);
+ return new String[]{ClassTransformer.class.getName()};
}
- @Override
public String getModContainerClass() {
return null;
}
- @Override
public String getSetupClass() {
return null;
}
- @Override
public void injectData(Map<String, Object> data) {
+
}
- @Override
public String getAccessTransformerClass() {
return null;
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java
index c55febc..888cca3 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java
@@ -1,5 +1,6 @@
package cc.polyfrost.oneconfig.internal.plugin;
+import cc.polyfrost.oneconfig.internal.plugin.asm.tweakers.VigilantTransformer;
import org.spongepowered.asm.lib.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
@@ -8,7 +9,7 @@ import java.util.List;
import java.util.Set;
public class OneConfigMixinPlugin implements IMixinConfigPlugin {
- public static boolean isVigilance = false;
+ private static boolean isVigilance = false;
@Override
public void onLoad(String mixinPackage) {
@@ -47,6 +48,10 @@ public class OneConfigMixinPlugin implements IMixinConfigPlugin {
@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
-
+ System.out.println(mixinClassName);
+ if (mixinClassName.equals("cc.polyfrost.oneconfig.internal.mixin.VigilantMixin")) {
+ System.out.println("A");
+ VigilantTransformer.transform(targetClass);
+ }
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/ClassTransformer.java b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/ClassTransformer.java
index 1a2766f..52256ca 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/ClassTransformer.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/ClassTransformer.java
@@ -11,6 +11,9 @@ import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.ClassNode;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
import java.util.Collection;
/**
@@ -22,6 +25,7 @@ import java.util.Collection;
public class ClassTransformer implements IClassTransformer {
private static final Logger logger = LogManager.getLogger("OneConfig ASM");
private final Multimap<String, ITransformer> transformerMap = ArrayListMultimap.create();
+ private static final boolean outputBytecode = Boolean.parseBoolean(System.getProperty("debugBytecode", "false"));
public ClassTransformer() {
registerTransformer(new NanoVGGLConfigTransformer());
@@ -37,14 +41,13 @@ public class ClassTransformer implements IClassTransformer {
}
@Override
- public byte[] transform(String name, String transformedName, byte[] basicClass) {
- if (basicClass == null) return null;
+ public byte[] transform(String name, String transformedName, byte[] bytes) {
+ if (bytes == null) return null;
Collection<ITransformer> transformers = transformerMap.get(transformedName);
- if (transformers.isEmpty()) return basicClass;
+ if (transformers.isEmpty()) return bytes;
-
- ClassReader reader = new ClassReader(basicClass);
+ ClassReader reader = new ClassReader(bytes);
ClassNode node = new ClassNode();
reader.accept(node, ClassReader.EXPAND_FRAMES);
@@ -59,6 +62,41 @@ public class ClassTransformer implements IClassTransformer {
logger.error("Exception when transforming " + transformedName + " : " + t.getClass().getSimpleName());
t.printStackTrace();
}
+
+ if (outputBytecode) {
+ File bytecodeDirectory = new File("bytecode");
+ String transformedClassName;
+
+ // anonymous classes
+ if (transformedName.contains("$")) {
+ transformedClassName = transformedName.replace('$', '.') + ".class";
+ } else {
+ transformedClassName = transformedName + ".class";
+ }
+
+ if (!bytecodeDirectory.exists()) {
+ bytecodeDirectory.mkdirs();
+ }
+
+ File bytecodeOutput = new File(bytecodeDirectory, transformedClassName);
+
+ try {
+ if (!bytecodeOutput.exists()) {
+ bytecodeOutput.createNewFile();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ try (FileOutputStream os = new FileOutputStream(bytecodeOutput)) {
+ // write to the generated class to /run/bytecode/classfile.class
+ // with the class bytes from transforming
+ os.write(cw.toByteArray());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
return cw.toByteArray();
}
} \ No newline at end of file
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/ITransformer.java b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/ITransformer.java
index 482a310..1bc50d1 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/ITransformer.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/ITransformer.java
@@ -1,9 +1,24 @@
package cc.polyfrost.oneconfig.internal.plugin.asm;
import org.objectweb.asm.tree.ClassNode;
+import org.objectweb.asm.tree.MethodNode;
public interface ITransformer {
String[] getClassName();
void transform(String transformedName, ClassNode node);
+
+ default void clearInstructions(MethodNode methodNode) {
+ methodNode.instructions.clear();
+
+ // dont waste time clearing local variables if they're empty
+ if (!methodNode.localVariables.isEmpty()) {
+ methodNode.localVariables.clear();
+ }
+
+ // dont waste time clearing try-catches if they're empty
+ if (!methodNode.tryCatchBlocks.isEmpty()) {
+ methodNode.tryCatchBlocks.clear();
+ }
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/tweakers/NanoVGGLConfigTransformer.java b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/tweakers/NanoVGGLConfigTransformer.java
index 4d7a5cc..2410f4b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/tweakers/NanoVGGLConfigTransformer.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/tweakers/NanoVGGLConfigTransformer.java
@@ -35,7 +35,7 @@ public class NanoVGGLConfigTransformer implements ITransformer {
));
list.add(new InsnNode(Opcodes.RETURN));
- method.instructions.clear();
+ clearInstructions(method);
method.instructions.insert(list);
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/tweakers/VigilantTransformer.java b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/tweakers/VigilantTransformer.java
index 58e3575..4f0c3b2 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/tweakers/VigilantTransformer.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/tweakers/VigilantTransformer.java
@@ -1,9 +1,9 @@
package cc.polyfrost.oneconfig.internal.plugin.asm.tweakers;
import cc.polyfrost.oneconfig.config.compatibility.vigilance.VigilanceConfig;
-import cc.polyfrost.oneconfig.internal.config.core.ConfigCore;
import cc.polyfrost.oneconfig.config.data.Mod;
import cc.polyfrost.oneconfig.config.data.ModType;
+import cc.polyfrost.oneconfig.internal.config.core.ConfigCore;
import cc.polyfrost.oneconfig.internal.plugin.asm.ITransformer;
import gg.essential.vigilance.Vigilant;
import gg.essential.vigilance.data.PropertyCollector;
@@ -16,6 +16,8 @@ import org.objectweb.asm.tree.*;
import java.io.File;
public class VigilantTransformer implements ITransformer {
+ private static boolean didASM = false;
+ private static boolean didMixin = false;
@SuppressWarnings("unused")
public static VigilanceConfig returnNewConfig(Vigilant vigilant, File file) {
if (vigilant != null && Minecraft.getMinecraft().isCallingFromMinecraftThread()) {
@@ -37,69 +39,143 @@ public class VigilantTransformer implements ITransformer {
@Override
public void transform(String transformedName, ClassNode node) {
- node.fields.add(new FieldNode(Opcodes.ACC_PUBLIC, "oneconfig$config", Type.getDescriptor(VigilanceConfig.class), null, null));
- node.fields.add(new FieldNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL, "oneconfig$file", Type.getDescriptor(File.class), null, null));
-
- node.interfaces.add("cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilantAccessor");
- MethodNode methodNode = new MethodNode(Opcodes.ACC_PUBLIC, "getPropertyCollector", "()Lgg/essential/vigilance/data/PropertyCollector;", null, null);
- LabelNode labelNode = new LabelNode();
- methodNode.instructions.add(labelNode);
- methodNode.instructions.add(new LineNumberNode(421421, labelNode));
- methodNode.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
- methodNode.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "propertyCollector", Type.getDescriptor(PropertyCollector.class)));
- methodNode.instructions.add(new InsnNode(Opcodes.ARETURN));
- node.methods.add(methodNode);
-
- MethodNode methodNode2 = new MethodNode(Opcodes.ACC_PUBLIC, "handleOneConfigDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", null, null);
- LabelNode labelNode2 = new LabelNode();
- LabelNode labelNode3 = new LabelNode();
- LabelNode labelNode4 = new LabelNode();
- methodNode2.instructions.add(labelNode2);
- methodNode2.instructions.add(new LineNumberNode(15636436, labelNode2));
- methodNode2.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
- methodNode2.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", Type.getDescriptor(VigilanceConfig.class)));
-
- methodNode2.instructions.add(new JumpInsnNode(Opcodes.IFNULL, labelNode4));
-
- methodNode2.instructions.add(labelNode3);
- methodNode2.instructions.add(new LineNumberNode(15636437, labelNode3));
- methodNode2.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
- methodNode2.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", Type.getDescriptor(VigilanceConfig.class)));
- methodNode2.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1));
- methodNode2.instructions.add(new VarInsnNode(Opcodes.ALOAD, 2));
- methodNode2.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, Type.getInternalName(VigilanceConfig.class), "addDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", false));
-
- methodNode2.instructions.add(labelNode4);
- methodNode2.instructions.add(new LineNumberNode(15636438, labelNode4));
- methodNode2.instructions.add(new InsnNode(Opcodes.RETURN));
- node.methods.add(methodNode2);
-
- for (MethodNode method : node.methods) {
- if (method.name.equals("initialize")) {
- InsnList list = new InsnList();
- list.add(new VarInsnNode(Opcodes.ALOAD, 0));
- list.add(new VarInsnNode(Opcodes.ALOAD, 0));
- list.add(new VarInsnNode(Opcodes.ALOAD, 0));
- list.add(new FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$file", Type.getDescriptor(File.class)));
- list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(getClass()), "returnNewConfig", "(Lgg/essential/vigilance/Vigilant;Ljava/io/File;)Lcc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig;", false));
- list.add(new FieldInsnNode(Opcodes.PUTFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", Type.getDescriptor(VigilanceConfig.class)));
- method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list);
- } else if (method.name.equals("addDependency") && method.desc.equals("(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V")) {
- InsnList list = new InsnList();
-
- list.add(new VarInsnNode(Opcodes.ALOAD, 0));
- list.add(new VarInsnNode(Opcodes.ALOAD, 1));
- list.add(new VarInsnNode(Opcodes.ALOAD, 2));
- list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "gg/essential/vigilance/Vigilant", "handleOneConfigDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", false));
-
- method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list);
- } else if (method.name.equals("<init>") && method.desc.equals("(Ljava/io/File;Ljava/lang/String;Lgg/essential/vigilance/data/PropertyCollector;Lgg/essential/vigilance/data/SortingBehavior;)V")) {
- InsnList list = new InsnList();
- list.add(new VarInsnNode(Opcodes.ALOAD, 0));
- list.add(new VarInsnNode(Opcodes.ALOAD, 1));
- list.add(new FieldInsnNode(Opcodes.PUTFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$file", Type.getDescriptor(File.class)));
- method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list);
+ if (!didMixin) {
+ node.fields.add(new FieldNode(Opcodes.ACC_PUBLIC, "oneconfig$config", Type.getDescriptor(VigilanceConfig.class), null, null));
+ node.fields.add(new FieldNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL, "oneconfig$file", Type.getDescriptor(File.class), null, null));
+
+ node.interfaces.add("cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilantAccessor");
+ MethodNode methodNode = new MethodNode(Opcodes.ACC_PUBLIC, "getPropertyCollector", "()Lgg/essential/vigilance/data/PropertyCollector;", null, null);
+ LabelNode labelNode = new LabelNode();
+ methodNode.instructions.add(labelNode);
+ methodNode.instructions.add(new LineNumberNode(421421, labelNode));
+ methodNode.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
+ methodNode.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "propertyCollector", Type.getDescriptor(PropertyCollector.class)));
+ methodNode.instructions.add(new InsnNode(Opcodes.ARETURN));
+ node.methods.add(methodNode);
+
+ MethodNode methodNode2 = new MethodNode(Opcodes.ACC_PUBLIC, "handleOneConfigDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", null, null);
+ LabelNode labelNode2 = new LabelNode();
+ LabelNode labelNode3 = new LabelNode();
+ LabelNode labelNode4 = new LabelNode();
+ methodNode2.instructions.add(labelNode2);
+ methodNode2.instructions.add(new LineNumberNode(15636436, labelNode2));
+ methodNode2.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
+ methodNode2.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", Type.getDescriptor(VigilanceConfig.class)));
+
+ methodNode2.instructions.add(new JumpInsnNode(Opcodes.IFNULL, labelNode4));
+
+ methodNode2.instructions.add(labelNode3);
+ methodNode2.instructions.add(new LineNumberNode(15636437, labelNode3));
+ methodNode2.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
+ methodNode2.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", Type.getDescriptor(VigilanceConfig.class)));
+ methodNode2.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1));
+ methodNode2.instructions.add(new VarInsnNode(Opcodes.ALOAD, 2));
+ methodNode2.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, Type.getInternalName(VigilanceConfig.class), "addDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", false));
+
+ methodNode2.instructions.add(labelNode4);
+ methodNode2.instructions.add(new LineNumberNode(15636438, labelNode4));
+ methodNode2.instructions.add(new InsnNode(Opcodes.RETURN));
+ node.methods.add(methodNode2);
+
+ for (MethodNode method : node.methods) {
+ if (method.name.equals("initialize")) {
+ InsnList list = new InsnList();
+ list.add(new VarInsnNode(Opcodes.ALOAD, 0));
+ list.add(new VarInsnNode(Opcodes.ALOAD, 0));
+ list.add(new VarInsnNode(Opcodes.ALOAD, 0));
+ list.add(new FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$file", Type.getDescriptor(File.class)));
+ list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(getClass()), "returnNewConfig", "(Lgg/essential/vigilance/Vigilant;Ljava/io/File;)Lcc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig;", false));
+ list.add(new FieldInsnNode(Opcodes.PUTFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", Type.getDescriptor(VigilanceConfig.class)));
+ method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list);
+ } else if (method.name.equals("addDependency") && method.desc.equals("(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V")) {
+ InsnList list = new InsnList();
+
+ list.add(new VarInsnNode(Opcodes.ALOAD, 0));
+ list.add(new VarInsnNode(Opcodes.ALOAD, 1));
+ list.add(new VarInsnNode(Opcodes.ALOAD, 2));
+ list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "gg/essential/vigilance/Vigilant", "handleOneConfigDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", false));
+
+ method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list);
+ } else if (method.name.equals("<init>") && method.desc.equals("(Ljava/io/File;Ljava/lang/String;Lgg/essential/vigilance/data/PropertyCollector;Lgg/essential/vigilance/data/SortingBehavior;)V")) {
+ InsnList list = new InsnList();
+ list.add(new VarInsnNode(Opcodes.ALOAD, 0));
+ list.add(new VarInsnNode(Opcodes.ALOAD, 1));
+ list.add(new FieldInsnNode(Opcodes.PUTFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$file", Type.getDescriptor(File.class)));
+ method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list);
+ }
+ }
+ didASM = true;
+ }
+ }
+
+ // this is the method above but using spongemixin's stupid relocate asm and static
+ public static void transform(org.spongepowered.asm.lib.tree.ClassNode node) {
+ if (!didASM) {
+ node.fields.add(new org.spongepowered.asm.lib.tree.FieldNode(Opcodes.ACC_PUBLIC, "oneconfig$config", Type.getDescriptor(VigilanceConfig.class), null, null));
+ node.fields.add(new org.spongepowered.asm.lib.tree.FieldNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL, "oneconfig$file", Type.getDescriptor(File.class), null, null));
+
+ node.interfaces.add("cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilantAccessor");
+ org.spongepowered.asm.lib.tree.MethodNode methodNode = new org.spongepowered.asm.lib.tree.MethodNode(Opcodes.ACC_PUBLIC, "getPropertyCollector", "()Lgg/essential/vigilance/data/PropertyCollector;", null, null);
+ org.spongepowered.asm.lib.tree.LabelNode labelNode = new org.spongepowered.asm.lib.tree.LabelNode();
+ methodNode.instructions.add(labelNode);
+ methodNode.instructions.add(new org.spongepowered.asm.lib.tree.LineNumberNode(421421, labelNode));
+ methodNode.instructions.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 0));
+ methodNode.instructions.add(new org.spongepowered.asm.lib.tree.FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "propertyCollector", Type.getDescriptor(PropertyCollector.class)));
+ methodNode.instructions.add(new org.spongepowered.asm.lib.tree.InsnNode(Opcodes.ARETURN));
+ node.methods.add(methodNode);
+
+ org.spongepowered.asm.lib.tree.MethodNode methodNode2 = new org.spongepowered.asm.lib.tree.MethodNode(Opcodes.ACC_PUBLIC, "handleOneConfigDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", null, null);
+ org.spongepowered.asm.lib.tree.LabelNode labelNode2 = new org.spongepowered.asm.lib.tree.LabelNode();
+ org.spongepowered.asm.lib.tree.LabelNode labelNode3 = new org.spongepowered.asm.lib.tree.LabelNode();
+ org.spongepowered.asm.lib.tree.LabelNode labelNode4 = new org.spongepowered.asm.lib.tree.LabelNode();
+ methodNode2.instructions.add(labelNode2);
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.LineNumberNode(15636436, labelNode2));
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 0));
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", Type.getDescriptor(VigilanceConfig.class)));
+
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.JumpInsnNode(Opcodes.IFNULL, labelNode4));
+
+ methodNode2.instructions.add(labelNode3);
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.LineNumberNode(15636437, labelNode3));
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 0));
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", Type.getDescriptor(VigilanceConfig.class)));
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 1));
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 2));
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.MethodInsnNode(Opcodes.INVOKEVIRTUAL, Type.getInternalName(VigilanceConfig.class), "addDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", false));
+
+ methodNode2.instructions.add(labelNode4);
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.LineNumberNode(15636438, labelNode4));
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.InsnNode(Opcodes.RETURN));
+ node.methods.add(methodNode2);
+
+ for (org.spongepowered.asm.lib.tree.MethodNode method : node.methods) {
+ if (method.name.equals("initialize")) {
+ org.spongepowered.asm.lib.tree.InsnList list = new org.spongepowered.asm.lib.tree.InsnList();
+ list.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 0));
+ list.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 0));
+ list.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 0));
+ list.add(new org.spongepowered.asm.lib.tree.FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$file", Type.getDescriptor(File.class)));
+ list.add(new org.spongepowered.asm.lib.tree.MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(VigilantTransformer.class), "returnNewConfig", "(Lgg/essential/vigilance/Vigilant;Ljava/io/File;)Lcc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig;", false));
+ list.add(new org.spongepowered.asm.lib.tree.FieldInsnNode(Opcodes.PUTFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", Type.getDescriptor(VigilanceConfig.class)));
+ method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list);
+ } else if (method.name.equals("addDependency") && method.desc.equals("(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V")) {
+ org.spongepowered.asm.lib.tree.InsnList list = new org.spongepowered.asm.lib.tree.InsnList();
+
+ list.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 0));
+ list.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 1));
+ list.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 2));
+ list.add(new org.spongepowered.asm.lib.tree.MethodInsnNode(Opcodes.INVOKEVIRTUAL, "gg/essential/vigilance/Vigilant", "handleOneConfigDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", false));
+
+ method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list);
+ } else if (method.name.equals("<init>") && method.desc.equals("(Ljava/io/File;Ljava/lang/String;Lgg/essential/vigilance/data/PropertyCollector;Lgg/essential/vigilance/data/SortingBehavior;)V")) {
+ org.spongepowered.asm.lib.tree.InsnList list = new org.spongepowered.asm.lib.tree.InsnList();
+ list.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 0));
+ list.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 1));
+ list.add(new org.spongepowered.asm.lib.tree.FieldInsnNode(Opcodes.PUTFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$file", Type.getDescriptor(File.class)));
+ method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list);
+ }
}
+ didMixin = true;
}
}
}
diff --git a/src/main/resources/mixins.oneconfig.json b/src/main/resources/mixins.oneconfig.json
index a3e954e..6b0b982 100644
--- a/src/main/resources/mixins.oneconfig.json
+++ b/src/main/resources/mixins.oneconfig.json
@@ -15,6 +15,7 @@
"NetHandlerPlayClientMixin",
"NetworkManagerMixin",
"ShaderGroupAccessor",
+ "VigilantMixin",
"WorldClientMixin"
]
} \ No newline at end of file