Open EvilCodeZ opened 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?
Yes im using Mojang mappings in my dev environment.
I looked and the EditBox class from Minecraft also has a setCursorPosition() method
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.
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)
@EvilCodeZ did you manage to fix this?
@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);
}
}
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 .
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: