diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..48f6c91 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,39 @@ +# Automatically build the project and run any configured tests for every push +# and submitted pull request. This can help catch issues that only occur on +# certain platforms or Java versions, and provides a first line of defence +# against bad commits. + +name: build +on: [pull_request, push] + +jobs: + build: + strategy: + matrix: + # Use these Java versions + java: [ + 16 # Minimum supported by Minecraft + ] + # and run on both Linux and Windows + os: [ubuntu-20.04, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - name: checkout repository + uses: actions/checkout@v2 + - name: validate gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: setup jdk ${{ matrix.java }} + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: make gradle wrapper executable + if: ${{ runner.os != 'Windows' }} + run: chmod +x ./gradlew + - name: build + run: ./gradlew build + - name: capture build artifacts + 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 + path: build/libs/ diff --git a/.gitignore b/.gitignore index 5e5fd36..17de685 100644 --- a/.gitignore +++ b/.gitignore @@ -1,24 +1,36 @@ -#Gradle +# gradle + .gradle/ build/ out/ classes/ -#IDEA +# eclipse + +*.launch + +# idea + .idea/ *.iml *.ipr *.iws -#vscode +# vscode + .settings/ .vscode/ bin/ .classpath .project -#fabric +# fabric + run/ -#Sublime Text +# macos + +*.DS_Store + +# Sublime Text *.sublime* diff --git a/README.md b/README.md new file mode 100644 index 0000000..90e9ca3 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Horse Info Mod - Waila Plugin + +## License + +This project is using MIT License diff --git a/build.gradle b/build.gradle index 81cee94..8fb95d7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,92 +1,88 @@ plugins { - id 'fabric-loom' version '0.4.29' - id 'maven-publish' - id "com.wynprice.cursemaven" version "2.1.4" + id 'fabric-loom' version '0.9-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}-${minecraft_version}" +version = "${project.mod_version}-${project.minecraft_version}" group = project.maven_group -minecraft { -} - repositories { - maven { - name = 'TehNut' - url = 'https://maven.tehnut.info' - } - maven { url = "https://minecraft.curseforge.com/api/maven" } + maven { url "https://bai.jfrog.io/artifactory/maven" } + maven { url "https://minecraft.curseforge.com/api/maven" } } dependencies { - //to change the versions see the gradle.properties file - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + // To change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" - - modImplementation "mcp.mobius.waila:Hwyla:${project.hwyla_version}" - // modCompile "curse.maven:hwyla:2987120" - // modCompile "curse.maven:hwyla:2987122" + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + + // WTHIT + modCompileOnly "mcp.mobius.waila:wthit-api:fabric-${project.wthit_version}" + modRuntime "mcp.mobius.waila:wthit:fabric-${project.wthit_version}" } processResources { - inputs.property "version", project.version - - from(sourceSets.main.resources.srcDirs) { - include "fabric.mod.json" - expand "version": project.version - } + inputs.property "version", project.version - from(sourceSets.main.resources.srcDirs) { - exclude "fabric.mod.json" - } + filesMatching("fabric.mod.json") { + expand "version": project.version + } } -// 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 -tasks.withType(JavaCompile) { - options.encoding = "UTF-8" +tasks.withType(JavaCompile).configureEach { + // 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" + + // Minecraft 1.17 (21w19a) upwards uses Java 16. + it.options.release = 16 } -// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task -// if it is present. -// If you remove this task, sources will not be generated. -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" - from sourceSets.main.allSource +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() } jar { - from "LICENSE" + from("LICENSE") { + rename { "${it}_${project.archivesBaseName}"} + } } // configure the maven publication publishing { - publications { - mavenJava(MavenPublication) { - // add all the jars that should be included when publishing to maven - artifact(jar) { - builtBy remapJar - } - artifact("${project.buildDir.absolutePath}/libs/${archivesBaseName}-${project.version}.jar"){ - builtBy remapJar - } - artifact(sourcesJar) { - builtBy remapSourcesJar - } - } - } + publications { + mavenJava(MavenPublication) { + // add all the jars that should be included when publishing to maven + artifact(remapJar) { + builtBy remapJar + } + artifact("${project.buildDir.absolutePath}/libs/${archivesBaseName}-${project.version}.jar"){ + builtBy remapJar + } + artifact(sourcesJar) { + builtBy remapSourcesJar + } + } + } - // select the repositories you want to publish to - repositories { - // uncomment to publish to the local maven - // mavenLocal() - } -} \ No newline at end of file + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. + } +} diff --git a/gradle.properties b/gradle.properties index 90b63a1..7ff0d32 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,17 @@ -org.gradle.jvmargs = -Xmx1G +# Done to increase the memory available to gradle. +org.gradle.jvmargs = -Xmx1G -#Fabric properties -minecraft_version = 1.16.1 -yarn_mappings = 1.16.1+build.4 -loader_version = 0.8.8+build.202 +# Fabric Properties +# check these on https://fabricmc.net/versions.html +minecraft_version = 1.17 +yarn_mappings = 1.17+build.13 +loader_version = 0.11.6 #Mod properties -mod_version = 0.2.2 +mod_version = 0.3.0 maven_group = net.pancham138.horseinfo archives_base_name = hwyla-addon-horseinfo -#Dependencies -fabric_api_version = 0.13.1+build.370-1.16 -hwyla_version = 1.16-1.9.22-74 \ No newline at end of file +# Dependencies +fabric_version = 0.36.0+1.17 +wthit_version = 3.6.1 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf..e708b1c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4b7e1f3..69a9715 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-5.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 8e25e6c..4f906e0 100755 --- a/gradlew +++ b/gradlew @@ -82,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -125,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -154,19 +156,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -175,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 9618d8d..107acd3 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/settings.gradle b/settings.gradle index 89fa615..f91a4fe 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,10 +1,9 @@ pluginManagement { repositories { - jcenter() maven { name = 'Fabric' url = 'https://maven.fabricmc.net/' } gradlePluginPortal() } -} \ No newline at end of file +} diff --git a/src/main/java/net/pancham138/horseinfo/HorseInfo.java b/src/main/java/net/pancham138/horseinfo/HorseInfo.java index 5bca09a..7b57717 100644 --- a/src/main/java/net/pancham138/horseinfo/HorseInfo.java +++ b/src/main/java/net/pancham138/horseinfo/HorseInfo.java @@ -42,7 +42,7 @@ public void register(IRegistrar registrar) { registrar.addConfig(ENABLED, true); - registrar.registerComponentProvider(this, TooltipPosition.BODY, HorseBaseEntity.class); + registrar.addComponent(this, TooltipPosition.BODY, HorseBaseEntity.class); } @Override diff --git a/src/main/java/net/pancham138/horseinfo/ModLog.java b/src/main/java/net/pancham138/horseinfo/ModLog.java index 0c6e501..b881724 100644 --- a/src/main/java/net/pancham138/horseinfo/ModLog.java +++ b/src/main/java/net/pancham138/horseinfo/ModLog.java @@ -2,7 +2,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.util.ReflectionUtil; public class ModLog { @@ -17,12 +16,16 @@ public static Logger getLogger(final Class clazz) { } public static Logger getLogger() { - return LogManager.getLogger(ReflectionUtil.getCallerClass(2), messageFactory); + return LogManager.getLogger(getClassName(2), messageFactory); } public static Logger getLogger(final Object value) { - return LogManager.getLogger(value != null ? value.getClass() : ReflectionUtil.getCallerClass(2), + return LogManager.getLogger(value != null ? value.getClass() : getClassName(2), messageFactory); } + private static String getClassName(final int depth) { + return new Throwable().getStackTrace()[depth].getClassName(); + } + } \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 20b3859..46b1a52 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -23,9 +23,11 @@ "mixins": [ ], "depends": { - "fabricloader": ">=0.4.0", + "fabricloader": ">=0.11.3", "fabric": "*", - "waila": ">=1.9.0" + "waila": ">=1.9.0", + "minecraft": "1.17.x", + "java": ">=16" }, "custom": { "waila:plugins": { @@ -33,4 +35,4 @@ "initializer": "net.pancham138.horseinfo.HorseInfo" } } -} \ No newline at end of file +}