26 changed files with 689 additions and 379 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
# Disable autocrlf on generated files, they always generate with LF
# Add any extra files or paths here to make git stop saying they
# are changed when only line endings change.
src/generated/**/.cache/cache text eol=lf
src/generated/**/.cache/* text eol=lf
src/generated/**/*.json text eol=lf
+34 -19
View File
@@ -1,25 +1,40 @@
# eclipse
bin
*.launch
.settings
.metadata
.classpath
.project
### Gradle ###
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/**/build/
# idea
out
*.ipr
### IntelliJ IDEA ###
.idea/
*.iws
*.iml
.idea
*.ipr
out/
!**/src/**/out/
# gradle
build
.gradle
.run/
# other
eclipse
run
### Eclipse ###
.apt_generated
.classpath
.eclipse/
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/**/bin/
# Files from Forge MDK
forge*changelog.txt
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
### Minecraft Modding ###
run/
!**/src/**/run/
**/src/generated/**/.cache/
repo/
!**/src/**/repo/
+156 -68
View File
@@ -1,102 +1,190 @@
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true
}
plugins {
id 'java-library'
id 'maven-publish'
id 'net.neoforged.moddev' version '2.0.147'
id 'idea'
}
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'
version = '1.0.3'
group = 'de.skate702.craftingkeys' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'craftingkeys'
tasks.named('wrapper', Wrapper).configure {
// Define wrapper values here so as to not have to always do so when updating gradlew.properties.
// Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with
// documentation attached on cursor hover of gradle classes and methods. However, this comes with increased
// file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards.
// (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`)
distributionType = Wrapper.DistributionType.BIN
}
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava.options.encoding = "UTF-8"
version = mod_version
group = mod_group_id
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft {
mappings channel: 'snapshot', version: '20201028-1.16.3'
sourceSets.main.resources {
// Include resources generated by data generators.
srcDir('src/generated/resources')
// Exclude common development only resources from finalized outputs
exclude("**/*.bbmodel") // BlockBench project files
exclude("src/generated/**/.cache") // datagen cache files
}
repositories {
// Add here additional repositories if required by some of the dependencies below.
}
base {
archivesName = mod_id
}
// Mojang ships Java 21 to end users in 1.21.1, so mods should target Java 21.
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
neoForge {
// Specify the version of NeoForge to use.
version = project.neo_version
parchment {
mappingsVersion = project.parchment_mappings_version
minecraftVersion = project.parchment_minecraft_version
}
// This line is optional. Access Transformers are automatically detected
// accessTransformers = project.files('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 level for the console
property 'forge.logging.console.level', 'debug'
mods {
craftingkeys {
source sourceSets.main
}
}
client()
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
server {
workingDirectory project.file('run')
server()
programArgument '--nogui'
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
mods {
craftingkeys {
source sourceSets.main
}
}
// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
type = "gameTestServer"
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
data {
workingDirectory project.file('run')
data()
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
// gameDirectory = project.file('run-data')
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
// applies to all the run configs above
configureEach {
// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
systemProperty 'forge.logging.markers', 'REGISTRIES'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
// You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
logLevel = org.slf4j.event.Level.DEBUG
}
}
mods {
craftingkeys {
source sourceSets.main
}
}
mods {
// define mod <-> source bindings
// these are used to tell the game which sources are for which mod
// multi mod projects should define one per mod
"${mod_id}" {
sourceSet(sourceSets.main)
}
}
}
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
// Sets up a dependency configuration called 'localRuntime'.
// This configuration should be used instead of 'runtimeOnly' to declare
// a dependency that will be present for runtime testing but that is
// "optional", meaning it will not be pulled by dependents of this mod.
configurations {
runtimeClasspath.extendsFrom localRuntime
}
dependencies {
minecraft 'net.minecraftforge:forge:1.16.5-36.2.20'
// Example optional mod dependency with JEI
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
// compileOnly "mezz.jei:jei-${mc_version}-neoforge-api:${jei_version}"
// We add the full version to localRuntime, not runtimeOnly, so that we do not publish a dependency on it
// localRuntime "mezz.jei:jei-${mc_version}-neoforge:${jei_version}"
// Example mod dependency using a mod jar from ./libs with a flat dir repository
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
// The group id is ignored when searching -- in this case, it is "blank"
// implementation "blank:coolmod-${mc_version}:${coolmod_version}"
// Example mod dependency using a file as dependency
// implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")
// Example project dependency using a sister or child project:
// implementation project(":myproject")
// For more info:
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}
// Example for how to get properties into the manifest for reading by the runtime..
jar {
manifest {
attributes([
"Specification-Title": "Crafting Keys",
"Specification-Vendor": "Crafting Keys",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"Crafting Keys",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
var replaceProperties = [
minecraft_version : minecraft_version,
minecraft_version_range: minecraft_version_range,
neo_version : neo_version,
loader_version_range : loader_version_range,
mod_id : mod_id,
mod_name : mod_name,
mod_license : mod_license,
mod_version : mod_version,
]
inputs.properties replaceProperties
expand replaceProperties
from "src/main/templates"
into "build/generated/sources/modMetadata"
}
// Include the output of "generateModMetadata" as an input directory for the build
// this works with both building through Gradle and the IDE.
sourceSets.main.resources.srcDir generateModMetadata
// To avoid having to run "generateModMetadata" manually, make it run on every project reload
neoForge.ideSyncTask generateModMetadata
jar.finalizedBy('reobfJar')
// Example configuration to allow publishing using the maven-publish plugin
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
register('mavenJava', MavenPublication) {
from components.java
}
}
repositories {
maven {
url "file:///${project.projectDir}/mcmodsrepo"
url "file://${project.projectDir}/repo"
}
}
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}
+38 -3
View File
@@ -1,4 +1,39 @@
# 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.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
org.gradle.jvmargs=-Xmx1G
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache=true
#read more on this at https://github.com/neoforged/ModDevGradle?tab=readme-ov-file#better-minecraft-parameter-names--javadoc-parchment
# you can also find the latest versions at: https://parchmentmc.org/docs/getting-started
parchment_minecraft_version=1.21.1
parchment_mappings_version=2024.11.17
# Environment Properties
# You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge
# The Minecraft version must agree with the Neo version to get a valid artifact
minecraft_version=1.21.1
# The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.21.1]
# The Neo version must agree with the Minecraft version to get a valid artifact
neo_version=21.1.219
# The loader version range can only use the major version of FML as bounds
loader_version_range=[1,)
## Mod Properties
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
# Must match the String constant located in the main mod class annotated with @Mod.
mod_id=craftingkeys
# The human-readable display name for the mod.
mod_name=Crafting Keys
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT
# The mod version. See https://semver.org/
mod_version=1.0.4
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
mod_group_id=de.skate702.craftingkeys
Binary file not shown.
+3 -1
View File
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-all.zip
Vendored
+196 -117
View File
@@ -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.
#
# 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
CLASSPATH="\\\"\\\""
# 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,92 +132,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
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
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# 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" )
# 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")"
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
# 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" \
-classpath "$CLASSPATH" \
-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" "$@"
Vendored
+45 -35
View File
@@ -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,36 @@ 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
set CLASSPATH=
@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%" -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
+9
View File
@@ -0,0 +1,9 @@
pluginManagement {
repositories {
gradlePluginPortal()
}
}
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
}
@@ -1,20 +1,27 @@
package de.skate702.craftingkeys;
import net.minecraft.client.gui.screen.EnchantmentScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.inventory.*;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraft.client.gui.screens.inventory.EnchantmentScreen;
import net.minecraft.client.gui.screens.Screen;
import de.skate702.craftingkeys.manager.*;
import de.skate702.craftingkeys.proxies.CraftingKeysProxy;
import de.skate702.craftingkeys.util.Logger;
import de.skate702.craftingkeys.util.Util;
import net.minecraftforge.common.MinecraftForge;
import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.client.gui.screens.inventory.AnvilScreen;
import net.minecraft.client.gui.screens.inventory.BrewingStandScreen;
import net.minecraft.client.gui.screens.inventory.CraftingScreen;
import net.minecraft.client.gui.screens.inventory.DispenserScreen;
import net.minecraft.client.gui.screens.inventory.FurnaceScreen;
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
import net.minecraft.client.gui.screens.inventory.MerchantScreen;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.client.event.ClientTickEvent;
import net.neoforged.neoforge.common.NeoForge;
/**
* The Main Class of the Mod with the important onTick-Method. Some Methods are
@@ -22,7 +29,7 @@ import org.apache.commons.lang3.tuple.Pair;
*
* @author skate702
*/
@Mod(CraftingKeys.MODID)
@Mod(value = CraftingKeys.MODID, dist = Dist.CLIENT)
public class CraftingKeys {
public static final String MODID = "craftingkeys";
@@ -35,9 +42,8 @@ public class CraftingKeys {
public CraftingKeys() {
instance = this;
MinecraftForge.EVENT_BUS.register(this);
NeoForge.EVENT_BUS.addListener(this::onTick);
ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.DISPLAYTEST, () -> Pair.of(() -> "client side mod only", (remoteversionstring,networkbool) -> networkbool));
Logger.info("load(e)", "Registered Mod.");
}
@@ -48,58 +54,57 @@ public class CraftingKeys {
*
* @param tick This is a tick. What did you think about it?
*/
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent tick) {
public void onTick(ClientTickEvent.Post tick) {
Screen currentScreen = Util.client.currentScreen;
Screen currentScreen = Util.client.screen;
if (currentScreen != null) {
if (currentScreen instanceof CraftingScreen) {
ContainerManager con = CraftingManager.getInstance(
((CraftingScreen) currentScreen).getContainer());
((CraftingScreen) currentScreen).getMenu());
con.acceptKey();
} else if (currentScreen instanceof InventoryScreen) {
ContainerManager con = InventoryManager.getInstance(
((InventoryScreen) currentScreen).getContainer());
((InventoryScreen) currentScreen).getMenu());
con.acceptKey();
} else if (currentScreen instanceof MerchantScreen) {
ContainerManager con = VillagerManager.getInstance(
((MerchantScreen) currentScreen).getContainer());
((MerchantScreen) currentScreen).getMenu());
con.acceptKey();
} else if (currentScreen instanceof FurnaceScreen) {
ContainerManager con = FurnaceManager.getInstance(
((FurnaceScreen) currentScreen).getContainer());
((FurnaceScreen) currentScreen).getMenu());
con.acceptKey();
} else if (currentScreen instanceof DispenserScreen) {
ContainerManager con = DispenserManager.getInstance(
((DispenserScreen) currentScreen).getContainer());
((DispenserScreen) currentScreen).getMenu());
con.acceptKey();
} else if (currentScreen instanceof BrewingStandScreen) {
ContainerManager con = BrewingManager.getInstance(
((BrewingStandScreen) currentScreen).getContainer());
((BrewingStandScreen) currentScreen).getMenu());
con.acceptKey();
} else if (currentScreen instanceof EnchantmentScreen) {
ContainerManager con = EnchantmentManager.getInstance(
((EnchantmentScreen) currentScreen).getContainer());
((EnchantmentScreen) currentScreen).getMenu());
con.acceptKey();
} else if (currentScreen instanceof AnvilScreen) {
ContainerManager con = AnvilManager.getInstance(
((AnvilScreen) currentScreen).getContainer());
((AnvilScreen) currentScreen).getMenu());
con.acceptKey();
}
@@ -2,7 +2,7 @@ package de.skate702.craftingkeys.config;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.InputMappings;
import com.mojang.blaze3d.platform.InputConstants;
import java.awt.event.KeyEvent;
@@ -22,12 +22,12 @@ public class Config {
private static int keyLowerLeft = KeyEvent.VK_Z;
private static int keyLowerCenter = KeyEvent.VK_X;
private static int keyLowerRight = KeyEvent.VK_C;
private static int keyStack = Minecraft.getInstance().gameSettings.keyBindSneak.getKey().getKeyCode();
private static int keyInteract = Minecraft.getInstance().gameSettings.keyBindSprint.getKey().getKeyCode();
private static int keyStack = Minecraft.getInstance().options.keyShift.getKey().getValue();
private static int keyInteract = Minecraft.getInstance().options.keySprint.getKey().getValue();
private static final int keyDrop = KeyEvent.VK_SPACE;
public static boolean isKeyDown(int keyCode) {
return InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), keyCode);
return InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), keyCode);
}
public static boolean isKeyTopLeftPressed() {
@@ -1,7 +1,7 @@
package de.skate702.craftingkeys.manager;
import de.skate702.craftingkeys.util.Logger;
import net.minecraft.inventory.container.Container;
import net.minecraft.world.inventory.AbstractContainerMenu;
/**
* Manages a Anvil GUI Inventory.
@@ -14,7 +14,7 @@ public class AnvilManager extends ContainerManager {
*
* @param container The container from a crafting GUI
*/
private AnvilManager(Container container) {
private AnvilManager(AbstractContainerMenu container) {
super(container);
}
@@ -24,7 +24,7 @@ public class AnvilManager extends ContainerManager {
* @param container A container from a GUI
* @return manager-singleton
*/
public static AnvilManager getInstance(Container container) {
public static AnvilManager getInstance(AbstractContainerMenu container) {
if (instance == null) {
instance = new AnvilManager(container);
} else {
@@ -1,7 +1,7 @@
package de.skate702.craftingkeys.manager;
import de.skate702.craftingkeys.util.Logger;
import net.minecraft.inventory.container.Container;
import net.minecraft.world.inventory.AbstractContainerMenu;
/**
* Manages a Brewing Stand GUI Inventory.
@@ -15,7 +15,7 @@ public class BrewingManager extends ContainerManager {
*
* @param container The container from a crafting GUI
*/
private BrewingManager(Container container) {
private BrewingManager(AbstractContainerMenu container) {
super(container);
}
@@ -25,7 +25,7 @@ public class BrewingManager extends ContainerManager {
* @param container A container from a GUI
* @return manager-singleton
*/
public static BrewingManager getInstance(Container container) {
public static BrewingManager getInstance(AbstractContainerMenu container) {
if (instance == null) {
instance = new BrewingManager(container);
} else {
@@ -5,13 +5,13 @@ import de.skate702.craftingkeys.config.Config;
import de.skate702.craftingkeys.util.InputUtil;
import de.skate702.craftingkeys.util.Logger;
import de.skate702.craftingkeys.util.Util;
import net.minecraft.block.Blocks;
import net.minecraft.client.gui.screen.inventory.InventoryScreen;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
import net.minecraft.client.KeyMapping;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
/**
* Provides all needed methods to handle and manage a gui inventory. Does also provide frames for own implementations.
@@ -21,14 +21,14 @@ public abstract class ContainerManager {
/**
* The Container to work with.
*/
Container container;
AbstractContainerMenu container;
/**
* Creates a new ContainerManager with the given container.
*
* @param container The container to work with
*/
ContainerManager(Container container) {
ContainerManager(AbstractContainerMenu container) {
this.container = container;
}
@@ -39,7 +39,7 @@ public abstract class ContainerManager {
public void acceptKey() {
// Get hovered slot and goal slotIndex of pressed key (if pressed)
Slot currentHoveredSlot = InputUtil.getSlotAtMousePosition(Util.client.currentScreen);
Slot currentHoveredSlot = InputUtil.getSlotAtMousePosition(Util.client.screen);
int slotIndex = specificKeyToSlotIndex();
// Handle accepted key
@@ -61,7 +61,7 @@ public abstract class ContainerManager {
!Util.isHoldingStack()) { // MOVE FROM SLOT
Logger.info("acceptKey()", "Key for index " + slotIndex + " pressed.");
onSpecificKeyPressed(currentHoveredSlot.slotNumber, slotIndex);
onSpecificKeyPressed(currentHoveredSlot.index, slotIndex);
} else if (Util.isHoldingStack()) { // MOVE FROM HAND
@@ -98,7 +98,7 @@ public abstract class ContainerManager {
// Handles Interaction with items held
// Stack up on hand if equal or small enough, else throw held stack away
if (Util.isHoldingStack() && getItemStack(getInteractionSlotIndex()) != null && (
!Util.getHeldStack().isItemEqual(getItemStack(getInteractionSlotIndex()))
!Util.getHeldStack().is(getItemStack(getInteractionSlotIndex()).getItem())
|| Util.getHeldStack().getCount() + getItemStack(getInteractionSlotIndex()).getCount()
> getItemStack(getInteractionSlotIndex()).getMaxStackSize())) {
moveStackToInventory(-1);
@@ -159,32 +159,32 @@ public abstract class ContainerManager {
void handleNumKey(Slot currentHoveredSlot) {
// hotbar-slots are always the last 9 slots of the currently opened inventory
int hotbarStartIndex = Util.client.player.openContainer.getInventory().size() - 9 - 1;
int hotbarStartIndex = Util.client.player.containerMenu.getItems().size() - 9 - 1;
if (Util.client.currentScreen instanceof InventoryScreen) {
if (Util.client.screen instanceof InventoryScreen) {
hotbarStartIndex -= 1;
}
int inputdelta;
KeyBinding[] hotbar = Util.client.gameSettings.keyBindsHotbar;
KeyMapping[] hotbar = Util.client.options.keyHotbarSlots;
if (Config.isKeyDown(hotbar[0].getKey().getKeyCode())) {
if (Config.isKeyDown(hotbar[0].getKey().getValue())) {
inputdelta = 1;
} else if (Config.isKeyDown(hotbar[1].getKey().getKeyCode())) {
} else if (Config.isKeyDown(hotbar[1].getKey().getValue())) {
inputdelta = 2;
} else if (Config.isKeyDown(hotbar[2].getKey().getKeyCode())) {
} else if (Config.isKeyDown(hotbar[2].getKey().getValue())) {
inputdelta = 3;
} else if (Config.isKeyDown(hotbar[3].getKey().getKeyCode())) {
} else if (Config.isKeyDown(hotbar[3].getKey().getValue())) {
inputdelta = 4;
} else if (Config.isKeyDown(hotbar[4].getKey().getKeyCode())) {
} else if (Config.isKeyDown(hotbar[4].getKey().getValue())) {
inputdelta = 5;
} else if (Config.isKeyDown(hotbar[5].getKey().getKeyCode())) {
} else if (Config.isKeyDown(hotbar[5].getKey().getValue())) {
inputdelta = 6;
} else if (Config.isKeyDown(hotbar[6].getKey().getKeyCode())) {
} else if (Config.isKeyDown(hotbar[6].getKey().getValue())) {
inputdelta = 7;
} else if (Config.isKeyDown(hotbar[7].getKey().getKeyCode())) {
} else if (Config.isKeyDown(hotbar[7].getKey().getValue())) {
inputdelta = 8;
} else if (Config.isKeyDown(hotbar[8].getKey().getKeyCode())) {
} else if (Config.isKeyDown(hotbar[8].getKey().getValue())) {
inputdelta = 9;
} else {
return;
@@ -194,7 +194,7 @@ public abstract class ContainerManager {
// if there could not be meant another stack at mouse position. cool logic!
if (!Util.isHoldingStack()) {
if (currentHoveredSlot == null || !currentHoveredSlot.getHasStack()) {
if (currentHoveredSlot == null || !currentHoveredSlot.hasItem()) {
Logger.info("handleNumKey()", "Trying output to hotbar speedup.");
onInteractionKeyPressed();
}
@@ -306,13 +306,13 @@ public abstract class ContainerManager {
int movedAmount = Math.min(amount, sourceSize);
// Clear goal slot (May fail on full inventory!); only available if not holdling
if (destination != null && !source.isItemEqual(destination) && srcIndex >= 0) {
if (destination != null && !source.is(destination.getItem()) && srcIndex >= 0) {
moveStackToInventory(destIndex);
destination = getItemStack(destIndex);
}
// Move some
if (destination == null || source.isItemEqual(destination)) {
if (destination == null || source.is(destination.getItem())) {
if (srcIndex >= 0) {
leftClick(srcIndex);
@@ -342,14 +342,14 @@ public abstract class ContainerManager {
*/
ItemStack getItemStack(int index) {
if (index >= 0 && index < container.inventorySlots.size()) {
if (index >= 0 && index < container.slots.size()) {
Slot slot = (Slot) (container.inventorySlots.get(index));
Slot slot = (Slot) (container.slots.get(index));
// NEW_1_11 No Null-Stacks anymore. Empty Stacks with air...
ItemStack returnStack = (slot == null) ? null : slot.getStack();
ItemStack returnStack = (slot == null) ? null : slot.getItem();
if(returnStack.getCount() == 0 && returnStack.getItem() == Item.getItemFromBlock(Blocks.AIR)) {
if(returnStack.getCount() == 0 && returnStack.getItem() == Item.byBlock(Blocks.AIR)) {
returnStack = null;
}
@@ -425,12 +425,12 @@ public abstract class ContainerManager {
private int calcInventoryDestination(ItemStack stackToMove) {
// First run: Try to find a nice stack to put items on additionally
for (int i = getInventoryStartIndex(); i < container.inventorySlots.size(); i++) {
for (int i = getInventoryStartIndex(); i < container.slots.size(); i++) {
ItemStack potentialGoalStack = getItemStack(i);
if (potentialGoalStack != null && stackToMove != null) {
if (potentialGoalStack.isItemEqual(stackToMove)) {
if (potentialGoalStack.is(stackToMove.getItem())) {
if (potentialGoalStack.getCount() + stackToMove.getCount() <= stackToMove.getMaxStackSize()) {
return i;
}
@@ -439,7 +439,7 @@ public abstract class ContainerManager {
}
// Second run: Find a free slot
for (int i = getInventoryStartIndex(); i < container.inventorySlots.size(); i++) {
for (int i = getInventoryStartIndex(); i < container.slots.size(); i++) {
if (getItemStack(i) == null) {
return i;
}
@@ -493,9 +493,8 @@ public abstract class ContainerManager {
int rightClickData = (rightClick) ? 1 : 0;
CraftingKeys.proxy.sendSlotClick(Util.client.playerController, container.windowId, index,
CraftingKeys.proxy.sendSlotClick(Util.client.gameMode, container.containerId, index,
rightClickData, 0, Util.client.player);
}
}
@@ -1,7 +1,7 @@
package de.skate702.craftingkeys.manager;
import de.skate702.craftingkeys.util.Logger;
import net.minecraft.inventory.container.Container;
import net.minecraft.world.inventory.AbstractContainerMenu;
/**
* Manages a Crafting GUI Inventory.
@@ -15,7 +15,7 @@ public class CraftingManager extends ContainerManager {
*
* @param container The container from a crafting GUI
*/
private CraftingManager(Container container) {
private CraftingManager(AbstractContainerMenu container) {
super(container);
}
@@ -25,7 +25,7 @@ public class CraftingManager extends ContainerManager {
* @param container A container from a GUI
* @return manager-singleton
*/
public static CraftingManager getInstance(Container container) {
public static CraftingManager getInstance(AbstractContainerMenu container) {
if (instance == null) {
instance = new CraftingManager(container);
} else {
@@ -1,7 +1,7 @@
package de.skate702.craftingkeys.manager;
import de.skate702.craftingkeys.util.Logger;
import net.minecraft.inventory.container.Container;
import net.minecraft.world.inventory.AbstractContainerMenu;
/**
* Manages a Dispenser GUI Inventory.
@@ -15,7 +15,7 @@ public class DispenserManager extends ContainerManager {
*
* @param container The container from a crafting GUI
*/
private DispenserManager(Container container) {
private DispenserManager(AbstractContainerMenu container) {
super(container);
}
@@ -25,7 +25,7 @@ public class DispenserManager extends ContainerManager {
* @param container A container from a GUI
* @return manager-singleton
*/
public static DispenserManager getInstance(Container container) {
public static DispenserManager getInstance(AbstractContainerMenu container) {
if (instance == null) {
instance = new DispenserManager(container);
} else {
@@ -1,7 +1,7 @@
package de.skate702.craftingkeys.manager;
import de.skate702.craftingkeys.util.Logger;
import net.minecraft.inventory.container.Container;
import net.minecraft.world.inventory.AbstractContainerMenu;
/**
* Manages a Enchantment Table GUI Inventory.
@@ -15,7 +15,7 @@ public class EnchantmentManager extends ContainerManager {
*
* @param container The container from a crafting GUI
*/
private EnchantmentManager(Container container) {
private EnchantmentManager(AbstractContainerMenu container) {
super(container);
}
@@ -25,7 +25,7 @@ public class EnchantmentManager extends ContainerManager {
* @param container A container from a GUI
* @return manager-singleton
*/
public static EnchantmentManager getInstance(Container container) {
public static EnchantmentManager getInstance(AbstractContainerMenu container) {
if (instance == null) {
instance = new EnchantmentManager(container);
} else {
@@ -1,7 +1,7 @@
package de.skate702.craftingkeys.manager;
import de.skate702.craftingkeys.util.Logger;
import net.minecraft.inventory.container.Container;
import net.minecraft.world.inventory.AbstractContainerMenu;
/**
* Manages a Furnace GUI Inventory.
@@ -15,7 +15,7 @@ public class FurnaceManager extends ContainerManager {
*
* @param container The container from a crafting GUI
*/
private FurnaceManager(Container container) {
private FurnaceManager(AbstractContainerMenu container) {
super(container);
}
@@ -25,7 +25,7 @@ public class FurnaceManager extends ContainerManager {
* @param container A container from a GUI
* @return manager-singleton
*/
public static FurnaceManager getInstance(Container container) {
public static FurnaceManager getInstance(AbstractContainerMenu container) {
if (instance == null) {
instance = new FurnaceManager(container);
} else {
@@ -1,7 +1,7 @@
package de.skate702.craftingkeys.manager;
import de.skate702.craftingkeys.util.Logger;
import net.minecraft.inventory.container.Container;
import net.minecraft.world.inventory.AbstractContainerMenu;
/**
* Manages a Inventory GUI Inventory.
@@ -15,7 +15,7 @@ public class InventoryManager extends ContainerManager {
*
* @param container The container from a crafting GUI
*/
private InventoryManager(Container container) {
private InventoryManager(AbstractContainerMenu container) {
super(container);
}
@@ -25,7 +25,7 @@ public class InventoryManager extends ContainerManager {
* @param container A container from a GUI
* @return manager-singleton
*/
public static InventoryManager getInstance(Container container) {
public static InventoryManager getInstance(AbstractContainerMenu container) {
if (instance == null) {
instance = new InventoryManager(container);
} else {
@@ -2,7 +2,7 @@ package de.skate702.craftingkeys.manager;
import de.skate702.craftingkeys.util.Logger;
import net.minecraft.inventory.container.Container;
import net.minecraft.world.inventory.AbstractContainerMenu;
/**
* Manages a Villager GUI Inventory.
@@ -16,7 +16,7 @@ public class VillagerManager extends ContainerManager {
*
* @param container The container from a crafting GUI
*/
private VillagerManager(Container container) {
private VillagerManager(AbstractContainerMenu container) {
super(container);
}
@@ -26,7 +26,7 @@ public class VillagerManager extends ContainerManager {
* @param container A container from a GUI
* @return manager-singleton
*/
public static VillagerManager getInstance(Container container) {
public static VillagerManager getInstance(AbstractContainerMenu container) {
if (instance == null) {
instance = new VillagerManager(container);
} else {
@@ -1,10 +1,10 @@
package de.skate702.craftingkeys.proxies;
import net.minecraft.client.multiplayer.PlayerController;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.ClickType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.ClickType;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
/**
* The common proxy.
@@ -24,9 +24,9 @@ public class CraftingKeysProxy {
* @param player The current player (from Client)
*/
@OnlyIn(Dist.CLIENT)
public void sendSlotClick(PlayerController controller, int windowId, int slot, int rightClick, @SuppressWarnings("SameParameterValue") int action,
PlayerEntity player) {
controller.windowClick(windowId, slot, rightClick, ClickType.PICKUP, player);
public void sendSlotClick(MultiPlayerGameMode controller, int windowId, int slot, int rightClick, @SuppressWarnings("SameParameterValue") int action,
Player player) {
controller.handleInventoryMouseClick(windowId, slot, rightClick, ClickType.PICKUP, player);
}
@@ -1,8 +1,8 @@
package de.skate702.craftingkeys.util;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.inventory.container.Slot;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.world.inventory.Slot;
/**
* This class provides methods to interact with the Mouse and key input.
@@ -27,8 +27,8 @@ public class InputUtil {
* @return Returns the slot (or null)
*/
public static Slot getSlotAtMousePosition(Screen screen) {
if (screen instanceof ContainerScreen) {
return ((ContainerScreen) screen).getSlotUnderMouse();
if (screen instanceof AbstractContainerScreen) {
return ((AbstractContainerScreen) screen).getSlotUnderMouse();
} else {
Logger.debug("getSlotAtMousePosition(gui)", "guiContainer == null");
return null;
@@ -1,6 +1,6 @@
package de.skate702.craftingkeys.util;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.resources.language.I18n;
public class LanguageLocalizer {
/**
@@ -10,6 +10,6 @@ public class LanguageLocalizer {
* @return localized The localized String
*/
public static String localize(String unloc) {
return I18n.format(unloc);
return I18n.get(unloc);
}
}
@@ -1,9 +1,10 @@
package de.skate702.craftingkeys.util;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.network.chat.Component;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.world.item.ItemStack;
/**
* Provides basic utility methods. For input methods, look at InputUtil.
@@ -31,7 +32,7 @@ public class Util {
* @return A item stack
*/
public static ItemStack getHeldStack() {
return client.player.inventory.getItemStack();
return ((AbstractContainerScreen<?>)client.screen).getMenu().getCarried();
}
/**
@@ -49,10 +50,10 @@ public class Util {
* @return True, if this is the first tick
*/
public static boolean isFirstInWorldTick() {
if (firstInWorldTick && client.world != null) {
if (firstInWorldTick && client.level != null) {
firstInWorldTick = false;
return true;
} else if (client.world == null) {
} else if (client.level == null) {
firstInWorldTick = true;
}
return false;
@@ -64,8 +65,7 @@ public class Util {
* @param lang_key key from lang-file
*/
public static void printMessage(String lang_key) {
String translated = new TranslationTextComponent(lang_key).getUnformattedComponentText();
client.player.sendChatMessage(translated);
client.player.displayClientMessage(Component.translatable(lang_key), false);
}
}
-25
View File
@@ -1,25 +0,0 @@
modLoader = "javafml" #mandatory
loaderVersion = "[36,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
license = "All rights reserved"
[[mods]] #mandatory
modId = "craftingkeys" #mandatory
version = "${file.jarVersion}" #mandatory
displayName = "Crafting Keys" #mandatory
displayURL = "http://craftingkeys.skate702.de" #optional
logoFile = "examplemod.png" #optional
credits = "Based on the open-source InvTweaks-Mod. Thanks a lot!" #optional
authors = "skate702 (sebinside)" #optional
description = "Simple better crafting! Crafing Keys enables new inventory key-bindings to speed up your crafting."
[[dependencies.craftingkeys]] #optional
modId = "forge" #mandatory
mandatory = true #mandatory
versionRange = "[36,)" #mandatory
ordering = "NONE"
side = "CLIENT"
[[dependencies.craftingkeys]]
modId = "minecraft"
mandatory = true
versionRange = "[1.16.5,)"
ordering = "NONE"
side = "CLIENT"
@@ -0,0 +1,93 @@
# This is an example neoforge.mods.toml file. It contains the data relating to the loading mods.
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
# The overall format is standard TOML format, v0.5.0.
# Note that there are a couple of TOML lists in this file.
# Find more information on toml format here: https://github.com/toml-lang/toml
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the FML version. This is currently 2.
loaderVersion="${loader_version_range}" #mandatory
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license="${mod_license}"
# A URL to refer people to when problems occur with this mod
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
# A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory
# The modid of the mod
modId="${mod_id}" #mandatory
# The version number of the mod
version="${mod_version}" #mandatory
# A display name for the mod
displayName="${mod_name}" #mandatory
# A URL to query for updates for this mod. See the JSON update specification https://docs.neoforged.net/docs/misc/updatechecker/
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI
displayURL="https://github.com/sebinside/CraftingKeys" #optional
# A file name (in the root of the mod JAR) containing a logo for display
#logoFile="examplemod.png" #optional
# A text field displayed in the mod UI
credits="Based on the open-source InvTweaks-Mod. Thanks a lot!" #optional
# The authors of the mod, displayed in the mod UI (optional)
authors="skate702 (sebinside), Meduris"
# The description text for the mod (multi line!) (#mandatory)
description='''
Simple better crafting! Crafing Keys enables new inventory key-bindings to speed up your crafting.
'''
# The [[mixins]] block allows you to declare your mixin config to FML so that it gets loaded.
#[[mixins]]
#config="${mod_id}.mixins.json"
# The [[accessTransformers]] block allows you to declare where your AT file is.
# If this block is omitted, a fallback attempt will be made to load an AT from META-INF/accesstransformer.cfg
#[[accessTransformers]]
#file="META-INF/accesstransformer.cfg"
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.${mod_id}]] #optional
# the modid of the dependency
modId="neoforge" #mandatory
# The type of the dependency. Can be one of "required", "optional", "incompatible" or "discouraged" (case insensitive).
# 'required' requires the mod to exist, 'optional' does not
# 'incompatible' will prevent the game from loading when the mod exists, and 'discouraged' will show a warning
type="required" #mandatory
# Optional field describing why the dependency is required or why it is incompatible
# reason="..."
# The version range of the dependency
versionRange="[${neo_version},)" #mandatory
# An ordering relationship for the dependency.
# BEFORE - This mod is loaded BEFORE the dependency
# AFTER - This mod is loaded AFTER the dependency
ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
side="BOTH"
# Here's another dependency
[[dependencies.${mod_id}]]
modId="minecraft"
type="required"
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="${minecraft_version_range}"
ordering="NONE"
side="BOTH"
# Features are specific properties of the game environment, that you may want to declare you require. This example declares
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
# stop your mod loading on the server for example.
#[features.${mod_id}]
#openGLVersion="[3.2,)"