Skip to content

Commit

Permalink
toPublic
Browse files Browse the repository at this point in the history
  • Loading branch information
Ecdcaeb committed Aug 2, 2024
1 parent ea93cb7 commit 92eaef4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/main/java/rml/loader/ResourceModLoader.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package rml.loader;

import dev.latvian.kubejs.documentation.P;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
import org.apache.logging.log4j.Logger;
import rml.jrx.announces.PrivateAPI;
import rml.jrx.announces.PublicAPI;
import rml.loader.api.event.RMLModuleLoadingEvent;
import rml.jrx.utils.file.FileHelper;
import rml.loader.api.event.RMLModuleLoadingEvent;
import rml.loader.api.mods.BuffedModIDContainer;
import rml.loader.api.mods.ContainerHolder;
import rml.loader.api.mods.module.Module;
import rml.loader.api.mods.module.ModuleType;
import rml.loader.core.RMLFMLLoadingPlugin;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
import org.apache.logging.log4j.Logger;

import javax.annotation.Nullable;
import java.util.HashSet;
Expand Down
24 changes: 21 additions & 3 deletions src/main/java/rml/loader/core/RMLTransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.IntInsnNode;
Expand All @@ -26,7 +27,6 @@
import rml.jrx.announces.PrivateAPI;
import rml.jrx.asm.MethodName;
import rml.jrx.utils.Tasks;
import rml.layer.cleanroom.LaunchClassLoaderUtil;

import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -75,9 +75,10 @@ public byte[] transform(String name, String transformedName, byte[] basicClass)
if (basicClass!=null && basicClass.length>0){
try{
if (!globalTransformers.isEmpty() || transformers.containsKey(transformedName)){
ClassReader classReader=new ClassReader(basicClass);
ClassNode cn=new ClassNode();
ClassReader classReader = new ClassReader(basicClass);
ClassNode cn = new ClassNode();
classReader.accept(cn, 0);
publicClass(cn);
int flags = 0;
boolean isTarget = false;
for(GlobalTransformer transformer:globalTransformers){
Expand All @@ -104,6 +105,22 @@ public byte[] transform(String name, String transformedName, byte[] basicClass)
}
return basicClass;
}

public static void publicClass(ClassNode classNode){
classNode.access = toPublic(classNode.access);
for(MethodNode mn : classNode.methods){
mn.access = toPublic(mn.access);
}
for(FieldNode fn : classNode.fields){
fn.access = toPublic(fn.access);
}
}

private static int toPublic(int access)
{
return access & ~(Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED) | Opcodes.ACC_PUBLIC;
}

public static class LaunchClassWriter extends ClassWriter{

public LaunchClassWriter(ClassReader classReader, int flags) {
Expand Down Expand Up @@ -263,6 +280,7 @@ public static void initForgeTransformers(){
}
return -1;
});
transformers.put("net.minecraftforge.fml.client.GuiModList", (cn)-> 0);
}
public static void initMinecraftTransformers(){
transformers.put("net.minecraft.advancements.FunctionManager",
Expand Down

0 comments on commit 92eaef4

Please sign in to comment.