├── README.md └── src └── main ├── java └── xyz │ └── blowsy │ └── inj │ ├── Command.java │ ├── Main.java │ ├── Utils.java │ └── impl │ ├── CommandClass.java │ ├── InjectionClass.java │ ├── Injector.java │ └── dump │ ├── CommandDumper.java │ └── InjectionDumper.java └── resources └── mcmod.info /README.md: -------------------------------------------------------------------------------- 1 | # esp injector 2 | 3 | allows the user to inject esp code into any given forge mod with a locatable initialization event. 4 | 5 | showcase: https://www.youtube.com/watch?v=8pf7gCiKsfE 6 | 7 | ``` 8 | /inject open 9 | /inject load 10 | /inject cmd [command] 11 | /inject [file] 12 | ``` 13 | 14 | concept mod, code is not refined. 15 | -------------------------------------------------------------------------------- /src/main/java/xyz/blowsy/inj/Command.java: -------------------------------------------------------------------------------- 1 | package xyz.blowsy.inj; 2 | 3 | import net.minecraft.command.CommandBase; 4 | import net.minecraft.command.CommandException; 5 | import net.minecraft.command.ICommandSender; 6 | import xyz.blowsy.inj.impl.Injector; 7 | 8 | import java.awt.*; 9 | import java.io.File; 10 | import java.io.IOException; 11 | 12 | public class Command extends CommandBase { 13 | 14 | private final String COMMAND = "inject"; 15 | private final long COOLDOWN = 2500L; 16 | private long PREV_EXEC = 0L; 17 | 18 | public String getCommandName() { return COMMAND; } 19 | 20 | public String getCommandUsage(ICommandSender sender) { return "/" + COMMAND; } 21 | 22 | public void processCommand(ICommandSender sender, String[] args) throws CommandException { 23 | if (!canPerform()) { 24 | return; 25 | } 26 | if (args.length == 1) { 27 | switch (args[0].toLowerCase()) { 28 | case "load": 29 | Main.loadFolder(); 30 | return; 31 | case "open": 32 | try { 33 | Desktop.getDesktop().open(new File(Main.FOLDER_PATH)); 34 | } catch (IOException e) { 35 | Utils.sendMessage("&cError locating folder. Reloaded folder."); 36 | Main.loadFolder(); 37 | } 38 | return; 39 | case "list": 40 | if (Main.files.isEmpty()) { 41 | Utils.sendMessage("&eNo files located in the directory."); 42 | return; 43 | } 44 | Utils.sendMessage("&eLoaded files:"); 45 | for (File file : Main.files) { 46 | Utils.sendMessage(" &e- &7" + file.getName()); 47 | } 48 | return; 49 | default: 50 | if (Main.files.isEmpty()) { 51 | Utils.sendMessage("&eNo files located in the directory."); 52 | return; 53 | } 54 | String name = args[0]; 55 | for (int i = 0; i < Main.files.size(); i++) { 56 | File file = Main.files.get(i); 57 | if (file.getName().equals(name)) { 58 | if (!file.exists() || !file.canRead()) { 59 | Utils.sendMessage("&eFile is no longer accessible. Reloaded folder."); 60 | Main.loadFolder(); 61 | return; 62 | } 63 | Main.getExecutor().execute(() -> { 64 | try { 65 | Injector.run(file); 66 | } catch (Exception e) { 67 | Utils.sendMessage("&cThere was an error."); 68 | e.printStackTrace(); 69 | } 70 | }); 71 | return; 72 | } 73 | } 74 | Utils.sendMessage("&eUnable to locate file."); 75 | return; 76 | } 77 | } else if (args.length == 2) { 78 | if (args[0].equalsIgnoreCase("cmd")) { 79 | Main.customCommandName = args[1]; 80 | Utils.sendMessage("&eCommand set to &3/" + Main.customCommandName); 81 | return; 82 | } 83 | } 84 | Utils.sendMessage("&eInvalid command usage."); 85 | } 86 | 87 | public int getRequiredPermissionLevel() { return 0; } 88 | 89 | public boolean canCommandSenderUseCommand(ICommandSender sender) { return true; } 90 | 91 | private boolean canPerform() { 92 | if (Utils.timeBetween(PREV_EXEC, System.currentTimeMillis()) > COOLDOWN) { 93 | PREV_EXEC = System.currentTimeMillis(); 94 | return true; 95 | } 96 | Utils.sendMessage("&cPlease do not spam these commands!"); 97 | return false; 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/xyz/blowsy/inj/Main.java: -------------------------------------------------------------------------------- 1 | package xyz.blowsy.inj; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraftforge.client.ClientCommandHandler; 5 | import net.minecraftforge.fml.common.Mod; 6 | import net.minecraftforge.fml.common.Mod.EventHandler; 7 | import net.minecraftforge.fml.common.event.FMLInitializationEvent; 8 | 9 | import java.io.File; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | import java.util.concurrent.ExecutorService; 13 | import java.util.concurrent.Executors; 14 | 15 | @Mod(modid = "examplemod-2", name = "Example Mod", version = "1.0", acceptedMinecraftVersions = "[1.8.9]") 16 | public class Main { 17 | 18 | private static final ExecutorService executor = Executors.newCachedThreadPool(); 19 | 20 | public static final String FOLDER_NAME = "InjectorFolder"; 21 | public static final String FOLDER_PATH = Minecraft.getMinecraft().mcDataDir + File.separator + FOLDER_NAME; 22 | public static final List files = new ArrayList<>(); 23 | 24 | public static String customCommandName = "cheat"; 25 | 26 | @EventHandler 27 | public void init(FMLInitializationEvent event) { 28 | shutdownHook(); 29 | ClientCommandHandler.instance.registerCommand(new Command()); 30 | loadFolder(); 31 | } 32 | 33 | public static void loadFolder() { 34 | files.clear(); 35 | File path = new File(FOLDER_PATH); 36 | Utils.sendMessage("&eChecking path: &7" + FOLDER_NAME); 37 | if (!path.exists()) { 38 | path.mkdirs(); // create folder 39 | return; 40 | } 41 | File[] folder = path.listFiles(); 42 | if (folder == null) { 43 | return; 44 | } 45 | for (int i = 0; i < folder.length; i++) { 46 | File file = folder[i]; 47 | if (!file.canRead() || !file.getName().endsWith(".jar")) { 48 | continue; 49 | } 50 | files.add(file); 51 | } 52 | Utils.sendMessage("&eLoaded folder. Identified &3" + files.size() + " &efiles."); 53 | } 54 | 55 | public static ExecutorService getExecutor() { 56 | return executor; 57 | } 58 | 59 | private void shutdownHook() { 60 | Runtime.getRuntime().addShutdownHook(new Thread(() -> { 61 | executor.shutdown(); 62 | })); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/xyz/blowsy/inj/Utils.java: -------------------------------------------------------------------------------- 1 | package xyz.blowsy.inj; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.util.ChatComponentText; 5 | import org.objectweb.asm.tree.ClassNode; 6 | 7 | import java.io.File; 8 | 9 | public class Utils { 10 | 11 | public static final String cc = "\u00A7"; 12 | public static final String prefix = "&7[&dINJ&7]&r"; 13 | private static final String line = "&7&m-------------------------"; 14 | 15 | public static final Minecraft mc = Minecraft.getMinecraft(); 16 | 17 | public static boolean nullCheck() { 18 | return mc.thePlayer != null && mc.theWorld != null; 19 | } 20 | 21 | public static void sendMessage(String message) { 22 | if (!nullCheck()) return; 23 | String txt = replace(prefix + " " + message); 24 | mc.thePlayer.addChatMessage(new ChatComponentText(txt)); 25 | } 26 | 27 | public static void sendLine() { 28 | sendMessage(line); 29 | } 30 | 31 | public static String replace(String text) { 32 | return text.replace("&", cc).replace("%and", "&"); 33 | } 34 | 35 | public static double round(double number, int decimals) { 36 | if (decimals == 0) return Math.round(number); 37 | double power = Math.pow(10, decimals); 38 | return Math.round(number*power)/power; 39 | } 40 | 41 | public static long timeBetween(long start, long end) { 42 | return Math.abs(end - start); 43 | } 44 | 45 | public static double longToSeconds(long value) { 46 | return round(value / 1000d, 2); 47 | } 48 | 49 | public static double getFileSizeKB(File file) { 50 | return round(file.length() / 1000.0, 1); 51 | } 52 | 53 | public static String classToMethodDesc(Class _class) { 54 | final String prefix = "(L", suffix = ";)V"; // return type is void 55 | return prefix + _class.getName().replace(".", "/") + suffix; 56 | } 57 | 58 | public static String classToAttribute(Class _class) { 59 | final String prefix = "L", suffix = ";"; 60 | return prefix + _class.getName().replace(".", "/") + suffix; 61 | } 62 | 63 | public static String getClassName(ClassNode classNode) { 64 | String name = classNode.name; 65 | if (classNode.name.contains("/")) { 66 | String[] split = classNode.name.split("/"); 67 | if (split.length > 0) { 68 | name = split[split.length - 1]; 69 | } 70 | } 71 | return name; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/xyz/blowsy/inj/impl/CommandClass.java: -------------------------------------------------------------------------------- 1 | package xyz.blowsy.inj.impl; 2 | 3 | import net.minecraft.command.CommandBase; 4 | import net.minecraft.command.ICommandSender; 5 | 6 | public class CommandClass extends CommandBase { 7 | 8 | // view this class as "ASMified" and copy paste it to CommandDumper 9 | // make sure to replace "[PLACEHOLDER]" with command string 10 | 11 | private String s = "[PLACEHOLDER]"; 12 | 13 | public String getCommandName() { 14 | return s; 15 | } 16 | 17 | public String getCommandUsage(ICommandSender s) { 18 | return "/" + s; 19 | } 20 | 21 | public void processCommand(ICommandSender s, String[] a) { 22 | InjectionClass.g(); 23 | } 24 | 25 | public boolean canCommandSenderUseCommand(ICommandSender s) { return true; } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/xyz/blowsy/inj/impl/InjectionClass.java: -------------------------------------------------------------------------------- 1 | package xyz.blowsy.inj.impl; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.Gui; 5 | import net.minecraft.client.renderer.GlStateManager; 6 | import net.minecraft.entity.player.EntityPlayer; 7 | import net.minecraft.util.ChatComponentText; 8 | import net.minecraft.util.Timer; 9 | import net.minecraftforge.client.ClientCommandHandler; 10 | import net.minecraftforge.client.event.RenderWorldLastEvent; 11 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 12 | import org.lwjgl.opengl.GL11; 13 | 14 | import java.awt.*; 15 | import java.lang.reflect.Field; 16 | 17 | public class InjectionClass { 18 | 19 | // view this class as "ASMified" and copy paste it to InjectionDumper 20 | 21 | private static final String inj = "CheatInjector created by blowsy."; 22 | 23 | private static boolean en = false; // cheat enabled or not 24 | 25 | private static Minecraft mc; // minecraft 26 | private Field t; // timer 27 | 28 | public InjectionClass() { 29 | // registering command class (remove when viewing ASMified) 30 | ClientCommandHandler.instance.registerCommand(new CommandClass()); 31 | mc = Minecraft.getMinecraft(); 32 | try { 33 | t = Minecraft.class.getDeclaredField("field_71428_T"); 34 | t.setAccessible(true); 35 | } catch (Exception e) { } 36 | } 37 | 38 | @SubscribeEvent 39 | public void r(RenderWorldLastEvent e) { 40 | if (!en || !nc()) return; 41 | for (EntityPlayer en : mc.theWorld.playerEntities) { 42 | if (en != mc.thePlayer && en.deathTime == 0) { 43 | esp(en); 44 | } 45 | } 46 | } 47 | 48 | private void esp(EntityPlayer e) { 49 | double x = e.lastTickPosX + (e.posX - e.lastTickPosX) * t().renderPartialTicks - mc.getRenderManager().viewerPosX; 50 | double y = e.lastTickPosY + (e.posY - e.lastTickPosY) * t().renderPartialTicks - mc.getRenderManager().viewerPosY; 51 | double z = e.lastTickPosZ + (e.posZ - e.lastTickPosZ) * t().renderPartialTicks - mc.getRenderManager().viewerPosZ; 52 | GlStateManager.pushMatrix(); 53 | // health ratio 54 | double r = e.getHealth() / e.getMaxHealth(); 55 | int b = (int) (74 * r); 56 | // health color 57 | int c = r < 0.3 ? Color.red.getRGB() : (r < 0.5 ? Color.orange.getRGB() : (r < 0.7 ? Color.yellow.getRGB() : Color.green.getRGB())); // rgb for health 58 | GL11.glTranslated(x, y - 0.2D, z); 59 | GL11.glRotated(-mc.getRenderManager().playerViewY, 0.0D, 1.0D, 0.0D); 60 | GlStateManager.disableDepth(); 61 | GL11.glScalef(0.03F, 0.03F, 0.03F); 62 | Gui.drawRect(21, -1, 26, 75, Color.black.getRGB()); 63 | Gui.drawRect(22, b, 25, 74, Color.darkGray.getRGB()); 64 | Gui.drawRect(22, 0, 25, b, c); // health 65 | GlStateManager.enableDepth(); 66 | GlStateManager.popMatrix(); 67 | } 68 | 69 | private Timer t() { // getTimer 70 | try { 71 | return (Timer) t.get(mc); 72 | } catch (IllegalAccessException | IndexOutOfBoundsException e) { return null; } 73 | } 74 | 75 | // nullCheck 76 | private boolean nc() { 77 | return mc.thePlayer != null && mc.theWorld != null; 78 | } 79 | 80 | // toggle module 81 | public static void g() { 82 | mc.thePlayer.addChatMessage(new ChatComponentText("set: " + (en = !en))); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/xyz/blowsy/inj/impl/Injector.java: -------------------------------------------------------------------------------- 1 | package xyz.blowsy.inj.impl; 2 | 3 | import net.minecraftforge.fml.common.Mod; 4 | import net.minecraftforge.fml.common.event.FMLInitializationEvent; 5 | import org.objectweb.asm.ClassReader; 6 | import org.objectweb.asm.ClassWriter; 7 | import org.objectweb.asm.Opcodes; 8 | import org.objectweb.asm.tree.*; 9 | import xyz.blowsy.inj.Utils; 10 | import xyz.blowsy.inj.impl.dump.CommandDumper; 11 | import xyz.blowsy.inj.impl.dump.InjectionDumper; 12 | 13 | import java.io.*; 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | import java.util.jar.JarEntry; 17 | import java.util.jar.JarFile; 18 | import java.util.jar.JarOutputStream; 19 | import java.util.zip.ZipEntry; 20 | 21 | public class Injector { 22 | 23 | private static JarOutputStream outputStream; 24 | private static Map classes = new HashMap<>(); 25 | private static long start = 0; 26 | 27 | public static final String CLASS_NAME = InjectionClass.class.getSimpleName(), CMD_CLASS_NAME = CommandClass.class.getSimpleName(); 28 | 29 | public static void run(File file) throws Exception { 30 | Utils.sendLine(); 31 | Utils.sendMessage("&eRunning injector on: &7" + file.getName() + " (" + Utils.getFileSizeKB(file) + " KB)"); 32 | File outputFile = new File(file.getAbsolutePath().replace(".jar", "-new.jar")); 33 | if (outputFile.exists()) { 34 | Utils.sendMessage("&eOverriding existing file."); 35 | } 36 | start = System.currentTimeMillis(); 37 | outputStream = new JarOutputStream(new FileOutputStream(outputFile)); 38 | JarFile jarFile = new JarFile(file); 39 | parseInput(jarFile); 40 | transform(); 41 | compileJar(); 42 | Utils.sendMessage("&eProcess finished in &3" + Utils.longToSeconds(Utils.timeBetween(start, System.currentTimeMillis())) + " &eseconds."); 43 | Utils.sendMessage("&eNew file: &7" + outputFile.getName() + " (" + Utils.getFileSizeKB(outputFile) + " KB)"); 44 | Utils.sendLine(); 45 | } 46 | 47 | private static void transform() { 48 | Utils.sendMessage("&eThere is a total of &3" + classes.size() + " &eclasses."); 49 | final String targetMethodDesc = Utils.classToMethodDesc(FMLInitializationEvent.class); 50 | final String targetAttribute = Utils.classToAttribute(Mod.EventHandler.class); 51 | for (ClassNode classNode : classes.values()) { 52 | for (MethodNode methodNode : classNode.methods) { 53 | if (methodNode.desc.equals(targetMethodDesc) && methodNode.visibleAnnotations != null) { 54 | for (AnnotationNode annNode : methodNode.visibleAnnotations) { 55 | if (!annNode.desc.equals(targetAttribute)) continue; 56 | foundInit(classNode, methodNode); 57 | return; 58 | } 59 | } 60 | } 61 | } 62 | Utils.sendMessage("&cUnable to find initialization event method."); 63 | } 64 | 65 | private static void foundInit(ClassNode classNode, MethodNode methodNode) { 66 | Utils.sendMessage("&aLocated initialization event method."); 67 | // creating new class names 68 | String injClassName = classNode.name.replace(Utils.getClassName(classNode), CLASS_NAME); 69 | String cmdClassName = classNode.name.replace(Utils.getClassName(classNode), CMD_CLASS_NAME); 70 | // injecting InjectionClass 71 | ClassNode injClass = new ClassNode(); 72 | ClassReader injReader = new ClassReader(InjectionDumper.dump(injClassName, cmdClassName)); 73 | injReader.accept(injClass, 0); 74 | injClass.name = injClassName; 75 | classes.put(injClass.name, injClass); 76 | // injecting CommandClass 77 | ClassNode cmdClass = new ClassNode(); 78 | ClassReader cmdReader = new ClassReader(CommandDumper.dump(injClassName, cmdClassName)); 79 | cmdReader.accept(cmdClass, 0); 80 | cmdClass.name = cmdClassName; 81 | classes.put(cmdClass.name, cmdClass); 82 | // add InjectionClass call to fml initilization event 83 | methodNode.instructions.insertBefore(methodNode.instructions.getFirst(), callMethod(injClassName)); 84 | } 85 | 86 | private static InsnList callMethod(String className) { 87 | InsnList insnList = new InsnList(); 88 | // gets the static field "MinecraftForge.EVENT_BUS" 89 | insnList.add(new FieldInsnNode(Opcodes.GETSTATIC, "net/minecraftforge/common/MinecraftForge", "EVENT_BUS", "Lnet/minecraftforge/fml/common/eventhandler/EventBus;")); 90 | // instantiates new class 91 | insnList.add(new TypeInsnNode(Opcodes.NEW, className)); 92 | insnList.add(new InsnNode(Opcodes.DUP)); 93 | insnList.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, className, "", "()V", false)); 94 | // calls the method "MinecraftForge.EVENT_BUS.register()" 95 | insnList.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "net/minecraftforge/fml/common/eventhandler/EventBus", "register", "(Ljava/lang/Object;)V", false)); 96 | return insnList; 97 | } 98 | 99 | private static void parseInput(JarFile jarFile) throws IOException { 100 | classes.clear(); 101 | jarFile.stream().forEach(entry -> { 102 | try { 103 | if (entry.getName().endsWith(".class")) { 104 | ClassReader classReader = new ClassReader(jarFile.getInputStream(entry)); 105 | ClassNode classNode = new ClassNode(); 106 | classReader.accept(classNode, 0); 107 | classes.put(classNode.name, classNode); 108 | } else if (!entry.isDirectory()) { 109 | outputStream.putNextEntry(new ZipEntry(entry.getName())); 110 | outputStream.write(toByteArray(jarFile.getInputStream(entry))); 111 | outputStream.closeEntry(); 112 | } 113 | } catch (IOException e) { 114 | Utils.sendMessage("&cError parsing file components."); 115 | e.printStackTrace(); 116 | } 117 | }); 118 | jarFile.close(); 119 | } 120 | 121 | private static void compileJar() throws IOException { 122 | classes.values().forEach(classNode -> { 123 | ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS); 124 | try { 125 | classNode.accept(classWriter); 126 | JarEntry jarEntry = new JarEntry(classNode.name.concat(".class")); 127 | outputStream.putNextEntry(jarEntry); 128 | outputStream.write(classWriter.toByteArray()); 129 | } catch (Exception e) { 130 | Utils.sendMessage("&cError dumping class &3" + Utils.getClassName(classNode) + " &cinto new Jar."); 131 | e.printStackTrace(); 132 | } 133 | }); 134 | outputStream.close(); 135 | } 136 | 137 | private static byte[] toByteArray(InputStream inputStream) throws IOException { 138 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 139 | byte[] buffer = new byte[0xFFFF]; 140 | int length; 141 | while ((length = inputStream.read(buffer)) != -1) { 142 | outputStream.write(buffer, 0, length); 143 | } 144 | outputStream.flush(); 145 | return outputStream.toByteArray(); 146 | } 147 | 148 | } 149 | -------------------------------------------------------------------------------- /src/main/java/xyz/blowsy/inj/impl/dump/CommandDumper.java: -------------------------------------------------------------------------------- 1 | package xyz.blowsy.inj.impl.dump; 2 | 3 | import org.objectweb.asm.*; 4 | import xyz.blowsy.inj.Main; 5 | 6 | public class CommandDumper implements Opcodes { 7 | 8 | public static byte[] dump(String injClassName, String cmdClassName) { 9 | 10 | ClassWriter cw = new ClassWriter(0); 11 | FieldVisitor fv; 12 | MethodVisitor mv; 13 | 14 | // mappings 15 | final String getCommandName = "func_71517_b", getCommandUsage = "func_71518_a", 16 | processCommand = "func_71515_b", canCommandSenderUseCommand = "func_71519_b"; 17 | 18 | cw.visit(52, ACC_PUBLIC + ACC_SUPER, cmdClassName, null, "net/minecraft/command/CommandBase", null); 19 | 20 | cw.visitSource("CommandClass.java", null); 21 | 22 | { 23 | fv = cw.visitField(ACC_PRIVATE, "s", "Ljava/lang/String;", null, null); 24 | fv.visitEnd(); 25 | } 26 | { 27 | mv = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null); 28 | mv.visitCode(); 29 | Label l0 = new Label(); 30 | mv.visitLabel(l0); 31 | mv.visitLineNumber(7, l0); 32 | mv.visitVarInsn(ALOAD, 0); 33 | mv.visitMethodInsn(INVOKESPECIAL, "net/minecraft/command/CommandBase", "", "()V", false); 34 | Label l1 = new Label(); 35 | mv.visitLabel(l1); 36 | mv.visitLineNumber(9, l1); 37 | mv.visitVarInsn(ALOAD, 0); 38 | 39 | // set custom command 40 | mv.visitLdcInsn(Main.customCommandName); 41 | 42 | mv.visitFieldInsn(PUTFIELD, cmdClassName, "s", "Ljava/lang/String;"); 43 | mv.visitInsn(RETURN); 44 | Label l2 = new Label(); 45 | mv.visitLabel(l2); 46 | mv.visitLocalVariable("this", "L" + cmdClassName + ";", null, l0, l2, 0); 47 | mv.visitMaxs(2, 1); 48 | mv.visitEnd(); 49 | } 50 | { 51 | mv = cw.visitMethod(ACC_PUBLIC, getCommandName, "()Ljava/lang/String;", null, null); 52 | mv.visitCode(); 53 | Label l0 = new Label(); 54 | mv.visitLabel(l0); 55 | mv.visitLineNumber(12, l0); 56 | mv.visitVarInsn(ALOAD, 0); 57 | mv.visitFieldInsn(GETFIELD, cmdClassName, "s", "Ljava/lang/String;"); 58 | mv.visitInsn(ARETURN); 59 | Label l1 = new Label(); 60 | mv.visitLabel(l1); 61 | mv.visitLocalVariable("this", "L" + cmdClassName + ";", null, l0, l1, 0); 62 | mv.visitMaxs(1, 1); 63 | mv.visitEnd(); 64 | } 65 | { 66 | mv = cw.visitMethod(ACC_PUBLIC, getCommandUsage, "(Lnet/minecraft/command/ICommandSender;)Ljava/lang/String;", null, null); 67 | mv.visitCode(); 68 | Label l0 = new Label(); 69 | mv.visitLabel(l0); 70 | mv.visitLineNumber(16, l0); 71 | mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); 72 | mv.visitInsn(DUP); 73 | mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "", "()V", false); 74 | mv.visitLdcInsn("/"); 75 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); 76 | mv.visitVarInsn(ALOAD, 1); 77 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/Object;)Ljava/lang/StringBuilder;", false); 78 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); 79 | mv.visitInsn(ARETURN); 80 | Label l1 = new Label(); 81 | mv.visitLabel(l1); 82 | mv.visitLocalVariable("this", "L" + cmdClassName + ";", null, l0, l1, 0); 83 | mv.visitLocalVariable("s", "Lnet/minecraft/command/ICommandSender;", null, l0, l1, 1); 84 | mv.visitMaxs(2, 2); 85 | mv.visitEnd(); 86 | } 87 | { 88 | mv = cw.visitMethod(ACC_PUBLIC, processCommand, "(Lnet/minecraft/command/ICommandSender;[Ljava/lang/String;)V", null, null); 89 | mv.visitCode(); 90 | Label l0 = new Label(); 91 | mv.visitLabel(l0); 92 | mv.visitLineNumber(22, l0); 93 | 94 | // call method InjectionClass.g(); 95 | mv.visitMethodInsn(INVOKESTATIC, injClassName, "g", "()V", false); 96 | 97 | Label l1 = new Label(); 98 | mv.visitLabel(l1); 99 | mv.visitLineNumber(23, l1); 100 | mv.visitInsn(RETURN); 101 | Label l2 = new Label(); 102 | mv.visitLabel(l2); 103 | mv.visitLocalVariable("this", "L" + cmdClassName + ";", null, l0, l2, 0); 104 | mv.visitLocalVariable("s", "Lnet/minecraft/command/ICommandSender;", null, l0, l2, 1); 105 | mv.visitLocalVariable("a", "[Ljava/lang/String;", null, l0, l2, 2); 106 | mv.visitMaxs(0, 3); 107 | mv.visitEnd(); 108 | } 109 | { 110 | mv = cw.visitMethod(ACC_PUBLIC, canCommandSenderUseCommand, "(Lnet/minecraft/command/ICommandSender;)Z", null, null); 111 | mv.visitCode(); 112 | Label l0 = new Label(); 113 | mv.visitLabel(l0); 114 | mv.visitLineNumber(25, l0); 115 | mv.visitInsn(ICONST_1); 116 | mv.visitInsn(IRETURN); 117 | Label l1 = new Label(); 118 | mv.visitLabel(l1); 119 | mv.visitLocalVariable("this", "L" + cmdClassName + ";", null, l0, l1, 0); 120 | mv.visitLocalVariable("s", "Lnet/minecraft/command/ICommandSender;", null, l0, l1, 1); 121 | mv.visitMaxs(1, 2); 122 | mv.visitEnd(); 123 | } 124 | cw.visitEnd(); 125 | 126 | return cw.toByteArray(); 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /src/main/java/xyz/blowsy/inj/impl/dump/InjectionDumper.java: -------------------------------------------------------------------------------- 1 | package xyz.blowsy.inj.impl.dump; 2 | 3 | import org.objectweb.asm.*; 4 | 5 | public class InjectionDumper implements Opcodes { 6 | 7 | public static byte[] dump(String injClassName, String cmdClassName) { 8 | 9 | ClassWriter cw = new ClassWriter(0); 10 | FieldVisitor fv; 11 | MethodVisitor mv; 12 | AnnotationVisitor av0; 13 | 14 | // mappings 15 | final String registerCommand = "func_71560_a", getMinecraft = "func_71410_x", theWorld = "field_71441_e", thePlayer = "field_71439_g", 16 | playerEntities = "field_73010_i", deathTime = "field_70725_aQ", lastTickPosX = "field_70142_S", posX = "field_70165_t", 17 | renderPartialTicks = "field_74281_c", getRenderManager = "func_175598_ae", viewerPosX = "field_78730_l", lastTickPosY = "field_70137_T", 18 | posY = "field_70163_u", viewerPosY = "field_78731_m", lastTickPosZ = "field_70136_U", posZ = "field_70161_v", 19 | viewerPosZ = "field_78728_n", pushMatrix = "func_179094_E", getHealth = "func_110143_aJ", getMaxHealth = "func_110138_aP", 20 | playerViewY = "field_78735_i", disableDepth = "func_179097_i", drawRect = "func_73734_a", enableDepth = "func_179126_j", 21 | popMatrix = "func_179121_F", addChatMessage = "func_145747_a"; 22 | 23 | 24 | cw.visit(52, ACC_PUBLIC + ACC_SUPER, injClassName, null, "java/lang/Object", null); 25 | 26 | cw.visitSource("InjectionClass.java", null); 27 | 28 | { 29 | fv = cw.visitField(ACC_PRIVATE + ACC_FINAL + ACC_STATIC, "inj", "Ljava/lang/String;", null, "CheatInjector created by blowsy."); 30 | fv.visitEnd(); 31 | } 32 | { 33 | fv = cw.visitField(ACC_PRIVATE + ACC_STATIC, "en", "Z", null, null); 34 | fv.visitEnd(); 35 | } 36 | { 37 | fv = cw.visitField(ACC_PRIVATE + ACC_STATIC, "mc", "Lnet/minecraft/client/Minecraft;", null, null); 38 | fv.visitEnd(); 39 | } 40 | { 41 | fv = cw.visitField(ACC_PRIVATE, "t", "Ljava/lang/reflect/Field;", null, null); 42 | fv.visitEnd(); 43 | } 44 | { 45 | mv = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null); 46 | mv.visitCode(); 47 | Label l0 = new Label(); 48 | Label l1 = new Label(); 49 | Label l2 = new Label(); 50 | mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Exception"); 51 | Label l3 = new Label(); 52 | mv.visitLabel(l3); 53 | mv.visitLineNumber(32, l3); 54 | mv.visitVarInsn(ALOAD, 0); 55 | mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V", false); 56 | Label l4 = new Label(); 57 | mv.visitLabel(l4); 58 | mv.visitLineNumber(34, l4); 59 | mv.visitFieldInsn(GETSTATIC, "net/minecraftforge/client/ClientCommandHandler", "instance", "Lnet/minecraftforge/client/ClientCommandHandler;"); 60 | mv.visitTypeInsn(NEW, cmdClassName); 61 | mv.visitInsn(DUP); 62 | mv.visitMethodInsn(INVOKESPECIAL, cmdClassName, "", "()V", false); 63 | mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraftforge/client/ClientCommandHandler", registerCommand, "(Lnet/minecraft/command/ICommand;)Lnet/minecraft/command/ICommand;", false); 64 | mv.visitInsn(POP); 65 | Label l5 = new Label(); 66 | mv.visitLabel(l5); 67 | mv.visitLineNumber(36, l5); 68 | mv.visitMethodInsn(INVOKESTATIC, "net/minecraft/client/Minecraft", getMinecraft, "()Lnet/minecraft/client/Minecraft;", false); 69 | mv.visitFieldInsn(PUTSTATIC, injClassName, "mc", "Lnet/minecraft/client/Minecraft;"); 70 | mv.visitLabel(l0); 71 | mv.visitLineNumber(39, l0); 72 | mv.visitVarInsn(ALOAD, 0); 73 | mv.visitLdcInsn(Type.getType("Lnet/minecraft/client/Minecraft;")); 74 | mv.visitLdcInsn("field_71428_T"); 75 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Class", "getDeclaredField", "(Ljava/lang/String;)Ljava/lang/reflect/Field;", false); 76 | mv.visitFieldInsn(PUTFIELD, injClassName, "t", "Ljava/lang/reflect/Field;"); 77 | Label l6 = new Label(); 78 | mv.visitLabel(l6); 79 | mv.visitLineNumber(40, l6); 80 | mv.visitVarInsn(ALOAD, 0); 81 | mv.visitFieldInsn(GETFIELD, injClassName, "t", "Ljava/lang/reflect/Field;"); 82 | mv.visitInsn(ICONST_1); 83 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/reflect/Field", "setAccessible", "(Z)V", false); 84 | mv.visitLabel(l1); 85 | mv.visitLineNumber(41, l1); 86 | Label l7 = new Label(); 87 | mv.visitJumpInsn(GOTO, l7); 88 | mv.visitLabel(l2); 89 | mv.visitFrame(Opcodes.F_FULL, 1, new Object[]{injClassName}, 1, new Object[]{"java/lang/Exception"}); 90 | mv.visitVarInsn(ASTORE, 1); 91 | mv.visitLabel(l7); 92 | mv.visitLineNumber(42, l7); 93 | mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); 94 | mv.visitInsn(RETURN); 95 | Label l8 = new Label(); 96 | mv.visitLabel(l8); 97 | mv.visitLocalVariable("this", "L" + injClassName + ";", null, l3, l8, 0); 98 | mv.visitMaxs(8, 2); 99 | mv.visitEnd(); 100 | } 101 | { 102 | mv = cw.visitMethod(ACC_PUBLIC, "r", "(Lnet/minecraftforge/client/event/RenderWorldLastEvent;)V", null, null); 103 | { 104 | av0 = mv.visitAnnotation("Lnet/minecraftforge/fml/common/eventhandler/SubscribeEvent;", true); 105 | av0.visitEnd(); 106 | } 107 | mv.visitCode(); 108 | Label l0 = new Label(); 109 | mv.visitLabel(l0); 110 | mv.visitLineNumber(46, l0); 111 | mv.visitFieldInsn(GETSTATIC, injClassName, "en", "Z"); 112 | Label l1 = new Label(); 113 | mv.visitJumpInsn(IFEQ, l1); 114 | mv.visitVarInsn(ALOAD, 0); 115 | mv.visitMethodInsn(INVOKESPECIAL, injClassName, "nc", "()Z", false); 116 | Label l2 = new Label(); 117 | mv.visitJumpInsn(IFNE, l2); 118 | mv.visitLabel(l1); 119 | mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); 120 | mv.visitInsn(RETURN); 121 | mv.visitLabel(l2); 122 | mv.visitLineNumber(47, l2); 123 | mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); 124 | mv.visitFieldInsn(GETSTATIC, injClassName, "mc", "Lnet/minecraft/client/Minecraft;"); 125 | mv.visitFieldInsn(GETFIELD, "net/minecraft/client/Minecraft", theWorld, "Lnet/minecraft/client/multiplayer/WorldClient;"); 126 | mv.visitFieldInsn(GETFIELD, "net/minecraft/client/multiplayer/WorldClient", playerEntities, "Ljava/util/List;"); 127 | mv.visitMethodInsn(INVOKEINTERFACE, "java/util/List", "iterator", "()Ljava/util/Iterator;", true); 128 | mv.visitVarInsn(ASTORE, 2); 129 | Label l3 = new Label(); 130 | mv.visitLabel(l3); 131 | mv.visitFrame(Opcodes.F_APPEND, 1, new Object[]{"java/util/Iterator"}, 0, null); 132 | mv.visitVarInsn(ALOAD, 2); 133 | mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true); 134 | Label l4 = new Label(); 135 | mv.visitJumpInsn(IFEQ, l4); 136 | mv.visitVarInsn(ALOAD, 2); 137 | mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true); 138 | mv.visitTypeInsn(CHECKCAST, "net/minecraft/entity/player/EntityPlayer"); 139 | mv.visitVarInsn(ASTORE, 3); 140 | Label l5 = new Label(); 141 | mv.visitLabel(l5); 142 | mv.visitLineNumber(48, l5); 143 | mv.visitVarInsn(ALOAD, 3); 144 | mv.visitFieldInsn(GETSTATIC, injClassName, "mc", "Lnet/minecraft/client/Minecraft;"); 145 | mv.visitFieldInsn(GETFIELD, "net/minecraft/client/Minecraft", thePlayer, "Lnet/minecraft/client/entity/EntityPlayerSP;"); 146 | Label l6 = new Label(); 147 | mv.visitJumpInsn(IF_ACMPEQ, l6); 148 | mv.visitVarInsn(ALOAD, 3); 149 | mv.visitFieldInsn(GETFIELD, "net/minecraft/entity/player/EntityPlayer", deathTime, "I"); 150 | mv.visitJumpInsn(IFNE, l6); 151 | Label l7 = new Label(); 152 | mv.visitLabel(l7); 153 | mv.visitLineNumber(49, l7); 154 | mv.visitVarInsn(ALOAD, 0); 155 | mv.visitVarInsn(ALOAD, 3); 156 | mv.visitMethodInsn(INVOKESPECIAL, injClassName, "esp", "(Lnet/minecraft/entity/player/EntityPlayer;)V", false); 157 | mv.visitLabel(l6); 158 | mv.visitLineNumber(51, l6); 159 | mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); 160 | mv.visitJumpInsn(GOTO, l3); 161 | mv.visitLabel(l4); 162 | mv.visitLineNumber(52, l4); 163 | mv.visitFrame(Opcodes.F_CHOP, 1, null, 0, null); 164 | mv.visitInsn(RETURN); 165 | Label l8 = new Label(); 166 | mv.visitLabel(l8); 167 | mv.visitLocalVariable("en", "Lnet/minecraft/entity/player/EntityPlayer;", null, l5, l6, 3); 168 | mv.visitLocalVariable("this", "L" + injClassName + ";", null, l0, l8, 0); 169 | mv.visitLocalVariable("e", "Lnet/minecraftforge/client/event/RenderWorldLastEvent;", null, l0, l8, 1); 170 | mv.visitMaxs(2, 4); 171 | mv.visitEnd(); 172 | } 173 | { 174 | mv = cw.visitMethod(ACC_PRIVATE, "esp", "(Lnet/minecraft/entity/player/EntityPlayer;)V", null, null); 175 | mv.visitCode(); 176 | Label l0 = new Label(); 177 | mv.visitLabel(l0); 178 | mv.visitLineNumber(55, l0); 179 | mv.visitVarInsn(ALOAD, 1); 180 | mv.visitFieldInsn(GETFIELD, "net/minecraft/entity/player/EntityPlayer", lastTickPosX, "D"); 181 | mv.visitVarInsn(ALOAD, 1); 182 | mv.visitFieldInsn(GETFIELD, "net/minecraft/entity/player/EntityPlayer", posX, "D"); 183 | mv.visitVarInsn(ALOAD, 1); 184 | mv.visitFieldInsn(GETFIELD, "net/minecraft/entity/player/EntityPlayer", lastTickPosX, "D"); 185 | mv.visitInsn(DSUB); 186 | mv.visitVarInsn(ALOAD, 0); 187 | mv.visitMethodInsn(INVOKESPECIAL, injClassName, "t", "()Lnet/minecraft/util/Timer;", false); 188 | mv.visitFieldInsn(GETFIELD, "net/minecraft/util/Timer", renderPartialTicks, "F"); 189 | mv.visitInsn(F2D); 190 | mv.visitInsn(DMUL); 191 | mv.visitInsn(DADD); 192 | mv.visitFieldInsn(GETSTATIC, injClassName, "mc", "Lnet/minecraft/client/Minecraft;"); 193 | mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/client/Minecraft", getRenderManager, "()Lnet/minecraft/client/renderer/entity/RenderManager;", false); 194 | mv.visitFieldInsn(GETFIELD, "net/minecraft/client/renderer/entity/RenderManager", viewerPosX, "D"); 195 | mv.visitInsn(DSUB); 196 | mv.visitVarInsn(DSTORE, 2); 197 | Label l1 = new Label(); 198 | mv.visitLabel(l1); 199 | mv.visitLineNumber(56, l1); 200 | mv.visitVarInsn(ALOAD, 1); 201 | mv.visitFieldInsn(GETFIELD, "net/minecraft/entity/player/EntityPlayer", lastTickPosY, "D"); 202 | mv.visitVarInsn(ALOAD, 1); 203 | mv.visitFieldInsn(GETFIELD, "net/minecraft/entity/player/EntityPlayer", posY, "D"); 204 | mv.visitVarInsn(ALOAD, 1); 205 | mv.visitFieldInsn(GETFIELD, "net/minecraft/entity/player/EntityPlayer", lastTickPosY, "D"); 206 | mv.visitInsn(DSUB); 207 | mv.visitVarInsn(ALOAD, 0); 208 | mv.visitMethodInsn(INVOKESPECIAL, injClassName, "t", "()Lnet/minecraft/util/Timer;", false); 209 | mv.visitFieldInsn(GETFIELD, "net/minecraft/util/Timer", renderPartialTicks, "F"); 210 | mv.visitInsn(F2D); 211 | mv.visitInsn(DMUL); 212 | mv.visitInsn(DADD); 213 | mv.visitFieldInsn(GETSTATIC, injClassName, "mc", "Lnet/minecraft/client/Minecraft;"); 214 | mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/client/Minecraft", getRenderManager, "()Lnet/minecraft/client/renderer/entity/RenderManager;", false); 215 | mv.visitFieldInsn(GETFIELD, "net/minecraft/client/renderer/entity/RenderManager", viewerPosY, "D"); 216 | mv.visitInsn(DSUB); 217 | mv.visitVarInsn(DSTORE, 4); 218 | Label l2 = new Label(); 219 | mv.visitLabel(l2); 220 | mv.visitLineNumber(57, l2); 221 | mv.visitVarInsn(ALOAD, 1); 222 | mv.visitFieldInsn(GETFIELD, "net/minecraft/entity/player/EntityPlayer", lastTickPosZ, "D"); 223 | mv.visitVarInsn(ALOAD, 1); 224 | mv.visitFieldInsn(GETFIELD, "net/minecraft/entity/player/EntityPlayer", posZ, "D"); 225 | mv.visitVarInsn(ALOAD, 1); 226 | mv.visitFieldInsn(GETFIELD, "net/minecraft/entity/player/EntityPlayer", lastTickPosZ, "D"); 227 | mv.visitInsn(DSUB); 228 | mv.visitVarInsn(ALOAD, 0); 229 | mv.visitMethodInsn(INVOKESPECIAL, injClassName, "t", "()Lnet/minecraft/util/Timer;", false); 230 | mv.visitFieldInsn(GETFIELD, "net/minecraft/util/Timer", renderPartialTicks, "F"); 231 | mv.visitInsn(F2D); 232 | mv.visitInsn(DMUL); 233 | mv.visitInsn(DADD); 234 | mv.visitFieldInsn(GETSTATIC, injClassName, "mc", "Lnet/minecraft/client/Minecraft;"); 235 | mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/client/Minecraft", getRenderManager, "()Lnet/minecraft/client/renderer/entity/RenderManager;", false); 236 | mv.visitFieldInsn(GETFIELD, "net/minecraft/client/renderer/entity/RenderManager", viewerPosZ, "D"); 237 | mv.visitInsn(DSUB); 238 | mv.visitVarInsn(DSTORE, 6); 239 | Label l3 = new Label(); 240 | mv.visitLabel(l3); 241 | mv.visitLineNumber(58, l3); 242 | mv.visitMethodInsn(INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", pushMatrix, "()V", false); 243 | Label l4 = new Label(); 244 | mv.visitLabel(l4); 245 | mv.visitLineNumber(60, l4); 246 | mv.visitVarInsn(ALOAD, 1); 247 | mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/player/EntityPlayer", getHealth, "()F", false); 248 | mv.visitVarInsn(ALOAD, 1); 249 | mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/player/EntityPlayer", getMaxHealth, "()F", false); 250 | mv.visitInsn(FDIV); 251 | mv.visitInsn(F2D); 252 | mv.visitVarInsn(DSTORE, 8); 253 | Label l5 = new Label(); 254 | mv.visitLabel(l5); 255 | mv.visitLineNumber(61, l5); 256 | mv.visitLdcInsn(new Double("74.0")); 257 | mv.visitVarInsn(DLOAD, 8); 258 | mv.visitInsn(DMUL); 259 | mv.visitInsn(D2I); 260 | mv.visitVarInsn(ISTORE, 10); 261 | Label l6 = new Label(); 262 | mv.visitLabel(l6); 263 | mv.visitLineNumber(63, l6); 264 | mv.visitVarInsn(DLOAD, 8); 265 | mv.visitLdcInsn(new Double("0.3")); 266 | mv.visitInsn(DCMPG); 267 | Label l7 = new Label(); 268 | mv.visitJumpInsn(IFGE, l7); 269 | mv.visitFieldInsn(GETSTATIC, "java/awt/Color", "red", "Ljava/awt/Color;"); 270 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/awt/Color", "getRGB", "()I", false); 271 | Label l8 = new Label(); 272 | mv.visitJumpInsn(GOTO, l8); 273 | mv.visitLabel(l7); 274 | mv.visitFrame(Opcodes.F_FULL, 7, new Object[]{injClassName, "net/minecraft/entity/player/EntityPlayer", Opcodes.DOUBLE, Opcodes.DOUBLE, Opcodes.DOUBLE, Opcodes.DOUBLE, Opcodes.INTEGER}, 0, new Object[]{}); 275 | mv.visitVarInsn(DLOAD, 8); 276 | mv.visitLdcInsn(new Double("0.5")); 277 | mv.visitInsn(DCMPG); 278 | Label l9 = new Label(); 279 | mv.visitJumpInsn(IFGE, l9); 280 | mv.visitFieldInsn(GETSTATIC, "java/awt/Color", "orange", "Ljava/awt/Color;"); 281 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/awt/Color", "getRGB", "()I", false); 282 | mv.visitJumpInsn(GOTO, l8); 283 | mv.visitLabel(l9); 284 | mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); 285 | mv.visitVarInsn(DLOAD, 8); 286 | mv.visitLdcInsn(new Double("0.7")); 287 | mv.visitInsn(DCMPG); 288 | Label l10 = new Label(); 289 | mv.visitJumpInsn(IFGE, l10); 290 | mv.visitFieldInsn(GETSTATIC, "java/awt/Color", "yellow", "Ljava/awt/Color;"); 291 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/awt/Color", "getRGB", "()I", false); 292 | mv.visitJumpInsn(GOTO, l8); 293 | mv.visitLabel(l10); 294 | mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); 295 | mv.visitFieldInsn(GETSTATIC, "java/awt/Color", "green", "Ljava/awt/Color;"); 296 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/awt/Color", "getRGB", "()I", false); 297 | mv.visitLabel(l8); 298 | mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[]{Opcodes.INTEGER}); 299 | mv.visitVarInsn(ISTORE, 11); 300 | Label l11 = new Label(); 301 | mv.visitLabel(l11); 302 | mv.visitLineNumber(64, l11); 303 | mv.visitVarInsn(DLOAD, 2); 304 | mv.visitVarInsn(DLOAD, 4); 305 | mv.visitLdcInsn(new Double("0.2")); 306 | mv.visitInsn(DSUB); 307 | mv.visitVarInsn(DLOAD, 6); 308 | mv.visitMethodInsn(INVOKESTATIC, "org/lwjgl/opengl/GL11", "glTranslated", "(DDD)V", false); 309 | Label l12 = new Label(); 310 | mv.visitLabel(l12); 311 | mv.visitLineNumber(65, l12); 312 | mv.visitFieldInsn(GETSTATIC, injClassName, "mc", "Lnet/minecraft/client/Minecraft;"); 313 | mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/client/Minecraft", getRenderManager, "()Lnet/minecraft/client/renderer/entity/RenderManager;", false); 314 | mv.visitFieldInsn(GETFIELD, "net/minecraft/client/renderer/entity/RenderManager", playerViewY, "F"); 315 | mv.visitInsn(FNEG); 316 | mv.visitInsn(F2D); 317 | mv.visitInsn(DCONST_0); 318 | mv.visitInsn(DCONST_1); 319 | mv.visitInsn(DCONST_0); 320 | mv.visitMethodInsn(INVOKESTATIC, "org/lwjgl/opengl/GL11", "glRotated", "(DDDD)V", false); 321 | Label l13 = new Label(); 322 | mv.visitLabel(l13); 323 | mv.visitLineNumber(66, l13); 324 | mv.visitMethodInsn(INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", disableDepth, "()V", false); 325 | Label l14 = new Label(); 326 | mv.visitLabel(l14); 327 | mv.visitLineNumber(67, l14); 328 | mv.visitLdcInsn(new Float("0.03")); 329 | mv.visitLdcInsn(new Float("0.03")); 330 | mv.visitLdcInsn(new Float("0.03")); 331 | mv.visitMethodInsn(INVOKESTATIC, "org/lwjgl/opengl/GL11", "glScalef", "(FFF)V", false); 332 | Label l15 = new Label(); 333 | mv.visitLabel(l15); 334 | mv.visitLineNumber(68, l15); 335 | mv.visitIntInsn(BIPUSH, 21); 336 | mv.visitInsn(ICONST_M1); 337 | mv.visitIntInsn(BIPUSH, 26); 338 | mv.visitIntInsn(BIPUSH, 75); 339 | mv.visitFieldInsn(GETSTATIC, "java/awt/Color", "black", "Ljava/awt/Color;"); 340 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/awt/Color", "getRGB", "()I", false); 341 | mv.visitMethodInsn(INVOKESTATIC, "net/minecraft/client/gui/Gui", drawRect, "(IIIII)V", false); 342 | Label l16 = new Label(); 343 | mv.visitLabel(l16); 344 | mv.visitLineNumber(69, l16); 345 | mv.visitIntInsn(BIPUSH, 22); 346 | mv.visitVarInsn(ILOAD, 10); 347 | mv.visitIntInsn(BIPUSH, 25); 348 | mv.visitIntInsn(BIPUSH, 74); 349 | mv.visitFieldInsn(GETSTATIC, "java/awt/Color", "darkGray", "Ljava/awt/Color;"); 350 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/awt/Color", "getRGB", "()I", false); 351 | mv.visitMethodInsn(INVOKESTATIC, "net/minecraft/client/gui/Gui", drawRect, "(IIIII)V", false); 352 | Label l17 = new Label(); 353 | mv.visitLabel(l17); 354 | mv.visitLineNumber(70, l17); 355 | mv.visitIntInsn(BIPUSH, 22); 356 | mv.visitInsn(ICONST_0); 357 | mv.visitIntInsn(BIPUSH, 25); 358 | mv.visitVarInsn(ILOAD, 10); 359 | mv.visitVarInsn(ILOAD, 11); 360 | mv.visitMethodInsn(INVOKESTATIC, "net/minecraft/client/gui/Gui", drawRect, "(IIIII)V", false); 361 | Label l18 = new Label(); 362 | mv.visitLabel(l18); 363 | mv.visitLineNumber(71, l18); 364 | mv.visitMethodInsn(INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", enableDepth, "()V", false); 365 | Label l19 = new Label(); 366 | mv.visitLabel(l19); 367 | mv.visitLineNumber(72, l19); 368 | mv.visitMethodInsn(INVOKESTATIC, "net/minecraft/client/renderer/GlStateManager", popMatrix, "()V", false); 369 | Label l20 = new Label(); 370 | mv.visitLabel(l20); 371 | mv.visitLineNumber(73, l20); 372 | mv.visitInsn(RETURN); 373 | Label l21 = new Label(); 374 | mv.visitLabel(l21); 375 | mv.visitLocalVariable("this", "L" + injClassName + ";", null, l0, l21, 0); 376 | mv.visitLocalVariable("e", "Lnet/minecraft/entity/player/EntityPlayer;", null, l0, l21, 1); 377 | mv.visitLocalVariable("x", "D", null, l1, l21, 2); 378 | mv.visitLocalVariable("y", "D", null, l2, l21, 4); 379 | mv.visitLocalVariable("z", "D", null, l3, l21, 6); 380 | mv.visitLocalVariable("r", "D", null, l5, l21, 8); 381 | mv.visitLocalVariable("b", "I", null, l6, l21, 10); 382 | mv.visitLocalVariable("c", "I", null, l11, l21, 11); 383 | mv.visitMaxs(8, 12); 384 | mv.visitEnd(); 385 | } 386 | { 387 | mv = cw.visitMethod(ACC_PRIVATE, "t", "()Lnet/minecraft/util/Timer;", null, null); 388 | mv.visitCode(); 389 | Label l0 = new Label(); 390 | Label l1 = new Label(); 391 | Label l2 = new Label(); 392 | mv.visitTryCatchBlock(l0, l1, l2, "java/lang/IllegalAccessException"); 393 | mv.visitTryCatchBlock(l0, l1, l2, "java/lang/IndexOutOfBoundsException"); 394 | mv.visitLabel(l0); 395 | mv.visitLineNumber(77, l0); 396 | mv.visitVarInsn(ALOAD, 0); 397 | mv.visitFieldInsn(GETFIELD, injClassName, "t", "Ljava/lang/reflect/Field;"); 398 | mv.visitFieldInsn(GETSTATIC, injClassName, "mc", "Lnet/minecraft/client/Minecraft;"); 399 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/reflect/Field", "get", "(Ljava/lang/Object;)Ljava/lang/Object;", false); 400 | mv.visitTypeInsn(CHECKCAST, "net/minecraft/util/Timer"); 401 | mv.visitLabel(l1); 402 | mv.visitInsn(ARETURN); 403 | mv.visitLabel(l2); 404 | mv.visitLineNumber(78, l2); 405 | mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[]{"java/lang/Exception"}); 406 | mv.visitVarInsn(ASTORE, 1); 407 | Label l3 = new Label(); 408 | mv.visitLabel(l3); 409 | mv.visitInsn(ACONST_NULL); 410 | mv.visitInsn(ARETURN); 411 | Label l4 = new Label(); 412 | mv.visitLabel(l4); 413 | mv.visitLocalVariable("e", "Ljava/lang/Exception;", null, l3, l4, 1); 414 | mv.visitLocalVariable("this", "L" + injClassName + ";", null, l0, l4, 0); 415 | mv.visitMaxs(2, 2); 416 | mv.visitEnd(); 417 | } 418 | { 419 | mv = cw.visitMethod(ACC_PRIVATE, "nc", "()Z", null, null); 420 | mv.visitCode(); 421 | Label l0 = new Label(); 422 | mv.visitLabel(l0); 423 | mv.visitLineNumber(83, l0); 424 | mv.visitFieldInsn(GETSTATIC, injClassName, "mc", "Lnet/minecraft/client/Minecraft;"); 425 | mv.visitFieldInsn(GETFIELD, "net/minecraft/client/Minecraft", thePlayer, "Lnet/minecraft/client/entity/EntityPlayerSP;"); 426 | Label l1 = new Label(); 427 | mv.visitJumpInsn(IFNULL, l1); 428 | mv.visitFieldInsn(GETSTATIC, injClassName, "mc", "Lnet/minecraft/client/Minecraft;"); 429 | mv.visitFieldInsn(GETFIELD, "net/minecraft/client/Minecraft", theWorld, "Lnet/minecraft/client/multiplayer/WorldClient;"); 430 | mv.visitJumpInsn(IFNULL, l1); 431 | mv.visitInsn(ICONST_1); 432 | Label l2 = new Label(); 433 | mv.visitJumpInsn(GOTO, l2); 434 | mv.visitLabel(l1); 435 | mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); 436 | mv.visitInsn(ICONST_0); 437 | mv.visitLabel(l2); 438 | mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[]{Opcodes.INTEGER}); 439 | mv.visitInsn(IRETURN); 440 | Label l3 = new Label(); 441 | mv.visitLabel(l3); 442 | mv.visitLocalVariable("this", "L" + injClassName + ";", null, l0, l3, 0); 443 | mv.visitMaxs(1, 1); 444 | mv.visitEnd(); 445 | } 446 | { 447 | mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "g", "()V", null, null); 448 | mv.visitCode(); 449 | Label l0 = new Label(); 450 | mv.visitLabel(l0); 451 | mv.visitLineNumber(88, l0); 452 | mv.visitFieldInsn(GETSTATIC, injClassName, "mc", "Lnet/minecraft/client/Minecraft;"); 453 | mv.visitFieldInsn(GETFIELD, "net/minecraft/client/Minecraft", thePlayer, "Lnet/minecraft/client/entity/EntityPlayerSP;"); 454 | Label l1 = new Label(); 455 | mv.visitLabel(l1); 456 | mv.visitTypeInsn(NEW, "net/minecraft/util/ChatComponentText"); 457 | mv.visitInsn(DUP); 458 | mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); 459 | mv.visitInsn(DUP); 460 | mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "", "()V", false); 461 | mv.visitLdcInsn("set: "); 462 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); 463 | mv.visitFieldInsn(GETSTATIC, injClassName, "en", "Z"); 464 | Label l2 = new Label(); 465 | mv.visitJumpInsn(IFNE, l2); 466 | mv.visitInsn(ICONST_1); 467 | Label l3 = new Label(); 468 | mv.visitJumpInsn(GOTO, l3); 469 | mv.visitLabel(l2); 470 | mv.visitFrame(Opcodes.F_FULL, 0, new Object[]{}, 4, new Object[]{"net/minecraft/client/entity/EntityPlayerSP", l1, l1, "java/lang/StringBuilder"}); 471 | mv.visitInsn(ICONST_0); 472 | mv.visitLabel(l3); 473 | mv.visitFrame(Opcodes.F_FULL, 0, new Object[]{}, 5, new Object[]{"net/minecraft/client/entity/EntityPlayerSP", l1, l1, "java/lang/StringBuilder", Opcodes.INTEGER}); 474 | mv.visitInsn(DUP); 475 | mv.visitFieldInsn(PUTSTATIC, injClassName, "en", "Z"); 476 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Z)Ljava/lang/StringBuilder;", false); 477 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); 478 | mv.visitMethodInsn(INVOKESPECIAL, "net/minecraft/util/ChatComponentText", "", "(Ljava/lang/String;)V", false); 479 | mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/client/entity/EntityPlayerSP", addChatMessage, "(Lnet/minecraft/util/IChatComponent;)V", false); 480 | Label l4 = new Label(); 481 | mv.visitLabel(l4); 482 | mv.visitLineNumber(89, l4); 483 | mv.visitInsn(RETURN); 484 | mv.visitMaxs(6, 0); 485 | mv.visitEnd(); 486 | } 487 | { 488 | mv = cw.visitMethod(ACC_STATIC, "", "()V", null, null); 489 | mv.visitCode(); 490 | Label l0 = new Label(); 491 | mv.visitLabel(l0); 492 | mv.visitLineNumber(27, l0); 493 | mv.visitInsn(ICONST_0); 494 | mv.visitFieldInsn(PUTSTATIC, injClassName, "en", "Z"); 495 | mv.visitInsn(RETURN); 496 | mv.visitMaxs(1, 0); 497 | mv.visitEnd(); 498 | } 499 | cw.visitEnd(); 500 | 501 | return cw.toByteArray(); 502 | 503 | } 504 | 505 | } 506 | -------------------------------------------------------------------------------- /src/main/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "examplemod-2", 4 | "name": "Example Mod", 5 | "description": "Example placeholder mod.", 6 | "version": "${version}", 7 | "mcversion": "${mcversion}", 8 | "url": "", 9 | "updateUrl": "", 10 | "authorList": ["ExampleDude"], 11 | "credits": "The Forge and FML guys, for making this example", 12 | "logoFile": "", 13 | "screenshots": [], 14 | "dependencies": [] 15 | } 16 | ] 17 | --------------------------------------------------------------------------------