Hi all,
I've been updating my mod from 1.18 to 1.19 and so far I've been able to fix the changes regarding literal/translatable Components and other minor changes, but the Button class' constructor seems to have changed, and I don't know how to update it.
Here is my working constructor for 1.18:
public BuySellButton(int x, int y, String buyText, String sellText, boolean isBuy, OnPress listener) {
super(x, y, 50, 12, new TextComponent((isBuy ? buyText : sellText)), listener);
this.isBuy = isBuy;
}
Simply changing the component does not work:
public BuySellButton(int x, int y, String buyText, String sellText, boolean isBuy, OnPress listener) {
super(x, y, 50, 12, Component.literal((isBuy ? buyText : sellText)), listener);
this.isBuy = isBuy;
}
Cannot resolve method 'super(int, int, int, int, MutableComponent, OnPress)'
Here are the available constructors/builders from the Button class:
public static Button.Builder builder(Component p_254439_, Button.OnPress p_254567_) {
return new Button.Builder(p_254439_, p_254567_);
}
protected Button(int p_259075_, int p_259271_, int p_260232_, int p_260028_, Component p_259351_, Button.OnPress p_260152_, Button.CreateNarration p_259552_) {
super(p_259075_, p_259271_, p_260232_, p_260028_, p_259351_);
this.onPress = p_260152_;
this.createNarration = p_259552_;
}
protected Button(Builder builder) {
this(builder.x, builder.y, builder.width, builder.height, builder.message, builder.onPress, builder.createNarration);
setTooltip(builder.tooltip); // Forge: Make use of the Builder tooltip
}
Can someone please help me understand how to update my Button constructor?