diff --git a/build.gradle.kts b/build.gradle.kts index 7296096..6c026e5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,6 +21,7 @@ architectury.common(stonecutter.tree.branches.mapNotNull { if (stonecutter.current.project !in it) null else it.prop("loom.platform") }) + repositories { maven("https://maven.neoforged.net/releases/") @@ -37,7 +38,18 @@ dependencies { minecraft("com.mojang:minecraft:$minecraft") mappings(loom.officialMojangMappings()) - modApi("dev.architectury:architectury:${mod.dep("architectury_version")}") + var archversion = "idk" + println(minecraft) + when(minecraft) { // NOTE: add more entries if you want to add more versions + "1.20.1" -> archversion = "9.2.14" + "1.20.4" -> archversion = "11.1.17" + "1.21.9" -> archversion = "18.0.5" + else -> archversion = "19.0.1" + } + + // modImplementation("dev.architectury:architectury:$rootProject.architectury_api_version") + // modImplementation("dev.architectury:architectury:${archversion}") + modImplementation("dev.architectury:architectury:${archversion}") if (loader == "fabric") { modImplementation("net.fabricmc:fabric-loader:${mod.dep("fabric_loader")}") // mappings("net.fabricmc:yarn:$minecraft+build.${mod.dep("yarn_build")}:v2") @@ -45,16 +57,17 @@ dependencies { //some features (like automatic resource loading from non vanilla namespaces) work only with fabric API installed //for example translations from assets/modid/lang/en_us.json won't be working, same stuff with textures //but we keep runtime only to not accidentally depend on fabric's api, because it doesn't exist in neo/forge + println(archversion) modRuntimeOnly("net.fabricmc.fabric-api:fabric-api:${mod.dep("fabric_version")}") modImplementation("net.fabricmc:fabric-language-kotlin:1.13.10+kotlin.2.3.20") - modApi("dev.architectury:architectury-fabric:${mod.dep("architectury_version")}") + modApi("dev.architectury:architectury-fabric:${archversion}") } if (loader == "forge") { "forge"("net.minecraftforge:forge:${minecraft}-${mod.dep("forge_loader")}") //implementation("thedarkcolour:kotlinforforge:1.16.0") // mappings("net.fabricmc:yarn:$minecraft+build.${mod.dep("yarn_build")}:v2") - modApi("dev.architectury:architectury-forge:${mod.dep("architectury_version")}") + modApi("dev.architectury:architectury-forge:${archversion}") "io.github.llamalad7:mixinextras-forge:${mod.dep("mixin_extras")}".let { implementation(it) include(it) @@ -69,7 +82,8 @@ dependencies { // } // }) - modApi("dev.architectury:architectury-forge:${mod.dep("architectury_version")}") + if (minecraft=="1.21.9" || minecraft=="1.21.11") modApi("dev.architectury:architectury-neoforge:${archversion}") + else modApi("dev.architectury:architectury-forge:${archversion}") // NOTE: this could be wrong implementation("thedarkcolour:kotlinforforge-neoforge:6.0.0") } } @@ -225,3 +239,205 @@ tasks.build { group = "versioned" description = "Must run through 'chiseledBuild'" } + +//import java.util.* +// +//plugins { +// id("dev.architectury.loom") +// id("architectury-plugin") +// id("me.modmuss50.mod-publish-plugin") +// id("com.gradleup.shadow") +//} +// +//val minecraft = stonecutter.current.version +//val loader = loom.platform.get().name.lowercase() +// +//version = "${mod.version}+$minecraft" +//group = mod.group +//base { +// archivesName.set("${mod.id}-$loader") +//} +// +//architectury.common(stonecutter.tree.branches.mapNotNull { +// if (stonecutter.current.project !in it) null +// else it.prop("loom.platform") +//}) +//repositories { +// maven("https://maven.neoforged.net/releases/") +// +// //modmenu +// maven("https://maven.terraformersmc.com/") +// //placeholder api (modmenu depencency) +// maven("https://maven.nucleoid.xyz/") +//} +//dependencies { +// minecraft("com.mojang:minecraft:$minecraft") +// mappings(loom.officialMojangMappings()) +// +// if (loader == "fabric") { +// modImplementation("net.fabricmc:fabric-loader:${mod.dep("fabric_loader")}") +//// mappings("net.fabricmc:yarn:$minecraft+build.${mod.dep("yarn_build")}:v2") +// modImplementation("com.terraformersmc:modmenu:${mod.dep("modmenu_version")}") +// +// //some features (like automatic resource loading from non vanilla namespaces) work only with fabric API installed +// //for example translations from assets/modid/lang/en_us.json won't be working, same stuff with textures +// //but we keep runtime only to not accidentally depend on fabric's api, because it doesn't exist in neo/forge +// modRuntimeOnly("net.fabricmc.fabric-api:fabric-api:${mod.dep("fabric_version")}") +// +// } +// if (loader == "forge") { +// "forge"("net.minecraftforge:forge:${minecraft}-${mod.dep("forge_loader")}") +//// mappings("net.fabricmc:yarn:$minecraft+build.${mod.dep("yarn_build")}:v2") +// +// "io.github.llamalad7:mixinextras-forge:${mod.dep("mixin_extras")}".let { +// implementation(it) +// include(it) +// } +// } +// if (loader == "neoforge") { +// "neoForge"("net.neoforged:neoforge:${mod.dep("neoforge_loader")}") +//// mappings(loom.layered { +//// mappings("net.fabricmc:yarn:$minecraft+build.${mod.dep("yarn_build")}:v2") +//// mod.dep("neoforge_patch").takeUnless { it.startsWith('[') }?.let { +//// mappings("dev.architectury:yarn-mappings-patch-neoforge:$it") +//// } +//// }) +// +// } +//} +// +//loom { +//// accessWidenerPath = rootProject.file("src/main/resources/template.accesswidener") +// +// decompilers { +// get("vineflower").apply { // Adds names to lambdas - useful for mixins +// options.put("mark-corresponding-synthetics", "1") +// } +// } +// if (loader == "forge") { +// forge.mixinConfigs( +// "template-common.mixins.json", +// "template-forge.mixins.json", +// ) +// } +//} +// +// +//val localProperties = Properties() +//val localPropertiesFile = rootProject.file("local.properties") +//if (localPropertiesFile.exists()) { +// localProperties.load(localPropertiesFile.inputStream()) +//} +//publishMods { +// val modrinthToken = localProperties.getProperty("publish.modrinthToken", "") +// val curseforgeToken = localProperties.getProperty("publish.curseforgeToken", "") +// +// +// file = project.tasks.remapJar.get().archiveFile +// dryRun = modrinthToken == null || curseforgeToken == null +// +// displayName = "${mod.name} ${loader.replaceFirstChar { it.uppercase() }} ${property("mod.mc_title")}-${mod.version}" +// version = mod.version +// changelog = rootProject.file("CHANGELOG.md").readText() +// type = BETA +// +// modLoaders.add(loader) +// +// val targets = property("mod.mc_targets").toString().split(' ') +// modrinth { +// projectId = property("publish.modrinth").toString() +// accessToken = modrinthToken +// targets.forEach(minecraftVersions::add) +// if (loader == "fabric") { +// requires("fabric-api") +// optional("modmenu") +// } +// } +// +// curseforge { +// projectId = property("publish.curseforge").toString() +// accessToken = curseforgeToken.toString() +// targets.forEach(minecraftVersions::add) +// if (loader == "fabric") { +// requires("fabric-api") +// optional("modmenu") +// } +// } +//} +// +//java { +// withSourcesJar() +// val java = if (stonecutter.eval(minecraft, ">=1.20.5")) JavaVersion.VERSION_21 else JavaVersion.VERSION_17 +// targetCompatibility = java +// sourceCompatibility = java +//} +// +//val shadowBundle: Configuration by configurations.creating { +// isCanBeConsumed = false +// isCanBeResolved = true +//} +// +//tasks.shadowJar { +// configurations = listOf(shadowBundle) +// archiveClassifier = "dev-shadow" +//} +// +//tasks.remapJar { +// injectAccessWidener = true +// input = tasks.shadowJar.get().archiveFile +// archiveClassifier = null +// dependsOn(tasks.shadowJar) +//} +// +//tasks.jar { +// archiveClassifier = "dev" +//} +// +//val buildAndCollect = tasks.register("buildAndCollect") { +// group = "versioned" +// description = "Must run through 'chiseledBuild'" +// from(tasks.remapJar.get().archiveFile, tasks.remapSourcesJar.get().archiveFile) +// into(rootProject.layout.buildDirectory.file("libs/${mod.version}/$loader")) +// dependsOn("build") +//} +// +//if (stonecutter.current.isActive) { +// rootProject.tasks.register("buildActive") { +// group = "project" +// dependsOn(buildAndCollect) +// } +// +// rootProject.tasks.register("runActive") { +// group = "project" +// dependsOn(tasks.named("runClient")) +// } +//} +// +//tasks.processResources { +// properties( +// listOf("fabric.mod.json"), +// "id" to mod.id, +// "name" to mod.name, +// "version" to mod.version, +// "minecraft" to mod.prop("mc_dep_fabric") +// ) +// properties( +// listOf("META-INF/mods.toml", "pack.mcmeta"), +// "id" to mod.id, +// "name" to mod.name, +// "version" to mod.version, +// "minecraft" to mod.prop("mc_dep_forgelike") +// ) +// properties( +// listOf("META-INF/neoforge.mods.toml", "pack.mcmeta"), +// "id" to mod.id, +// "name" to mod.name, +// "version" to mod.version, +// "minecraft" to mod.prop("mc_dep_forgelike") +// ) +//} +// +//tasks.build { +// group = "versioned" +// description = "Must run through 'chiseledBuild'" +//} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 2e7a830..4b92127 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,7 +24,6 @@ mod.mc_targets=[VERSIONED] deps.mixin_extras=0.4.1 deps.fabric_loader=0.18.3 deps.fabric_version=[VERSIONED] -deps.architectury_version=9.1.12 deps.forge_loader=[VERSIONED] deps.neoforge_loader=[VERSIONED] diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 757bb91..61285a6 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 ac57dd1..19a6bde 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-9.2.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.0-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 17a9170..adff685 --- a/gradlew +++ b/gradlew @@ -1,78 +1,128 @@ -#!/usr/bin/env sh +#!/bin/sh + +# +# Copyright © 2015 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## 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/platforms/jvm/plugins-application/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="" +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || 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 + # 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,96 +131,118 @@ 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 -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 - -# 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\"" - fi - i=$((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" ;; +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=SC2039,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=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" 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, 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. -# Collect all arguments for the java command, following the shell quoting and substitution rules -if $JAVACMD --add-opens java.base/java.lang=ALL-UNNAMED -version ; then - DEFAULT_JVM_OPTS="--add-opens java.base/java.lang=ALL-UNNAMED $DEFAULT_JVM_OPTS" +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + 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 + # 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 fi -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")" +# 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 optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# 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 f955316..c4bdd3a 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,4 +1,22 @@ -@if "%DEBUG%" == "" @echo off +@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 +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -9,25 +27,29 @@ 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% +@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% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -35,48 +57,35 @@ 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% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 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%" -jar "%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/src/main/java/org/neoflock/neocomputers/platforms/fabric/ModMenuIntegration.java b/src/main/java/org/neoflock/neocomputers/platforms/fabric/ModMenuIntegration.java index df742f9..7c7a5d6 100644 --- a/src/main/java/org/neoflock/neocomputers/platforms/fabric/ModMenuIntegration.java +++ b/src/main/java/org/neoflock/neocomputers/platforms/fabric/ModMenuIntegration.java @@ -1,5 +1,5 @@ //? if fabric { -/*package org.neoflock.neocomputers.platforms.fabric; +package org.neoflock.neocomputers.platforms.fabric; import com.terraformersmc.modmenu.api.ConfigScreenFactory; import com.terraformersmc.modmenu.api.ModMenuApi; @@ -10,4 +10,4 @@ public class ModMenuIntegration implements ModMenuApi { return ConfigScreen::createConfigScreen; } } -*///?} +//?} diff --git a/src/main/java/org/neoflock/neocomputers/platforms/fabric/NeoComputersFabric.java b/src/main/java/org/neoflock/neocomputers/platforms/fabric/NeoComputersFabric.java index a78593e..5503c9b 100644 --- a/src/main/java/org/neoflock/neocomputers/platforms/fabric/NeoComputersFabric.java +++ b/src/main/java/org/neoflock/neocomputers/platforms/fabric/NeoComputersFabric.java @@ -1,5 +1,5 @@ //? if fabric { -/*package org.neoflock.neocomputers.platforms.fabric; +package org.neoflock.neocomputers.platforms.fabric; import org.neoflock.neocomputers.ModPlatform; import net.fabricmc.api.ModInitializer; @@ -24,4 +24,4 @@ public class NeoComputersFabric implements ModInitializer { } } } -*///?} \ No newline at end of file +//?} \ No newline at end of file diff --git a/src/main/java/org/neoflock/neocomputers/platforms/neoforge/NeoComputersNeoForge.java b/src/main/java/org/neoflock/neocomputers/platforms/neoforge/NeoComputersNeoForge.java index cd5c939..6afd1e4 100644 --- a/src/main/java/org/neoflock/neocomputers/platforms/neoforge/NeoComputersNeoForge.java +++ b/src/main/java/org/neoflock/neocomputers/platforms/neoforge/NeoComputersNeoForge.java @@ -1,5 +1,5 @@ //? if neoforge { -package org.neoflock.neocomputers.platforms.neoforge; +/*package org.neoflock.neocomputers.platforms.neoforge; import org.neoflock.neocomputers.ConfigScreen; import org.neoflock.neocomputers.ModPlatform; @@ -8,8 +8,8 @@ import net.neoforged.fml.ModLoadingContext; import net.neoforged.fml.common.Mod; import org.neoflock.neocomputers.NeoComputers; //? if <1.21 { -/*import net.neoforged.neoforge.client.ConfigScreenHandler; -*///?} else { +/^import net.neoforged.neoforge.client.ConfigScreenHandler; +^///?} else { import net.neoforged.neoforge.client.gui.IConfigScreenFactory; //?} @Mod("neocomputers") @@ -18,11 +18,11 @@ public class NeoComputersNeoForge { NeoComputers.INSTANCE.entrypoint(new NeoForgePlatform()); ModLoadingContext.get().registerExtensionPoint( //? if <1.21 { - /*ConfigScreenHandler.ConfigScreenFactory.class, + /^ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory( ((client, parent) -> ConfigScreen.createConfigScreen(parent)) ) - *///?} else { + ^///?} else { IConfigScreenFactory.class, () -> (client, parent) -> ConfigScreen.createConfigScreen(parent) //?} @@ -40,4 +40,4 @@ public class NeoComputersNeoForge { } } } -//?} \ No newline at end of file +*///?} \ No newline at end of file diff --git a/src/main/kotlin/org/neoflock/neocomputers/NeoComputers.kt b/src/main/kotlin/org/neoflock/neocomputers/NeoComputers.kt index 9abefdd..44fe2bc 100644 --- a/src/main/kotlin/org/neoflock/neocomputers/NeoComputers.kt +++ b/src/main/kotlin/org/neoflock/neocomputers/NeoComputers.kt @@ -1,7 +1,14 @@ package org.neoflock.neocomputers +import com.google.common.base.Suppliers +import dev.architectury.event.events.common.LifecycleEvent +import dev.architectury.registry.registries.RegistrarManager +import org.neoflock.neocomputers.block.Blocks +import org.neoflock.neocomputers.item.Items +import org.neoflock.neocomputers.item.Tabs import org.slf4j.Logger import org.slf4j.LoggerFactory +import java.util.function.Supplier object NeoComputers { @@ -9,8 +16,16 @@ object NeoComputers { val LOGGER: Logger = LoggerFactory.getLogger("NeoComputers") var PLATFORM: ModPlatform? = null + fun entrypoint(platform: ModPlatform?) { PLATFORM = platform + + Blocks.BLOCKS.register(); + Blocks.registerBlockItems(); + Items.ITEMS.register(); + + Tabs.TABS.register(); + LOGGER.info("Registered!") //LOGGER.info("Started mod in %s loader".formatted(NeoComputersInit.PLATFORM.getModloader())) //LOGGER.info("Kotlin: %s".formatted(NeoComputers.hello())) LOGGER.info("Started mod in ${NeoComputers.PLATFORM?.modloader} loader") diff --git a/src/main/kotlin/org/neoflock/neocomputers/block/BaseBlock.kt b/src/main/kotlin/org/neoflock/neocomputers/block/BaseBlock.kt index 044edd2..7299515 100644 --- a/src/main/kotlin/org/neoflock/neocomputers/block/BaseBlock.kt +++ b/src/main/kotlin/org/neoflock/neocomputers/block/BaseBlock.kt @@ -3,12 +3,9 @@ package org.neoflock.neocomputers.block import net.minecraft.world.level.block.Block class BaseBlock : Block { - protected val tier: Int + val tier: Int + constructor(tier: Int): super(Properties.of()) { this.tier = tier } - - public fun getTier(): Int { - return tier - } } \ No newline at end of file diff --git a/src/main/kotlin/org/neoflock/neocomputers/block/Blocks.kt b/src/main/kotlin/org/neoflock/neocomputers/block/Blocks.kt index bbcd831..06491cf 100644 --- a/src/main/kotlin/org/neoflock/neocomputers/block/Blocks.kt +++ b/src/main/kotlin/org/neoflock/neocomputers/block/Blocks.kt @@ -1,50 +1,68 @@ -package org.libreflock.neocomputers.block +package org.neoflock.neocomputers.block +import com.google.common.base.Suppliers import dev.architectury.registry.registries.DeferredRegister +import dev.architectury.registry.registries.Registrar +import dev.architectury.registry.registries.RegistrarManager import dev.architectury.registry.registries.RegistrySupplier import net.minecraft.core.registries.Registries +import net.minecraft.resources.Identifier +import net.minecraft.resources.ResourceKey import net.minecraft.world.item.BlockItem import net.minecraft.world.item.Item import net.minecraft.world.level.block.Block -import org.libreflock.neocomputers.item.Items -import org.libreflock.neocomputers.item.Tabs +import net.minecraft.world.level.block.state.BlockBehaviour +// import org.neoflock.neocomputers.item.Tabs +// import org.neoflock.neocomputers.item.Items import org.neoflock.neocomputers.NeoComputers import org.neoflock.neocomputers.block.BaseBlock +import org.neoflock.neocomputers.item.Items +import org.neoflock.neocomputers.item.Tabs import java.util.function.Consumer import java.util.function.Supplier object Blocks { + // val CASE: MutableList?>? = + // BaseBlock.register(intArrayOf(0, 1, 2), "case", { tier -> CaseBlock(tier) }) + + val BLOCKS: DeferredRegister = DeferredRegister.create(NeoComputers.MODID, Registries.BLOCK) + // val TESTBLOCK : RegistrySupplier = registerBlock("test") + val TESTBLOCK: RegistrySupplier = BLOCKS.register("test") { Block(BlockBehaviour.Properties.of().setId(ResourceKey.create(Registries.BLOCK, Identifier.fromNamespaceAndPath(NeoComputers.MODID, "test")))) } - val CASE: MutableList?>? = - BaseBlock.register(intArrayOf(0, 1, 2), "case", { tier -> CaseBlock(tier) }) - // public static final RegistrySupplier CASE0 = BLOCKS.register("case0", () -> new CaseBlock(0)); // public static final RegistrySupplier CASE1 = BLOCKS.register("case1", () -> new CaseBlock(1)); // public static final RegistrySupplier CASE2 = BLOCKS.register("case2", () -> new CaseBlock(2)); // public static final RegistrySupplier CABLE = BLOCKS.register("cable", () -> new CableBlock()); - val SCREEN: RegistrySupplier? = BLOCKS.register("screen", Supplier { ScreenBlock() }) - val CABLE: RegistrySupplier? = BLOCKS.register("cable", Supplier { CableBlock() }) + // val SCREEN: RegistrySupplier? = BLOCKS.register("screen", Supplier { ScreenBlock() }) + // val CABLE: RegistrySupplier? = BLOCKS.register("cable", Supplier { CableBlock() }) + + // fun registerBlock(name: String): RegistrySupplier { + // // var Registrar items = MANAGER.get().get(Registries.ITEM); + // var blocks: Registrar = NeoComputers.MANAGER.get().get(Registries.BLOCK); + // return blocks.register(Identifier.fromNamespaceAndPath(NeoComputers.MODID, name)) { + // Block( + // BlockBehaviour.Properties.of().setId( + // ResourceKey.create( + // Registries.BLOCK, + // Identifier.fromNamespaceAndPath(NeoComputers.MODID, name) + // ) + // ) + // ) + // } + // } fun registerBlockItems() { BLOCKS.forEach(Consumer { sup: RegistrySupplier? -> - // sup.pre - // sup.((blk) -> { - // NeoComputers.LOGGER.info(blk.getDescriptionId()); + NeoComputers.LOGGER.info("mango viagra") + // TODO: base blocks // if (blk instanceof BaseBlock) { // Items.ITEMS.register(sup.getId().getPath(), () -> new BaseBlock.BaseBlockItem(blk, new Item.Properties().arch$tab(Tabs.TAB))); // } else { // Items.ITEMS.register(sup.getId().getPath(), () -> new BlockItem(blk, new Item.Properties().arch$tab(Tabs.TAB))); // } - // }); - Items.ITEMS.register(sup!!.getId().getPath(), { - if (sup.get() is BaseBlock) { - return@register BaseBlockItem(sup.get(), Item.Properties().`arch$tab`(Tabs.TAB)) - } else { - return@register BlockItem(sup.get(), Item.Properties().`arch$tab`(Tabs.TAB)) - } - }) + Items.ITEMS.register(sup!!.id.path) { BlockItem(sup.get()!!, Item.Properties().`arch$tab`(Tabs.TAB).setId(ResourceKey.create(Registries.ITEM, sup.id)))} }) } } \ No newline at end of file diff --git a/src/main/kotlin/org/neoflock/neocomputers/item/Items.kt b/src/main/kotlin/org/neoflock/neocomputers/item/Items.kt new file mode 100644 index 0000000..d79388c --- /dev/null +++ b/src/main/kotlin/org/neoflock/neocomputers/item/Items.kt @@ -0,0 +1,10 @@ +package org.neoflock.neocomputers.item; + +import dev.architectury.registry.registries.DeferredRegister +import net.minecraft.core.registries.Registries +import net.minecraft.world.item.Item +import org.neoflock.neocomputers.NeoComputers + +object Items { + val ITEMS: DeferredRegister = DeferredRegister.create(NeoComputers.MODID, Registries.ITEM) +} \ No newline at end of file diff --git a/src/main/kotlin/org/neoflock/neocomputers/item/Tabs.kt b/src/main/kotlin/org/neoflock/neocomputers/item/Tabs.kt new file mode 100644 index 0000000..071758f --- /dev/null +++ b/src/main/kotlin/org/neoflock/neocomputers/item/Tabs.kt @@ -0,0 +1,22 @@ +package org.neoflock.neocomputers.item; + +import dev.architectury.registry.CreativeTabRegistry +import dev.architectury.registry.registries.DeferredRegister +import dev.architectury.registry.registries.RegistrySupplier +import net.minecraft.core.registries.Registries +import net.minecraft.network.chat.Component +import net.minecraft.world.item.CreativeModeTab +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.Items +import org.neoflock.neocomputers.NeoComputers +import java.util.function.Supplier + + +object Tabs { + val TABS: DeferredRegister = DeferredRegister.create(NeoComputers.MODID, Registries.CREATIVE_MODE_TAB) + + val TAB: RegistrySupplier = TABS.register("neocomputers_tab", Supplier {CreativeTabRegistry.create( + Component.literal("NeoComputers"), + Supplier { ItemStack(Items.ACACIA_BOAT) } + )}) +} \ No newline at end of file diff --git a/src/main/kotlin/org/neoflock/neocomputers/util/TieredSupplier.kt b/src/main/kotlin/org/neoflock/neocomputers/util/TieredSupplier.kt new file mode 100644 index 0000000..d080747 --- /dev/null +++ b/src/main/kotlin/org/neoflock/neocomputers/util/TieredSupplier.kt @@ -0,0 +1,5 @@ +package org.neoflock.neocomputers.util + +fun interface TieredSupplier { + fun get(tier: Int): T +} \ No newline at end of file diff --git a/stonecutter.gradle.kts b/stonecutter.gradle.kts index cb9313f..2be3523 100644 --- a/stonecutter.gradle.kts +++ b/stonecutter.gradle.kts @@ -5,7 +5,7 @@ plugins { id("com.gradleup.shadow") version "9.3.0" apply false id("me.modmuss50.mod-publish-plugin") version "0.8.4" apply false } -stonecutter active "1.21.11-neoforge" /* [SC] DO NOT EDIT */ +stonecutter active "1.21.11-fabric" /* [SC] DO NOT EDIT */ stonecutter.automaticPlatformConstants = true // Builds every version into `build/libs/{mod.version}/{loader}`