From a57a34ab582667bd5d72aadcb53d06792584312e Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 5 Aug 2023 11:10:34 -0500 Subject: [PATCH] Fix GetConfigScreen and WrapperFactory using Java 8+ code --- .../common/wrappers/WrapperFactory.java | 6 ++++-- .../common/wrappers/gui/GetConfigScreen.java | 16 ++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java index 8992217d1..8ce60f9a7 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/WrapperFactory.java @@ -101,16 +101,18 @@ public class WrapperFactory implements IWrapperFactory // correct number of parameters from the API // chunk - if (!(objectArray[0] instanceof ChunkAccess chunk)) + if (!(objectArray[0] instanceof ChunkAccess)) { throw new ClassCastException(createChunkWrapperErrorMessage(objectArray)); } + ChunkAccess chunk = (ChunkAccess)objectArray[0]; // light source - if (!(objectArray[1] instanceof LevelReader lightSource)) + if (!(objectArray[1] instanceof LevelReader)) { throw new ClassCastException(createChunkWrapperErrorMessage(objectArray)); } + LevelReader lightSource = (LevelReader)objectArray[1]; return new ChunkWrapper(chunk, lightSource, /*A DH wrapped level isn't necessary*/null); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GetConfigScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GetConfigScreen.java index 109f5a6e0..b7c816b1a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GetConfigScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/GetConfigScreen.java @@ -25,13 +25,17 @@ public class GetConfigScreen // This shouldn't be here, but I need a way to test it after Minecraft inits its assets //System.out.println(ConfigBase.INSTANCE.generateLang(false, true)); - return switch (useScreen) + switch (useScreen) { - case Classic -> ClassicConfigGUI.getScreen(ConfigBase.INSTANCE, parent, "client"); - case OpenGL -> MinecraftScreen.getScreen(parent, new OpenGLConfigScreen(), ModInfo.ID + ".title"); + case Classic: + return ClassicConfigGUI.getScreen(ConfigBase.INSTANCE, parent, "client"); + case OpenGL: MinecraftScreen.getScreen(parent, new OpenGLConfigScreen(), ModInfo.ID + ".title"); + return null; // case JavaFX -> MinecraftScreen.getScreen(parent, new JavaScreenHandlerScreen(new JavaScreenHandlerScreen.ExampleScreen()), ModInfo.ID + ".title"); - case JavaFX -> MinecraftScreen.getScreen(parent, new JavaScreenHandlerScreen(new ConfigScreen()), ModInfo.ID + ".title"); - default -> null; - }; + case JavaFX: + return MinecraftScreen.getScreen(parent, new JavaScreenHandlerScreen(new ConfigScreen()), ModInfo.ID + ".title"); + default: + return null; + } } } \ No newline at end of file