Skip to content

Commit 2405895

Browse files
committed
Fix installing OptiFine with 1.16+
1 parent 0622f0c commit 2405895

3 files changed

Lines changed: 34 additions & 25 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Fixes
10+
- Fix an error when attempting to install OptiFine with 1.16+
11+
912
## [0.9.4] - 2021-01-02
1013

1114
### Fixes

src/main/java/io/github/ImpactDevelopment/installer/gui/pages/MainPage.java

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -226,34 +226,40 @@ private JPanel buildOptiFineSetting(AppWindow app) {
226226
grid.add(radial);
227227

228228
if (usingOptiFine) {
229+
String version = config.getSettingValue(OptiFineSetting.INSTANCE);
230+
String warningText = version == null ? "OptiFine is not currently supported on this version.<br>A new Installer that supports this combination may be released in the future."
231+
: "OptiFine can sometimes cause visual issues in Impact;<br>only include it if you need it!";
232+
229233
JPanel warning = new JPanel(new FlowLayout());
230-
warning.add(new JLabel("<html><center>OptiFine can sometimes cause visual issues in Impact;<br>only include it if you need it!</center></html>"));
234+
warning.add(new JLabel("<html><center>" + warningText + "</center></html>"));
231235
grid.add(warning);
232236

233-
String version = config.getSettingValue(OptiFineSetting.INSTANCE);
234-
if (!version.equals(MISSING)) {
235-
grid.add(buildSetting(OptiFineSetting.INSTANCE, "OptiFine version", app));
236-
}
237-
switch (version) {
238-
case MISSING:
239-
case CUSTOM:
240-
grid.add(buildPathSetting(OptiFineFileSetting.INSTANCE, "OptiFine installer", JFileChooser.FILES_ONLY, app));
241-
break;
242-
}
237+
// OptiFine version can be null if it isn't supported
238+
if (version != null) {
239+
if (!version.equals(MISSING)) {
240+
grid.add(buildSetting(OptiFineSetting.INSTANCE, "OptiFine version", app));
241+
}
242+
switch (version) {
243+
case MISSING:
244+
case CUSTOM:
245+
grid.add(buildPathSetting(OptiFineFileSetting.INSTANCE, "OptiFine installer", JFileChooser.FILES_ONLY, app));
246+
break;
247+
}
243248

244-
try {
245-
FlowLayout layout = new FlowLayout();
246-
layout.setHgap(0);
247-
JPanel download = new JPanel(layout);
248-
JLabel text = new JLabel("<html>You can download OptiFine from their website: </html>");
249-
download.add(text);
250-
251-
JHyperlink link = new JHyperlink("optifine.net", "https://optifine.net/downloads");
252-
download.add(link);
253-
254-
grid.add(download);
255-
} catch (URISyntaxException e) {
256-
throw new RuntimeException("", e);
249+
try {
250+
FlowLayout layout = new FlowLayout();
251+
layout.setHgap(0);
252+
JPanel download = new JPanel(layout);
253+
JLabel text = new JLabel("<html>You can download OptiFine from their website: </html>");
254+
download.add(text);
255+
256+
JHyperlink link = new JHyperlink("optifine.net", "https://optifine.net/downloads");
257+
download.add(link);
258+
259+
grid.add(download);
260+
} catch (URISyntaxException e) {
261+
throw new RuntimeException("", e);
262+
}
257263
}
258264
}
259265

src/main/java/io/github/ImpactDevelopment/installer/setting/settings/OptiFineSetting.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public enum OptiFineSetting implements ChoiceSetting<String> {
5151

5252
@Override
5353
public List<String> getPossibleValues(InstallationConfig config) {
54-
if (config.getSettingValue(InstallationModeSetting.INSTANCE) == InstallationModeOptions.FORGE || config.getSettingValue(InstallationModeSetting.INSTANCE) == InstallationModeOptions.FORGE_PLUS_LITELOADER || config.getSettingValue(MinecraftVersionSetting.INSTANCE).compareTo("1.15.2") > 0) {
54+
if (config.getSettingValue(InstallationModeSetting.INSTANCE) == InstallationModeOptions.FORGE || config.getSettingValue(InstallationModeSetting.INSTANCE) == InstallationModeOptions.FORGE_PLUS_LITELOADER) {
5555
return Collections.emptyList();
5656
}
5757
String minecraftVersion = config.getSettingValue(MinecraftVersionSetting.INSTANCE);

0 commit comments

Comments
 (0)