Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crafting performance improvements #64

Open
richardhendricks opened this issue Dec 12, 2019 · 1 comment
Open

Crafting performance improvements #64

richardhendricks opened this issue Dec 12, 2019 · 1 comment

Comments

@richardhendricks
Copy link
Owner

richardhendricks commented Dec 12, 2019

Forestry Worktable (time limit and move recipe to start)
TiCon crafting stations (time limit and move recipe to start, if possible)
AE2
ASM patch for generic crafting table, and for 2x2 crafting grid

@richardhendricks
Copy link
Owner Author

public boolean injectMethod(String aMethodName, ClassWriter cw) {
    MethodVisitor mv;
    boolean didInject = false;
    FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO,
            "Injecting " + aMethodName + ".");
    if (aMethodName.equals("getKeyName")) {
        mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC + ACC_SYNCHRONIZED, "getKeyName", "(I)Ljava/lang/String;", null,
                null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(49, l0);
        mv.visitVarInsn(ILOAD, 0);
        mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/preloader/asm/transformers/ClassTransformer_LWJGL_Keyboard",
                "getKeyName", "(I)Ljava/lang/String;", false);
        mv.visitInsn(ARETURN);
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLocalVariable("key", "I", null, l0, l1, 0);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
        didInject = true;
    }
    FMLRelaunchLog.log("[GT++ ASM] LWJGL Keybinding index out of bounds fix", Level.INFO, "Method injection complete.");
    return didInject;
}

While that kinda looks a tad ugly, it's all generated code..
from mv = to mv.visitEnd()
Just replaces the entire method with a static call to return mine instead.
LWJGL ain't getting any fixes, lol.
mv.visitLabel(l0);
mv.visitLineNumber(49, l0);

Are only required for the JVM to print correct stack information.. so you can skip it if you're lazy and writing by hand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant