Skip to content

ScriptCompiler

Hileb edited this page May 12, 2025 · 3 revisions

IScriptCompiler is a java service.

See IScriptCompiler

name is the unique name of the compiler, used for the compiler assignment, such as javaShota.

compile the ScriptFile to a Runnable.

ShotaCompiler is the default compiler. It is based on the javax.tool.

The text would be merged. And the final text would be processed to a normal java codes. ->

package mods.Hileb.shotaasm.dynamic;
// the property of imports
import mods.Hileb.shotaasm.api.TransformerRegistry;
import mods.Hileb.shotaasm.api.ShotaContext;
import org.objectweb.asm.*;
import org.objectweb.asm.tree.*;
import org.objectweb.asm.util.*;
import org.objectweb.asm.commons.*;
import org.objectweb.asm.signature.*;
import static org.objectweb.asm.Opcodes.*;
public class //The file name
 implements Runnable {
    public void run() {
       // Your codes here
    }
}

property

import

the property of import would be imported.

event

If absence, the script would be compiled and run immediately.

Or else, the script would be compiled and run later.

It should be the type of the stage event. You could check it here. LoaderState

example:

#compiler groovyShota
#import org.apache.logging.log4j.LogManager
#import org.apache.logging.log4j.Logger

System.out.print("Shota Strat his own tests!!! ^o^")
final Logger LOGGER = LogManager.getLogger("Groovy Cute shota")
LOGGER.info("Now, i have my own logger!!")

TransformerRegistry.registerASMExplicitTransformer(
 -99,
     { ClassNode cn ->
         cn.methods.each { MethodNode mn ->
         mn.instructions.iterator().each {
         if (it instanceof org.objectweb.asm.tree.LdcInsnNode && it.cst instanceof String && it.cst.startsWith("Cleanroom")) {
                   it.cst = it.cst + " & Cute Shota"
                   LOGGER.info("change the title to {}", it.cst)
             }
         }
     }
 },
 "net.minecraft.client.Minecraft"
)
Clone this wiki locally