diff --git a/build.gradle b/build.gradle index d88888c5ee..3b78ab7fc0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,139 +1,80 @@ -buildscript { - repositories { - maven { - name = "forge" - url = "https://files.minecraftforge.net/maven" - } - maven { - name = 'sponge' - url = 'https://repo.spongepowered.org/repository/maven-public' - } - } - - dependencies { - classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT" - classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT' - } +plugins { + id 'maven-publish' + id 'fabric-loom' version '1.4-SNAPSHOT' + id 'ploceus' version '1.4-SNAPSHOT' } -apply plugin: 'net.minecraftforge.gradle.liteloader' -apply plugin: 'org.spongepowered.mixin' -apply plugin: 'maven-publish' - -minecraft { - version = project.minecraft_version - mappings = project.mappings_version - runDir = 'minecraft' - makeObfSourceJar = false +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 - ext.mod_version = project.mod_version - - if (mod_version.endsWith('-dev')) { - mod_version = mod_version + "." + new Date().format('yyyyMMdd.HHmmss') - } - - replaceIn "MaLiLibReference.java" - replace "@MOD_VERSION@", mod_version +repositories { } -compileJava { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 - options.encoding = 'UTF-8' -} +ext.configFile = file "build.properties" -sourceSets { - main { - ext.refMap = 'mixins.' + project.mod_id + '.refmap.json' - } +configFile.withReader { + def prop = new Properties() + prop.load(it) + project.ext.config = new ConfigSlurper().parse prop } -group = project.mod_id // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = project.mod_file_name + '-' + project.minecraft_version_out -version = project.minecraft.mod_version - -/** - * This section allows you to customise the generated litemod.json file - */ -litemod { - json { - name = project.mod_id - displayName = project.mod_name - mcversion = project.minecraft_version - version = project.minecraft.mod_version - author = project.author - - // Uncomment any of the following lines and fill in your own details as required - //dependsOn = [ 'modid', 'othermod' ] - //requiredAPIs = [ 'someapi' ] - //tweakClass = 'name.of.tweaker.here' - mixinConfigs = [ 'mixins.' + project.mod_id + '.json' ] - } +dependencies { + minecraft "com.mojang:minecraft:${config.minecraft_version}" + mappings loom.layered { + addLayer ploceus.mcpMappings('stable', '1.12', '39') + } + modImplementation "net.fabricmc:fabric-loader:${config.fabric_loader_version}" + implementation "com.google.code.findbugs:jsr305:3.0.2" + ploceus.dependOsl(config.osl_version) + modCompileOnly "com.terraformersmc:modmenu:${config.mod_menu_version}" } -/** - * This section allows you to customise your generated jar (litemod) file. By - * default it includes the generated litemod.json file, however if you prefer to - * include your own file from resources, simply remove the line below. - */ -jar { - // Remove the "-mc1.12" suffix from the file name - classifier = "" - // Don't append a 'mod-' filename prefix >_> - baseName = archivesBaseName - - from litemod.outputs - - /* - manifest.mainAttributes ( - 'Built-By': System.properties['user.name'], - 'Created-By': System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")", - 'Implementation-Title': project.mod_id, - 'Implementation-Version': project.version - ) - */ +group = config.group + "." + config.mod_id +base { + archivesName = config.mod_file_name + '-' + config.minecraft_version_out } +version = config.mod_version -mixin { - defaultObfuscationEnv notch +if (version.endsWith('-dev')) { + version += "." + new Date().format('yyyyMMdd.HHmmss') } -//tasks.withType(Jar)*.baseName = archivesBaseName - -processResources -{ +processResources { // Exclude the GIMP image files exclude '**/*.xcf' exclude '**/xcf' // this will ensure that this task is redone when the versions change. - inputs.property "mod_version", project.minecraft.mod_version - inputs.property "minecraft_version", project.minecraft_version - - // replace stuff in mcmod.info, nothing else - from(sourceSets.main.resources.srcDirs) { - include 'mcmod.info' - - // replace version and mcversion - expand 'mod_version': project.minecraft.mod_version, 'minecraft_version': project.minecraft_version - } - - // copy everything else, thats not the mcmod.info - from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' + //inputs.property "minecraft_version", project.config.minecraft_version + + inputs.property "mod_version", config.mod_version + + filesMatching("fabric.mod.json") { + expand "mod_version": config.mod_version } } -task deobfJar(type: Jar) { - from sourceSets.main.output - // This classifier is standard and should not be changed - classifier = 'deobf' +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" + + it.options.release = 8 } -// This section enables the last two tasks -artifacts { - //archives sourcesJar - archives deobfJar +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") { + rename { "${it}_${project.base.archivesName.get()}"} + } } tasks.publish.dependsOn build @@ -141,10 +82,10 @@ publishing { publications { mavenJava(MavenPublication) { artifactId project.archivesBaseName - from components.java - artifact deobfJar - artifact sourceJar + // add all the jars that should be included when publishing to maven + //artifact(jar) { builtBy remapJar } + from components.java } } diff --git a/build.properties b/build.properties new file mode 100644 index 0000000000..fe8af371bf --- /dev/null +++ b/build.properties @@ -0,0 +1,17 @@ +# Thu Jan 14 08:33:00 EET 2016 +group = fi.dy.masa +mod_id = malilib +mod_name = MaLiLib +author = masa +mod_file_name = malilib-ornithe + +# Current mod version +mod_version = 0.54.0.2 + +# Minecraft, Fabric and mappings versions +minecraft_version_out = 1.12.2 +minecraft_version = 1.12.2 + +fabric_loader_version = 0.14.22 +osl_version = 0.10.3 +mod_menu_version = 0.1.0+mc1.12.2 diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 58dadbf9c2..0000000000 --- a/gradle.properties +++ /dev/null @@ -1,16 +0,0 @@ -org.gradle.jvmargs = -Xmx4G -org.gradle.daemon = false -org.gradle.cache.cleanup = false - -mod_id = malilib -mod_file_name = malilib-liteloader -mod_name = MaLiLib -author = masa - -# Current mod version -mod_version = 0.55.0-test.1 - -# Minecraft and mappings version -minecraft_version_out = 1.12.2 -minecraft_version = 1.12.2 -mappings_version = stable_39 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 3baa851b28..033e24c4cd 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 e496c054f6..ac72c34e8a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 index 4f906e0c81..fcb6fca147 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,98 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +118,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,88 +129,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # 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 - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg 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" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -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" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 107acd32c4..93e3f59f13 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000000..459e3f1a78 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,17 @@ +pluginManagement { + repositories { + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + maven { + name = 'Ornithe Releases' + url = 'https://maven.ornithemc.net/releases' + } + maven { + name = 'Ornithe Snapshots' + url = 'https://maven.ornithemc.net/snapshots' + } + gradlePluginPortal() + } +} diff --git a/src/main/java/malilib/LiteModMaLiLib.java b/src/main/java/malilib/LiteModMaLiLib.java deleted file mode 100644 index fde619a24c..0000000000 --- a/src/main/java/malilib/LiteModMaLiLib.java +++ /dev/null @@ -1,63 +0,0 @@ -package malilib; - -import java.io.File; -import com.mumfrey.liteloader.Configurable; -import com.mumfrey.liteloader.InitCompleteListener; -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.ShutdownListener; -import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.modconfig.ConfigPanel; - -import net.minecraft.client.Minecraft; - -import malilib.config.ConfigManagerImpl; -import malilib.event.dispatch.InitializationDispatcherImpl; -import malilib.registry.Registry; - -public class LiteModMaLiLib implements Configurable, LiteMod, InitCompleteListener, ShutdownListener -{ - public LiteModMaLiLib() - { - } - - @Override - public String getName() - { - return MaLiLibReference.MOD_NAME; - } - - @Override - public String getVersion() - { - return MaLiLibReference.MOD_VERSION; - } - - @Override - public Class getConfigPanelClass() - { - return MaLiLibConfigPanel.class; - } - - @Override - public void init(File configPath) - { - } - - @Override - public void upgradeSettings(String version, File configPath, File oldConfigPath) - { - } - - @Override - public void onInitCompleted(Minecraft minecraft, LiteLoader loader) - { - // Dispatch the init calls to all the registered handlers - ((InitializationDispatcherImpl) Registry.INITIALIZATION_DISPATCHER).onGameInitDone(); - } - - @Override - public void onShutDown() - { - ((ConfigManagerImpl) Registry.CONFIG_MANAGER).saveIfDirty(); - } -} diff --git a/src/main/java/malilib/MaLiLib.java b/src/main/java/malilib/MaLiLib.java index 2b04d79b27..de5dea0c95 100644 --- a/src/main/java/malilib/MaLiLib.java +++ b/src/main/java/malilib/MaLiLib.java @@ -2,11 +2,17 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import net.ornithemc.osl.entrypoints.api.ModInitializer; -public class MaLiLib +public class MaLiLib implements ModInitializer { public static final Logger LOGGER = LogManager.getLogger(MaLiLibReference.MOD_ID); + @Override + public void init() + { + } + public static boolean canShowCoordinates() { return MaLiLibConfigs.Generic.HIDE_ALL_COORDINATES.getBooleanValue() == false; diff --git a/src/main/java/malilib/MaLiLibConfigPanel.java b/src/main/java/malilib/MaLiLibConfigPanel.java deleted file mode 100644 index adfef89793..0000000000 --- a/src/main/java/malilib/MaLiLibConfigPanel.java +++ /dev/null @@ -1,11 +0,0 @@ -package malilib; - -import malilib.gui.config.liteloader.RedirectingConfigPanel; - -public class MaLiLibConfigPanel extends RedirectingConfigPanel -{ - public MaLiLibConfigPanel() - { - super(MaLiLibConfigScreen::create); - } -} diff --git a/src/main/java/malilib/compat/modmenu/ModMenuImpl.java b/src/main/java/malilib/compat/modmenu/ModMenuImpl.java new file mode 100644 index 0000000000..2417032172 --- /dev/null +++ b/src/main/java/malilib/compat/modmenu/ModMenuImpl.java @@ -0,0 +1,19 @@ +package malilib.compat.modmenu; + +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; +import malilib.MaLiLibConfigScreen; +import malilib.gui.BaseScreen; + +public class ModMenuImpl implements ModMenuApi +{ + @Override + public ConfigScreenFactory getModConfigScreenFactory() + { + return (currentScreen) -> { + BaseScreen screen = MaLiLibConfigScreen.create(); + screen.setParent(currentScreen); + return screen; + }; + } +} \ No newline at end of file diff --git a/src/main/java/malilib/config/util/ConfigUtils.java b/src/main/java/malilib/config/util/ConfigUtils.java index 8255179b98..f2bb511dcb 100644 --- a/src/main/java/malilib/config/util/ConfigUtils.java +++ b/src/main/java/malilib/config/util/ConfigUtils.java @@ -9,7 +9,6 @@ import java.util.List; import java.util.Map; import java.util.function.Predicate; -import com.mumfrey.liteloader.core.LiteLoader; import org.apache.commons.lang3.StringUtils; import net.minecraft.util.text.TextFormatting; @@ -38,7 +37,7 @@ public class ConfigUtils { public static Path getConfigDirectory() { - return LiteLoader.getCommonConfigFolder().toPath(); + return FileUtils.getMinecraftDirectory().resolve("config"); } /** diff --git a/src/main/java/malilib/gui/BaseScreen.java b/src/main/java/malilib/gui/BaseScreen.java index 2b05642c84..c1b5816727 100644 --- a/src/main/java/malilib/gui/BaseScreen.java +++ b/src/main/java/malilib/gui/BaseScreen.java @@ -1,6 +1,5 @@ package malilib.gui; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; @@ -695,7 +694,7 @@ public boolean isMouseOver(int mouseX, int mouseY) } @Override - public void handleKeyboardInput() throws IOException + public void handleKeyboardInput() { if (Keyboard.getEventKeyState() == false && this.onKeyReleased(Keyboard.getEventKey(), 0, 0)) diff --git a/src/main/java/malilib/gui/config/liteloader/RedirectingConfigPanel.java b/src/main/java/malilib/gui/config/liteloader/RedirectingConfigPanel.java deleted file mode 100644 index 86b6568980..0000000000 --- a/src/main/java/malilib/gui/config/liteloader/RedirectingConfigPanel.java +++ /dev/null @@ -1,41 +0,0 @@ -package malilib.gui.config.liteloader; - -import java.util.function.Supplier; -import com.mumfrey.liteloader.modconfig.AbstractConfigPanel; -import com.mumfrey.liteloader.modconfig.ConfigPanelHost; - -import malilib.gui.BaseScreen; - -public abstract class RedirectingConfigPanel extends AbstractConfigPanel -{ - protected final Supplier configScreenFactory; - - public RedirectingConfigPanel(Supplier configScreenFactory) - { - this.configScreenFactory = configScreenFactory; - } - - @Override - public void onPanelHidden() - { - // NO-OP - } - - @Override - protected void addOptions(ConfigPanelHost host) - { - BaseScreen.openScreen(this.configScreenFactory.get()); - } - - @Override - public String getPanelTitle() - { - return ""; - } - - // This is mainly useful for the LiteFabric mod or related things - public Supplier getConfigScreenFactory() - { - return this.configScreenFactory; - } -} diff --git a/src/main/java/malilib/gui/widget/list/entry/config/list/StatusEffectListConfigWidget.java b/src/main/java/malilib/gui/widget/list/entry/config/list/StatusEffectListConfigWidget.java index e914bfd5e7..898c8b7535 100644 --- a/src/main/java/malilib/gui/widget/list/entry/config/list/StatusEffectListConfigWidget.java +++ b/src/main/java/malilib/gui/widget/list/entry/config/list/StatusEffectListConfigWidget.java @@ -42,9 +42,9 @@ public static List getSortedEffectList() { List effects = new ArrayList<>(); - for (Potion effect : Potion.REGISTRY) + for (Object effect : Potion.REGISTRY) { - effects.add(effect); + effects.add((Potion) effect); } effects.sort(Comparator.comparing(StatusEffectListConfig::getRegistryName)); diff --git a/src/main/java/malilib/util/StringUtils.java b/src/main/java/malilib/util/StringUtils.java index 3cc17a7147..43c61795b9 100644 --- a/src/main/java/malilib/util/StringUtils.java +++ b/src/main/java/malilib/util/StringUtils.java @@ -6,11 +6,12 @@ import java.util.Collections; import java.util.List; import java.util.Locale; +import java.util.Optional; import java.util.function.Consumer; import java.util.function.Function; import javax.annotation.Nullable; -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.core.LiteLoader; +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ServerData; @@ -63,11 +64,11 @@ public static String getModVersionString(String modId) { try { - LiteMod mod = LiteLoader.getInstance().getMod(modId); + Optional container = FabricLoader.getInstance().getModContainer(modId); - if (mod != null) + if (container.isPresent()) { - return mod.getVersion(); + return container.get().getMetadata().getVersion().getFriendlyString(); } } catch (Exception ignore) {} diff --git a/src/main/java/malilib/util/game/wrap/GameUtils.java b/src/main/java/malilib/util/game/wrap/GameUtils.java index 6c4c0942af..d60fc1f943 100644 --- a/src/main/java/malilib/util/game/wrap/GameUtils.java +++ b/src/main/java/malilib/util/game/wrap/GameUtils.java @@ -177,7 +177,7 @@ public static void profilerPush(String name) public static void profilerPush(Supplier nameSupplier) { - getClient().profiler.func_194340_a(nameSupplier); + getClient().profiler.m_4994039(nameSupplier); } public static void profilerSwap(String name) @@ -187,7 +187,7 @@ public static void profilerSwap(String name) public static void profilerSwap(Supplier nameSupplier) { - getClient().profiler.func_194339_b(nameSupplier); + getClient().profiler.m_3681950(nameSupplier); } public static void profilerPop() diff --git a/src/main/java/malilib/util/game/wrap/RegistryUtils.java b/src/main/java/malilib/util/game/wrap/RegistryUtils.java index 74141f4525..3aff558353 100644 --- a/src/main/java/malilib/util/game/wrap/RegistryUtils.java +++ b/src/main/java/malilib/util/game/wrap/RegistryUtils.java @@ -66,9 +66,9 @@ public static List getSortedBlockList() { List blocks = new ArrayList<>(); - for (Block block : Block.REGISTRY) + for (Object block : Block.REGISTRY) { - blocks.add(block); + blocks.add((Block) block); } blocks.sort(Comparator.comparing(RegistryUtils::getBlockIdStr)); @@ -115,9 +115,9 @@ public static List getSortedItemList() { List items = new ArrayList<>(); - for (Item item : Item.REGISTRY) + for (Object item : Item.REGISTRY) { - items.add(item); + items.add((Item) item); } items.sort(Comparator.comparing(RegistryUtils::getItemIdStr)); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000000..8f6b8ebd8b --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,39 @@ +{ + "schemaVersion": 1, + "id": "malilib", + "name": "MaLiLib", + "version": "${mod_version}", + + "description": "A library mod required by masa's client-side mods", + "authors": [ + "masa" + ], + "contact": { + "homepage": "https://www.curseforge.com/minecraft/mc-mods/malilib", + "issues": "https://github.com/maruohon/malilib/issues", + "sources": "https://github.com/maruohon/malilib", + "twitter": "https://twitter.com/maruohon", + "discord": "https://discordapp.com/channels/211786369951989762/453662800460644354/" + }, + + "license": "LGPLv3", + "icon": "assets/malilib/icon.png", + "environment": "client", + "entrypoints": { + "init": [ + "malilib.MaLiLib" + ], + "modmenu": [ + "malilib.compat.modmenu.ModMenuImpl" + ] + }, + "mixins": [ + "mixins.malilib.json" + ], + + "depends": { + "minecraft": "1.12.2", + "osl-entrypoints": "*", + "osl-resource-loader": "*" + } +} diff --git a/src/main/resources/litemod.json b/src/main/resources/litemod.json deleted file mode 100644 index 6e913dbc54..0000000000 --- a/src/main/resources/litemod.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "malilib", - "mcversion": "1.12.2", - "mixinConfigs": [ "mixins.malilib.json" ] -} \ No newline at end of file diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info deleted file mode 100644 index 87bd635f5d..0000000000 --- a/src/main/resources/mcmod.info +++ /dev/null @@ -1,16 +0,0 @@ -[ - { - "modid": "malilib", - "name": "MaLiLib", - "description": "Library mod for masa's client-side mods", - "version": "${mod_version}", - "mcversion": "${minecraft_version}", - "url": "https://www.curseforge.com/minecraft/mc-mods/malilib", - "updateUrl": "", - "authorList": [ "masa" ], - "credits": "", - "logoFile": "", - "screenshots": [], - "dependencies": [] - } -] diff --git a/src/main/resources/mixins.malilib.json b/src/main/resources/mixins.malilib.json index 28c64ef8bf..96efaa624c 100644 --- a/src/main/resources/mixins.malilib.json +++ b/src/main/resources/mixins.malilib.json @@ -2,8 +2,7 @@ "required": true, "package": "malilib.mixin", "compatibilityLevel": "JAVA_8", - "minVersion": "0.7", - "refmap": "mixins.malilib.refmap.json", + "minVersion": "0.8", "client": [ "access.AbstractHorseMixin", "access.GuiContainerMixin",