Hi, so I am new to modding and I have been making my first mod with some basic hacks like fly. However, while trying to add button widgets to the Save and exit/disconnect screen the Button Widget is highlighted red and gives me an error. There is not much information about why but I have spent 5 hours trying to fix this and I don't know what to do anymore. I think it once said something about the ButtonWidget class being protected but that didn't really help me. I was using a tutorial to learn to do this and I think I had the exact same code (With different names) I followed it word for word and checked everything. I'm using fabric 1.19.3.
package net.hypericats.hyperionclient.mixin;
import net.hypericats.hyperionclient.HyperionClientModuleScreen;
import net.minecraft.client.gui.screen.GameMenuScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.Text;
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(GameMenuScreen.class)
public abstract class GameMenuButtonsMixin extends Screen {
protected GameMenuButtonsMixin(Text text) { super(text); }
@Inject(at = @At("HEAD"), method = "initWidgets", require = 1)
void initWidgets(CallbackInfo ci) {
assert this.client != null;
this.addDrawableChild(new ButtonWidget(10, 10, 90, 20, Text.literal("Hyperion Client Modules"),
btn -> {this.client.setScreen(new HyperionClientModuleScreen(this, this.client.options));
}));
}
}
This is my Mixin class for the buttons
package net.hypericats.hyperionclient;
import net.hypericats.hyperionclient.event.KeyInputHandler;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.option.GameOptions;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
public class HyperionClientModuleScreen extends Screen {
private final Screen parent;
private final GameOptions settings;
public HyperionClientModuleScreen(Screen parent, GameOptions gameOptions) {
super(Text.literal("Hyperion Client Modules"));
this.parent = parent;
this.settings = gameOptions;
}
Text flyHackText() {
if(KeyInputHandler.FlyHax) {
return Text.literal("Flying is enabled");
} else {
return Text.literal("Flying is disabled");
}
}
protected void init() {
assert this.client != null;
this.addDrawableChild(new ButtonWidget(10, 10, 90, 20, flyHackText(), (btn) -> {
KeyInputHandler.FlyHax = !KeyInputHandler.FlyHax;
btn.setMessage(flyHackText());
}));
this.addDrawableChild(new ButtonWidget(10, this.height - 10, 90, 20, ScreenTexts.BACK, (btn) -> this.client.setScreen(this.parent)));
}
}
And this is the screen referenced in the mixin.
Also while running the client I get this error:
class ButtonWidget cannot be applied to given types;
this.addDrawableChild(new ButtonWidget(10, 10, 90, 20, flyHackText(), (btn) -> {
^
required: int,int,int,int,Text,PressAction,NarrationSupplier
found: int,int,int,int,Text,(btn)->{ K[...])); }
reason: actual and formal argument lists differ in length
I looked it up and it seems I missing something (Narraration supplier?) but I think that's not needed. I also tried adding some in but it didn't work, unless I did it wrong?