diff --git a/.gitignore b/.gitignore index 6bbc2ab..3c37caf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,118 @@ -# eclipse -bin -*.launch -.settings -.metadata -.classpath -.project - -# idea -out +# User-specific stuff +.idea/ + +*.iml *.ipr *.iws -*.iml -.idea -# gradle -build +# IntelliJ +out/ +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + .gradle +build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Cache of project +.gradletasknamecache + +**/build/ -# other -eclipse -run -images +# Common working directory +run/ -# Files from Forge MDK -forge*changelog.txt +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar diff --git a/build.gradle b/build.gradle index 7f7601f..c68c126 100644 --- a/build.gradle +++ b/build.gradle @@ -1,134 +1,138 @@ -buildscript { - repositories { - maven { url = 'https://files.minecraftforge.net/maven' } - jcenter() - mavenCentral() - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true - } -} -apply plugin: 'net.minecraftforge.gradle' -// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. -apply plugin: 'eclipse' -apply plugin: 'maven-publish' - - -ext.configFile = file('build.properties') -ext.config = parseConfig(configFile) - -version = config.version -group = "schauweg.${config.mod_id}" // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = config.mod_name - -sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. - -minecraft { - // The mappings can be changed at any time, and must be in the following format. - // snapshot_YYYYMMDD Snapshot are built nightly. - // stable_# Stables are built at the discretion of the MCP team. - // Use non-default mappings at your own risk. they may not always work. - // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'snapshot', version: '20190719-1.14.3' - // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. - - // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') - - // Default run configurations. - // These can be tweaked, removed, or duplicated as needed. - runs { - client { - workingDirectory project.file('run') - - // Recommended logging data for a userdev environment - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - - // Recommended logging level for the console - property 'forge.logging.console.level', 'debug' - - mods { - examplemod { - source sourceSets.main - } - } - } +plugins { + id 'fabric-loom' version '1.0-SNAPSHOT' + id 'maven-publish' - server { - workingDirectory project.file('run') + id "com.modrinth.minotaur" version "2.+" + id 'com.matthewprenger.cursegradle' version '1.4.0' +} - // Recommended logging data for a userdev environment - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' +sourceCompatibility = JavaVersion.VERSION_17 +targetCompatibility = JavaVersion.VERSION_17 - // Recommended logging level for the console - property 'forge.logging.console.level', 'debug' +archivesBaseName = "${project.mod_name} ${project.mod_version} (${project.minecraft_version})" +version = project.mod_version +group = project.maven_group +def CHANGELOG = new File("./gradle", "CHANGELOG.md").text +def SUPPORTED_VERSIONS = Arrays.asList(project.supported_versions.split(',')) - mods { - examplemod { - source sourceSets.main - } - } - } +repositories { + maven { + name = 'Cloth Config' + url = 'https://maven.shedaniel.me' + } + maven { + name = 'TerraformersMC' + url = 'https://maven.terraformersmc.com/releases' } } dependencies { - minecraft 'net.minecraftforge:forge:1.14.4-28.1.0' -} + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" -processResources { - // replace stuff in mcmod.info, nothing else - from(sourceSets.main.resources.srcDirs) { - include 'META-INF/mods.toml' + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - // replace version and mcversion - expand 'version': version + //Cloth Config + modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config}") { + exclude(group: "net.fabricmc.fabric-api") } + include("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config}") - // copy everything else, thats not the mods.toml - from(sourceSets.main.resources.srcDirs) { - exclude 'META-INF/mods.toml', '**/psd/**' + //Modmenu + modImplementation("com.terraformersmc:modmenu:${project.modmenu}") { + exclude(group: "net.fabricmc.fabric-api") } } -def parseConfig(File config) { - config.withReader { - def prop = new Properties() - prop.load(it) - return (new ConfigSlurper().parse(prop)) +processResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": project.version } } -jar { - archiveName = "${config.mc_version}-${baseName}-${version}.${extension}" - - manifest { - attributes([ - "Specification-Title": "${config.mod_id}", - "Specification-Vendor": "schauweg", - "Specification-Version": "1", // We are version 1 of ourselves - "Implementation-Title": "${config.mod_id}", - "Implementation-Version": "${version}", - "Implementation-Vendor" :"schauweg", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") - ]) - } +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" + it.options.release = 17 +} + +java { + withSourcesJar() } -def reobfFile = file("$buildDir/reobfJar/output.jar") -def reobfArtifact = artifacts.add('default', reobfFile) { - type 'jar' - builtBy 'reobfJar' + +jar { + from("LICENSE") { + rename { "${it}_${archivesBaseName}" } + } } +// configure the maven publication +// configure the maven publication publishing { publications { mavenJava(MavenPublication) { - artifact reobfArtifact + // add all the jars that should be included when publishing to maven + artifact(remapJar) { + builtBy remapJar + } + artifact(sourcesJar) { + builtBy remapSourcesJar + } } } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. repositories { - maven { - url "file:///${project.projectDir}/mcmodsrepo" + // 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. + } +} + +import com.modrinth.minotaur.dependencies.ModDependency +if (System.getenv().MODRINTH_TOKEN) modrinth { + projectId = project.modrinth_id + versionName = archivesBaseName + versionNumber = "${project.mod_version}-${project.minecraft_version}" + versionType = "beta" + uploadFile = tasks.remapJar + gameVersions = [project.minecraft_version] + loaders = ["fabric"] + dependencies = [ + new ModDependency("fabric-api", "required"), + new ModDependency("cloth-config", "embedded"), + new ModDependency("modmenu", "optional") + ] +} + +if (System.getenv().CURSEFORGE_API_KEY) curseforge { + apiKey = System.getenv().CURSEFORGE_API_KEY + + project { + id = project.curseforge_id + addGameVersion "Fabric" + for (final def cf_ver in SUPPORTED_VERSIONS) addGameVersion cf_ver + + changelog = CHANGELOG + releaseType = "beta" + + mainArtifact(remapJar) { + displayName = archivesBaseName + relations { + requiredDependency "fabric-api" + embeddedLibrary "cloth-config" + + optionalDependency 'modmenu' + } } + + afterEvaluate { uploadTask.dependsOn(remapJar) } } + + options { forgeGradleIntegration = false } } \ No newline at end of file diff --git a/build.properties b/build.properties deleted file mode 100644 index a05b416..0000000 --- a/build.properties +++ /dev/null @@ -1,5 +0,0 @@ -mod_name=TimeToLive -mod_id=timetolive -version=0.1 -mc_version=1.14.4 -dir_output=../Build Output/TTL/ diff --git a/gradle.properties b/gradle.properties index 784899a..a900c16 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,26 @@ -# Sets default memory used for gradle commands. Can be overridden by user or command line properties. -# This is required to provide enough memory for the Minecraft decompilation process. +# Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=false + +# Fabric Properties +# check these on https://fabricmc.net/versions.html + minecraft_version=1.19.2 + yarn_mappings=1.19.2+build.28 + loader_version=0.14.10 + +#Fabric api + fabric_version=0.64.0+1.19.2 + +# Mod Properties + mod_version = 0.4 + maven_group = schauweg + archives_base_name = timetolive + mod_name = Time To Live + +# Dependencies + cloth_config=8.0.75 + modmenu=4.0.5 + +# Upload configs + curseforge_id = 357220 + modrinth_id = rCeI5tOW + supported_versions=1.19.2 \ No newline at end of file diff --git a/gradle/CHANGELOG.md b/gradle/CHANGELOG.md new file mode 100644 index 0000000..9846fad --- /dev/null +++ b/gradle/CHANGELOG.md @@ -0,0 +1 @@ +-Update to Minecraft 1.19.2 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7a3265e..7454180 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 949819d..ffed3a2 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-7.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip diff --git a/gradlew b/gradlew index cccdd3d..c53aefa 100644 --- a/gradlew +++ b/gradlew @@ -1,78 +1,129 @@ -#!/usr/bin/env sh +#!/bin/sh + +# +# 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. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## -## -## 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/master/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_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${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="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # 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 + # Determine the Java command to use to start the JVM. 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 @@ -81,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + 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. Please set the JAVA_HOME variable in your environment to match the @@ -89,84 +140,95 @@ location of your Java installation." 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*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + 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" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; 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 # 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=$((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" - -# 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 +# 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 \ + "$@" + +# 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 f955316..107acd3 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ 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= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe 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. @@ -35,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% @@ -45,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 new file mode 100644 index 0000000..5b60df3 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +pluginManagement { + repositories { + jcenter() + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + gradlePluginPortal() + } +} diff --git a/src/main/java/schauweg/timetolive/CountdownRenderer.java b/src/main/java/schauweg/timetolive/CountdownRenderer.java new file mode 100644 index 0000000..78b150b --- /dev/null +++ b/src/main/java/schauweg/timetolive/CountdownRenderer.java @@ -0,0 +1,95 @@ +package schauweg.timetolive; + +import com.google.common.collect.Iterables; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.Camera; +import net.minecraft.client.render.Frustum; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.Entity; +import net.minecraft.entity.TntEntity; +import net.minecraft.entity.mob.CreeperEntity; +import net.minecraft.util.math.Matrix4f; +import net.minecraft.util.math.Quaternion; +import net.minecraft.util.math.Vec3d; +import schauweg.timetolive.config.TTLConfigManger; +import schauweg.timetolive.mixin.CreeperEntityMixin; + +import java.util.stream.StreamSupport; + +public class CountdownRenderer { + + public static void render(MatrixStack matrices, float partialTicks, Camera camera, Matrix4f projection, Frustum capturedFrustum) { + MinecraftClient mc = MinecraftClient.getInstance(); + if(mc.world == null || !MinecraftClient.isHudEnabled()) { + return; + } + final Entity cameraEntity = camera.getFocusedEntity() != null ? camera.getFocusedEntity() : mc.player; //possible fix for optifine (see https://github.com/UpcraftLP/Orderly/issues/3) + assert cameraEntity != null : "Camera Entity must not be null!"; + + Vec3d cameraPos = camera.getPos(); + final Frustum frustum; + if(capturedFrustum != null) { + frustum = capturedFrustum; + } + else { + frustum = new Frustum(matrices.peek().getPositionMatrix(), projection); + frustum.setPosition(cameraPos.getX(), cameraPos.getY(), cameraPos.getZ()); + } + + StreamSupport.stream(mc.world.getEntities().spliterator(), false).filter(entity -> entity instanceof CreeperEntity && entity != cameraEntity && entity.isAlive() && Iterables.isEmpty(entity.getPassengersDeep()) && entity.shouldRender(cameraPos.getX(), cameraPos.getY(), cameraPos.getZ()) && (entity.ignoreCameraFrustum || frustum.isVisible(entity.getBoundingBox()))).map(CreeperEntity.class::cast).forEach(entity -> { + + if (entity.isIgnited()){ + int fuse = ((CreeperEntityMixin)entity).getFuseTime() - ((CreeperEntityMixin)entity).getCurrentFuseTime(); + renderCountdown(entity, matrices, partialTicks, camera, cameraEntity, fuse); + } + + }); + + StreamSupport.stream(mc.world.getEntities().spliterator(), false).filter(entity -> entity instanceof TntEntity && entity != cameraEntity && entity.isAlive() && Iterables.isEmpty(entity.getPassengersDeep()) && entity.shouldRender(cameraPos.getX(), cameraPos.getY(), cameraPos.getZ()) && (entity.ignoreCameraFrustum || frustum.isVisible(entity.getBoundingBox()))).map(TntEntity.class::cast).forEach(entity -> renderCountdown(entity, matrices, partialTicks, camera, cameraEntity, entity.getFuse())); + } + + + @SuppressWarnings( "deprecation" ) + private static void renderCountdown(Entity passedEntity, MatrixStack matrices, float partialTicks, Camera camera, Entity viewPoint, int fuse){ + MinecraftClient mc = MinecraftClient.getInstance(); + + matrices.push(); + double x = passedEntity.prevX + (passedEntity.getX() - passedEntity.prevX) * partialTicks; + double y = passedEntity.prevY + (passedEntity.getY() - passedEntity.prevY) * partialTicks; + double z = passedEntity.prevZ + (passedEntity.getZ() - passedEntity.prevZ) * partialTicks; + + EntityRenderDispatcher renderManager = MinecraftClient.getInstance().getEntityRenderDispatcher(); + matrices.translate(x - renderManager.camera.getPos().x, y - renderManager.camera.getPos().y + passedEntity.getHeight() + 0.5F, z - renderManager.camera.getPos().z); + + VertexConsumerProvider.Immediate immediate = mc.getBufferBuilders().getEntityVertexConsumers(); + Quaternion rotation = camera.getRotation().copy(); + rotation.scale(-1.0F); + matrices.multiply(rotation); + + matrices.scale(-0.025F, -0.025F, 0.025F); + + String time = TTLConfigManger.getConfig().isDisplayInTicks() ? fuse + " t" : ticksToTime(fuse); + float offset = (float)(-mc.textRenderer.getWidth(time)/2); + Matrix4f modelViewMatrix = matrices.peek().getPositionMatrix(); + mc.textRenderer.draw(time, offset, 0, 553648127, false, modelViewMatrix, immediate, true, 1056964608, 15728640); + mc.textRenderer.draw(time, offset, 0, -1, false, modelViewMatrix, immediate, false, 0, 15728640); + + matrices.pop(); + } + + private static String ticksToTime(int ticks){ + if(ticks > 20*3600){ + int h = ticks/20/3600; + return h+" h"; + } else if(ticks > 20*60){ + int m = ticks/20/60; + return m+" m"; + } else { + int s = ticks / 20; + int ms = (ticks % 20) / 2; + return s+"."+ms+" s"; + } + } +} diff --git a/src/main/java/schauweg/timetolive/Main.java b/src/main/java/schauweg/timetolive/Main.java index 3edf05c..0ba6b75 100644 --- a/src/main/java/schauweg/timetolive/Main.java +++ b/src/main/java/schauweg/timetolive/Main.java @@ -1,22 +1,18 @@ -package schauweg.timetolive; - -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.Mod; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -// The value here should match an entry in the META-INF/mods.toml file -@Mod(Main.MOD_ID) -public class Main -{ - - public static final String MOD_ID = "timetolive"; - - // Directly reference a log4j logger. - private static final Logger LOGGER = LogManager.getLogger(); - - public Main() { - MinecraftForge.EVENT_BUS.register(new TNTCountdownRenderer()); - } - -} +package schauweg.timetolive; + +import com.google.gson.FieldNamingPolicy; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import net.fabricmc.api.ClientModInitializer; +import schauweg.timetolive.config.TTLConfigManger; + +public class Main implements ClientModInitializer { + + public static final String MOD_ID = "timetolive"; + public static final Gson GSON = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).setPrettyPrinting().create(); + + @Override + public void onInitializeClient() { + TTLConfigManger.initializeConfig(); + } +} diff --git a/src/main/java/schauweg/timetolive/TNTCountdownRenderer.java b/src/main/java/schauweg/timetolive/TNTCountdownRenderer.java deleted file mode 100644 index b6b8120..0000000 --- a/src/main/java/schauweg/timetolive/TNTCountdownRenderer.java +++ /dev/null @@ -1,119 +0,0 @@ -package schauweg.timetolive; - -import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.culling.Frustum; -import net.minecraft.client.renderer.entity.EntityRendererManager; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.TNTEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; -import org.lwjgl.opengl.GL11; - -public class TNTCountdownRenderer { - - @SubscribeEvent - public void onRenderWorldLast(RenderWorldLastEvent event) { - - Minecraft mc = Minecraft.getInstance(); - - Entity cameraEntity = mc.getRenderViewEntity(); - BlockPos renderingVector = cameraEntity.getPosition(); - Frustum frustum = new Frustum(); - - float partialTicks = event.getPartialTicks(); - double viewX = cameraEntity.lastTickPosX + (cameraEntity.posX - cameraEntity.lastTickPosX) * partialTicks; - double viewY = cameraEntity.lastTickPosY + (cameraEntity.posY - cameraEntity.lastTickPosY) * partialTicks; - double viewZ = cameraEntity.lastTickPosZ + (cameraEntity.posZ - cameraEntity.lastTickPosZ) * partialTicks; - frustum.setPosition(viewX, viewY, viewZ); - - ClientWorld client = mc.world; - Iterable entitiesById = client.getAllEntities(); - - for(Entity entity : entitiesById) { - if (entity != null && entity instanceof TNTEntity && entity.isInRangeToRender3d(renderingVector.getX(), renderingVector.getY(), renderingVector.getZ()) && (entity.ignoreFrustumCheck || frustum.isBoundingBoxInFrustum(entity.getBoundingBox()))){ - renderFuseCountdown((TNTEntity) entity, partialTicks, 0.5F); - } - } - - } - - private void renderFuseCountdown(TNTEntity passedEntity, float partialTicks, float nameOffset) { - Minecraft mc = Minecraft.getInstance(); - float pastTranslate = 0F; - - int fuse = passedEntity.getFuse(); - - String fuseText = ticksToTime(fuse); - - double x = passedEntity.lastTickPosX + (passedEntity.posX - passedEntity.lastTickPosX) * partialTicks; - double y = passedEntity.lastTickPosY + (passedEntity.posY - passedEntity.lastTickPosY) * partialTicks; - double z = passedEntity.lastTickPosZ + (passedEntity.posZ - passedEntity.lastTickPosZ) * partialTicks; - - EntityRendererManager renderManager = Minecraft.getInstance().getRenderManager(); - double renderPosX = ObfuscationReflectionHelper.getPrivateValue(EntityRendererManager.class, renderManager, "field_78725_b"); //renderPosX - double renderPosY = ObfuscationReflectionHelper.getPrivateValue(EntityRendererManager.class, renderManager, "field_78726_c"); //renderPosY - double renderPosZ = ObfuscationReflectionHelper.getPrivateValue(EntityRendererManager.class, renderManager, "field_78723_d"); //renderPosZ - - GlStateManager.translatef(0F, pastTranslate, 0F); - - float scale = 0.026666672F; - - GlStateManager.pushMatrix(); - GlStateManager.translatef((float) (x - renderPosX), (float) (y - renderPosY + passedEntity.getHeight()) + nameOffset, (float) (z - renderPosZ)); - GL11.glNormal3f(0.0F, 1.0F, 0.0F); - GlStateManager.rotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F); - GlStateManager.rotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F); - GlStateManager.scalef(-scale, -scale, scale); - boolean lighting = GL11.glGetBoolean(GL11.GL_LIGHTING); - GlStateManager.disableLighting(); - GlStateManager.depthMask(false); - GlStateManager.disableDepthTest(); - GlStateManager.disableTexture(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder buffer = tessellator.getBuffer(); - - int j = mc.fontRenderer.getStringWidth(fuseText) / 2; - - buffer.begin(7, DefaultVertexFormats.POSITION_COLOR); - buffer.pos((double)(-j - 1), (double)(-1 ), 0.0D).color(0, 0, 0, 64).endVertex(); - buffer.pos((double)(-j - 1), (double)(8), 0.0D).color(0, 0, 0, 64).endVertex(); - buffer.pos((double)(j + 1), (double)(8), 0.0D).color(0, 0, 0, 64).endVertex(); - buffer.pos((double)(j + 1), (double)(-1), 0.0D).color(0, 0, 0, 64).endVertex(); - tessellator.draw(); - - GlStateManager.enableTexture(); - mc.fontRenderer.drawString(fuseText, -j,0, 553648127); - GlStateManager.enableDepthTest(); - GlStateManager.depthMask(true); - if(lighting) - GlStateManager.enableLighting(); - mc.fontRenderer.drawString(fuseText, -j,0, -1); - GlStateManager.disableBlend(); - GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); - GlStateManager.popMatrix(); - } - - - private static String ticksToTime(int ticks){ - if(ticks > 20*3600){ - int h = ticks/20/3600; - return h+" h"; - } else if(ticks > 20*60){ - int m = ticks/20/60; - return m+" m"; - } else { - int s = ticks / 20; - int ms = (ticks % 20) / 2; - return s+"."+ms+" s"; - } - } -} diff --git a/src/main/java/schauweg/timetolive/config/TTLConfig.java b/src/main/java/schauweg/timetolive/config/TTLConfig.java new file mode 100644 index 0000000..5daa73a --- /dev/null +++ b/src/main/java/schauweg/timetolive/config/TTLConfig.java @@ -0,0 +1,23 @@ +package schauweg.timetolive.config; + +public class TTLConfig { + + private boolean overlayActive = true; + private boolean displayInTicks = false; + + public boolean isOverlayActive() { + return overlayActive; + } + + public void setOverlayActive(boolean overlayActive) { + this.overlayActive = overlayActive; + } + + public boolean isDisplayInTicks() { + return displayInTicks; + } + + public void setDisplayInTicks(boolean displayInTicks) { + this.displayInTicks = displayInTicks; + } +} diff --git a/src/main/java/schauweg/timetolive/config/TTLConfigManger.java b/src/main/java/schauweg/timetolive/config/TTLConfigManger.java new file mode 100644 index 0000000..9873eac --- /dev/null +++ b/src/main/java/schauweg/timetolive/config/TTLConfigManger.java @@ -0,0 +1,71 @@ +package schauweg.timetolive.config; + +import net.fabricmc.loader.api.FabricLoader; +import schauweg.timetolive.Main; + +import java.io.*; + +public class TTLConfigManger { + + private static File file; + private static TTLConfig config; + + private static void prepareConfigFile() { + if (file != null) { + return; + } + file = FabricLoader.getInstance().getConfigDir().resolve(Main.MOD_ID+".json").toFile(); + } + + public static TTLConfig initializeConfig() { + if (config != null) { + return config; + } + + config = new TTLConfig(); + load(); + + return config; + } + + private static void load() { + prepareConfigFile(); + + try { + if (!file.exists()) { + save(); + } + if (file.exists()) { + BufferedReader br = new BufferedReader(new FileReader(file)); + + TTLConfig parsed = Main.GSON.fromJson(br, TTLConfig.class); + if (parsed != null) { + config = parsed; + } + } + } catch (FileNotFoundException e) { + System.err.println("Couldn't load Login Toast configuration file; reverting to defaults"); + e.printStackTrace(); + } + } + + public static void save() { + prepareConfigFile(); + + String jsonString = Main.GSON.toJson(config); + + try (FileWriter fileWriter = new FileWriter(file)) { + fileWriter.write(jsonString); + } catch (IOException e) { + System.err.println("Couldn't save Login Toast configuration file"); + e.printStackTrace(); + } + } + + public static TTLConfig getConfig() { + if (config == null) { + config = new TTLConfig(); + } + return config; + } +} diff --git a/src/main/java/schauweg/timetolive/config/TTLConfigScreen.java b/src/main/java/schauweg/timetolive/config/TTLConfigScreen.java new file mode 100644 index 0000000..ce5132e --- /dev/null +++ b/src/main/java/schauweg/timetolive/config/TTLConfigScreen.java @@ -0,0 +1,51 @@ +package schauweg.timetolive.config; + +import me.shedaniel.clothconfig2.api.ConfigBuilder; +import me.shedaniel.clothconfig2.api.ConfigCategory; +import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.text.Text; + +import java.util.function.Function; + +public class TTLConfigScreen { + + public static Screen getScreen(Screen parent){ + TTLConfig config = TTLConfigManger.getConfig(); + + ConfigBuilder builder = ConfigBuilder.create() + .setParentScreen(parent) + .setTitle(Text.translatable("timetolive.config.menu")); + + ConfigCategory general = builder.getOrCreateCategory(Text.translatable("timetolive.config.general")); + ConfigEntryBuilder entryBuilder = builder.entryBuilder(); + + general.addEntry(entryBuilder.startBooleanToggle(Text.translatable("timetolive.config.option.enable"), config.isOverlayActive()) + .setDefaultValue(true) + .setSaveConsumer(config::setOverlayActive) + .setYesNoTextSupplier(getYesNoSupplier("timetolive.config.option.enable.enabled", "timetolive.config.option.enable.disabled")) + .build()); + + + general.addEntry(entryBuilder.startBooleanToggle(Text.translatable("timetolive.config.option.displayticks"), config.isDisplayInTicks()) + .setDefaultValue(false) + .setSaveConsumer(config::setDisplayInTicks) + .setYesNoTextSupplier(getYesNoSupplier("timetolive.config.option.displayticks.ticks", "timetolive.config.option.displayticks.seconds")) + .build()); + + builder.setSavingRunnable(TTLConfigManger::save); + + return builder.build(); + } + + + private static Function getYesNoSupplier(String keyYes, String keyNo){ + return x ->{ + if (x) + return Text.translatable(keyYes); + else + return Text.translatable(keyNo); + }; + } + +} diff --git a/src/main/java/schauweg/timetolive/mixin/CreeperEntityMixin.java b/src/main/java/schauweg/timetolive/mixin/CreeperEntityMixin.java new file mode 100644 index 0000000..2ab9b5f --- /dev/null +++ b/src/main/java/schauweg/timetolive/mixin/CreeperEntityMixin.java @@ -0,0 +1,17 @@ +package schauweg.timetolive.mixin; + + +import net.minecraft.entity.mob.CreeperEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(CreeperEntity.class) +public interface CreeperEntityMixin { + + @Accessor("currentFuseTime") + int getCurrentFuseTime(); + + @Accessor("fuseTime") + int getFuseTime(); + +} diff --git a/src/main/java/schauweg/timetolive/mixin/WorldRendererMixin.java b/src/main/java/schauweg/timetolive/mixin/WorldRendererMixin.java new file mode 100644 index 0000000..955e08f --- /dev/null +++ b/src/main/java/schauweg/timetolive/mixin/WorldRendererMixin.java @@ -0,0 +1,26 @@ +package schauweg.timetolive.mixin; + +import net.minecraft.client.render.*; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.math.Matrix4f; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import schauweg.timetolive.CountdownRenderer; +import schauweg.timetolive.config.TTLConfigManger; + +@Mixin(WorldRenderer.class) +public class WorldRendererMixin { + + @Shadow + private Frustum capturedFrustum; + + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;checkEmpty(Lnet/minecraft/client/util/math/MatrixStack;)V", ordinal = 0)) + private void render(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f projection, CallbackInfo ci) { + if (!TTLConfigManger.getConfig().isOverlayActive()) return; + CountdownRenderer.render(matrices, tickDelta, camera, projection, this.capturedFrustum); + } + +} diff --git a/src/main/java/schauweg/timetolive/modmenu/TTLModMenuIntegration.java b/src/main/java/schauweg/timetolive/modmenu/TTLModMenuIntegration.java new file mode 100644 index 0000000..2924e0c --- /dev/null +++ b/src/main/java/schauweg/timetolive/modmenu/TTLModMenuIntegration.java @@ -0,0 +1,14 @@ +package schauweg.timetolive.modmenu; + +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; +import schauweg.timetolive.config.TTLConfigScreen; + + +public class TTLModMenuIntegration implements ModMenuApi { + + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return TTLConfigScreen::getScreen; + } +} diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml deleted file mode 100644 index be0abcb..0000000 --- a/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,12 +0,0 @@ -modLoader="javafml" #mandatory -loaderVersion="[28,)" #mandatory (28 is current forge version) - -[[mods]] #mandatory -modId="timetolive" #mandatory -version="${version}" -displayName="Time to Live" -logoFile="logo.png" #optional -authors="Schauweg" #optional -description=''' -This mod simply displays a countdown timer of the remaining time a TNT entity has left. -''' \ No newline at end of file diff --git a/src/main/resources/assets/timetolive/icon.png b/src/main/resources/assets/timetolive/icon.png new file mode 100644 index 0000000..f266bfe Binary files /dev/null and b/src/main/resources/assets/timetolive/icon.png differ diff --git a/src/main/resources/assets/timetolive/lang/en_us.json b/src/main/resources/assets/timetolive/lang/en_us.json new file mode 100644 index 0000000..4f5f57d --- /dev/null +++ b/src/main/resources/assets/timetolive/lang/en_us.json @@ -0,0 +1,10 @@ +{ + "timetolive.config.menu": "Time To Live Config Menu", + "timetolive.config.general": "General", + "timetolive.config.option.enable": "Enable or Disable the countdown", + "timetolive.config.option.enable.enabled": "Enabled", + "timetolive.config.option.enable.disabled": "Disabled", + "timetolive.config.option.displayticks": "Display the countdown as ticks or seconds", + "timetolive.config.option.displayticks.ticks": "Ticks", + "timetolive.config.option.displayticks.seconds": "Seconds" +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..dac0f00 --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,29 @@ +{ + "schemaVersion": 1, + "id": "timetolive", + "version": "${version}", + + "name": "Time To Live", + "description": "Displays a countdown above a TNT entity!", + "authors": [ + "Schauweg" + ], + "icon": "assets/timetolive/icon.png", + "environment": "client", + "entrypoints": { + "client": [ + "schauweg.timetolive.Main" + ], + "modmenu": [ "schauweg.timetolive.modmenu.TTLModMenuIntegration" ] + }, + "mixins": [ + "timetolive.mixins.json" + ], + + "depends": { + "fabricloader": ">=0.14.8", + "fabric": "*", + "minecraft": "1.19.x", + "java": ">=17" + } +} diff --git a/src/main/resources/logo.png b/src/main/resources/logo.png deleted file mode 100644 index 4470d92..0000000 Binary files a/src/main/resources/logo.png and /dev/null differ diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta deleted file mode 100644 index 42ab490..0000000 --- a/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,7 +0,0 @@ -{ - "pack": { - "description": "examplemod resources", - "pack_format": 4, - "_comment": "A pack_format of 4 requires json lang files. Note: we require v4 pack meta for all mods." - } -} diff --git a/src/main/resources/timetolive.mixins.json b/src/main/resources/timetolive.mixins.json new file mode 100644 index 0000000..7f95398 --- /dev/null +++ b/src/main/resources/timetolive.mixins.json @@ -0,0 +1,12 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "schauweg.timetolive.mixin", + "client": [ + "WorldRendererMixin", + "CreeperEntityMixin" + ], + "injectors": { + "defaultRequire": 1 + } +}