From 7c241e1594e23104aa868438cb2e8945e5125494 Mon Sep 17 00:00:00 2001 From: m1504 Date: Tue, 2 Aug 2022 20:52:47 +0800 Subject: [PATCH] Update Fabric to 1.19.1. Support more minecraft version. --- build.gradle | 35 ++++++++++++++----- gradle.properties | 27 ++++++-------- .../java/com/laosun/stackone/StackOneMod.java | 5 --- 3 files changed, 37 insertions(+), 30 deletions(-) diff --git a/build.gradle b/build.gradle index 16ca879..3b803fe 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,10 @@ plugins { - id 'fabric-loom' version '0.11-SNAPSHOT' + id 'fabric-loom' version '0.7-SNAPSHOT' id 'maven-publish' } -sourceCompatibility = JavaVersion.VERSION_17 -targetCompatibility = JavaVersion.VERSION_17 +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 archivesBaseName = project.archives_base_name version = project.mod_version @@ -16,7 +16,6 @@ repositories { // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. // See https://docs.gradle.org/current/userguide/declaring_repositories.html // for more information about repositories. - maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/'} } dependencies { @@ -27,6 +26,9 @@ dependencies { // Fabric API. This is technically optional, but you probably want it anyway. modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + + // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. + // You may need to force-disable transitiveness on them. } processResources { @@ -38,8 +40,19 @@ processResources { } tasks.withType(JavaCompile).configureEach { - // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. - it.options.release = 17 + // ensure that the encoding is set to UTF-8, no matter what the system default is + // this fixes some edge cases with special characters not displaying correctly + // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html + // 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 + } } java { @@ -59,7 +72,13 @@ jar { publishing { publications { mavenJava(MavenPublication) { - from components.java + // add all the jars that should be included when publishing to maven + artifact(remapJar) { + builtBy remapJar + } + artifact(sourcesJar) { + builtBy remapSourcesJar + } } } @@ -70,4 +89,4 @@ publishing { // The repositories here will be used for publishing your artifact, not for // retrieving dependencies. } -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index f1ffe43..1f23cf5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,24 +1,17 @@ # Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G +org.gradle.jvmargs=-Xmx8G # Fabric Properties - # check these on https://fabricmc.net/develop -minecraft_version=1.19.1 -yarn_mappings=1.19.1+build.5 -loader_version=0.14.8 +# check these on https://fabricmc.net/versions.html +minecraft_version=1.16.5 +yarn_mappings=1.16.5+build.9 +loader_version=0.11.3 # Mod Properties - mod_version = fabric-all-1.0.2 - maven_group = com.laosun.stackone - archives_base_name = stackone +mod_version = fabric-all-1.0.2 +maven_group = com.laosun +archives_base_name = stackone # Dependencies -fabric_version=0.58.5+1.19.1 - -#systemProp.http.proxyHost=127.0.0.1:3128 -#systemProp.http.proxyPort=3128 -#systemProp.https.proxyHost=127.0.0.1 -#systemProp.https.proxyPort=03128 - - -#Fabric api +# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api (or https://fabricmc.net/versions.html) +fabric_version=0.34.2+1.16 \ No newline at end of file diff --git a/src/main/java/com/laosun/stackone/StackOneMod.java b/src/main/java/com/laosun/stackone/StackOneMod.java index 698492a..8a410e9 100644 --- a/src/main/java/com/laosun/stackone/StackOneMod.java +++ b/src/main/java/com/laosun/stackone/StackOneMod.java @@ -3,22 +3,17 @@ import net.fabricmc.api.ModInitializer; import net.minecraft.item.Item; import net.minecraft.util.registry.Registry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.lang.reflect.Field; public class StackOneMod implements ModInitializer { // This logger is used to write text to the console and the log file. // It is considered best practice to use your mod id as the logger's name. - // That way, it's clear which mod wrote info, warnings, and errors. - public static final Logger LOGGER = LoggerFactory.getLogger("stackone"); @Override public void onInitialize() { for (Item i : Registry.ITEM) { try { - LOGGER.debug(i.getTranslationKey()); Class a = Item.class; Field f2; try {