Skip to content

Commit f21ca2f

Browse files
committed
Support 1.19
1 parent 718083c commit f21ca2f

File tree

7 files changed

+104
-51
lines changed

7 files changed

+104
-51
lines changed

README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ can directly go to the configuration screen with just a single button, and
1717
unless you have an extreme amount of mods installed, they are all likely to fit
1818
on a single page.
1919

20-
This mod requires Minecraft 1.17.1, 1.18.1 or 1.18.2 and the Fabric loader.
20+
This mod requires Minecraft 1.17.1 - 1.19 and the Fabric loader.
2121

2222
## Screenshot
2323

@@ -48,13 +48,13 @@ https://modrinth.com/mod/fabric-api).
4848

4949
The latest version is 1.1.0.
5050

51-
Direct download links for Minecraft 1.18.1-1.18.2:
51+
Direct download links for Minecraft 1.19:
5252

53-
* Download from GitHub: [modsettings-1.1.0+1.18.1.jar](
54-
https://github.com/magicus/ModSettings/releases/download/v1.1.0%2B1.18.1/modsettings-1.1.0+1.18.1.jar)
55-
* Download from Modrinth: [modsettings-1.1.0+1.18.1.jar](
56-
https://cdn.modrinth.com/data/mfDfQvcJ/versions/1.1.0+1.18.1/modsettings-1.1.0%2B1.18.1.jar)
57-
* Download from CurseForge: [modsettings-1.1.0+1.18.1.jar](
53+
* Download from GitHub: [modsettings-1.1.0+1.19.jar](
54+
https://github.com/magicus/ModSettings/releases/download/v1.1.0%2B1.19/modsettings-1.1.0+1.19.jar)
55+
* Download from Modrinth: [modsettings-1.1.0+1.19.jar](
56+
https://cdn.modrinth.com/data/mfDfQvcJ/versions/1.1.0+1.19/modsettings-1.1.0%2B1.19.jar)
57+
* Download from CurseForge: [modsettings-1.1.0+1.19.jar](
5858
https://www.curseforge.com/minecraft/mc-mods/mod-settings/download/3757415)
5959

6060
For all other Minecraft releases, check these download sites:
@@ -72,10 +72,6 @@ mod.](https://lmgtfy.app/?q=how+to+install+minecraft+fabric+mods)
7272

7373
Do you have any problems with the mod? Please open an issue here on Github.
7474

75-
Currently only Minecraft versions 1.17.1 to 1.18.2 are supported, but it would
76-
probably be trivial to add support for other versions. If you want support for
77-
another version, please open an issue and state the requested version.
78-
7975
## Known Incompatibilities
8076

8177
The mod [Content Creator Integration](
@@ -86,4 +82,4 @@ if you do not click the CCI button. The mod hardcodes references to
8682
implementation details of Mod Menu itself so the bug does not manifest using Mod
8783
Menu. This [will be fixed](
8884
https://github.com/iChun/ContentCreatorIntegration-IssuesAndDocumentation/issues/82)
89-
in future versions.
85+
in future versions of CCI.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '0.10-SNAPSHOT'
2+
id 'fabric-loom' version '0.12-SNAPSHOT'
33
}
44

55
sourceCompatibility = JavaVersion.VERSION_17

gradle.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
org.gradle.jvmargs=-Xmx1G
33

44
# Fabric Properties
5-
# check these on https://fabricmc.net/versions.html
6-
minecraft_version=1.18.1
7-
yarn_mappings=1.18.1+build.22
8-
loader_version=0.12.12
5+
# check these on https://fabricmc.net/develop
6+
minecraft_version=1.19
7+
yarn_mappings=1.19+build.4
8+
loader_version=0.14.8
99

1010
# Mod Properties
1111
project_name=Mod Settings
12-
mod_version=1.1.0+1.18.1
12+
mod_version=1.1.0+1.19
1313
maven_group=se.icus.mag
1414
archives_base_name=modsettings
1515

1616
# Fabric api
17-
fabric_version=0.46.1+1.18
17+
fabric_version=0.57.0+1.19

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
import net.minecraft.client.gui.screen.TitleScreen;
88
import net.minecraft.client.gui.widget.ButtonWidget;
99
import net.minecraft.client.gui.widget.ClickableWidget;
10+
import net.minecraft.text.MutableText;
1011
import net.minecraft.text.Text;
11-
import net.minecraft.text.TranslatableText;
12+
import net.minecraft.text.TranslatableTextContent;
1213

1314
import java.util.List;
1415

@@ -78,12 +79,13 @@ private static void injectModSettingsButton(Screen screen, int fullButtonWidth,
7879

7980
private static boolean buttonHasText(ClickableWidget button, String translationKey) {
8081
Text text = button.getMessage();
81-
return text instanceof TranslatableText && ((TranslatableText) text).getKey().equals(translationKey);
82+
return text instanceof MutableText mutableText &&
83+
mutableText.getContent().equals(new TranslatableTextContent(translationKey));
8284
}
8385

8486
public static class ModSettingsButton extends ButtonWidget {
8587
public ModSettingsButton(int x, int y, int width, int height, Screen screen) {
86-
super(x, y, width, height, new TranslatableText("modsettings.button.title"),
88+
super(x, y, width, height, Text.translatable("modsettings.button.title"),
8789
button -> MinecraftClient.getInstance().setScreen(new ModSettingsScreen(screen)));
8890
}
8991
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package se.icus.mag.modsettings.gui;
2+
3+
import com.google.common.collect.ImmutableList;
4+
import net.minecraft.client.MinecraftClient;
5+
import net.minecraft.client.gui.Element;
6+
import net.minecraft.client.gui.Selectable;
7+
import net.minecraft.client.gui.widget.ButtonWidget;
8+
import net.minecraft.client.gui.widget.ElementListWidget;
9+
import net.minecraft.client.util.math.MatrixStack;
10+
import net.minecraft.text.Text;
11+
12+
import java.util.List;
13+
14+
public class ModListWidget extends ElementListWidget<ModListWidget.Entry> {
15+
private static final int BUTTON_HEIGHT = 20;
16+
17+
public ModListWidget(MinecraftClient client, int width, int height, int top, int bottom, int itemHeight) {
18+
super(client, width, height, top, bottom, itemHeight);
19+
this.centerListVertically = false;
20+
}
21+
22+
@Override
23+
public int getRowWidth() {
24+
return 400;
25+
}
26+
27+
@Override
28+
protected int getScrollbarPositionX() {
29+
return super.getScrollbarPositionX() + 32;
30+
}
31+
32+
public void addAll(ModSettingsScreen.ModSettingsOption[] options) {
33+
for (int i = 0; i < options.length; i += 2) {
34+
addEntry(new ModEntry(options[i], i < options.length - 1 ? options[i + 1] : null));
35+
}
36+
}
37+
38+
public class ModEntry extends Entry {
39+
final List<ButtonWidget> buttons;
40+
41+
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()),
43+
button -> client.setScreen(mod1.configScreen()));
44+
if (mod2 != null) {
45+
ButtonWidget rightButton = new ButtonWidget(ModListWidget.this.width / 2 - 155 + 160, 0, 150, BUTTON_HEIGHT, Text.of(mod2.modName()),
46+
button -> client.setScreen(mod2.configScreen()));
47+
buttons = ImmutableList.of(leftButton, rightButton);
48+
} else {
49+
buttons = ImmutableList.of(leftButton);
50+
}
51+
}
52+
53+
@Override
54+
public List<? extends Selectable> selectableChildren() {
55+
return buttons;
56+
}
57+
58+
@Override
59+
public List<? extends Element> children() {
60+
return buttons;
61+
}
62+
63+
@Override
64+
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
65+
buttons.forEach(button -> {
66+
button.y = y;
67+
button.render(matrices, mouseX, mouseY, tickDelta);
68+
});
69+
}
70+
}
71+
72+
public static abstract class Entry extends ElementListWidget.Entry<Entry> {
73+
}
74+
}
Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
package se.icus.mag.modsettings.gui;
22

33
import net.minecraft.client.gui.screen.Screen;
4-
import net.minecraft.client.gui.screen.ScreenTexts;
5-
import net.minecraft.client.gui.widget.ButtonListWidget;
64
import net.minecraft.client.gui.widget.ButtonWidget;
7-
import net.minecraft.client.gui.widget.ClickableWidget;
8-
import net.minecraft.client.option.GameOptions;
9-
import net.minecraft.client.option.Option;
105
import net.minecraft.client.util.math.MatrixStack;
6+
import net.minecraft.screen.ScreenTexts;
117
import net.minecraft.text.Text;
12-
import net.minecraft.text.TranslatableText;
138
import se.icus.mag.modsettings.Main;
149
import se.icus.mag.modsettings.ModRegistry;
1510

@@ -22,11 +17,11 @@ public class ModSettingsScreen extends Screen {
2217
private static final int TITLE_COLOR = 0xffffff;
2318

2419
private final Screen previous;
25-
private ButtonListWidget list;
20+
private ModListWidget list;
2621
private boolean initIsProcessing;
2722

2823
public ModSettingsScreen(Screen previous) {
29-
super(new TranslatableText("modsettings.screen.title"));
24+
super(Text.translatable("modsettings.screen.title"));
3025
this.previous = previous;
3126
}
3227

@@ -38,7 +33,7 @@ protected void init() {
3833
initIsProcessing = true;
3934

4035
// Put list between 32 pixels from top and bottom
41-
this.list = new ButtonListWidget(this.client, this.width, this.height, 32, this.height - 32, 25);
36+
this.list = new ModListWidget(this.client, this.width, this.height, 32, this.height - 32, 25);
4237
this.list.addAll(getAllModConfigOptions());
4338

4439
this.addSelectableChild(this.list);
@@ -48,8 +43,8 @@ protected void init() {
4843
initIsProcessing = false;
4944
}
5045

51-
private Option[] getAllModConfigOptions() {
52-
List<Option> options = new LinkedList<>();
46+
private ModSettingsOption[] getAllModConfigOptions() {
47+
List<ModSettingsOption> options = new LinkedList<>();
5348
for (String modId : ModRegistry.getInstance().getAllModIds()) {
5449
try {
5550
Screen configScreen = ModRegistry.getInstance().getConfigScreen(modId, this);
@@ -60,7 +55,7 @@ private Option[] getAllModConfigOptions() {
6055
Main.LOGGER.error("Error creating Settings screen from mod " + modId, e);
6156
}
6257
}
63-
return options.toArray(new Option[0]);
58+
return options.toArray(new ModSettingsOption[0]);
6459
}
6560

6661
@Override
@@ -72,24 +67,10 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
7267
}
7368

7469
@Override
75-
public void onClose() {
70+
public void close() {
7671
this.client.setScreen(this.previous);
7772
}
7873

79-
public class ModSettingsOption extends Option {
80-
private final String modName;
81-
private final Screen configScreen;
82-
83-
public ModSettingsOption(String modId, String modName, Screen configScreen) {
84-
super(modId);
85-
this.modName = modName;
86-
this.configScreen = configScreen;
87-
}
88-
89-
@Override
90-
public ClickableWidget createButton(GameOptions options, int x, int y, int width) {
91-
return new ButtonWidget(x, y, width, BUTTON_HEIGHT, Text.of(this.modName),
92-
button -> client.setScreen(this.configScreen));
93-
}
74+
public record ModSettingsOption(String modId, String modName, Screen configScreen) {
9475
}
9576
}

src/main/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
"fabricloader": ">=0.7.4",
3434
"fabric-screen-api-v1": ">=1.0.4",
3535
"fabric-key-binding-api-v1": ">=1.0.1",
36-
"minecraft": "1.18.x"
36+
"minecraft": "~1.19"
3737
}
3838
}

0 commit comments

Comments
 (0)