Skip to content

Commit 5cc73a3

Browse files
committed
Support 1.19.3, for real this time
1 parent 2469386 commit 5cc73a3

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

src/main/java/se/icus/mag/modsettings/LegacyApiWrapper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ public LegacyApiWrapper(io.github.prospector.modmenu.api.ModMenuApi legacyApi) {
1515

1616
@Override
1717
public ConfigScreenFactory<?> getModConfigScreenFactory() {
18-
return new LegacyScreenFactory(legacyApi.getModConfigScreenFactory());
18+
return new LegacyScreenFactory<>(legacyApi.getModConfigScreenFactory());
1919
}
2020

2121
@Override
2222
public Map<String, ConfigScreenFactory<?>> getProvidedConfigScreenFactories() {
2323
Map<String, io.github.prospector.modmenu.api.ConfigScreenFactory<?>> legacyMap = legacyApi.getProvidedConfigScreenFactories();
2424

2525
return legacyMap.keySet().stream().collect(Collectors.toMap(id -> id,
26-
id -> new LegacyScreenFactory(legacyMap.get(id))));
26+
id -> new LegacyScreenFactory<>(legacyMap.get(id))));
2727
}
2828

2929
public static class LegacyScreenFactory<S extends Screen> implements ConfigScreenFactory<S> {
3030
private io.github.prospector.modmenu.api.ConfigScreenFactory<S> legcayFactory;
3131

32-
public LegacyScreenFactory(io.github.prospector.modmenu.api.ConfigScreenFactory legcayFactory) {
32+
public LegacyScreenFactory(io.github.prospector.modmenu.api.ConfigScreenFactory<S> legcayFactory) {
3333
this.legcayFactory = legcayFactory;
3434
}
3535

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package se.icus.mag.modsettings.gui;
2+
3+
import net.minecraft.client.gui.widget.ButtonWidget;
4+
import net.minecraft.text.Text;
5+
6+
public class Button extends ButtonWidget {
7+
public Button(int x, int y, int width, int height, Text message, PressAction onPress) {
8+
super(x, y, width, height, message, onPress, DEFAULT_NARRATION_SUPPLIER);
9+
}
10+
}

src/main/java/se/icus/mag/modsettings/gui/MenuScreensChanger.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,21 @@ private static void injectModSettingsButton(Screen screen, int fullButtonWidth,
5252
if (shortenModMenu) {
5353
// If we find a wide ModMenu button, shorten it and fit in our button on the same row
5454
savedButton.setWidth(HALF_BUTTON_WIDTH);
55-
savedButton.x = screen.width / 2 + halfButtonSpacer;
55+
savedButton.setX(screen.width / 2 + halfButtonSpacer);
5656

5757
ClickableWidget msbutton = new ModSettingsButton(screen.width / 2 - fullButtonWidth / 2,
58-
savedButton.y, HALF_BUTTON_WIDTH, BUTTON_HEIGHT, screen);
58+
savedButton.getY(), HALF_BUTTON_WIDTH, BUTTON_HEIGHT, screen);
5959
buttons.add(msbutton);
6060
} else {
6161
if (savedButton == null) {
6262
// There is no "Options..." button. Just grab an arbitrary button
6363
savedButton = buttons.get(0);
6464
}
6565
// Shift all buttons starting at "Options..." down
66-
int optionsY = savedButton.y;
66+
int optionsY = savedButton.getY();
6767
for (ClickableWidget button : buttons) {
68-
if (button.y >= optionsY) {
69-
button.y += BUTTON_VERICAL_SPACING;
68+
if (button.getY() >= optionsY) {
69+
button.setY(button.getY() + BUTTON_VERICAL_SPACING);
7070
}
7171
}
7272

@@ -83,7 +83,7 @@ private static boolean buttonHasText(ClickableWidget button, String translationK
8383
mutableText.getContent().equals(new TranslatableTextContent(translationKey));
8484
}
8585

86-
public static class ModSettingsButton extends ButtonWidget {
86+
public static class ModSettingsButton extends Button {
8787
public ModSettingsButton(int x, int y, int width, int height, Screen screen) {
8888
super(x, y, width, height, Text.translatable("modsettings.button.title"),
8989
button -> MinecraftClient.getInstance().setScreen(new ModSettingsScreen(screen)));

src/main/java/se/icus/mag/modsettings/gui/ModListWidget.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public class ModEntry extends Entry {
3939
final List<ButtonWidget> buttons;
4040

4141
public ModEntry(ModSettingsScreen.ModSettingsOption mod1, ModSettingsScreen.ModSettingsOption mod2) {
42-
ButtonWidget leftButton = new ButtonWidget(ModListWidget.this.width / 2 - 155, 0, 150, BUTTON_HEIGHT, Text.of(mod1.modName()),
42+
ButtonWidget leftButton = new Button(ModListWidget.this.width / 2 - 155, 0, 150, BUTTON_HEIGHT, Text.of(mod1.modName()),
4343
button -> client.setScreen(mod1.configScreen()));
4444
if (mod2 != null) {
45-
ButtonWidget rightButton = new ButtonWidget(ModListWidget.this.width / 2 - 155 + 160, 0, 150, BUTTON_HEIGHT, Text.of(mod2.modName()),
45+
ButtonWidget rightButton = new Button(ModListWidget.this.width / 2 - 155 + 160, 0, 150, BUTTON_HEIGHT, Text.of(mod2.modName()),
4646
button -> client.setScreen(mod2.configScreen()));
4747
buttons = ImmutableList.of(leftButton, rightButton);
4848
} else {
@@ -63,7 +63,7 @@ public List<? extends Element> children() {
6363
@Override
6464
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
6565
buttons.forEach(button -> {
66-
button.y = y;
66+
button.setY(y);
6767
button.render(matrices, mouseX, mouseY, tickDelta);
6868
});
6969
}

src/main/java/se/icus/mag/modsettings/gui/ModSettingsScreen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected void init() {
3737
this.list.addAll(getAllModConfigOptions());
3838

3939
this.addSelectableChild(this.list);
40-
this.addDrawableChild(new ButtonWidget(this.width / 2 - FULL_BUTTON_WIDTH / 2, this.height - 27,
40+
this.addDrawableChild(new Button(this.width / 2 - FULL_BUTTON_WIDTH / 2, this.height - 27,
4141
FULL_BUTTON_WIDTH, BUTTON_HEIGHT, ScreenTexts.DONE,
4242
button -> this.client.setScreen(this.previous)));
4343
initIsProcessing = false;

0 commit comments

Comments
 (0)