maruohon / malilib

Library mod for masa's client-side Minecraft mods
GNU Lesser General Public License v3.0
297 stars 136 forks source link

StackOverflowException when scrolling down in litematica config menu #149

Open EvilCodeZ opened 9 months ago

EvilCodeZ commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

Yes im using Mojang mappings in my dev environment.

EvilCodeZ commented 9 months ago

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

maruohon commented 9 months ago

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 commented 6 months ago

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 commented 6 months ago

@EvilCodeZ did you manage to fix this?

EvilCodeZ commented 5 months ago

@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 commented 5 months ago

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 .