From d82b338ad36a6180d2d9305fc055760ce11ab535 Mon Sep 17 00:00:00 2001 From: Alexdoru <57050655+Alexdoru@users.noreply.github.com> Date: Mon, 4 Aug 2025 11:14:20 +0200 Subject: [PATCH] Delete useless coremod (#6) --- gradle.properties | 2 +- src/main/java/DummyCore/ASM/DCASMManager.java | 132 ------------------ .../java/DummyCore/ASM/DCLoadingPlugin.java | 35 ----- 3 files changed, 1 insertion(+), 168 deletions(-) delete mode 100644 src/main/java/DummyCore/ASM/DCASMManager.java delete mode 100644 src/main/java/DummyCore/ASM/DCLoadingPlugin.java diff --git a/gradle.properties b/gradle.properties index 60c8728..4f92717 100644 --- a/gradle.properties +++ b/gradle.properties @@ -97,7 +97,7 @@ mixinsPackage = # Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin! # This parameter is for legacy compatibility only # Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin -coreModClass = ASM.DCLoadingPlugin +coreModClass = # If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class # that is annotated with @Mod) you want this to be true. When in doubt: leave it on false! diff --git a/src/main/java/DummyCore/ASM/DCASMManager.java b/src/main/java/DummyCore/ASM/DCASMManager.java deleted file mode 100644 index f373595..0000000 --- a/src/main/java/DummyCore/ASM/DCASMManager.java +++ /dev/null @@ -1,132 +0,0 @@ -package DummyCore.ASM; - -import java.util.Arrays; -import java.util.List; - -import net.minecraft.launchwrapper.IClassTransformer; - -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.tree.AnnotationNode; -import org.objectweb.asm.tree.ClassNode; - -import DummyCore.Utils.Notifier; - -public class DCASMManager implements IClassTransformer { - - @Override - public byte[] transform(String name, String transformedName, byte[] basicClass) { - if (basicClass != null) // If the class we are loading exists - { - ClassNode classNode = new ClassNode(); // Creating a most basic bytecode->runtime command helper. - ClassReader classReader = new ClassReader(basicClass); // Parsing the bytecode to runtime commands - classReader.accept(classNode, 0); // Giving our helper a parsed list of commands without any code - // modifications. - if (classNode.invisibleAnnotations != null && classNode.invisibleAnnotations.size() > 0) // If we have some - // invisible - // annotations on - // our class. - { - boolean checkClass = false; - for (int i = 0; i < classNode.invisibleAnnotations.size(); ++i) // Looking through all annotations - // presented on the class - { - AnnotationNode node = classNode.invisibleAnnotations.get(i); - if (node.desc.equalsIgnoreCase("LDummyCore/Utils/DCASMCheck;")) // If the given annotation is a - // DummyCore annotation, that - // sygnals, that the class needs to be checked. - { - checkClass = true; - break; // We have to send our class outside the loop to make sure there is no - // ConcurrentModificationException. - } - } - if (checkClass) return handleClass(name, transformedName, basicClass, classNode, classReader); // If - // class - // requires - // inspection - // we are - // sending - // it - // into - // our - // method - } - } - return basicClass; - } - - public byte[] handleClass(String name, String transformedName, byte[] basicClass, ClassNode cn, ClassReader cr) { - Notifier.notifyCustomMod( - "DummyCoreASM", - "Class " + name - + " has requested a DummyCore ASM check via DummyCore/Utils/DCASMCheck annotation. Examining..."); - String[] checkedClss = new String[0]; // Initializing the interfaces variable - for (int i = 0; i < cn.invisibleAnnotations.size(); ++i) // Checking through all annotations. - { - AnnotationNode node = cn.invisibleAnnotations.get(i); - if (node.desc.equalsIgnoreCase("LDummyCore/Utils/ExistanceCheck;") && node.values != null - && node.values.size() > 0) // Checking if the annotation found is the one, that makes us go through - { - Notifier.notifyCustomMod( - "DummyCoreASM", - "Class " + name - + " has requested a DummyCore ASM check on it's implementations via DummyCore/Utils/ExistanceCheck annotation. Examining..."); - List classes = List.class.cast(node.values.get(1)); // Getting a full list of classes that we need to - // check for existance - checkedClss = new String[classes.size()]; - checkedClss = String[].class.cast(classes.toArray(checkedClss)); - break; - } - } - Notifier.notifyCustomMod( - "DummyCoreASM", - "Class " + name + " has given the next interfaces to check: " + Arrays.asList(checkedClss)); - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); // Creating the ability to modify bytecode using - // modified instructions - if (checkedClss.length > 0) // If we have interfaces to check - { - for (int i = 0; i < checkedClss.length; ++i) { - if (!classExists(checkedClss[i])) // If the class was NOT found - { - J: for (int j = 0; j < cn.interfaces.size(); ++j) // Looping through all interfaces presented in the - // class - { - if (cn.interfaces.get(j).equalsIgnoreCase(checkedClss[i].replace('.', '/'))) // If thi is the - // one we are - // looking for - { - Notifier.notifyCustomMod( - "DummyCoreASM", - "Class " + name - + " has a " - + cn.interfaces.get(j) - + " implementation, but the referenced class was not found. Removing the given interface."); - cn.interfaces.remove(j); // Removing it. - break J; - } - } - } else { - Notifier.notifyCustomMod( - "DummyCoreASM", - "Class " + name - + " has a " - + checkedClss[i] - + " implementation, and the referenced class was found. Skipping to the next interface..."); - } - } - } - cn.accept(cw); // Writing changed Instructions into bytecode helper - Notifier.notifyCustomMod("DummyCoreASM", "Class " + name + " has been checked."); - return cw.toByteArray(); // Returning modified bytecode. - } - - boolean classExists(String s) { - try { - Class c = Class.forName(s); - return c != null; - } catch (ClassNotFoundException e) { - return false; - } - } -} diff --git a/src/main/java/DummyCore/ASM/DCLoadingPlugin.java b/src/main/java/DummyCore/ASM/DCLoadingPlugin.java deleted file mode 100644 index c1ba2cf..0000000 --- a/src/main/java/DummyCore/ASM/DCLoadingPlugin.java +++ /dev/null @@ -1,35 +0,0 @@ -package DummyCore.ASM; - -import java.util.Map; - -import cpw.mods.fml.relauncher.IFMLLoadingPlugin; -import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion; -import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions; - -@MCVersion("1.7.10") -@TransformerExclusions("DummyCore.ASM.*") -public class DCLoadingPlugin implements IFMLLoadingPlugin { - - @Override - public String[] getASMTransformerClass() { - return new String[] { DCASMManager.class.getName() }; - } - - @Override - public String getModContainerClass() { - return null; - } - - @Override - public String getSetupClass() { - return null; - } - - @Override - public void injectData(Map data) {} - - @Override - public String getAccessTransformerClass() { - return null; - } -}