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

StackOverflowException when scrolling down in litematica config menu #149

Open
EvilCodeZ opened this issue Mar 3, 2024 · 8 comments
Open

Comments

@EvilCodeZ
Copy link

Used malilib version: 0.18.1
Used litematica version: 0.17.0

When you open the config screen in litematica and scroll down to the end with your mouse wheel and when reaching the end the game crashes because of this exception:

java.lang.StackOverflowError: null
	at org.lwjgl.glfw.GLFW.glfwGetKey(GLFW.java:3746) ~[lwjgl-glfw-3.3.2.jar:?]
	at com.mojang.blaze3d.platform.InputConstants.isKeyDown(InputConstants.java:473) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at net.minecraft.client.gui.screens.Screen.hasShiftDown(Screen.java:377) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiBase.isShiftDown(GuiBase.java:675) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
	at fi.dy.masa.malilib.gui.GuiTextFieldGeneric.setCursorPosition(GuiTextFieldGeneric.java:93) ~[malilib-0.18.1-b5d892a0cad8e7f6.jar:?]
	at net.minecraft.client.gui.components.EditBox.moveCursorTo(EditBox.java:256) ~[minecraft-merged-6456f037b0-1.20.4-loom.mappings.1_20_4.layered+hash.2008316880-v2.jar:?]
...
...
@maruohon
Copy link
Owner

maruohon commented Mar 3, 2024

This obviously doesn't happen "in normal circumstances" or the mod would be unusable.

Did you build malilib yourself, maybe using Mojang mappings? There is a method name conflict in the text field class when using Mojmap. Or where is malilib-0.18.1-b5d892a0cad8e7f6.jar from?

@EvilCodeZ
Copy link
Author

Yes im using Mojang mappings in my dev environment.

@EvilCodeZ
Copy link
Author

I looked and the EditBox class from Minecraft also has a setCursorPosition() method

@maruohon
Copy link
Owner

maruohon commented Mar 3, 2024

Yes exactly. You would have to rename that method, and the places it's called from (which in my mods seems to only be from Litematica's GuiSchematicSaveBase#initGui()), if you need to use Mojmap, to avoid that recursive call.

@tolland
Copy link

tolland commented May 29, 2024

Any suggestions on what steps are required to fix this from the other project?

In my case I am adding malilib and litematica to my baritone build and seeing the same thing from this branch:
https://github.com/tolland/baritone/tree/1.20.4-bump1

If you drop the two libs into the fabric/run/client/mods directory, and try some menu items in litematica, it will throw that exception.

If I build baritone, and deploy that mod alongside litematica and malilib into a fresh minecraft, I don't see the problem. It only occurs in the dev env. (But this makes further dev work a PITA)

@tolland
Copy link

tolland commented May 29, 2024

@EvilCodeZ did you manage to fix this?

@EvilCodeZ
Copy link
Author

@EvilCodeZ did you manage to fix this?

Not really i tried this but then it started crashing on some other places but i don't remember it exactly because i quitted my project months ago.

import fi.dy.masa.malilib.gui.GuiTextFieldGeneric;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.network.chat.Component;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(GuiTextFieldGeneric.class)
public abstract class GuiTextFieldGenericMixin extends EditBox {

    private static final ThreadLocal<Integer> IN_SET_CURSOR_POSITION = ThreadLocal.withInitial(() -> 0);

    public GuiTextFieldGenericMixin(Font font, int width, int height, Component message) {
        super(font, width, height, message);
    }

    @Inject(method = "setCursorPosition", at = @At("HEAD"), cancellable = true)
    private void onSetCursorPosition(int pos, CallbackInfo ci) {
        if (IN_SET_CURSOR_POSITION.get() > 0) {
            ci.cancel();
            super.setCursorPosition(pos);
            return;
        }
        IN_SET_CURSOR_POSITION.set(IN_SET_CURSOR_POSITION.get() + 1);
    }

    @Inject(method = "setCursorPosition", at = @At("RETURN"))
    private void onSetCursorPositionReturn(int pos, CallbackInfo ci) {
        IN_SET_CURSOR_POSITION.set(IN_SET_CURSOR_POSITION.get() - 1);
    }
}

@sakura-ryoko
Copy link

sakura-ryoko commented Jun 14, 2024

The "setCursorPostion" -- the problem is the name of the function, because it causes problems against "Lunar" from using Mojmap, so the function was deleted from malilib .

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

4 participants