Hwyla

Hwyla

86M Downloads

Plugin settings button crashes game

MODKILLER1001 opened this issue ยท 4 comments

commented

Issue Description:

Note: If this bug occurs in a modpack, please report this to the modpack author. Otherwise, delete this line and add your description here. If this is a feature request, this template does not apply to you. Just delete everything.
When going to change setting in plugin menu my game crashes.

What happens:

My game crashes.

What you expected to happen:

to open the plugin menu.

Steps to reproduce:

  1. go to mods
  2. hwyla
  3. go to the 3 lines for settings
  4. click plugin settings
    ...

Affected Versions (Do not use "latest"):

  • Hwyla: 1.16.2-1.9.23-79.jar
  • Minecraft: 1.16.4
  • Forge: FABRIC

Possible Conflicting Mods (Provide their version, as well)

https://hastebin.com/itobogevas.yaml Logs

commented

I can back this bug up with a Crash Report. On Fabric 0.11.1 Minecraft 1.16.4 there is a crash whenever interacting with the Config in-game
crash-2021-01-16_18.48.43-client.txt

commented

any way fix this?

commented

same here it crash my game when usiing fabric

commented

I believe this is the crash I've just encountered, so I've look at the compiled code and followed the stacktrace backwards.

Exception: a NullPointerException (AbstractButtonWidget.message.getString() throws an NPE)

Cause: In GuiConfigWaila, the buttons are created with a Text parameter being null. During the AbstractButtonWidget.<init>, the parameter is saved to message. Now when HWYLA creates the OptionsEntryButton, it calls setMessage with a non-null Text object. At this point, the setMessage compares the Text.getString() method for each of them and checks their equality. This is where the crash happens.

Code snippets:

AbstractButtonWidget:

    public void setMessage(Text text) {
        if (!Objects.equals(text.getString(), this.message.getString())) {
           this.queueNarration(250);
        }

        this.message = text;
    }

GuiConfigWaila:

options.add(new OptionsEntryButton(Util.createTranslationKey("config", new Identifier(Waila.MODID, "general")), new ButtonWidget(0, 0, 100, 20, /* NPE-causing value */ null, w -> { /* ... */ })))
// and a couple more

OptionsEntryButton:

    public OptionsEntryButton(String title, ButtonWidget button) {
        this.title = I18n.translate(title);
        this.button = button;
        // This call is the method that throws an NPE, due to the above code.
        button.setMessage(new LiteralText(this.title));
    }

Solution: Set the default button texts in GuiConfigWaila from null to a non-null value (ex. new LiteralText("")). This will result in the AbstractButtonWidget.setMessage(Text) call to not NPE because neither read value will be null.