diff --git a/build.gradle b/build.gradle index fb9650a7d..a6713ebf3 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,8 @@ plugins { // Architectury is used here only as a replacement for forge's own loom id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false + + id 'xyz.wagyourtail.jvmdowngrader' version '0.9.1' apply true } @@ -27,17 +29,17 @@ def writeBuildGradlePredefine(List mcVers, int mcIndex) StringBuilder sb = new StringBuilder(); sb.append("# DON'T TOUCH THIS FILE, This is handled by the build script\n"); - - + + for (int i = 0; i < mcVers.size(); i++) { String verStr = mcVers[i].replace(".", "_"); sb.append("MC_" + verStr + "=" + i.toString() + "\n"); - + if (mcIndex == i) sb.append("MC_VER=" + i.toString() + "\n"); } - + // Check if this is a development build if (mod_version.toLowerCase().contains("dev")) @@ -102,23 +104,20 @@ subprojects { p -> // Apply plugins apply plugin: "java" apply plugin: "com.github.johnrengelman.shadow" + apply plugin: "xyz.wagyourtail.jvmdowngrader" if (isMinecraftSubProject) apply plugin: "systems.manifold.manifold-gradle-plugin" - + // Apply forge's loom - if ((findProject(":forge") && p == project(":forge")) || - (findProject(":neoforge") && p == project(":neoforge")) - ) - { + if ( (findProject(":forge") && p == project(":forge")) || (findProject(":neoforge") && p == project(":neoforge")) ) apply plugin: "dev.architectury.loom" - } // Set the manifold version (may not be required tough) manifold { manifoldVersion = rootProject.manifold_version } - + // set up custom configurations (configurations are a way to handle dependencies) configurations { @@ -174,12 +173,12 @@ subprojects { p -> //=====================// // shared dependencies // //=====================// - + // Manifold if (isMinecraftSubProject) { annotationProcessor("systems.manifold:manifold-preprocessor:${rootProject.manifold_version}") } - + // Log4j // TODO: Change to shadowMe later to work in the standalone jar // We cannot do this now as it would break Quilt @@ -191,7 +190,7 @@ subprojects { p -> forgeShadowMe("org.joml:joml:${rootProject.joml_version}") else implementation("org.joml:joml:${rootProject.joml_version}") - + // JUnit tests implementation("org.junit.jupiter:junit-jupiter:5.8.2") implementation("org.junit.jupiter:junit-jupiter-engine:5.8.2") @@ -201,22 +200,22 @@ subprojects { p -> // Note: MC 1.16 uses 8.2.1, and versions after use 8.5.12 // We cannot relocate this library since we call some MC classes that reference it implementation("it.unimi.dsi:fastutil:${rootProject.fastutil_version}") - - + + // Compression forgeShadowMe("org.lz4:lz4-java:${rootProject.lz4_version}") // LZ4 forgeShadowMe("org.tukaani:xz:${rootProject.xz_version}") // LZMA // Sqlite Database forgeShadowMe("org.xerial:sqlite-jdbc:${rootProject.sqlite_jdbc_version}") - + // NightConfig (includes Toml & Json) forgeShadowMe("com.electronwill.night-config:toml:${rootProject.nightconfig_version}") forgeShadowMe("com.electronwill.night-config:json:${rootProject.nightconfig_version}") // SVG (not needed atm) // forgeShadowMe("com.formdev:svgSalamander:${rootProject.svgSalamander_version}") - + // Netty // Breaks 1.16.5 //forgeShadowMe("io.netty:netty-all:${rootProject.netty_version}") @@ -225,9 +224,9 @@ subprojects { p -> forgeShadowMe("org.lwjgl:lwjgl-jawt:${rootProject.lwjgl_version}") { exclude group: "org.lwjgl", module: "lwjgl" // This module is imported by Minecraft so exclude it } - - - + + + //==========================// // conditional dependencies // //==========================// @@ -277,7 +276,7 @@ subprojects { p -> if (isMinecraftSubProject && p != project(":common")) { configurations.push(project.configurations.shadowCommon) // Shadow the common subproject relocate "com.seibel.distanthorizons.common", "loaderCommon.${p.name}.com.seibel.distanthorizons.common" // Move the loader files to a different location - + if (findProject(":fabricLike") && p != project(":fabricLike")) { configurations.push(project.configurations.shadowFabricLike) // Shadow the fabricLike subproject relocate "com.seibel.distanthorizons.fabriclike", "loaderCommon.${p.name}.com.seibel.distanthorizons.fabriclike" // Move the loader files to a different location @@ -291,11 +290,11 @@ subprojects { p -> // Compression (LZ4) relocate "net.jpountz", "${librariesLocation}.jpountz" - + // Sqlite Database //At the moment, there is a bug in this library which doesnt allow it to be relocated // relocate "org.sqlite", "${librariesLocation}.sqlite" - + // JOML if (project.hasProperty("embed_joml") && embed_joml == "true") relocate "org.joml", "${librariesLocation}.joml" @@ -305,14 +304,27 @@ subprojects { p -> // SVG (not needed atm) // relocate "com.kitfox.svg", "${librariesLocation}.kitfox.svg" - + // Netty relocate "io.netty", "${librariesLocation}.netty" mergeServiceFiles() } - // Using jar.finalizedBy(shadowJar) causes issues so we do this scuffed bypass - jar.dependsOn(shadowJar) + + // For downgrading the Java version of our project to match the minimum Java version required by the selected Minecraft version. + task jarDowngrade(type: xyz.wagyourtail.jvmdg.gradle.task.DowngradeJar) { + inputFile = tasks.shadowJar.archiveFile + downgradeTo = JavaVersion.toVersion(rootProject.java_version as Integer) + archiveClassifier = "downgraded-${rootProject.java_version}" + } + task apiDowngrade(type: xyz.wagyourtail.jvmdg.gradle.task.ShadeJar) { + inputFile = jarDowngrade.archiveFile + downgradeTo = JavaVersion.toVersion(rootProject.java_version as Integer) + archiveClassifier = "downgraded-${rootProject.java_version}-shaded-java-api" + } + // We're using a custom downgrade task so we disable the original downgrade tasks + downgradeJar.enabled = false + shadeDowngradedApi.enabled = false // Put stuff from gradle.properties into the mod info @@ -352,7 +364,7 @@ subprojects { p -> // TODO: Find something we can use so we can basically re-map only when the jar is shadowed and relocated // println p.tasks.findByName('shadowJar') - + // These "hasProperty"'s are so that they can be passed through the cli (ie in the CI) try { if (infoGitCommit == "null") @@ -388,14 +400,14 @@ subprojects { p -> fabric_incompatibility_list : fabric_incompatibility_list, fabric_recommend_list : fabric_recommend_list, ] - + // replace any properties in the sub-projects with the values defined here inputs.properties replaceProperties replaceProperties.put "project", project filesMatching(resourceTargets) { expand replaceProperties } - + intoTargets.each { target -> if (file(target).exists()) { copy { @@ -431,11 +443,9 @@ subprojects { p -> jar { from "LICENSE.txt" manifest { - attributes( - 'Implementation-Title': rootProject.mod_name, - 'Implementation-Version': rootProject.mod_version, - 'Main-Class': 'com.seibel.distanthorizons.core.jar.JarMain' // When changing the main of the jar change this line - ) + attributes 'Implementation-Title': rootProject.mod_name, + 'Implementation-Version': rootProject.mod_version, + 'Main-Class': 'com.seibel.distanthorizons.core.jar.JarMain' // When changing the main of the jar change this line } } @@ -465,11 +475,11 @@ allprojects { p -> apply plugin: "java" apply plugin: "maven-publish" - + archivesBaseName = rootProject.mod_name version = project.name + "-" + rootProject.versionStr group = rootProject.maven_group - + // this is the text that appears at the top of the overview (home) page // and is used when bookmarking a page javadoc.title = rootProject.mod_name + "-" + project.name @@ -557,44 +567,6 @@ allprojects { p -> // TODO: If neoforged is ever needed, should we use that, or call it a forge mod? } - // Adds some dependencies that are in vanilla but not in core - if (p == project(":core")) { - OperatingSystem os = org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentOperatingSystem; - - // Set the OS lwjgl is using to the current os - project.ext.lwjglNatives = "natives-" + os.toFamilyName() - - dependencies { // All of these dependencies are in Vanilla Minecraft, but we need to depend on it as we arent importing Minecraft in the core - // Imports most of lwjgl's libraries (well, only the ones that we need) - implementation platform("org.lwjgl:lwjgl-bom:${rootProject.lwjgl_version}") // TODO: Use Minecraft's version for lwjgl_version (which changes in nearly every version) instead of a hard defined version for all versions - - // REMEMBER: Dont shadow stuff here, these are just the libs that are included in Minecraft so that the core can use - implementation "org.lwjgl:lwjgl" - implementation "org.lwjgl:lwjgl-assimp" - implementation "org.lwjgl:lwjgl-glfw" - implementation "org.lwjgl:lwjgl-openal" - implementation "org.lwjgl:lwjgl-opengl" - implementation "org.lwjgl:lwjgl-stb" - implementation "org.lwjgl:lwjgl-tinyfd" - runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives" - runtimeOnly "org.lwjgl:lwjgl-assimp::$lwjglNatives" - runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives" - runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives" - runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives" - runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives" - runtimeOnly "org.lwjgl:lwjgl-tinyfd::$lwjglNatives" - implementation "org.joml:joml:${rootProject.joml_version}" - - - // Some other dependencies - implementation("org.jetbrains:annotations:16.0.2") - implementation("com.google.code.findbugs:jsr305:3.0.2") - implementation("com.google.common:google-collect:0.5") - implementation("com.google.guava:guava:31.1-jre") - } - } - - task copyCommonLoaderResources(type: Copy) { from project(":common").file("src/main/resources/${accessWidenerVersion}.distanthorizons.accesswidener") into(file(p.file("build/resources/main"))) @@ -616,16 +588,17 @@ allprojects { p -> tasks.withType(JavaCompile) { if (isMinecraftSubProject) { - options.release = rootProject.java_version as Integer + options.release = rootProject.java_version as Integer // Neoforge complains without this options.compilerArgs += ["-Xplugin:Manifold"] - } else { - options.release = 8; // Core & Api should use Java 8 no matter what - //options.release = rootProject.java_version as Integer // But if you want to test some stuff, then this can be enabled } options.encoding = "UTF-8" } + // Sets the project's actual Java version (it's recommended to use this over the `options.release` method above) java { + sourceCompatibility = rootProject.java_version + targetCompatibility = rootProject.java_version + withSourcesJar() } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java b/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java index 746ced882..0514b6dfd 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java @@ -103,7 +103,7 @@ public abstract class AbstractModInitializer LOGGER.info(ModInfo.READABLE_NAME + " Initialized"); ApiEventInjector.INSTANCE.fireAllEvents(DhApiAfterDhInitEvent.class, null); - this.subscribeRegisterCommandsEvent(dispatcher -> { this.commandDispatcher = dispatcher; }); + this.subscribeRegisterCommandsEvent(dispatcher -> this.commandDispatcher = dispatcher); this.subscribeServerStartingEvent(server -> { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/DependencySetupDoneCheck.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/DependencySetupDoneCheck.java index cf1835753..861c67599 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/DependencySetupDoneCheck.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/DependencySetupDoneCheck.java @@ -26,6 +26,6 @@ public class DependencySetupDoneCheck // TODO move to DependencySetup public static boolean isDone = false; // TODO why is this here and what is its purpose? - public static Supplier getIsCurrentThreadDistantGeneratorThread = (() -> { return false; }); + public static Supplier getIsCurrentThreadDistantGeneratorThread = (() -> false); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java index e475dbc69..171fb9151 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/McObjectConverter.java @@ -102,33 +102,17 @@ public class McObjectConverter lodDirections = new EDhDirection[lodDirs.length]; for (EDhDirection lodDir : lodDirs) { - Direction dir; - switch (lodDir.name().toUpperCase()) - { - case "DOWN": - dir = Direction.DOWN; - break; - case "UP": - dir = Direction.UP; - break; - case "NORTH": - dir = Direction.NORTH; - break; - case "SOUTH": - dir = Direction.SOUTH; - break; - case "WEST": - dir = Direction.WEST; - break; - case "EAST": - dir = Direction.EAST; - break; - default: - dir = null; - break; - } - - if (dir == null) + Direction dir = switch (lodDir.name().toUpperCase()) { + case "DOWN" -> Direction.DOWN; + case "UP" -> Direction.UP; + case "NORTH" -> Direction.NORTH; + case "SOUTH" -> Direction.SOUTH; + case "WEST" -> Direction.WEST; + case "EAST" -> Direction.EAST; + default -> null; + }; + + if (dir == null) { throw new IllegalArgumentException("Invalid direction on init mapping: " + lodDir); } 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 293a53037..b342e24b6 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 @@ -161,19 +161,17 @@ public class WrapperFactory implements IWrapperFactory // correct number of parameters from the API // chunk - if (!(objectArray[0] instanceof ChunkAccess)) + if (!(objectArray[0] instanceof ChunkAccess chunk)) { throw new ClassCastException(createChunkWrapperErrorMessage(objectArray)); } - ChunkAccess chunk = (ChunkAccess) objectArray[0]; // level / light source - if (!(objectArray[1] instanceof Level)) + if (!(objectArray[1] instanceof Level level)) { throw new ClassCastException(createChunkWrapperErrorMessage(objectArray)); } // the level is needed for the DH level wrapper... - Level level = (Level) objectArray[1]; // ...the LevelReader is needed for chunk lighting LevelReader lightSource = level; @@ -245,11 +243,10 @@ public class WrapperFactory implements IWrapperFactory public IDhApiBiomeWrapper getBiomeWrapper(Object[] objectArray, IDhApiLevelWrapper levelWrapper) { // confirm the API level wrapper is also a Core wrapper - if (!(levelWrapper instanceof ILevelWrapper)) + if (!(levelWrapper instanceof ILevelWrapper coreLevelWrapper)) { throw new ClassCastException("Invalid ["+IDhApiLevelWrapper.class.getSimpleName()+"] value given. Level wrapper object must be one given by the DH API (it can't be a custom implementation), specifically of type ["+ILevelWrapper.class.getName()+"]."); } - ILevelWrapper coreLevelWrapper = (ILevelWrapper) levelWrapper; @@ -304,11 +301,10 @@ public class WrapperFactory implements IWrapperFactory public IDhApiBlockStateWrapper getBlockStateWrapper(Object[] objectArray, IDhApiLevelWrapper levelWrapper) { // confirm the API level wrapper is also a Core wrapper - if (!(levelWrapper instanceof ILevelWrapper)) + if (!(levelWrapper instanceof ILevelWrapper coreLevelWrapper)) { throw new ClassCastException("Invalid ["+IDhApiLevelWrapper.class.getSimpleName()+"] value given. Level wrapper object must be one given by the DH API (it can't be a custom implementation), specifically of type ["+ILevelWrapper.class.getName()+"]."); } - ILevelWrapper coreLevelWrapper = (ILevelWrapper) levelWrapper; @@ -317,12 +313,11 @@ public class WrapperFactory implements IWrapperFactory { throw new ClassCastException(createBlockStateWrapperErrorMessage(objectArray)); } - if (!(objectArray[0] instanceof BlockState)) + if (!(objectArray[0] instanceof BlockState blockState)) { throw new ClassCastException(createBlockStateWrapperErrorMessage(objectArray)); } - BlockState blockState = (BlockState) objectArray[0]; return BlockStateWrapper.fromBlockState(blockState, coreLevelWrapper); #else // See preprocessor comment in createChunkWrapper() for full documentation (not a typo, check createChunkWrapper()'s else statement for full documentation) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java index 5f1b205b0..1df647202 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BiomeWrapper.java @@ -266,7 +266,7 @@ public class BiomeWrapper implements IBiomeWrapper } return EMPTY_WRAPPER; } - else if (resourceLocationString.trim().isEmpty() || resourceLocationString.equals("")) + else if (resourceLocationString.trim().isEmpty() || resourceLocationString.isEmpty()) { LOGGER.warn("Null biome string deserialized."); return EMPTY_WRAPPER; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java index a72505ee9..664811b8c 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/BlockStateWrapper.java @@ -34,6 +34,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.Property; import org.apache.logging.log4j.Logger; import java.awt.*; @@ -461,7 +462,7 @@ public class BlockStateWrapper implements IBlockStateWrapper // we need the final string for the concurrent hash map later final String finalResourceStateString = resourceStateString; - if (finalResourceStateString.equals(AIR_STRING) || finalResourceStateString.equals("")) // the empty string shouldn't normally happen, but just in case + if (finalResourceStateString.equals(AIR_STRING) || finalResourceStateString.isEmpty()) // the empty string shouldn't normally happen, but just in case { return AIR; } @@ -602,7 +603,7 @@ public class BlockStateWrapper implements IBlockStateWrapper // alphabetically sort the list so they are always in the same order List> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection); - sortedBlockPropteryList.sort((a, b) -> a.getName().compareTo(b.getName())); + sortedBlockPropteryList.sort(Comparator.comparing(Property::getName)); StringBuilder stringBuilder = new StringBuilder(); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockStateCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockStateCache.java index 52b81458c..b93473737 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockStateCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockStateCache.java @@ -312,12 +312,12 @@ public class ClientBlockStateCache } if (quads != null && !quads.isEmpty()) { - needPostTinting = quads.get(0).isTinted(); - needShade = quads.get(0).isShade(); - tintIndex = quads.get(0).getTintIndex(); + needPostTinting = quads.getFirst().isTinted(); + needShade = quads.getFirst().isShade(); + tintIndex = quads.getFirst().getTintIndex(); baseColor = calculateColorFromTexture( #if MC_VER < MC_1_17_1 quads.get(0).sprite, - #else quads.get(0).getSprite(), #endif + #else quads.getFirst().getSprite(), #endif ColorMode.getColorMode(blockState.getBlock())); } else diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java index 05a94f172..189eaacc1 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/chunk/ChunkWrapper.java @@ -83,7 +83,7 @@ public class ChunkWrapper implements IChunkWrapper private static final Logger LOGGER = DhLoggerBuilder.getLogger(); /** can be used for interactions with the underlying chunk where creating new BlockPos objects could cause issues for the garbage collector. */ - private static final ThreadLocal MUTABLE_BLOCK_POS_REF = ThreadLocal.withInitial(() -> new BlockPos.MutableBlockPos()); + private static final ThreadLocal MUTABLE_BLOCK_POS_REF = ThreadLocal.withInitial(BlockPos.MutableBlockPos::new); private final ChunkAccess chunk; @@ -345,9 +345,8 @@ public class ChunkWrapper implements IChunkWrapper #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 return false; // MC's lighting engine doesn't work consistently enough to trust for 1.16 or 1.17 #else - if (this.chunk instanceof LevelChunk) + if (this.chunk instanceof LevelChunk levelChunk) { - LevelChunk levelChunk = (LevelChunk) this.chunk; if (levelChunk.getLevel() instanceof ClientLevel) { // connected to a server @@ -474,9 +473,7 @@ public class ChunkWrapper implements IChunkWrapper }); #else this.chunk.findBlockLightSources((blockPos, blockState) -> - { - this.blockLightPosList.add(new DhBlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ())); - }); + this.blockLightPosList.add(new DhBlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()))); #endif } @@ -507,9 +504,8 @@ public class ChunkWrapper implements IChunkWrapper /** Should be called after client light updates are triggered. */ private void updateIsClientLightingCorrect() { - if (this.chunk instanceof LevelChunk && ((LevelChunk) this.chunk).getLevel() instanceof ClientLevel) + if (this.chunk instanceof LevelChunk levelChunk && ((LevelChunk) this.chunk).getLevel() instanceof ClientLevel) { - LevelChunk levelChunk = (LevelChunk) this.chunk; ClientChunkCache clientChunkCache = ((ClientLevel) levelChunk.getLevel()).getChunkSource(); this.isMcClientLightingCorrect = clientChunkCache.getChunkForLighting(this.chunk.getPos().x, this.chunk.getPos().z) != null && #if MC_VER <= MC_1_17_1 diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java index 2ca6c27a0..2ba322647 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java @@ -145,9 +145,9 @@ public class ClassicConfigGUI case 0: ((EntryInfo) info.guiValue).error = null; break; case -1: - ((EntryInfo) info.guiValue).error = new AbstractMap.SimpleEntry<>(editBox, TextOrTranslatable("§cMinimum length is " + ((ConfigEntry) info).getMin())); break; + ((EntryInfo) info.guiValue).error = new AbstractMap.SimpleEntry<>(editBox, TextOrTranslatable("§cMinimum length is " + ((ConfigEntry) info).getMin())); break; case 1: - ((EntryInfo) info.guiValue).error = new AbstractMap.SimpleEntry<>(editBox, TextOrTranslatable("§cMaximum length is " + ((ConfigEntry) info).getMax())); break; + ((EntryInfo) info.guiValue).error = new AbstractMap.SimpleEntry<>(editBox, TextOrTranslatable("§cMaximum length is " + ((ConfigEntry) info).getMax())); break; case 2: ((EntryInfo) info.guiValue).error = new AbstractMap.SimpleEntry<>(editBox, TextOrTranslatable("§cValue is invalid")); break; } @@ -235,7 +235,7 @@ public class ClassicConfigGUI ConfigBase.INSTANCE.configFileINSTANCE.saveToFile(); Objects.requireNonNull(this.minecraft).setScreen(this.parent); - CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run()); + CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach(Runnable::run); } @Override @@ -319,7 +319,7 @@ public class ClassicConfigGUI - CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run()); + CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach(Runnable::run); } @@ -332,7 +332,7 @@ public class ClassicConfigGUI if (ConfigEntry.class.isAssignableFrom(info.getClass())) { Button.OnPress btnAction = button -> { - ((ConfigEntry) info).uiSetWithoutSaving(((ConfigEntry) info).getDefaultValue()); + ((ConfigEntry) info).uiSetWithoutSaving(((ConfigEntry) info).getDefaultValue()); ((EntryInfo) info.guiValue).index = 0; this.reload = true; Objects.requireNonNull(minecraft).setScreen(this); @@ -376,9 +376,7 @@ public class ClassicConfigGUI } if (ConfigUIButton.class.isAssignableFrom(info.getClass())) { - Button widget = MakeBtn(name, this.width / 2 - 100, this.height - 28, 100 * 2, 20, (button -> { - ((ConfigUIButton) info).runAction(); - })); + Button widget = MakeBtn(name, this.width / 2 - 100, this.height - 28, 100 * 2, 20, (button -> ((ConfigUIButton) info).runAction())); this.list.addButton(widget, null, null, null); return; } 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 90c9299a5..d99cd83a5 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,19 +25,18 @@ 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)); - switch (useScreen) + return switch (useScreen) { - case Classic: - return ClassicConfigGUI.getScreen(ConfigBase.INSTANCE, parent, "client"); - case OpenGL: + case Classic -> ClassicConfigGUI.getScreen(ConfigBase.INSTANCE, parent, "client"); + case OpenGL -> + { MinecraftScreen.getScreen(parent, new OpenGLConfigScreen(), ModInfo.ID + ".title"); - return null; + yield null; + } // case JavaFX -> MinecraftScreen.getScreen(parent, new JavaScreenHandlerScreen(new JavaScreenHandlerScreen.ExampleScreen()), ModInfo.ID + ".title"); - case JavaFX: - return MinecraftScreen.getScreen(parent, new JavaScreenHandlerScreen(new ConfigScreen()), ModInfo.ID + ".title"); - default: - throw new IllegalArgumentException("No config screen implementation defined for ["+useScreen+"]."); - } + case JavaFX -> MinecraftScreen.getScreen(parent, new JavaScreenHandlerScreen(new ConfigScreen()), ModInfo.ID + ".title"); + default -> throw new IllegalArgumentException("No config screen implementation defined for [" + useScreen + "]."); + }; } } \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java index 25ac35ea3..ad07c2d3d 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java @@ -134,9 +134,7 @@ public class ChangelogScreen extends DhScreen this.addBtn( // Close - MakeBtn(Translatable(ModInfo.ID + ".general.back"), 5, this.height - 25, 100, 20, (btn) -> { - this.onClose(); - }) + MakeBtn(Translatable(ModInfo.ID + ".general.back"), 5, this.height - 25, 100, 20, (btn) -> this.onClose()) ); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java index f4d52e9d6..d582fe9c2 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java @@ -135,9 +135,7 @@ public class UpdateModScreen extends DhScreen }) ); this.addBtn( // Later (not now) - MakeBtn(Translatable(ModInfo.ID + ".updater.later"), this.width / 2 + 2, this.height / 2 + 70, 100, 20, (btn) -> { - this.onClose(); - }) + MakeBtn(Translatable(ModInfo.ID + ".updater.later"), this.width / 2 + 2, this.height / 2 + 70, 100, 20, (btn) -> this.onClose()) ); this.addBtn( // Never MakeBtn(Translatable(ModInfo.ID + ".updater.never"), this.width / 2 - 102, this.height / 2 + 70, 100, 20, (btn) -> { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java index 684240b85..6818d4cb2 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftClientWrapper.java @@ -127,20 +127,12 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra } case ENABLED: - switch (lodDirection) - { - case DOWN: - return 0.5F; - default: - case UP: - return 1.0F; - case NORTH: - case SOUTH: - return 0.8F; - case WEST: - case EAST: - return 0.6F; - } + return switch (lodDirection) { + case DOWN -> 0.5F; + default -> 1.0F; + case NORTH, SOUTH -> 0.8F; + case WEST, EAST -> 0.6F; + }; case DISABLED: return 1.0F; @@ -250,7 +242,7 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra @Override public ArrayList getAllServerWorlds() { - ArrayList worlds = new ArrayList(); + ArrayList worlds = new ArrayList<>(); Iterable serverWorlds = MINECRAFT.getSingleplayerServer().getAllLevels(); for (ServerLevel world : serverWorlds) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java index bd01cc0b4..eedfceee0 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/BatchGenerationEnvironment.java @@ -147,7 +147,7 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv if (index == -1) continue; times.get(index).add(e.timeNs); } - times.get(0).add(event.getTotalTimeNs()); + times.getFirst().add(event.getTotalTimeNs()); } public String toString() @@ -653,9 +653,8 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv chunksToGenerate.forEach((chunkWrapper) -> { ChunkAccess chunk = chunkWrapper.getChunk(); - if (chunk instanceof ProtoChunk) + if (chunk instanceof ProtoChunk protoChunk) { - ProtoChunk protoChunk = ((ProtoChunk) chunk); protoChunk.setLightEngine(region.getLightEngine()); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java index 2b4cf1052..6ff95c53e 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java @@ -294,7 +294,7 @@ public class ChunkLoader #else .getOrThrow((message) -> (RuntimeException) LOGGER.errorAndThrow(message, null)) #endif - : new PalettedContainer(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES); + : new PalettedContainer<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES); #if MC_VER < MC_1_18_2 biomeContainer = tagSection.contains("biomes", 10) @@ -309,7 +309,7 @@ public class ChunkLoader #else .getOrThrow((message) -> (RuntimeException) LOGGER.errorAndThrow(message, null)) #endif - : new PalettedContainer>(biomes.asHolderIdMap(), biomes.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES); + : new PalettedContainer<>(biomes.asHolderIdMap(), biomes.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES); #endif #if MC_VER < MC_1_20_1 @@ -434,7 +434,7 @@ public class ChunkLoader for (int sectionIndex = 0; sectionIndex < chunkSectionListTag.size(); sectionIndex++) { Tag chunkSectionTag = chunkSectionListTag.get(sectionIndex); - if (!(chunkSectionTag instanceof CompoundTag)) + if (!(chunkSectionTag instanceof CompoundTag chunkSectionCompoundTag)) { if (!lightingSectionErrorLogged) { @@ -443,10 +443,9 @@ public class ChunkLoader } return null; } - CompoundTag chunkSectionCompoundTag = (CompoundTag) chunkSectionTag; - - - // if null all lights = 0 + + + // if null all lights = 0 byte[] blockLightNibbleArray = chunkSectionCompoundTag.getByteArray("BlockLight"); byte[] skyLightNibbleArray = chunkSectionCompoundTag.getByteArray("SkyLight"); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java index 30632bef1..1ece9e8b1 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/DhLitWorldGenRegion.java @@ -84,7 +84,7 @@ public class DhLitWorldGenRegion extends WorldGenRegion private final ChunkPos firstPos; private final List cache; - private final Long2ObjectOpenHashMap chunkMap = new Long2ObjectOpenHashMap(); + private final Long2ObjectOpenHashMap chunkMap = new Long2ObjectOpenHashMap<>(); /** * Present to reduce the chance that we accidentally break underlying MC code that isn't thread safe, @@ -142,7 +142,7 @@ public class DhLitWorldGenRegion extends WorldGenRegion centerChunk); #endif - this.firstPos = chunkList.get(0).getPos(); + this.firstPos = chunkList.getFirst().getPos(); this.generator = generator; this.lightEngine = lightEngine; this.writeRadius = writeRadius; diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java index fcdc779b3..f7ee4ca9f 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/WorldGenStructFeatManager.java @@ -231,11 +231,9 @@ public class WorldGenStructFeatManager extends #if MC_VER < MC_1_19_2 StructureF Map map = chunk.getAllReferences(); ImmutableList.Builder builder = ImmutableList.builder(); - Iterator> var5 = map.entrySet().iterator(); - while (var5.hasNext()) + for (Map.Entry entry : map.entrySet()) { - Map.Entry entry = var5.next(); Structure configuredStructureFeature = entry.getKey(); if (predicate.test(configuredStructureFeature)) { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureReference.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureReference.java index c5dc640e8..5ba19c761 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureReference.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/step/StepStructureReference.java @@ -54,7 +54,7 @@ public final class StepStructureReference List chunkWrappers) { - ArrayList chunksToDo = new ArrayList(); + ArrayList chunksToDo = new ArrayList<>(); for (ChunkWrapper chunkWrapper : chunkWrappers) { diff --git a/coreSubProjects b/coreSubProjects index fef87df09..ef87a4e59 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit fef87df09b41a2ed16c74b1426f0c0089db088af +Subproject commit ef87a4e5951c8a7f69820848c91a47a57b758b14 diff --git a/fabric/build.gradle b/fabric/build.gradle index 2d3b583fc..bb4535e72 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -23,8 +23,8 @@ loom { } remapJar { - inputFile = apiDowngrade.archiveFile - dependsOn apiDowngrade + inputFile = shadeDowngradedApi.archiveFile + dependsOn shadeDowngradedApi } diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java index 3b3b0d8a9..ba37e63da 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java @@ -106,7 +106,7 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy // tick events // //=============// - ClientTickEvents.START_CLIENT_TICK.register((client) -> { ClientApi.INSTANCE.clientTickEvent(); }); + ClientTickEvents.START_CLIENT_TICK.register((client) -> ClientApi.INSTANCE.clientTickEvent()); diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinMinecraft.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinMinecraft.java index f6b4b112a..42ded1760 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinMinecraft.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinMinecraft.java @@ -98,7 +98,7 @@ public class MixinMinecraft } else { - versionId = GitlabGetter.INSTANCE.projectPipelines.get(0).get("sha"); + versionId = GitlabGetter.INSTANCE.projectPipelines.getFirst().get("sha"); } Minecraft.getInstance().setScreen(new UpdateModScreen( diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinOptionsScreen.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinOptionsScreen.java index d638536f7..26bc1462c 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinOptionsScreen.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinOptionsScreen.java @@ -104,14 +104,14 @@ public class MixinOptionsScreen extends Screen // add the button to the correct location in the UI // TODO is there a better way to do this instead of using access transformers to inject into the exact UI elements? - LinearLayout layout = (LinearLayout) this.layout.headerFrame.children.get(0).child; + LinearLayout layout = (LinearLayout) this.layout.headerFrame.children.getFirst().child; // determine how wide the other option buttons are so we can put our botton to the left of them all AtomicInteger width = new AtomicInteger(0); - layout.visitChildren(x -> { width.addAndGet(x.getWidth()); }); + layout.visitChildren(x -> width.addAndGet(x.getWidth())); width.addAndGet(-10); // padding between the DH button and the FOV slider - layout.wrapped.addChild(this.getOptionsButton(), 1, 2, (settings) -> { settings.paddingLeft(width.get() * -1); }); + layout.wrapped.addChild(this.getOptionsButton(), 1, 2, (settings) -> settings.paddingLeft(width.get() * -1)); layout.arrangeElements(); #endif diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/config/ModMenuIntegration.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/config/ModMenuIntegration.java index 2d809c45d..0037ddb96 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/config/ModMenuIntegration.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/config/ModMenuIntegration.java @@ -32,7 +32,7 @@ public class ModMenuIntegration implements ModMenuApi @Override public ConfigScreenFactory getModConfigScreenFactory() { - return parent -> GetConfigScreen.getScreen(parent); + return GetConfigScreen::getScreen; } } diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/ModChecker.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/ModChecker.java index dcd7d7fd7..ac0b7ec60 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/ModChecker.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/ModChecker.java @@ -37,7 +37,7 @@ public class ModChecker implements IModChecker @Override public File modLocation(String modid) { - return new File(FabricLoader.getInstance().getModContainer(modid).get().getOrigin().getPaths().get(0).toUri()); + return new File(FabricLoader.getInstance().getModContainer(modid).get().getOrigin().getPaths().getFirst().toUri()); } } diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/SodiumAccessor.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/SodiumAccessor.java index bb4764c25..1f8f20bcc 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/SodiumAccessor.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/wrappers/modAccessor/SodiumAccessor.java @@ -69,11 +69,9 @@ public class SodiumAccessor implements ISodiumAccessor #if MC_VER >= MC_1_20_1 // TODO: This is just a tmp solution, use a proper solution later - return MC_RENDER.getMaximumRenderedChunks().stream().filter((DhChunkPos chunk) -> { - return (renderer.isBoxVisible( - chunk.getMinBlockX() + 1, height.getMinBuildHeight() + 1, chunk.getMinBlockZ() + 1, - chunk.getMinBlockX() + 15, height.getMaxBuildHeight() - 1, chunk.getMinBlockZ() + 15)); - }).collect(Collectors.toCollection(HashSet::new)); + return MC_RENDER.getMaximumRenderedChunks().stream().filter((DhChunkPos chunk) -> (renderer.isBoxVisible( + chunk.getMinBlockX() + 1, height.getMinBuildHeight() + 1, chunk.getMinBlockZ() + 1, + chunk.getMinBlockX() + 15, height.getMaxBuildHeight() - 1, chunk.getMinBlockZ() + 15))).collect(Collectors.toCollection(HashSet::new)); #elif MC_VER >= MC_1_18_2 // 0b11 = Lighted chunk & loaded chunk return renderer.getChunkTracker().getChunks(0b00).filter( diff --git a/forge/build.gradle b/forge/build.gradle index ea30313f3..c2625980c 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -51,8 +51,8 @@ loom { } remapJar { - inputFile = apiDowngrade.archiveFile - dependsOn apiDowngrade + inputFile = shadeDowngradedApi.archiveFile + dependsOn shadeDowngradedApi } def addMod(path, enabled) { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23a4..a4413138c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 04da288d0..855006dcf 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -23,7 +23,7 @@ loom { mixin { // Mixins are defined in the `mods.toml` } - + // "runs" isn't required, but when we do need it then it can be useful runs { client { @@ -31,7 +31,7 @@ loom { setConfigName("NeoForge Client") ideConfigGenerated(true) runDir("../run") - //vmArgs("-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg) +// vmArgs("-XX:-OmitStackTraceInFastThrow", minecraftMemoryJavaArg) } server { server() @@ -42,7 +42,13 @@ loom { } } +remapJar { + inputFile = apiDowngrade.archiveFile + dependsOn apiDowngrade +// classifier null + atAccessWideners.add("distanthorizons.accesswidener") +} def addMod(path, enabled) { if (enabled == "2") @@ -50,24 +56,21 @@ def addMod(path, enabled) { else if (enabled == "1") dependencies { modCompileOnly(path) } } + dependencies { minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" - mappings loom.layered() - { + mappings loom.layered() { // Mojmap mappings officialMojangMappings() // Parchment mappings (it adds parameter mappings & javadoc) parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip") } - - + // Neoforge neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}" addMod("curse.maven:TerraFirmaCraft-302973:4616004", rootProject.enable_terrafirmacraft) } - - task deleteResources(type: Delete) { delete file("build/resources/main") } @@ -86,13 +89,6 @@ tasks.named('runClient') { finalizedBy(deleteResources) } -remapJar { - inputFile = shadowJar.archiveFile - dependsOn shadowJar - - atAccessWideners.add("distanthorizons.accesswidener") -} - sourcesJar { def commonSources = project(":common").sourcesJar dependsOn commonSources diff --git a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/NeoforgeClientProxy.java b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/NeoforgeClientProxy.java index e5dc92b42..2d15858c1 100644 --- a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/NeoforgeClientProxy.java +++ b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/NeoforgeClientProxy.java @@ -129,12 +129,11 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy LOGGER.info("level load"); LevelAccessor level = event.getLevel(); - if (!(level instanceof ClientLevel)) + if (!(level instanceof ClientLevel clientLevel)) { return; } - ClientLevel clientLevel = (ClientLevel) level; IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel); // TODO this causes a crash due to level being set to null somewhere ClientApi.INSTANCE.clientLevelLoadEvent(clientLevelWrapper); @@ -145,12 +144,11 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy LOGGER.info("level unload"); LevelAccessor level = event.getLevel(); - if (!(level instanceof ClientLevel)) + if (!(level instanceof ClientLevel clientLevel)) { return; } - ClientLevel clientLevel = (ClientLevel) level; IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel); ClientApi.INSTANCE.clientLevelUnloadEvent(clientLevelWrapper); } diff --git a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/NeoforgeMain.java b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/NeoforgeMain.java index 8dd61f085..6f5e3f8a3 100644 --- a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/NeoforgeMain.java +++ b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/NeoforgeMain.java @@ -88,7 +88,7 @@ public class NeoforgeMain extends AbstractModInitializer @Override protected void subscribeRegisterCommandsEvent(Consumer> eventHandler) { - NeoForge.EVENT_BUS.addListener((RegisterCommandsEvent e) -> { eventHandler.accept(e.getDispatcher()); }); + NeoForge.EVENT_BUS.addListener((RegisterCommandsEvent e) -> eventHandler.accept(e.getDispatcher())); } @Override @@ -100,7 +100,7 @@ public class NeoforgeMain extends AbstractModInitializer @Override protected void subscribeServerStartingEvent(Consumer eventHandler) { - NeoForge.EVENT_BUS.addListener((ServerStartingEvent e) -> { eventHandler.accept(e.getServer()); }); + NeoForge.EVENT_BUS.addListener((ServerStartingEvent e) -> eventHandler.accept(e.getServer())); } @Override diff --git a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinMinecraft.java b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinMinecraft.java index a202069a0..ffdf6c6fb 100644 --- a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinMinecraft.java +++ b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinMinecraft.java @@ -86,7 +86,7 @@ public class MixinMinecraft } else { - versionId = GitlabGetter.INSTANCE.projectPipelines.get(0).get("sha"); + versionId = GitlabGetter.INSTANCE.projectPipelines.getFirst().get("sha"); } Minecraft.getInstance().setScreen(new UpdateModScreen( diff --git a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinOptionsScreen.java b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinOptionsScreen.java index b1a661e78..db5c850d0 100644 --- a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinOptionsScreen.java +++ b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinOptionsScreen.java @@ -104,14 +104,14 @@ public class MixinOptionsScreen extends Screen // add the button to the correct location in the UI // TODO is there a better way to do this instead of using access transformers to inject into the exact UI elements? - LinearLayout layout = (LinearLayout) this.layout.headerFrame.children.get(0).child; + LinearLayout layout = (LinearLayout) this.layout.headerFrame.children.getFirst().child; // determine how wide the other option buttons are so we can put our botton to the left of them all AtomicInteger width = new AtomicInteger(0); - layout.visitChildren(x -> { width.addAndGet(x.getWidth()); }); + layout.visitChildren(x -> width.addAndGet(x.getWidth())); width.addAndGet(-10); // padding between the DH button and the FOV slider - layout.wrapped.addChild(this.getOptionsButton(), 1, 2, (settings) -> { settings.paddingLeft(width.get() * -1); }); + layout.wrapped.addChild(this.getOptionsButton(), 1, 2, (settings) -> settings.paddingLeft(width.get() * -1)); layout.arrangeElements(); #endif