From 50f0be767c69f3ac49c3a2c4c8669354a39fd9b3 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Wed, 12 May 2021 20:41:38 +0100 Subject: [PATCH] Update to 21w19a and Java 16 This commit can be used as an example on how to update your mod to Java 16. You will need to ensure you have Java 16 installed and set as the active version to run this. Gradle 7 is required along with loom 0.8 --- .github/workflows/build.yml | 6 ++---- build.gradle | 15 +++++---------- gradle.properties | 6 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- src/main/resources/fabric.mod.json | 5 +++-- src/main/resources/modid.mixins.json | 2 +- 6 files changed, 15 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 31c38ee..48f6c91 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,9 +12,7 @@ jobs: matrix: # Use these Java versions java: [ - 1.8, # Minimum supported by Minecraft - 11, # Current Java LTS - 15 # Latest version + 16 # Minimum supported by Minecraft ] # and run on both Linux and Windows os: [ubuntu-20.04, windows-latest] @@ -34,7 +32,7 @@ jobs: - name: build run: ./gradlew build - name: capture build artifacts - if: ${{ runner.os == 'Linux' && matrix.java == '11' }} # Only upload artifacts built from LTS java on one OS + if: ${{ runner.os == 'Linux' && matrix.java == '16' }} # Only upload artifacts built from latest java on one OS uses: actions/upload-artifact@v2 with: name: Artifacts diff --git a/build.gradle b/build.gradle index a4b5de7..f807b77 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,10 @@ plugins { - id 'fabric-loom' version '0.6-SNAPSHOT' + id 'fabric-loom' version '0.8-SNAPSHOT' id 'maven-publish' } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_16 +targetCompatibility = JavaVersion.VERSION_16 archivesBaseName = project.archives_base_name version = project.mod_version @@ -46,13 +46,8 @@ tasks.withType(JavaCompile).configureEach { // If Javadoc is generated, this must be specified in that task too. it.options.encoding = "UTF-8" - // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too - // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. - // We'll use that if it's available, but otherwise we'll use the older option. - def targetVersion = 8 - if (JavaVersion.current().isJava9Compatible()) { - it.options.release = targetVersion - } + // Minecraft 1.17 (21w19a) upwards uses Java 16. + it.options.release = 16 } java { diff --git a/gradle.properties b/gradle.properties index 40e9e57..cf1ec16 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.16.5 - yarn_mappings=1.16.5+build.6 + minecraft_version=21w19a + yarn_mappings=21w19a+build.1 loader_version=0.11.3 # Mod Properties @@ -14,4 +14,4 @@ org.gradle.jvmargs=-Xmx1G # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.32.5+1.16 + fabric_version=0.34.4+1.17 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 442d913..e5338d3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index df92d8b..a0bfabb 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -27,9 +27,10 @@ ], "depends": { - "fabricloader": ">=0.7.4", + "fabricloader": ">=0.11.3", "fabric": "*", - "minecraft": "1.16.x" + "minecraft": "1.17.x", + "java": ">=16" }, "suggests": { "another-mod": "*" diff --git a/src/main/resources/modid.mixins.json b/src/main/resources/modid.mixins.json index 21fe73a..9cf7e06 100644 --- a/src/main/resources/modid.mixins.json +++ b/src/main/resources/modid.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "net.fabricmc.example.mixin", - "compatibilityLevel": "JAVA_8", + "compatibilityLevel": "JAVA_16", "mixins": [ ], "client": [