mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-15 17:54:50 +00:00
Compare commits
48
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d613d06471 | ||
|
|
65ffbad491 | ||
|
|
885609720e | ||
|
|
bacf246504 | ||
|
|
1ab3350eb8 | ||
|
|
f3aa12483d | ||
|
|
d86c472790 | ||
|
|
4124151208 | ||
|
|
68ad800620 | ||
|
|
2c7207485d | ||
|
|
e8094794c3 | ||
|
|
ad86d8f9c5 | ||
|
|
30c87e9160 | ||
|
|
5eeb001534 | ||
|
|
962754ee10 | ||
|
|
0e34840c21 | ||
|
|
a12fadb10d | ||
|
|
9218e233aa | ||
|
|
23e16abae6 | ||
|
|
b3cb4db9ca | ||
|
|
45fea43a4b | ||
|
|
088d9c08a8 | ||
|
|
98547c2bcf | ||
|
|
02fa633043 | ||
|
|
9df6ab0232 | ||
|
|
89cc203875 | ||
|
|
4b247d08a5 | ||
|
|
8ecc8f20d5 | ||
|
|
74b9f8339a | ||
|
|
e20756a196 | ||
|
|
6d0f83c499 | ||
|
|
8e219c06be | ||
|
|
3fc576b6fc | ||
|
|
249cb2b308 | ||
|
|
e8d8c1994b | ||
|
|
195b47944f | ||
|
|
3224fdef7d | ||
|
|
46a159d788 | ||
|
|
bd20e00a6e | ||
|
|
bf06b09d5a | ||
|
|
1b1dd3567a | ||
|
|
f106b5e766 | ||
|
|
f1dea5460a | ||
|
|
9b73b94d16 | ||
|
|
e133afc774 | ||
|
|
75ff631f16 | ||
|
|
6f5d45c4ea | ||
|
|
fb51475bb9 |
No files matched your search
@@ -0,0 +1,2 @@
|
||||
# Ignore spotlessApply reformat
|
||||
f106b5e7665df6341ae8539f74dc391a7efc98b1
|
||||
@@ -27,3 +27,4 @@ whitelist.json
|
||||
*.iws
|
||||
src/main/resources/mixins.*.json
|
||||
*.bat
|
||||
.DS_Store
|
||||
@@ -12,7 +12,7 @@ If you have issues with NEI outside of the GTNH modpack you may report them in t
|
||||
- Uses a parallel stream to search the item list over multiple cores, resulting in 2-6x faster searches on average
|
||||
- Loads the recipe handlers in parallel
|
||||
* A textbox for search with most of the features you'd expect - moving forward, backwards, selection, etc
|
||||
* Bookmarks! What are you in the process of crafting? Bookmark it using either 'A' or configure your own key.
|
||||
* Bookmarks! Are you in the process of crafting? Bookmark it using either 'A' or configure your own key.
|
||||
* Toggle bookmark pane. Default shortcut key `B`. Item Subsets menu is only available if bookmarks are not visible.
|
||||
* Utility/Cheat buttons line up and wrap based on GUI size
|
||||
* ItemList is no longer regenerated from the ItemRegistry on every inventory load
|
||||
@@ -27,13 +27,6 @@ If you have issues with NEI outside of the GTNH modpack you may report them in t
|
||||
* Remove TMI style
|
||||
* Removed inventory Load/Save state
|
||||
|
||||
## Development
|
||||
Before launching, you need to add
|
||||
```
|
||||
-Dfml.coreMods.load=codechicken.nei.asm.NEICorePlugin
|
||||
```
|
||||
as a command line argument to the VM.
|
||||
|
||||
## License
|
||||
|
||||
GTNH Modifications Copyright (c) 2019-2022 mitchej123 and the GTNH Team
|
||||
|
||||
+911
-526
File diff suppressed because it is too large.
Load diff
+3
-3
@@ -1,7 +1,7 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
compile('com.github.GTNewHorizons:CodeChickenLib:1.1.5.5:dev')
|
||||
compile('com.github.GTNewHorizons:CodeChickenCore:1.1.6:dev')
|
||||
shadowImplementation('org.apache.commons:commons-csv:1.8')
|
||||
api('com.github.GTNewHorizons:CodeChickenLib:1.1.8:dev')
|
||||
api('com.github.GTNewHorizons:CodeChickenCore:1.1.11:dev')
|
||||
shadowImplementation('org.apache.commons:commons-csv:1.10.0')
|
||||
}
|
||||
+13
-5
@@ -26,11 +26,19 @@ developmentEnvironmentUserName = Developer
|
||||
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
|
||||
# version in @Mod([...], version = VERSION, [...])
|
||||
# Leave these properties empty to skip individual token replacements
|
||||
replaceGradleTokenInFile = NEIModContainer.java
|
||||
gradleTokenModId = GRADLETOKEN_MODID
|
||||
gradleTokenModName = GRADLETOKEN_MODNAME
|
||||
gradleTokenVersion = GRADLETOKEN_VERSION
|
||||
gradleTokenGroupName =
|
||||
# Generate a class with String fields for the mod id, name, version and group name named with the fields below
|
||||
generateGradleTokenClass = codechicken.nei.Tags
|
||||
gradleTokenModId = MODID
|
||||
gradleTokenModName = MODNAME
|
||||
gradleTokenVersion = VERSION
|
||||
gradleTokenGroupName = GROUPNAME
|
||||
# [DEPRECATED]
|
||||
# Multiple source files can be defined here by providing a comma-seperated list: Class1.java,Class2.java,Class3.java
|
||||
# public static final String VERSION = "GRADLETOKEN_VERSION";
|
||||
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
|
||||
# version in @Mod([...], version = VERSION, [...])
|
||||
# Leave these properties empty to skip individual token replacements
|
||||
replaceGradleTokenInFile =
|
||||
|
||||
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
|
||||
# leave this property empty.
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+2
-1
@@ -1,5 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -17,78 +17,113 @@
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
# Resolve links: $0 may be a link
|
||||
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
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# 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"'
|
||||
|
||||
# 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
|
||||
@@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
@@ -105,84 +140,105 @@ location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
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 or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# 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=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# 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
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
+15
-23
@@ -14,7 +14,7 @@
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@@ -25,10 +25,14 @@
|
||||
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="-Xmx64m" "-Xms64m"
|
||||
|
||||
@@ -37,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@@ -51,7 +55,7 @@ goto fail
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
@@ -61,38 +65,26 @@ echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
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
|
||||
|
||||
@@ -1,15 +1,4 @@
|
||||
// Add any additional repositiroes for your dependencies here
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name 'GTNH Maven'
|
||||
url 'http://jenkins.usrv.eu:8081/nexus/content/groups/public/'
|
||||
}
|
||||
maven {
|
||||
url 'https://cursemaven.com'
|
||||
content {
|
||||
includeGroup 'curse.maven'
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
-3
@@ -1,10 +1,31 @@
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven {
|
||||
// RetroFuturaGradle
|
||||
name "GTNH Maven"
|
||||
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||
allowInsecureProtocol = true
|
||||
mavenContent {
|
||||
includeGroup("com.gtnewhorizons.retrofuturagradle")
|
||||
}
|
||||
}
|
||||
gradlePluginPortal()
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.diffplug.blowdryerSetup' version '1.6.0'
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' // Provides java toolchains
|
||||
}
|
||||
|
||||
apply plugin: 'com.diffplug.blowdryerSetup'
|
||||
|
||||
blowdryerSetup {
|
||||
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.1.4')
|
||||
repoSubfolder 'gtnhShared'
|
||||
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.0')
|
||||
//devLocal '.' // Use this when testing config updates locally
|
||||
}
|
||||
|
||||
rootProject.name = "NotEnoughItems"
|
||||
|
||||
@@ -4,17 +4,6 @@ import static codechicken.lib.gui.GuiDraw.drawRect;
|
||||
import static codechicken.lib.gui.GuiDraw.getMousePosition;
|
||||
import static codechicken.nei.NEIClientUtils.translate;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.ItemPanel.ItemPanelSlot;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.BookmarkRecipeId;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.util.NBTJson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import java.awt.Point;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -23,19 +12,32 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.ItemPanel.ItemPanelSlot;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.BookmarkRecipeId;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.util.NBTJson;
|
||||
import codechicken.nei.util.ReadableNumberConverter;
|
||||
|
||||
public class BookmarkPanel extends PanelWidget {
|
||||
|
||||
protected File bookmarkFile;
|
||||
@@ -51,6 +53,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
protected int activeNamespaceIndex = 0;
|
||||
|
||||
protected static class BookmarkStackMeta {
|
||||
|
||||
public int factor;
|
||||
public BookmarkRecipeId recipeId;
|
||||
public boolean ingredient = false;
|
||||
@@ -69,7 +72,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
TODO_LIST
|
||||
}
|
||||
|
||||
protected static class BookmarkGrid extends ItemsGrid {
|
||||
public static class BookmarkGrid extends ItemsGrid {
|
||||
|
||||
protected static final float SCALE_SPEED = 0.1f;
|
||||
|
||||
@@ -81,6 +84,10 @@ public class BookmarkPanel extends PanelWidget {
|
||||
protected boolean[] todoSpaces;
|
||||
protected int todoItemsCount = 0;
|
||||
|
||||
public BookmarkGrid() {
|
||||
this.setShowRecipeTooltips(true);
|
||||
}
|
||||
|
||||
public void setViewMode(BookmarkViewMode mode) {
|
||||
if (viewMode == mode) {
|
||||
return;
|
||||
@@ -175,11 +182,8 @@ public class BookmarkPanel extends PanelWidget {
|
||||
} else {
|
||||
meta = getMetadata(idx);
|
||||
|
||||
if (idx > 0
|
||||
&& ((i % columns) == 0)
|
||||
== (meta.recipeId != null
|
||||
&& meta.ingredient
|
||||
&& meta.recipeId.equals(getRecipeId(idx - 1)))) {
|
||||
if (idx > 0 && ((i % columns) == 0) == (meta.recipeId != null && meta.ingredient
|
||||
&& meta.recipeId.equals(getRecipeId(idx - 1)))) {
|
||||
pmask.add(null);
|
||||
} else {
|
||||
pmask.add(idx++);
|
||||
@@ -210,7 +214,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
for (int idx = 0; idx < realItems.size(); idx++) {
|
||||
final BookmarkStackMeta meta = getMetadata(idx);
|
||||
if ((recipeId == null && meta.recipeId == null
|
||||
|| recipeId != null && meta.recipeId != null && recipeId.equals(meta.recipeId))
|
||||
|| recipeId != null && meta.recipeId != null && recipeId.equals(meta.recipeId))
|
||||
&& StackInfo.equalItemAndNBT(stackA, getItem(idx), useNBT)) {
|
||||
return idx;
|
||||
}
|
||||
@@ -296,8 +300,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
}
|
||||
|
||||
private boolean isPartOfFocusedRecipe(ItemPanelSlot focused, int myIdx) {
|
||||
return NEIClientUtils.shiftKey()
|
||||
&& focused != null
|
||||
return NEIClientUtils.shiftKey() && focused != null
|
||||
&& LayoutManager.bookmarkPanel.sortedStackIndex == -1
|
||||
&& getRecipeId(focused.slotIndex) != null
|
||||
&& getRecipeId(myIdx) != null
|
||||
@@ -313,12 +316,8 @@ public class BookmarkPanel extends PanelWidget {
|
||||
} else if (focus != null) {
|
||||
BookmarkStackMeta meta = getMetadata(idx);
|
||||
if (isPartOfFocusedRecipe(focus, idx)) {
|
||||
drawRect(
|
||||
rect.x,
|
||||
rect.y,
|
||||
rect.w,
|
||||
rect.h,
|
||||
meta.ingredient ? 0x88b3b300 : 0x88009933); // highlight recipe
|
||||
drawRect(rect.x, rect.y, rect.w, rect.h, meta.ingredient ? 0x88b3b300 : 0x88009933); // highlight
|
||||
// recipe
|
||||
} else if (focus.slotIndex == idx) {
|
||||
drawRect(rect.x, rect.y, rect.w, rect.h, 0xee555555); // highlight
|
||||
}
|
||||
@@ -331,16 +330,14 @@ public class BookmarkPanel extends PanelWidget {
|
||||
|| LayoutManager.bookmarkPanel.sortedStackIndex != idx) {
|
||||
final ItemStack stack = getItem(idx);
|
||||
final BookmarkStackMeta meta = getMetadata(idx);
|
||||
final String stackSize = meta.factor < 0 || meta.fluidDisplay ? "" : String.valueOf(stack.stackSize);
|
||||
|
||||
final String stackSize = meta.factor < 0 || meta.fluidDisplay ? ""
|
||||
: ReadableNumberConverter.INSTANCE.toWideReadableForm(stack.stackSize);
|
||||
if (animation.containsKey(stack) && animation.get(stack) < 1) {
|
||||
final float currentScale = animation.get(stack) + SCALE_SPEED;
|
||||
animation.put(stack, currentScale);
|
||||
drawPoppingItem(rect, stack, stackSize, currentScale);
|
||||
} else {
|
||||
|
||||
GuiContainerManager.drawItem(rect.x + 1, rect.y + 1, stack, true, stackSize);
|
||||
|
||||
if (meta.recipeId != null && !meta.ingredient && NEIClientConfig.showRecipeMarker()) {
|
||||
drawRecipeMarker(rect.x, rect.y, GuiContainerManager.getFontRenderer(stack));
|
||||
}
|
||||
@@ -388,6 +385,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
namespaceLabel = new Label("1", true);
|
||||
|
||||
namespacePrev = new Button("Prev") {
|
||||
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
|
||||
if (rightclick) {
|
||||
@@ -404,6 +402,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
};
|
||||
|
||||
namespaceNext = new Button("Next") {
|
||||
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (rightclick) {
|
||||
return false;
|
||||
@@ -433,16 +432,29 @@ public class BookmarkPanel extends PanelWidget {
|
||||
return String.format("(%d/%d) [%d]", getPage(), Math.max(1, getNumPages()), size);
|
||||
}
|
||||
|
||||
public void addItem(ItemStack itemStack) {
|
||||
addItem(itemStack, true);
|
||||
}
|
||||
|
||||
public void addItem(ItemStack itemStack, boolean saveStackSize) {
|
||||
final BookmarkGrid BGrid = (BookmarkGrid) grid;
|
||||
int idx = BGrid.indexOf(itemStack, true);
|
||||
if (idx != -1) {
|
||||
BGrid.removeItem(idx);
|
||||
}
|
||||
addOrRemoveItem(itemStack, null, null, false, saveStackSize);
|
||||
}
|
||||
|
||||
public int getNameSpaceSize() {
|
||||
return namespaces.size();
|
||||
}
|
||||
|
||||
public void addOrRemoveItem(ItemStack stackA) {
|
||||
addOrRemoveItem(stackA, null, null, false, false);
|
||||
}
|
||||
|
||||
public void addOrRemoveItem(
|
||||
ItemStack stackover,
|
||||
final String handlerName,
|
||||
final List<PositionedStack> ingredients,
|
||||
boolean saveIngredients,
|
||||
boolean saveStackSize) {
|
||||
public void addOrRemoveItem(ItemStack stackover, final String handlerName, final List<PositionedStack> ingredients,
|
||||
boolean saveIngredients, boolean saveStackSize) {
|
||||
loadBookmarksIfNeeded();
|
||||
|
||||
final Point mousePos = getMousePosition();
|
||||
@@ -456,7 +468,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
final ItemStack normalizedA = StackInfo.loadFromNBT(nbTagA);
|
||||
BookmarkRecipeId recipeId = null;
|
||||
|
||||
if (handlerName != "" && ingredients != null && !ingredients.isEmpty()) {
|
||||
if (handlerName != "" && ingredients != null) {
|
||||
recipeId = new BookmarkRecipeId(handlerName, ingredients);
|
||||
}
|
||||
|
||||
@@ -466,7 +478,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
BGrid.removeRecipe(idx, saveIngredients);
|
||||
} else {
|
||||
|
||||
if (saveIngredients && handlerName != "" && ingredients != null && !ingredients.isEmpty()) {
|
||||
if (saveIngredients && handlerName != "" && ingredients != null) {
|
||||
final Map<NBTTagCompound, Integer> unique = new HashMap<>();
|
||||
final ArrayList<NBTTagCompound> sorted = new ArrayList<>();
|
||||
|
||||
@@ -518,7 +530,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
BookmarkRecipeId recipeId = ((BookmarkGrid) grid).findRecipeId(stackA);
|
||||
|
||||
if (recipeId == null) {
|
||||
for (int idx = 0; idx < namespaces.size() && recipeId == null; idx++) {
|
||||
for (int idx = 0; idx < getNameSpaceSize() && recipeId == null; idx++) {
|
||||
if (idx == activeNamespaceIndex) continue;
|
||||
recipeId = namespaces.get(idx).findRecipeId(stackA);
|
||||
}
|
||||
@@ -535,18 +547,18 @@ public class BookmarkPanel extends PanelWidget {
|
||||
|
||||
protected int fixCountOfNamespaces() {
|
||||
|
||||
if (namespaces.get(namespaces.size() - 1).size() > 0) {
|
||||
if (namespaces.get(getNameSpaceSize() - 1).size() > 0) {
|
||||
namespaces.add(new BookmarkGrid());
|
||||
} else if (activeNamespaceIndex == namespaces.size() - 2 && grid.size() == 0) {
|
||||
namespaces.remove(namespaces.size() - 1);
|
||||
} else if (activeNamespaceIndex == getNameSpaceSize() - 2 && grid.size() == 0) {
|
||||
namespaces.remove(getNameSpaceSize() - 1);
|
||||
}
|
||||
|
||||
return namespaces.size();
|
||||
return getNameSpaceSize();
|
||||
}
|
||||
|
||||
protected boolean removeEmptyNamespaces() {
|
||||
|
||||
if (activeNamespaceIndex != namespaces.size() - 1 && grid.size() == 0) {
|
||||
if (activeNamespaceIndex != getNameSpaceSize() - 1 && grid.size() == 0) {
|
||||
namespaces.remove(activeNamespaceIndex);
|
||||
grid = namespaces.get(activeNamespaceIndex);
|
||||
return true;
|
||||
@@ -564,7 +576,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
removeEmptyNamespaces();
|
||||
|
||||
if (activeNamespaceIndex == 0) {
|
||||
activeNamespaceIndex = namespaces.size() - 1;
|
||||
activeNamespaceIndex = getNameSpaceSize() - 1;
|
||||
} else {
|
||||
activeNamespaceIndex--;
|
||||
}
|
||||
@@ -622,8 +634,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
src.close();
|
||||
dst.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
}
|
||||
} catch (IOException e) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -638,7 +649,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
|
||||
for (int grpIdx = 0; grpIdx < namespaces.size() - 1; grpIdx++) {
|
||||
for (int grpIdx = 0; grpIdx < getNameSpaceSize() - 1; grpIdx++) {
|
||||
final BookmarkGrid grid = namespaces.get(grpIdx);
|
||||
|
||||
JsonObject settings = new JsonObject();
|
||||
@@ -725,10 +736,8 @@ public class BookmarkPanel extends PanelWidget {
|
||||
}
|
||||
|
||||
if (settings.get("viewmode") != null) {
|
||||
namespaces
|
||||
.get(namespaceIndex)
|
||||
.setViewMode(BookmarkViewMode.valueOf(
|
||||
settings.get("viewmode").getAsString()));
|
||||
namespaces.get(namespaceIndex)
|
||||
.setViewMode(BookmarkViewMode.valueOf(settings.get("viewmode").getAsString()));
|
||||
}
|
||||
|
||||
if (settings.get("active") != null && settings.get("active").getAsBoolean()) {
|
||||
@@ -755,22 +764,14 @@ public class BookmarkPanel extends PanelWidget {
|
||||
ItemStack itemStack = StackInfo.loadFromNBT(itemStackNBT);
|
||||
|
||||
if (itemStack != null) {
|
||||
namespaces
|
||||
.get(namespaceIndex)
|
||||
.addItem(
|
||||
itemStack,
|
||||
new BookmarkStackMeta(
|
||||
recipeId,
|
||||
jsonObject.has("factor")
|
||||
? jsonObject.get("factor").getAsInt()
|
||||
: 0,
|
||||
jsonObject.has("ingredient")
|
||||
? jsonObject
|
||||
.get("ingredient")
|
||||
.getAsBoolean()
|
||||
: false,
|
||||
itemStackNBT.hasKey("gtFluidName")),
|
||||
false);
|
||||
namespaces.get(namespaceIndex).addItem(
|
||||
itemStack,
|
||||
new BookmarkStackMeta(
|
||||
recipeId,
|
||||
jsonObject.has("factor") ? jsonObject.get("factor").getAsInt() : 0,
|
||||
jsonObject.has("ingredient") ? jsonObject.get("ingredient").getAsBoolean() : false,
|
||||
itemStackNBT.hasKey("gtFluidName")),
|
||||
false);
|
||||
} else {
|
||||
NEIClientConfig.logger.warn(
|
||||
"Failed to load bookmarked ItemStack from json string, the item no longer exists:\n{}",
|
||||
@@ -934,8 +935,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
} else if (sortedGrid.getViewMode() == BookmarkViewMode.TODO_LIST) {
|
||||
final ItemStack stack = sortedGrid.getItem(sortedStackIndex);
|
||||
final BookmarkStackMeta meta = sortedGrid.getMetadata(sortedStackIndex);
|
||||
final boolean isIngredient = sortedStackIndex > 0
|
||||
&& meta.recipeId != null
|
||||
final boolean isIngredient = sortedStackIndex > 0 && meta.recipeId != null
|
||||
&& meta.ingredient
|
||||
&& meta.recipeId.equals(sortedGrid.getRecipeId(sortedStackIndex - 1));
|
||||
|
||||
@@ -947,13 +947,12 @@ public class BookmarkPanel extends PanelWidget {
|
||||
sortedStackIndex = sortedGrid.indexOf(stack, meta.recipeId);
|
||||
}
|
||||
|
||||
} else if (mouseOverSlot != null
|
||||
&& meta.recipeId != null
|
||||
} else if (mouseOverSlot != null && meta.recipeId != null
|
||||
&& sortedGrid.getMetadata(mouseOverSlot.slotIndex).ingredient
|
||||
&& meta.recipeId.equals(sortedGrid.getRecipeId(mouseOverSlot.slotIndex))) {
|
||||
sortedGrid.moveItem(sortedStackIndex, mouseOverSlot.slotIndex);
|
||||
sortedStackIndex = sortedGrid.indexOf(stack, meta.recipeId);
|
||||
}
|
||||
sortedGrid.moveItem(sortedStackIndex, mouseOverSlot.slotIndex);
|
||||
sortedStackIndex = sortedGrid.indexOf(stack, meta.recipeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -992,10 +991,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
GuiContainerManager.drawItem(
|
||||
mousex - 8,
|
||||
mousey - 8,
|
||||
namespaces
|
||||
.get(sortedNamespaceIndex)
|
||||
.getItem(sortedStackIndex)
|
||||
.copy(),
|
||||
namespaces.get(sortedNamespaceIndex).getItem(sortedStackIndex).copy(),
|
||||
true);
|
||||
GuiContainerManager.drawItems.zLevel -= 100;
|
||||
}
|
||||
@@ -1061,11 +1057,10 @@ public class BookmarkPanel extends PanelWidget {
|
||||
public boolean onMouseWheel(int shift, int mousex, int mousey) {
|
||||
|
||||
if (new Rectangle4i(
|
||||
namespacePrev.x,
|
||||
namespacePrev.y,
|
||||
namespaceNext.x + namespaceNext.w - namespacePrev.x,
|
||||
namespacePrev.h)
|
||||
.contains(mousex, mousey)) {
|
||||
namespacePrev.x,
|
||||
namespacePrev.y,
|
||||
namespaceNext.x + namespaceNext.w - namespacePrev.x,
|
||||
namespacePrev.h).contains(mousex, mousey)) {
|
||||
|
||||
if (shift > 0) {
|
||||
prevNamespace();
|
||||
@@ -1121,8 +1116,10 @@ public class BookmarkPanel extends PanelWidget {
|
||||
meta.factor = factor;
|
||||
} else {
|
||||
meta.factor = nbTag.getInteger("Count") == factor && shift < 0 ? -1 * factor : factor;
|
||||
nbTag.setInteger("Count", Math.max(nbTag.getInteger("Count") + factor * shift, factor));
|
||||
BGrid.replaceItem(slotIndex, StackInfo.loadFromNBT(nbTag));
|
||||
if ((long) nbTag.getInteger("Count") + ((long) factor * shift) <= Integer.MAX_VALUE) {
|
||||
nbTag.setInteger("Count", Math.max(nbTag.getInteger("Count") + factor * shift, factor));
|
||||
BGrid.replaceItem(slotIndex, StackInfo.loadFromNBT(nbTag));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import static codechicken.lib.gui.GuiDraw.getStringWidth;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Button extends Widget {
|
||||
|
||||
public Button(String s) {
|
||||
label = s;
|
||||
}
|
||||
@@ -60,10 +61,7 @@ public abstract class Button extends Widget {
|
||||
public Image icon;
|
||||
|
||||
/**
|
||||
* 0x4 = state flag, as opposed to 1 click
|
||||
* 0 = normal
|
||||
* 1 = on
|
||||
* 2 = disabled
|
||||
* 0x4 = state flag, as opposed to 1 click 0 = normal 1 = on 2 = disabled
|
||||
*/
|
||||
public int state;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package codechicken.nei;
|
||||
|
||||
public abstract class ButtonCycled extends Button {
|
||||
|
||||
public ButtonCycled() {}
|
||||
|
||||
public ButtonCycled(int num) {
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.core.ClientUtils;
|
||||
import codechicken.core.GuiModListScroll;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.recipe.GuiRecipeTab;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import cpw.mods.fml.client.CustomModLoadingErrorDisplayException;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
@@ -23,14 +9,12 @@ import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
@@ -44,32 +28,35 @@ import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import org.apache.commons.csv.CSVFormat;
|
||||
import org.apache.commons.csv.CSVParser;
|
||||
import org.apache.commons.csv.CSVRecord;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import codechicken.core.ClientUtils;
|
||||
import codechicken.core.GuiModListScroll;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.recipe.GuiRecipeTab;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import cpw.mods.fml.client.CustomModLoadingErrorDisplayException;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
|
||||
public class ClientHandler {
|
||||
private static String[] defaultSerialHandlers = {"WayofTime.alchemicalWizardry.client.nei.NEIAlchemyRecipeHandler"};
|
||||
private static String[] defaultHeightHackHandlerRegex = {
|
||||
"buildcraft.compat.nei.*",
|
||||
"cofh.thermalexpansion.plugins.nei.handlers.*",
|
||||
"crazypants.enderio.nei.*",
|
||||
"forestry.factory.recipes.nei.*",
|
||||
"ic2.neiIntegration.core.recipehandler.*",
|
||||
"mariculture.plugins.nei.*",
|
||||
"redgear.brewcraft.plugins.nei.*",
|
||||
"tconstruct.plugins.nei.*",
|
||||
"WayofTime.alchemicalWizardry.client.nei.*",
|
||||
};
|
||||
|
||||
private static String[] defaultHandlerOrdering = {
|
||||
"# Each line in this file should either be a comment (starts with '#') or an ordering.",
|
||||
"# Ordering lines are <handler ID>,<ordering number>.",
|
||||
"# Handlers will be sorted in order of number ascending, so smaller numbers first.",
|
||||
"# Any handlers that are missing from this file will be assigned to 0.",
|
||||
"# Negative numbers are fine.",
|
||||
"# If you delete this file, it will be regenerated with all registered handler IDs.",
|
||||
};
|
||||
"# Each line in this file should either be a comment (starts with '#') or an ordering.",
|
||||
"# Ordering lines are <handler ID>,<ordering number>.",
|
||||
"# Handlers will be sorted in order of number ascending, so smaller numbers first.",
|
||||
"# Any handlers that are missing from this file will be assigned to 0.", "# Negative numbers are fine.",
|
||||
"# If you delete this file, it will be regenerated with all registered handler IDs.", };
|
||||
private static ClientHandler instance;
|
||||
|
||||
private ArrayList<EntityItem> SMPmagneticItems = new ArrayList<>();
|
||||
@@ -100,9 +87,10 @@ public class ClientHandler {
|
||||
items = SMPmagneticItems;
|
||||
} else {
|
||||
items = world.getEntitiesWithinAABB(
|
||||
EntityItem.class, player.boundingBox.expand(distancexz, distancey, distancexz));
|
||||
EntityItem.class,
|
||||
player.boundingBox.expand(distancexz, distancey, distancexz));
|
||||
}
|
||||
for (Iterator<EntityItem> iterator = items.iterator(); iterator.hasNext(); ) {
|
||||
for (Iterator<EntityItem> iterator = items.iterator(); iterator.hasNext();) {
|
||||
EntityItem item = iterator.next();
|
||||
|
||||
if (item.delayBeforeCanPickup > 0) continue;
|
||||
@@ -166,17 +154,19 @@ public class ClientHandler {
|
||||
if (!file.exists()) {
|
||||
try (FileWriter writer = new FileWriter(file)) {
|
||||
NEIClientConfig.logger.info("Creating default serial handlers list {}", file);
|
||||
Collection<String> toSave = Loader.isModLoaded("dreamcraft")
|
||||
? Collections.singletonList("")
|
||||
: Arrays.asList(defaultSerialHandlers);
|
||||
IOUtils.writeLines(toSave, "\n", writer);
|
||||
URL defaultSerialHandlersResource = ClientHandler.class
|
||||
.getResource("/assets/nei/cfg/serialhandlers.cfg");
|
||||
if (defaultSerialHandlersResource != null) {
|
||||
IOUtils.copy(defaultSerialHandlersResource.openStream(), writer);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to save default serial handlers list to file {}", file, e);
|
||||
}
|
||||
}
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
NEIClientConfig.logger.info("Loading serial handlers from file {}", file);
|
||||
NEIClientConfig.serialHandlers = new HashSet<>(IOUtils.readLines(reader));
|
||||
NEIClientConfig.serialHandlers = IOUtils.readLines(reader).stream().filter((line) -> !line.startsWith("#"))
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to load serial handlers from file {}", file, e);
|
||||
}
|
||||
@@ -187,8 +177,11 @@ public class ClientHandler {
|
||||
if (!file.exists()) {
|
||||
try (FileWriter writer = new FileWriter(file)) {
|
||||
NEIClientConfig.logger.info("Creating default height hack handlers list {}", file);
|
||||
Collection<String> toSave = Arrays.asList(defaultHeightHackHandlerRegex);
|
||||
IOUtils.writeLines(toSave, "\n", writer);
|
||||
URL defaultHeightHackHandlersResource = ClientHandler.class
|
||||
.getResource("/assets/nei/cfg/heighthackhandlers.cfg");
|
||||
if (defaultHeightHackHandlersResource != null) {
|
||||
IOUtils.copy(defaultHeightHackHandlersResource.openStream(), writer);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to save default height hack handlers list to file {}", file, e);
|
||||
}
|
||||
@@ -197,7 +190,7 @@ public class ClientHandler {
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
NEIClientConfig.logger.info("Loading height hack handlers from file {}", file);
|
||||
NEIClientConfig.heightHackHandlerRegex = IOUtils.readLines(reader).stream()
|
||||
.map(Pattern::compile)
|
||||
.filter((line) -> !line.startsWith("#")).map(Pattern::compile)
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to load height hack handlers from file {}", file, e);
|
||||
@@ -228,8 +221,7 @@ public class ClientHandler {
|
||||
NEIClientConfig.logger.info("Creating default handler ordering CSV {}", file);
|
||||
|
||||
List<String> toWrite = Lists.newArrayList(defaultHandlerOrdering);
|
||||
GuiRecipeTab.handlerMap.keySet().stream()
|
||||
.sorted()
|
||||
GuiRecipeTab.handlerMap.keySet().stream().sorted()
|
||||
.forEach(handlerId -> toWrite.add(String.format("%s,0", handlerId)));
|
||||
|
||||
IOUtils.writeLines(toWrite, "\n", writer);
|
||||
@@ -279,7 +271,11 @@ public class ClientHandler {
|
||||
|
||||
if (!NEIClientConfig.isEnabled()) return;
|
||||
|
||||
KeyManager.tickKeyStates();
|
||||
/*
|
||||
* NEI plugins are loaded in a separate thread. Make sure loading them has finished otherwise a CME might
|
||||
* occur in KeyManager if a plugin calls API.addKeyBind() during initialization.
|
||||
*/
|
||||
if (NEIClientConfig.isLoaded()) KeyManager.tickKeyStates();
|
||||
|
||||
NEIController.updateUnlimitedItems(mc.thePlayer.inventory);
|
||||
if (mc.currentScreen == null) NEIController.processCreativeCycling(mc.thePlayer.inventory);
|
||||
@@ -319,7 +315,7 @@ public class ClientHandler {
|
||||
NEIClientConfig.setInternalEnabled(false);
|
||||
|
||||
if (!Minecraft.getMinecraft().isSingleplayer()) // wait for server to initiate in singleplayer
|
||||
NEIClientConfig.loadWorld("remote/" + ClientUtils.getServerIP().replace(':', '~'));
|
||||
NEIClientConfig.loadWorld("remote/" + ClientUtils.getServerIP().replace(':', '~'));
|
||||
|
||||
ItemMobSpawner.clearEntityReferences(world);
|
||||
}
|
||||
@@ -334,6 +330,7 @@ public class ClientHandler {
|
||||
|
||||
public static RuntimeException throwCME(final String message) {
|
||||
final GuiScreen errorGui = new GuiErrorScreen(null, null) {
|
||||
|
||||
@Override
|
||||
public void handleMouseInput() {}
|
||||
|
||||
@@ -351,17 +348,14 @@ public class ClientHandler {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
CustomModLoadingErrorDisplayException e = new CustomModLoadingErrorDisplayException() {
|
||||
|
||||
@Override
|
||||
public void initGui(GuiErrorScreen errorScreen, FontRenderer fontRenderer) {
|
||||
Minecraft.getMinecraft().displayGuiScreen(errorGui);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(
|
||||
GuiErrorScreen errorScreen,
|
||||
FontRenderer fontRenderer,
|
||||
int mouseRelX,
|
||||
int mouseRelY,
|
||||
public void drawScreen(GuiErrorScreen errorScreen, FontRenderer fontRenderer, int mouseRelX, int mouseRelY,
|
||||
float tickTime) {}
|
||||
};
|
||||
throw e;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -11,8 +9,13 @@ import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ContainerCreativeInv extends Container {
|
||||
|
||||
private class SlotArmor extends Slot {
|
||||
|
||||
final int armorType;
|
||||
|
||||
public SlotArmor(IInventory inv, int x, int y, int slot, int armor) {
|
||||
@@ -38,14 +41,15 @@ public class ContainerCreativeInv extends Container {
|
||||
}
|
||||
|
||||
private class SlotBlockArmor extends SlotArmor {
|
||||
|
||||
public SlotBlockArmor(IInventory inv, int x, int y, int slot, int armor) {
|
||||
super(inv, x, y, slot, armor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return super.isItemValid(stack)
|
||||
|| stack != null; // && Block.getBlockFromItem(stack.getItem()) != Blocks.air;
|
||||
return super.isItemValid(stack) || stack != null; // && Block.getBlockFromItem(stack.getItem()) !=
|
||||
// Blocks.air;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,20 +58,22 @@ public class ContainerCreativeInv extends Container {
|
||||
public ContainerCreativeInv(EntityPlayer player, ExtendedCreativeInv extraInv) {
|
||||
this.player = player;
|
||||
InventoryPlayer invPlayer = player.inventory;
|
||||
for (int row = 0; row < 6; row++)
|
||||
for (int col = 0; col < 9; col++)
|
||||
addSlotToContainer(new Slot(extraInv, col + row * 9, 8 + col * 18, 5 + row * 18));
|
||||
for (int row = 0; row < 6; row++) for (int col = 0; col < 9; col++)
|
||||
addSlotToContainer(new Slot(extraInv, col + row * 9, 8 + col * 18, 5 + row * 18));
|
||||
|
||||
for (int row = 0; row < 3; ++row)
|
||||
for (int col = 0; col < 9; ++col)
|
||||
addSlotToContainer(new Slot(invPlayer, col + row * 9 + 9, 8 + col * 18, 118 + row * 18));
|
||||
for (int row = 0; row < 3; ++row) for (int col = 0; col < 9; ++col)
|
||||
addSlotToContainer(new Slot(invPlayer, col + row * 9 + 9, 8 + col * 18, 118 + row * 18));
|
||||
|
||||
for (int col = 0; col < 9; ++col) addSlotToContainer(new Slot(invPlayer, col, 8 + col * 18, 176));
|
||||
|
||||
addSlotToContainer(new SlotBlockArmor(invPlayer, invPlayer.getSizeInventory() - 1, -15, 23, 0));
|
||||
for (int armorType = 1; armorType < 4; armorType++)
|
||||
addSlotToContainer(new SlotArmor(
|
||||
invPlayer, invPlayer.getSizeInventory() - 1 - armorType, -15, 23 + armorType * 18, armorType));
|
||||
for (int armorType = 1; armorType < 4; armorType++) addSlotToContainer(
|
||||
new SlotArmor(
|
||||
invPlayer,
|
||||
invPlayer.getSizeInventory() - 1 - armorType,
|
||||
-15,
|
||||
23 + armorType * 18,
|
||||
armorType));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.lib.render.CCRenderState;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -13,13 +13,18 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.render.CCRenderState;
|
||||
|
||||
/**
|
||||
* This is crap code, don't ever do this.
|
||||
*/
|
||||
public class ContainerEnchantmentModifier extends ContainerEnchantment {
|
||||
|
||||
public static class EnchantmentHash {
|
||||
|
||||
public EnchantmentHash(Enchantment e, int i, int l) {
|
||||
enchantment = e;
|
||||
state = i;
|
||||
@@ -101,9 +106,7 @@ public class ContainerEnchantmentModifier extends ContainerEnchantment {
|
||||
int barempty = height - getScrollBarHeight();
|
||||
int sbary = rely + (int) (barempty * percentscrolled + 0.5);
|
||||
|
||||
if (button == 0
|
||||
&& getScrollBarHeight() < height
|
||||
&& // the scroll bar can move (not full length)
|
||||
if (button == 0 && getScrollBarHeight() < height && // the scroll bar can move (not full length)
|
||||
mousex >= relx + cwidth
|
||||
&& mousex < relx + cwidth + getScrollBarWidth()
|
||||
&& mousey >= rely
|
||||
@@ -217,10 +220,10 @@ public class ContainerEnchantmentModifier extends ContainerEnchantment {
|
||||
if (NEIServerUtils.stackHasEnchantment(toolstack, e.effectId)) {
|
||||
state = 2;
|
||||
level = NEIServerUtils.getEnchantmentLevel(toolstack, e.effectId);
|
||||
} else if (NEIServerUtils.doesEnchantmentConflict(NEIServerUtils.getEnchantments(toolstack), e)
|
||||
&& validate) {
|
||||
state = 1;
|
||||
}
|
||||
} else
|
||||
if (NEIServerUtils.doesEnchantmentConflict(NEIServerUtils.getEnchantments(toolstack), e) && validate) {
|
||||
state = 1;
|
||||
}
|
||||
slotEnchantment.add(new EnchantmentHash(e, state, level));
|
||||
}
|
||||
if (numoptions != slotEnchantment.size()) {
|
||||
@@ -255,7 +258,12 @@ public class ContainerEnchantmentModifier extends ContainerEnchantment {
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
if (hasScrollBar()) {
|
||||
gui.drawTexturedModalRect(
|
||||
relx, rely + slot * slotheight, 0, gui.ySize + slotheight * shade, cwidth - 30, slotheight);
|
||||
relx,
|
||||
rely + slot * slotheight,
|
||||
0,
|
||||
gui.ySize + slotheight * shade,
|
||||
cwidth - 30,
|
||||
slotheight);
|
||||
gui.drawTexturedModalRect(
|
||||
relx + cwidth - 30,
|
||||
rely + slot * slotheight,
|
||||
@@ -265,7 +273,12 @@ public class ContainerEnchantmentModifier extends ContainerEnchantment {
|
||||
slotheight);
|
||||
} else {
|
||||
gui.drawTexturedModalRect(
|
||||
relx, rely + slot * slotheight, 0, gui.ySize + slotheight * shade, cwidth + 7, slotheight);
|
||||
relx,
|
||||
rely + slot * slotheight,
|
||||
0,
|
||||
gui.ySize + slotheight * shade,
|
||||
cwidth + 7,
|
||||
slotheight);
|
||||
}
|
||||
|
||||
gui.getFontRenderer().drawString(text, relx + 4, rely + slot * slotheight + 5, textColourFromState(shade));
|
||||
@@ -284,12 +297,8 @@ public class ContainerEnchantmentModifier extends ContainerEnchantment {
|
||||
|
||||
Gui.drawRect(sbarx, rely, sbarx + getScrollBarWidth(), rely + height, 0xFF202020); // background
|
||||
Gui.drawRect(sbarx, sbary, sbarx + getScrollBarWidth(), sbary + getScrollBarHeight(), 0xFF8B8B8B); // corners
|
||||
Gui.drawRect(
|
||||
sbarx,
|
||||
sbary,
|
||||
sbarx + getScrollBarWidth() - 1,
|
||||
sbary + getScrollBarHeight() - 1,
|
||||
0xFFF0F0F0); // topleft up
|
||||
Gui.drawRect(sbarx, sbary, sbarx + getScrollBarWidth() - 1, sbary + getScrollBarHeight() - 1, 0xFFF0F0F0); // topleft
|
||||
// up
|
||||
Gui.drawRect(
|
||||
sbarx + 1,
|
||||
sbary + 1,
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.lib.inventory.ContainerExtended;
|
||||
import codechicken.lib.inventory.InventoryNBT;
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.lib.inventory.SlotHandleClicks;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -16,8 +11,16 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
|
||||
import codechicken.lib.inventory.ContainerExtended;
|
||||
import codechicken.lib.inventory.InventoryNBT;
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.lib.inventory.SlotHandleClicks;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
|
||||
public class ContainerPotionCreator extends ContainerExtended {
|
||||
|
||||
public class SlotPotion extends Slot {
|
||||
|
||||
public SlotPotion(IInventory inv, int slotIndex, int x, int y) {
|
||||
super(inv, slotIndex, x, y);
|
||||
}
|
||||
@@ -40,6 +43,7 @@ public class ContainerPotionCreator extends ContainerExtended {
|
||||
}
|
||||
|
||||
public class SlotPotionStore extends SlotHandleClicks {
|
||||
|
||||
public SlotPotionStore(IInventory inv, int slotIndex, int x, int y) {
|
||||
super(inv, slotIndex, x, y);
|
||||
}
|
||||
@@ -68,6 +72,7 @@ public class ContainerPotionCreator extends ContainerExtended {
|
||||
}
|
||||
|
||||
public static class InventoryPotionStore extends InventoryNBT {
|
||||
|
||||
public InventoryPotionStore() {
|
||||
super(9, NEIClientConfig.global.nbt.getCompoundTag("potionStore"));
|
||||
}
|
||||
@@ -128,9 +133,9 @@ public class ContainerPotionCreator extends ContainerExtended {
|
||||
PotionEffect e = PotionEffect.readCustomPotionEffectFromNBT(tag);
|
||||
if (e.getPotionID() != effectID) newEffects.appendTag(tag);
|
||||
}
|
||||
if (add)
|
||||
newEffects.appendTag(new PotionEffect(effectID, packet.readInt(), packet.readUByte())
|
||||
.writeCustomPotionEffectToNBT(new NBTTagCompound()));
|
||||
if (add) newEffects.appendTag(
|
||||
new PotionEffect(effectID, packet.readInt(), packet.readUByte())
|
||||
.writeCustomPotionEffectToNBT(new NBTTagCompound()));
|
||||
potion.getTagCompound().setTag("CustomPotionEffects", newEffects);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,32 +1,29 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.nei.api.IHighlightHandler;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import codechicken.nei.api.IHighlightHandler;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
|
||||
public class DefaultHighlightHandler implements IHighlightHandler {
|
||||
|
||||
@Override
|
||||
public List<String> handleTextData(
|
||||
ItemStack stack,
|
||||
World world,
|
||||
EntityPlayer player,
|
||||
MovingObjectPosition mop,
|
||||
List<String> currenttip,
|
||||
ItemInfo.Layout layout) {
|
||||
public List<String> handleTextData(ItemStack stack, World world, EntityPlayer player, MovingObjectPosition mop,
|
||||
List<String> currenttip, ItemInfo.Layout layout) {
|
||||
String name = null;
|
||||
try {
|
||||
String s = GuiContainerManager.itemDisplayNameShort(stack);
|
||||
if (s != null && !s.endsWith("Unnamed")) name = s;
|
||||
|
||||
if (name != null) currenttip.add(name);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
if (name != null && stack.getItem() == Items.redstone) {
|
||||
int md = world.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ);
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
|
||||
public class DoubleFilteredFilter implements ItemFilter {
|
||||
|
||||
private ItemFilter filter;
|
||||
private ItemList.PatternItemFilter patternFilter;
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class ExtendedCreativeInv implements IInventory {
|
||||
|
||||
final PlayerSave playerSave;
|
||||
final Side side;
|
||||
|
||||
|
||||
@@ -4,21 +4,25 @@ import static codechicken.nei.NEIServerUtils.areStacksIdentical;
|
||||
import static codechicken.nei.NEIServerUtils.areStacksSameType;
|
||||
import static codechicken.nei.NEIServerUtils.copyStack;
|
||||
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
|
||||
public class FastTransferManager {
|
||||
|
||||
/**
|
||||
* Based on the general assumption that we want to fill top to bottom, left to right
|
||||
*/
|
||||
public static class SlotPositionComparator implements Comparator<Integer> {
|
||||
|
||||
final Container container;
|
||||
|
||||
public SlotPositionComparator(Container c) {
|
||||
@@ -101,8 +105,7 @@ public class FastTransferManager {
|
||||
if (!fillZoneWithHeldItem(window, toZone)) return;
|
||||
|
||||
for (int transferFrom : slotZones.get(fromZone)) {
|
||||
ItemStack transferStack =
|
||||
window.inventorySlots.getSlot(transferFrom).getStack();
|
||||
ItemStack transferStack = window.inventorySlots.getSlot(transferFrom).getStack();
|
||||
|
||||
if (!areStacksSameType(heldStack, transferStack)) continue;
|
||||
|
||||
@@ -142,12 +145,10 @@ public class FastTransferManager {
|
||||
ItemStack after = compareAfter.get(i);
|
||||
|
||||
if (!areStacksIdentical(before, after) && after != null)
|
||||
if (before == null
|
||||
? areStacksSameType(stack, after)
|
||||
: // transfered into this empty slot
|
||||
areStacksSameType(stack, after)
|
||||
&& after.stackSize - before.stackSize > 0) // it added to this stack
|
||||
return i;
|
||||
if (before == null ? areStacksSameType(stack, after) : // transfered into this empty slot
|
||||
areStacksSameType(stack, after) && after.stackSize - before.stackSize > 0) // it added to
|
||||
// this stack
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -180,16 +181,16 @@ public class FastTransferManager {
|
||||
|
||||
if (from.isItemValid(from.getStack())) moveOneItem(window, fromSlot, toSlot);
|
||||
else // slots that you can't put stuff in
|
||||
moveOutputSet(window, fromSlot, toSlot);
|
||||
moveOutputSet(window, fromSlot, toSlot);
|
||||
}
|
||||
|
||||
public void moveOutputSet(GuiContainer window, int fromSlot, int toSlot) {
|
||||
if (NEIClientUtils.getHeldItem() != null) return;
|
||||
|
||||
clickSlot(window, fromSlot); // pickup fromSlot
|
||||
if (NEIClientUtils.getHeldItem()
|
||||
== null) // maybe this container does auto transfers. No need to pick up the final item
|
||||
return;
|
||||
if (NEIClientUtils.getHeldItem() == null) // maybe this container does auto transfers. No need to pick up the
|
||||
// final item
|
||||
return;
|
||||
clickSlot(window, toSlot); // place one in toSlot
|
||||
}
|
||||
|
||||
@@ -202,15 +203,15 @@ public class FastTransferManager {
|
||||
public void retrieveItem(GuiContainer window, int toSlot) {
|
||||
Slot slot = window.inventorySlots.getSlot(toSlot);
|
||||
ItemStack slotStack = slot.getStack();
|
||||
if (slotStack == null
|
||||
|| slotStack.stackSize == slot.getSlotStackLimit()
|
||||
|| slotStack.stackSize == slotStack.getMaxStackSize()) return;
|
||||
if (slotStack == null || slotStack.stackSize == slot.getSlotStackLimit()
|
||||
|| slotStack.stackSize == slotStack.getMaxStackSize())
|
||||
return;
|
||||
|
||||
generateSlotMap(window.inventorySlots, slotStack);
|
||||
|
||||
Integer destZone = slotZoneMap.get(toSlot);
|
||||
if (destZone == null) // slots that don't accept
|
||||
return;
|
||||
return;
|
||||
|
||||
int firstZoneSlot = findShiftClickDestinationSlot(window.inventorySlots, toSlot);
|
||||
int firstZone = -1;
|
||||
@@ -239,9 +240,9 @@ public class FastTransferManager {
|
||||
Slot slot = window.inventorySlots.getSlot(i);
|
||||
ItemStack stack1 = slot.getStack();
|
||||
|
||||
if (areStacksSameType(stack, stack1)
|
||||
&& stack1.stackSize != slot.getSlotStackLimit()
|
||||
&& // get from full stacks on second pass
|
||||
if (areStacksSameType(stack, stack1) && stack1.stackSize != slot.getSlotStackLimit() && // get from full
|
||||
// stacks on second
|
||||
// pass
|
||||
stack1.stackSize != stack1.getMaxStackSize()) {
|
||||
moveOneItem(window, i, toSlot);
|
||||
return true;
|
||||
@@ -312,7 +313,7 @@ public class FastTransferManager {
|
||||
generateSlotMap(window.inventorySlots, held);
|
||||
Integer zone = slotZoneMap.get(pickedUpFromSlot);
|
||||
if (zone == null) // something went wrong and we can't work out where the item was picked up from
|
||||
return;
|
||||
return;
|
||||
|
||||
for (int slotIndex : slotZones.get(zone)) {
|
||||
Slot slot = window.inventorySlots.getSlot(slotIndex);
|
||||
|
||||
@@ -2,15 +2,18 @@ package codechicken.nei;
|
||||
|
||||
import static codechicken.nei.NEIClientUtils.translate;
|
||||
|
||||
import codechicken.lib.render.CCRenderState;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.render.CCRenderState;
|
||||
|
||||
public class GuiEnchantmentModifier extends GuiContainer {
|
||||
|
||||
final ContainerEnchantmentModifier container;
|
||||
|
||||
public GuiEnchantmentModifier(InventoryPlayer inventoryplayer, World world, int i, int j, int k) {
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.render.CCRenderState;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.api.INEIGuiHandler;
|
||||
import codechicken.nei.api.TaggedInventoryArea;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiExtendedCreativeInv extends GuiContainer implements INEIGuiHandler {
|
||||
|
||||
public GuiExtendedCreativeInv(Container par1Container) {
|
||||
super(par1Container);
|
||||
ySize = 198;
|
||||
|
||||
@@ -4,9 +4,11 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiNEIButton extends GuiButton {
|
||||
|
||||
protected static final ResourceLocation guiTex = new ResourceLocation("textures/gui/widgets.png");
|
||||
|
||||
public GuiNEIButton(int i, int j, int k, int l, int i1, String s) {
|
||||
@@ -22,8 +24,8 @@ public class GuiNEIButton extends GuiButton {
|
||||
boolean flag = i >= xPosition && j >= yPosition && i < xPosition + width && j < yPosition + height;
|
||||
int k = getHoverState(flag);
|
||||
drawTexturedModalRect(xPosition, yPosition, 0, 46 + k * 20, width / 2, height / 2); // top left
|
||||
drawTexturedModalRect(
|
||||
xPosition + width / 2, yPosition, 200 - width / 2, 46 + k * 20, width / 2, height / 2); // top right
|
||||
drawTexturedModalRect(xPosition + width / 2, yPosition, 200 - width / 2, 46 + k * 20, width / 2, height / 2); // top
|
||||
// right
|
||||
drawTexturedModalRect(
|
||||
xPosition,
|
||||
yPosition + height / 2,
|
||||
@@ -40,14 +42,23 @@ public class GuiNEIButton extends GuiButton {
|
||||
height / 2); // bottom right
|
||||
mouseDragged(minecraft, i, j);
|
||||
|
||||
if (!enabled)
|
||||
drawCenteredString(
|
||||
fontrenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2, 0xffa0a0a0);
|
||||
else if (flag)
|
||||
drawCenteredString(
|
||||
fontrenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2, 0xffffa0);
|
||||
else
|
||||
drawCenteredString(
|
||||
fontrenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2, 0xe0e0e0);
|
||||
if (!enabled) drawCenteredString(
|
||||
fontrenderer,
|
||||
displayString,
|
||||
xPosition + width / 2,
|
||||
yPosition + (height - 8) / 2,
|
||||
0xffa0a0a0);
|
||||
else if (flag) drawCenteredString(
|
||||
fontrenderer,
|
||||
displayString,
|
||||
xPosition + width / 2,
|
||||
yPosition + (height - 8) / 2,
|
||||
0xffffa0);
|
||||
else drawCenteredString(
|
||||
fontrenderer,
|
||||
displayString,
|
||||
xPosition + width / 2,
|
||||
yPosition + (height - 8) / 2,
|
||||
0xe0e0e0);
|
||||
}
|
||||
}
|
||||
@@ -2,24 +2,29 @@ package codechicken.nei;
|
||||
|
||||
import static codechicken.nei.NEIClientUtils.translate;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.core.gui.GuiCCButton;
|
||||
import codechicken.core.gui.GuiCCTextField;
|
||||
import codechicken.core.gui.GuiScrollSlot;
|
||||
import codechicken.core.inventory.GuiContainerWidget;
|
||||
import codechicken.lib.render.CCRenderState;
|
||||
import codechicken.lib.render.FontUtils;
|
||||
import java.awt.Dimension;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiPotionCreator extends GuiContainerWidget {
|
||||
|
||||
public class GuiSlotPotionEffects extends GuiScrollSlot {
|
||||
|
||||
public int selectedslot = -1;
|
||||
public boolean enabled = true;
|
||||
private final ArrayList<Potion> validPotions = new ArrayList<>();
|
||||
@@ -69,7 +74,12 @@ public class GuiPotionCreator extends GuiContainerWidget {
|
||||
CCRenderState.changeTexture("textures/gui/container/enchanting_table.png");
|
||||
drawTexturedModalRect(x, y, 0, 166 + getSlotHeight(slot) * shade, width - 30, getSlotHeight(slot));
|
||||
drawTexturedModalRect(
|
||||
x + width - 30, y, width - 23, 166 + getSlotHeight(slot) * shade, 30, getSlotHeight(slot));
|
||||
x + width - 30,
|
||||
y,
|
||||
width - 23,
|
||||
166 + getSlotHeight(slot) * shade,
|
||||
30,
|
||||
getSlotHeight(slot));
|
||||
|
||||
if (potion.hasStatusIcon()) {
|
||||
CCRenderState.changeTexture("textures/gui/container/inventory.png");
|
||||
@@ -94,9 +104,7 @@ public class GuiPotionCreator extends GuiContainerWidget {
|
||||
|
||||
private PotionEffect getEffect(int id) {
|
||||
ItemStack potion = container.potionInv.getStackInSlot(0);
|
||||
if (potion != null
|
||||
&& potion.hasTagCompound()
|
||||
&& potion.getTagCompound().hasKey("CustomPotionEffects")) {
|
||||
if (potion != null && potion.hasTagCompound() && potion.getTagCompound().hasKey("CustomPotionEffects")) {
|
||||
NBTTagList potionTagList = potion.getTagCompound().getTagList("CustomPotionEffects", 10);
|
||||
for (int i = 0; i < potionTagList.tagCount(); i++) {
|
||||
PotionEffect effect = PotionEffect.readCustomPotionEffectFromNBT(potionTagList.getCompoundTagAt(i));
|
||||
@@ -167,6 +175,7 @@ public class GuiPotionCreator extends GuiContainerWidget {
|
||||
}
|
||||
|
||||
public class GuiDurationField extends GuiCCTextField {
|
||||
|
||||
private String baseValue;
|
||||
|
||||
public GuiDurationField(int x, int y, int width, int height) {
|
||||
@@ -216,8 +225,8 @@ public class GuiPotionCreator extends GuiContainerWidget {
|
||||
@Override
|
||||
public void drawText() {
|
||||
String s = getText();
|
||||
String seconds =
|
||||
s.substring(Math.max(0, s.length() - 2), Math.max(0, s.length() - 2) + Math.min(s.length(), 2));
|
||||
String seconds = s
|
||||
.substring(Math.max(0, s.length() - 2), Math.max(0, s.length() - 2) + Math.min(s.length(), 2));
|
||||
String minutes = s.length() < 3 ? "" : s.substring(0, s.length() - 2);
|
||||
int ty = y + height / 2 - 4;
|
||||
int tcolour = getTextColour();
|
||||
|
||||
@@ -5,23 +5,27 @@ import static codechicken.lib.gui.GuiDraw.drawString;
|
||||
import static codechicken.lib.gui.GuiDraw.drawTooltipBox;
|
||||
import static codechicken.lib.gui.GuiDraw.getStringWidth;
|
||||
|
||||
import codechicken.lib.config.ConfigTag;
|
||||
import codechicken.nei.KeyManager.IKeyStateTracker;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import codechicken.lib.config.ConfigTag;
|
||||
import codechicken.nei.KeyManager.IKeyStateTracker;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
|
||||
public class HUDRenderer implements IKeyStateTracker {
|
||||
|
||||
@Override
|
||||
public void tickKeyStates() {
|
||||
if (KeyManager.keyStates.get("world.highlight_tips").down) {
|
||||
@@ -32,8 +36,7 @@ public class HUDRenderer implements IKeyStateTracker {
|
||||
|
||||
public static void renderOverlay() {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.currentScreen == null
|
||||
&& mc.theWorld != null
|
||||
if (mc.currentScreen == null && mc.theWorld != null
|
||||
&& !mc.gameSettings.keyBindPlayerList.getIsKeyPressed()
|
||||
&& NEIClientConfig.getBooleanSetting("world.highlight_tips")
|
||||
&& mc.objectMouseOver != null
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package codechicken.nei;
|
||||
|
||||
public class Image {
|
||||
|
||||
public int x;
|
||||
public int y;
|
||||
public int width;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.nei.api.IInfiniteItemHandler;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.nei.api.IInfiniteItemHandler;
|
||||
|
||||
public class InfiniteStackSizeHandler implements IInfiniteItemHandler {
|
||||
|
||||
@Override
|
||||
public void onPickup(ItemStack heldItem) {
|
||||
heldItem.stackSize = 1;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.nei.api.IInfiniteItemHandler;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.nei.api.IInfiniteItemHandler;
|
||||
|
||||
public class InfiniteToolHandler implements IInfiniteItemHandler {
|
||||
|
||||
@Override
|
||||
public void onPickup(ItemStack heldItem) {
|
||||
heldItem.setItemDamage(0);
|
||||
|
||||
@@ -5,15 +5,14 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
|
||||
public class InventoryCraftingDummy extends InventoryCrafting {
|
||||
|
||||
public InventoryCraftingDummy() {
|
||||
super(
|
||||
new Container() {
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
3,
|
||||
3);
|
||||
super(new Container() {
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
}, 3, 3);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,5 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.nei.ThreadOperationTimer.TimeoutException;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
@@ -15,11 +8,22 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
|
||||
import codechicken.nei.ThreadOperationTimer.TimeoutException;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
|
||||
public class ItemList {
|
||||
|
||||
/**
|
||||
* Fields are replaced atomically and contents never modified.
|
||||
*/
|
||||
@@ -38,12 +42,12 @@ public class ItemList {
|
||||
private static final HashSet<Item> erroredItems = new HashSet<>();
|
||||
private static final HashSet<String> stackTraces = new HashSet<>();
|
||||
/**
|
||||
* Unlike {@link LayoutManager#itemsLoaded}, this indicates whether item loading is
|
||||
* actually finished or not.
|
||||
* Unlike {@link LayoutManager#itemsLoaded}, this indicates whether item loading is actually finished or not.
|
||||
*/
|
||||
public static boolean loadFinished;
|
||||
|
||||
public static class EverythingItemFilter implements ItemFilter {
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack item) {
|
||||
return true;
|
||||
@@ -51,6 +55,7 @@ public class ItemList {
|
||||
}
|
||||
|
||||
public static class NothingItemFilter implements ItemFilter {
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack item) {
|
||||
return false;
|
||||
@@ -58,6 +63,7 @@ public class ItemList {
|
||||
}
|
||||
|
||||
public static class PatternItemFilter implements ItemFilter {
|
||||
|
||||
public Pattern pattern;
|
||||
|
||||
public PatternItemFilter(Pattern pattern) {
|
||||
@@ -71,6 +77,7 @@ public class ItemList {
|
||||
}
|
||||
|
||||
public static class AllMultiItemFilter implements ItemFilter {
|
||||
|
||||
public List<ItemFilter> filters;
|
||||
|
||||
public AllMultiItemFilter(List<ItemFilter> filters) {
|
||||
@@ -83,18 +90,18 @@ public class ItemList {
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack item) {
|
||||
for (ItemFilter filter : filters)
|
||||
try {
|
||||
if (!filter.matches(item)) return false;
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Exception filtering " + item + " with " + filter, e);
|
||||
}
|
||||
for (ItemFilter filter : filters) try {
|
||||
if (!filter.matches(item)) return false;
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Exception filtering " + item + " with " + filter, e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class AnyMultiItemFilter implements ItemFilter {
|
||||
|
||||
public List<ItemFilter> filters;
|
||||
|
||||
public AnyMultiItemFilter(List<ItemFilter> filters) {
|
||||
@@ -107,18 +114,18 @@ public class ItemList {
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack item) {
|
||||
for (ItemFilter filter : filters)
|
||||
try {
|
||||
if (filter.matches(item)) return true;
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Exception filtering " + item + " with " + filter, e);
|
||||
}
|
||||
for (ItemFilter filter : filters) try {
|
||||
if (filter.matches(item)) return true;
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Exception filtering " + item + " with " + filter, e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static interface ItemsLoadedCallback {
|
||||
|
||||
public void itemsLoaded();
|
||||
}
|
||||
|
||||
@@ -135,7 +142,7 @@ public class ItemList {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use getItemListFilter().matches(item)
|
||||
* @deprecated use getItemListFilter().matches(item)
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean itemMatches(ItemStack item) {
|
||||
@@ -155,28 +162,27 @@ public class ItemList {
|
||||
}
|
||||
|
||||
public static final RestartableTask loadItems = new RestartableTask("NEI Item Loading") {
|
||||
|
||||
private void damageSearch(Item item, List<ItemStack> permutations) {
|
||||
HashSet<String> damageIconSet = new HashSet<>();
|
||||
for (int damage = 0; damage < 16; damage++)
|
||||
try {
|
||||
ItemStack itemstack = new ItemStack(item, 1, damage);
|
||||
IIcon icon = item.getIconIndex(itemstack);
|
||||
String name = GuiContainerManager.concatenatedDisplayName(itemstack, false);
|
||||
String s = name + "@" + (icon == null ? 0 : icon.hashCode());
|
||||
if (!damageIconSet.contains(s)) {
|
||||
damageIconSet.add(s);
|
||||
permutations.add(itemstack);
|
||||
}
|
||||
} catch (TimeoutException t) {
|
||||
throw t;
|
||||
} catch (Throwable t) {
|
||||
NEIServerUtils.logOnce(
|
||||
t,
|
||||
stackTraces,
|
||||
"Ommiting " + item + ":" + damage + " "
|
||||
+ item.getClass().getSimpleName(),
|
||||
item.toString());
|
||||
for (int damage = 0; damage < 16; damage++) try {
|
||||
ItemStack itemstack = new ItemStack(item, 1, damage);
|
||||
IIcon icon = item.getIconIndex(itemstack);
|
||||
String name = GuiContainerManager.concatenatedDisplayName(itemstack, false);
|
||||
String s = name + "@" + (icon == null ? 0 : icon.hashCode());
|
||||
if (!damageIconSet.contains(s)) {
|
||||
damageIconSet.add(s);
|
||||
permutations.add(itemstack);
|
||||
}
|
||||
} catch (TimeoutException t) {
|
||||
throw t;
|
||||
} catch (Throwable t) {
|
||||
NEIServerUtils.logOnce(
|
||||
t,
|
||||
stackTraces,
|
||||
"Ommiting " + item + ":" + damage + " " + item.getClass().getSimpleName(),
|
||||
item.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -239,6 +245,7 @@ public class ItemList {
|
||||
public static ForkJoinPool forkJoinPool = getPool(numProcessors * 2 / 3);
|
||||
|
||||
public static final RestartableTask updateFilter = new RestartableTask("NEI Item Filtering") {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
// System.out.println("Executing NEI Item Filtering");
|
||||
@@ -246,10 +253,8 @@ public class ItemList {
|
||||
ItemFilter filter = getItemListFilter();
|
||||
|
||||
try {
|
||||
filtered = ItemList.forkJoinPool
|
||||
.submit(() -> items.parallelStream()
|
||||
.filter(PresetsWidget::matches)
|
||||
.filter(filter::matches)
|
||||
filtered = ItemList.forkJoinPool.submit(
|
||||
() -> items.parallelStream().filter(PresetsWidget::matches).filter(filter::matches)
|
||||
.collect(Collectors.toCollection(ArrayList::new)))
|
||||
.get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package codechicken.nei;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
@@ -20,6 +21,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
public class ItemMobSpawner extends ItemBlock {
|
||||
|
||||
private static Map<Integer, EntityLiving> entityHashMap;
|
||||
private static Map<Integer, String> IDtoNameMap;
|
||||
public static int idPig;
|
||||
@@ -48,20 +50,11 @@ public class ItemMobSpawner extends ItemBlock {
|
||||
return Blocks.mob_spawner.getBlockTextureFromSide(0);
|
||||
}
|
||||
|
||||
public boolean onItemUse(
|
||||
ItemStack itemstack,
|
||||
EntityPlayer entityplayer,
|
||||
World world,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
int par7,
|
||||
float par8,
|
||||
float par9,
|
||||
float par10) {
|
||||
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int par7,
|
||||
float par8, float par9, float par10) {
|
||||
if (super.onItemUse(itemstack, entityplayer, world, x, y, z, par7, par8, par9, par10) && world.isRemote) {
|
||||
TileEntityMobSpawner tileentitymobspawner =
|
||||
(TileEntityMobSpawner) world.getTileEntity(placedX, placedY, placedZ);
|
||||
TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner) world
|
||||
.getTileEntity(placedX, placedY, placedZ);
|
||||
if (tileentitymobspawner != null) {
|
||||
setDefaultTag(itemstack);
|
||||
String mobtype = IDtoNameMap.get(itemstack.getItemDamage());
|
||||
@@ -93,8 +86,7 @@ public class ItemMobSpawner extends ItemBlock {
|
||||
loadSpawners(world);
|
||||
Class<?> clazz = (Class<?>) EntityList.IDtoClassMapping.get(ID);
|
||||
try {
|
||||
e = (EntityLiving)
|
||||
clazz.getConstructor(new Class[] {World.class}).newInstance(world);
|
||||
e = (EntityLiving) clazz.getConstructor(new Class[] { World.class }).newInstance(world);
|
||||
} catch (Throwable t) {
|
||||
if (clazz == null)
|
||||
NEIClientConfig.logger.error("Null class for entity (" + ID + ", " + IDtoNameMap.get(ID));
|
||||
@@ -117,15 +109,13 @@ public class ItemMobSpawner extends ItemBlock {
|
||||
public static void loadSpawners(World world) {
|
||||
if (loaded) return;
|
||||
loaded = true;
|
||||
HashMap<Class<Entity>, String> classToStringMapping =
|
||||
(HashMap<Class<Entity>, String>) EntityList.classToStringMapping;
|
||||
HashMap<Class<Entity>, Integer> classToIDMapping =
|
||||
(HashMap<Class<Entity>, Integer>) EntityList.classToIDMapping;
|
||||
HashMap<Class<Entity>, String> classToStringMapping = (HashMap<Class<Entity>, String>) EntityList.classToStringMapping;
|
||||
HashMap<Class<Entity>, Integer> classToIDMapping = (HashMap<Class<Entity>, Integer>) EntityList.classToIDMapping;
|
||||
for (Class<Entity> eclass : classToStringMapping.keySet()) {
|
||||
if (!EntityLiving.class.isAssignableFrom(eclass)) continue;
|
||||
try {
|
||||
EntityLiving entityliving = (EntityLiving)
|
||||
eclass.getConstructor(new Class[] {World.class}).newInstance(world);
|
||||
EntityLiving entityliving = (EntityLiving) eclass.getConstructor(new Class[] { World.class })
|
||||
.newInstance(world);
|
||||
entityliving.isChild();
|
||||
|
||||
int id = classToIDMapping.get(eclass);
|
||||
@@ -136,13 +126,11 @@ public class ItemMobSpawner extends ItemBlock {
|
||||
IDtoNameMap.put(id, name);
|
||||
|
||||
if (name.equals("Pig")) idPig = id;
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
} catch (Throwable ignored) {}
|
||||
}
|
||||
|
||||
IDtoNameMap.entrySet()
|
||||
.removeIf(e -> getEntity(e.getKey()).getClass() == EntityPig.class
|
||||
&& !e.getValue().equals("Pig"));
|
||||
.removeIf(e -> getEntity(e.getKey()).getClass() == EntityPig.class && !e.getValue().equals("Pig"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,16 +2,19 @@ package codechicken.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.drawRect;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
|
||||
public class ItemPanel extends PanelWidget {
|
||||
|
||||
/**
|
||||
* Backwards compat :-/
|
||||
* Backwards compat :-/
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Deprecated
|
||||
@@ -33,6 +36,7 @@ public class ItemPanel extends PanelWidget {
|
||||
public ItemQuantityField quantity;
|
||||
|
||||
public static class ItemPanelSlot {
|
||||
|
||||
public ItemStack item;
|
||||
public int slotIndex;
|
||||
|
||||
@@ -48,6 +52,7 @@ public class ItemPanel extends PanelWidget {
|
||||
}
|
||||
|
||||
protected static class ItemPanelGrid extends ItemsGrid {
|
||||
|
||||
public ArrayList<ItemStack> newItems;
|
||||
|
||||
public void setItems(ArrayList<ItemStack> items) {
|
||||
@@ -94,6 +99,7 @@ public class ItemPanel extends PanelWidget {
|
||||
super.init();
|
||||
|
||||
more = new Button("+") {
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (rightclick) return false;
|
||||
@@ -110,6 +116,7 @@ public class ItemPanel extends PanelWidget {
|
||||
}
|
||||
};
|
||||
less = new Button("-") {
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (rightclick) return false;
|
||||
@@ -159,19 +166,30 @@ public class ItemPanel extends PanelWidget {
|
||||
}
|
||||
|
||||
protected int resizeFooter(GuiContainer gui) {
|
||||
if (!NEIClientConfig.showItemQuantityWidget()) return 0;
|
||||
|
||||
final int BUTTON_SIZE = 16;
|
||||
if (!NEIClientConfig.showItemQuantityWidget() && NEIClientConfig.isSearchWidgetCentered()) return 0;
|
||||
|
||||
final int BUTTON_SIZE = 20;
|
||||
more.w = less.w = BUTTON_SIZE;
|
||||
more.h = less.h = quantity.h = BUTTON_SIZE;
|
||||
quantity.h = BUTTON_SIZE;
|
||||
|
||||
less.x = x;
|
||||
more.x = x + w - BUTTON_SIZE;
|
||||
more.y = less.y = quantity.y = y + h - BUTTON_SIZE;
|
||||
if (NEIClientConfig.isSearchWidgetCentered()) {
|
||||
more.h = less.h = BUTTON_SIZE;
|
||||
more.x = x + w - BUTTON_SIZE;
|
||||
more.y = less.y = quantity.y = y + h - BUTTON_SIZE;
|
||||
less.x = x;
|
||||
quantity.x = x + BUTTON_SIZE + 2;
|
||||
quantity.w = more.x - quantity.x - 2;
|
||||
} else {
|
||||
quantity.x = (int) (x + (w * 0.7)) + 3;
|
||||
quantity.y = y + h - BUTTON_SIZE;
|
||||
quantity.w = (int) ((w * 0.3) - BUTTON_SIZE - 1);
|
||||
|
||||
quantity.x = x + BUTTON_SIZE + 2;
|
||||
quantity.w = more.x - quantity.x - 2;
|
||||
more.h = less.h = BUTTON_SIZE / 2;
|
||||
more.y = y + h - (more.h * 2);
|
||||
|
||||
less.x = more.x = quantity.x + quantity.w;
|
||||
less.y = more.y + more.h;
|
||||
}
|
||||
|
||||
return BUTTON_SIZE + 2;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package codechicken.nei;
|
||||
|
||||
public class ItemPanels {
|
||||
|
||||
public static final ItemPanel itemPanel = new ItemPanel();
|
||||
public static final BookmarkPanel bookmarkPanel = new BookmarkPanel();
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package codechicken.nei;
|
||||
import static codechicken.nei.NEIClientUtils.translate;
|
||||
|
||||
public class ItemQuantityField extends TextField {
|
||||
|
||||
public ItemQuantityField(String ident) {
|
||||
super(ident);
|
||||
centered = true;
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import codechicken.lib.config.ConfigTagParent;
|
||||
import codechicken.nei.ItemList.ItemsLoadedCallback;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.config.GuiItemSorter;
|
||||
import codechicken.nei.config.OptionOpenGui;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class ItemSorter implements Comparator<ItemStack>, ItemsLoadedCallback {
|
||||
|
||||
public static class SortEntry {
|
||||
|
||||
public final String name;
|
||||
public final Comparator<ItemStack> comparator;
|
||||
|
||||
@@ -44,7 +48,7 @@ public class ItemSorter implements Comparator<ItemStack>, ItemsLoadedCallback {
|
||||
|
||||
public static void sort(ArrayList<ItemStack> items) {
|
||||
try {
|
||||
// items = (ArrayList<ItemStack>)
|
||||
// items = (ArrayList<ItemStack>)
|
||||
// items.parallelStream().sorted(instance).collect(Collectors.toList());
|
||||
items.sort(instance);
|
||||
} catch (Exception e) {
|
||||
@@ -125,6 +129,7 @@ public class ItemSorter implements Comparator<ItemStack>, ItemsLoadedCallback {
|
||||
});
|
||||
tag.getTag("inventory.itemsort").setDefaultValue(getSaveString(list));
|
||||
API.addOption(new OptionOpenGui("inventory.itemsort", GuiItemSorter.class) {
|
||||
|
||||
@Override
|
||||
public void useGlobals() {
|
||||
super.useGlobals();
|
||||
|
||||
@@ -4,20 +4,24 @@ import static codechicken.lib.inventory.InventoryUtils.actualDamage;
|
||||
import static codechicken.lib.inventory.InventoryUtils.newItemStack;
|
||||
import static net.minecraftforge.oredict.OreDictionary.WILDCARD_VALUE;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* A maplike class for ItemStack keys with wildcard damage/NBT. Optimised for lookup
|
||||
*/
|
||||
public class ItemStackMap<T> {
|
||||
|
||||
public static class StackMetaKey {
|
||||
|
||||
public final int damage;
|
||||
public final NBTTagCompound tag;
|
||||
|
||||
@@ -42,6 +46,7 @@ public class ItemStackMap<T> {
|
||||
}
|
||||
|
||||
public static class Entry<T> {
|
||||
|
||||
public final ItemStack key;
|
||||
public final T value;
|
||||
|
||||
@@ -52,6 +57,7 @@ public class ItemStackMap<T> {
|
||||
}
|
||||
|
||||
public class DetailMap {
|
||||
|
||||
private boolean hasWildcard;
|
||||
private T wildcard;
|
||||
private HashMap<Integer, T> damageMap;
|
||||
@@ -121,8 +127,7 @@ public class ItemStackMap<T> {
|
||||
}
|
||||
|
||||
private void updateSize() {
|
||||
int newSize = (hasWildcard ? 1 : 0)
|
||||
+ (metaMap != null ? metaMap.size() : 0)
|
||||
int newSize = (hasWildcard ? 1 : 0) + (metaMap != null ? metaMap.size() : 0)
|
||||
+ (tagMap != null ? tagMap.size() : 0)
|
||||
+ (damageMap != null ? damageMap.size() : 0);
|
||||
|
||||
@@ -151,16 +156,12 @@ public class ItemStackMap<T> {
|
||||
|
||||
public void addEntries(Item item, List<Entry<T>> list) {
|
||||
if (wildcard != null) list.add(new Entry<>(newItemStack(item, 1, WILDCARD_VALUE, WILDCARD_TAG), wildcard));
|
||||
if (damageMap != null)
|
||||
for (Map.Entry<Integer, T> entry : damageMap.entrySet())
|
||||
list.add(new Entry<>(newItemStack(item, 1, entry.getKey(), WILDCARD_TAG), entry.getValue()));
|
||||
if (tagMap != null)
|
||||
for (Map.Entry<NBTTagCompound, T> entry : tagMap.entrySet())
|
||||
list.add(new Entry<>(newItemStack(item, 1, WILDCARD_VALUE, entry.getKey()), entry.getValue()));
|
||||
if (metaMap != null)
|
||||
for (Map.Entry<StackMetaKey, T> entry : metaMap.entrySet())
|
||||
list.add(new Entry<>(
|
||||
newItemStack(item, 1, entry.getKey().damage, entry.getKey().tag), entry.getValue()));
|
||||
if (damageMap != null) for (Map.Entry<Integer, T> entry : damageMap.entrySet())
|
||||
list.add(new Entry<>(newItemStack(item, 1, entry.getKey(), WILDCARD_TAG), entry.getValue()));
|
||||
if (tagMap != null) for (Map.Entry<NBTTagCompound, T> entry : tagMap.entrySet())
|
||||
list.add(new Entry<>(newItemStack(item, 1, WILDCARD_VALUE, entry.getKey()), entry.getValue()));
|
||||
if (metaMap != null) for (Map.Entry<StackMetaKey, T> entry : metaMap.entrySet()) list.add(
|
||||
new Entry<>(newItemStack(item, 1, entry.getKey().damage, entry.getKey().tag), entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,8 +224,7 @@ public class ItemStackMap<T> {
|
||||
|
||||
public List<ItemStack> keys() {
|
||||
LinkedList<ItemStack> list = new LinkedList<>();
|
||||
for (Map.Entry<Item, DetailMap> entry : itemMap.entrySet())
|
||||
entry.getValue().addKeys(entry.getKey(), list);
|
||||
for (Map.Entry<Item, DetailMap> entry : itemMap.entrySet()) entry.getValue().addKeys(entry.getKey(), list);
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -236,8 +236,7 @@ public class ItemStackMap<T> {
|
||||
|
||||
public List<Entry<T>> entries() {
|
||||
LinkedList<Entry<T>> list = new LinkedList<>();
|
||||
for (Map.Entry<Item, DetailMap> entry : itemMap.entrySet())
|
||||
entry.getValue().addEntries(entry.getKey(), list);
|
||||
for (Map.Entry<Item, DetailMap> entry : itemMap.entrySet()) entry.getValue().addEntries(entry.getKey(), list);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
|
||||
public class ItemStackSet extends ItemStackMap<ItemStack> implements ItemFilter {
|
||||
|
||||
public ItemStackSet with(ItemStack... items) {
|
||||
for (ItemStack item : items) add(item);
|
||||
return this;
|
||||
|
||||
@@ -1,26 +1,39 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.drawRect;
|
||||
import static codechicken.lib.gui.GuiDraw.getMousePosition;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.ItemPanel.ItemPanelSlot;
|
||||
import codechicken.nei.api.GuiInfo;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.shader.Framebuffer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.ItemPanel.ItemPanelSlot;
|
||||
import codechicken.nei.api.GuiInfo;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.BookmarkRecipeId;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
|
||||
public class ItemsGrid {
|
||||
|
||||
public static final int SLOT_SIZE = 18;
|
||||
|
||||
protected int width;
|
||||
@@ -38,6 +51,7 @@ public class ItemsGrid {
|
||||
|
||||
protected int rows;
|
||||
protected int columns;
|
||||
protected boolean showRecipeTooltips = false;
|
||||
|
||||
protected boolean[] invalidSlotMap;
|
||||
|
||||
@@ -71,6 +85,11 @@ public class ItemsGrid {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void setPage(int page) {
|
||||
this.page = Math.max(0, Math.min(page, getNumPages() - 1));
|
||||
onGridChanged();
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return page + 1;
|
||||
}
|
||||
@@ -140,6 +159,10 @@ public class ItemsGrid {
|
||||
refreshBuffer = true;
|
||||
}
|
||||
|
||||
public void setShowRecipeTooltips(boolean show) {
|
||||
this.showRecipeTooltips = show;
|
||||
}
|
||||
|
||||
public void refresh(GuiContainer gui) {
|
||||
updateGuiOverlapSlots(gui);
|
||||
shiftPage(0);
|
||||
@@ -173,8 +196,7 @@ public class ItemsGrid {
|
||||
|
||||
for (int r = 0; r < rows; r++) {
|
||||
final int idx = columns * r + c;
|
||||
if (GuiInfo.hideItemPanelSlot(gui, getSlotRect(r, c))
|
||||
&& idx >= 0
|
||||
if (GuiInfo.hideItemPanelSlot(gui, getSlotRect(r, c)) && idx >= 0
|
||||
&& idx < invalidSlotMap.length
|
||||
&& !invalidSlotMap[idx]) {
|
||||
invalidSlotMap[idx] = true;
|
||||
@@ -203,7 +225,10 @@ public class ItemsGrid {
|
||||
|
||||
public Rectangle4i getSlotRect(int row, int column) {
|
||||
return new Rectangle4i(
|
||||
marginLeft + paddingLeft + column * SLOT_SIZE, marginTop + row * SLOT_SIZE, SLOT_SIZE, SLOT_SIZE);
|
||||
marginLeft + paddingLeft + column * SLOT_SIZE,
|
||||
marginTop + row * SLOT_SIZE,
|
||||
SLOT_SIZE,
|
||||
SLOT_SIZE);
|
||||
}
|
||||
|
||||
public boolean isInvalidSlot(int index) {
|
||||
@@ -232,6 +257,120 @@ public class ItemsGrid {
|
||||
}
|
||||
}
|
||||
|
||||
private int recipeTooltipSlotIdx = -1;
|
||||
private int recipeTooltipLines = 2;
|
||||
private Runnable recipeTooltipUpdater = null;
|
||||
private GuiRecipe<?> recipeTooltipGui = null;
|
||||
|
||||
public void update() {
|
||||
if (recipeTooltipUpdater != null) {
|
||||
recipeTooltipUpdater.run();
|
||||
recipeTooltipUpdater = null;
|
||||
}
|
||||
if (recipeTooltipGui != null) {
|
||||
recipeTooltipGui.updateAsTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> List<T> listOrEmptyList(final List<T> listOrNull) {
|
||||
return listOrNull == null ? Collections.emptyList() : listOrNull;
|
||||
}
|
||||
|
||||
private void drawRecipeTooltip(int mousex, int mousey, List<String> itemTooltip) {
|
||||
if (!NEIClientConfig.isLoaded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
ItemPanelSlot focused = getSlotMouseOver(mousex, mousey);
|
||||
if (focused == null) {
|
||||
recipeTooltipSlotIdx = -1;
|
||||
recipeTooltipGui = null;
|
||||
return;
|
||||
}
|
||||
final List<Integer> mask = getMask();
|
||||
|
||||
int slotIdx = -1;
|
||||
for (int i = 0; i < mask.size(); i++) {
|
||||
if (mask.get(i) == null) {
|
||||
continue;
|
||||
}
|
||||
if (focused.slotIndex != mask.get(i)) {
|
||||
continue;
|
||||
}
|
||||
slotIdx = i;
|
||||
break;
|
||||
}
|
||||
if (slotIdx == -1) {
|
||||
recipeTooltipSlotIdx = -1;
|
||||
recipeTooltipGui = null;
|
||||
return;
|
||||
}
|
||||
|
||||
final Point mouseover = getMousePosition();
|
||||
final ItemPanelSlot panelSlot = ItemPanels.bookmarkPanel.getSlotMouseOver(mouseover.x, mouseover.y);
|
||||
final BookmarkRecipeId recipeId;
|
||||
if (panelSlot != null) {
|
||||
recipeId = ItemPanels.bookmarkPanel.getBookmarkRecipeId(panelSlot.slotIndex);
|
||||
} else {
|
||||
recipeId = ItemPanels.bookmarkPanel.getBookmarkRecipeId(focused.item);
|
||||
}
|
||||
if (recipeId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (slotIdx != recipeTooltipSlotIdx) {
|
||||
recipeTooltipSlotIdx = slotIdx;
|
||||
recipeTooltipGui = null;
|
||||
recipeTooltipUpdater = () -> {
|
||||
recipeTooltipGui = GuiCraftingRecipe.createRecipeGui("item", false, false, false, focused.item);
|
||||
if (recipeTooltipGui != null) {
|
||||
recipeTooltipGui.limitToOneRecipe();
|
||||
recipeTooltipGui.initGui(true);
|
||||
recipeTooltipGui.guiTop = 0;
|
||||
recipeTooltipGui.guiLeft = 0;
|
||||
}
|
||||
recipeTooltipLines = Math.max(1, itemTooltip.size());
|
||||
};
|
||||
}
|
||||
if (recipeTooltipGui == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
final float tooltipYOffset;
|
||||
if (mousey - marginTop > height / 2) {
|
||||
tooltipYOffset = mousey - recipeTooltipGui.getHeightAsWidget() + 8;
|
||||
} else {
|
||||
tooltipYOffset = mousey + ((recipeTooltipLines < 2) ? 1 : 3 + ((recipeTooltipLines - 1) * 10));
|
||||
}
|
||||
GL11.glTranslatef(mousex, tooltipYOffset, 500);
|
||||
|
||||
final GuiContainer gui;
|
||||
if (mc.currentScreen instanceof GuiRecipe) {
|
||||
gui = ((GuiRecipe<?>) mc.currentScreen).firstGui;
|
||||
} else if (mc.currentScreen instanceof GuiContainer) {
|
||||
gui = (GuiContainer) mc.currentScreen;
|
||||
} else {
|
||||
gui = null;
|
||||
}
|
||||
recipeTooltipGui.drawGuiContainerBackgroundLayer(0.0f, -100, -100);
|
||||
if (recipeTooltipGui.slotcontainer != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Slot> slots = (List<Slot>) recipeTooltipGui.slotcontainer.inventorySlots;
|
||||
for (Slot slot : slots) {
|
||||
if (slot != null && slot.getStack() != null) {
|
||||
GuiContainerManager.drawItem(slot.xDisplayPosition, slot.yDisplayPosition, slot.getStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
recipeTooltipGui.drawGuiContainerForegroundLayer(-100, -100);
|
||||
for (GuiButton btn : recipeTooltipGui.getOverlayButtons()) {
|
||||
btn.drawButton(mc, -100, -100);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
protected void drawSlotOutline(@Nullable ItemPanelSlot focused, int slotIdx, Rectangle4i rect) {
|
||||
if (focused != null && focused.slotIndex == slotIdx) {
|
||||
drawRect(rect.x, rect.y, rect.w, rect.h, 0xee555555); // highlight
|
||||
@@ -297,7 +436,10 @@ public class ItemsGrid {
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDepthMask(true);
|
||||
OpenGlHelper.glBlendFunc(
|
||||
GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.GL_SRC_ALPHA,
|
||||
GL11.GL_ONE_MINUS_SRC_ALPHA,
|
||||
GL11.GL_SRC_ALPHA,
|
||||
GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
drawItems();
|
||||
@@ -314,6 +456,16 @@ public class ItemsGrid {
|
||||
}
|
||||
}
|
||||
|
||||
public void postDrawTooltips(int mousex, int mousey, List<String> tooltip) {
|
||||
if (NEIClientConfig.showRecipeTooltips() && showRecipeTooltips) {
|
||||
try {
|
||||
drawRecipeTooltip(mousex, mousey, tooltip);
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.warn("Cannot draw recipe tooltip", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setVisible() {
|
||||
if (getItems().isEmpty() && getMessageOnEmpty() != null) {
|
||||
LayoutManager.addWidget(messageLabel);
|
||||
|
||||
@@ -8,11 +8,14 @@ import java.util.Map.Entry;
|
||||
* Good old down/held/up keystate tracker
|
||||
*/
|
||||
public class KeyManager {
|
||||
|
||||
public static interface IKeyStateTracker {
|
||||
|
||||
public void tickKeyStates();
|
||||
}
|
||||
|
||||
public static class KeyState {
|
||||
|
||||
public boolean down;
|
||||
public boolean held;
|
||||
public boolean up;
|
||||
|
||||
@@ -4,6 +4,7 @@ import static codechicken.lib.gui.GuiDraw.drawString;
|
||||
import static codechicken.lib.gui.GuiDraw.drawStringC;
|
||||
|
||||
public class Label extends Widget {
|
||||
|
||||
final boolean centered;
|
||||
final int colour;
|
||||
public String text;
|
||||
|
||||
@@ -32,6 +32,23 @@ import static codechicken.nei.NEIClientUtils.toggleMagnetMode;
|
||||
import static codechicken.nei.NEIClientUtils.toggleRaining;
|
||||
import static codechicken.nei.NEIClientUtils.translate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainerCreative;
|
||||
import net.minecraft.client.renderer.InventoryEffectRenderer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.KeyManager.IKeyStateTracker;
|
||||
import codechicken.nei.api.API;
|
||||
@@ -48,27 +65,10 @@ import codechicken.nei.guihook.IContainerObjectHandler;
|
||||
import codechicken.nei.guihook.IContainerTooltipHandler;
|
||||
import codechicken.nei.recipe.GuiRecipeTab;
|
||||
import codechicken.nei.recipe.RecipeCatalysts;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainerCreative;
|
||||
import net.minecraft.client.renderer.InventoryEffectRenderer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class LayoutManager
|
||||
implements IContainerInputHandler,
|
||||
IContainerTooltipHandler,
|
||||
IContainerDrawHandler,
|
||||
IContainerObjectHandler,
|
||||
IKeyStateTracker {
|
||||
public class LayoutManager implements IContainerInputHandler, IContainerTooltipHandler, IContainerDrawHandler,
|
||||
IContainerObjectHandler, IKeyStateTracker {
|
||||
|
||||
private static LayoutManager instance;
|
||||
|
||||
/** Note: this variable isn't actually used by this mod, but NEI add-ons might need it. */
|
||||
@@ -113,10 +113,9 @@ public class LayoutManager
|
||||
public static HashMap<Integer, LayoutStyle> layoutStyles = new HashMap<>();
|
||||
|
||||
/**
|
||||
* This is set to true immediately after item loading thread is started,
|
||||
* to prevent duplicated loading thread from being executed.
|
||||
* If you want to know if item list is actually finished loading,
|
||||
* Use {@link ItemList#loadFinished} instead.
|
||||
* This is set to true immediately after item loading thread is started, to prevent duplicated loading thread from
|
||||
* being executed. If you want to know if item list is actually finished loading, Use {@link ItemList#loadFinished}
|
||||
* instead.
|
||||
*/
|
||||
public static boolean itemsLoaded = false;
|
||||
|
||||
@@ -139,11 +138,8 @@ public class LayoutManager
|
||||
|
||||
@Override
|
||||
public void onPreDraw(GuiContainer gui) {
|
||||
if (!isHidden()
|
||||
&& isEnabled()
|
||||
&& gui
|
||||
instanceof
|
||||
InventoryEffectRenderer) // Reset the gui to the center of the screen, for potion effect offsets
|
||||
if (!isHidden() && isEnabled() && gui instanceof InventoryEffectRenderer) // Reset the gui to the center of the
|
||||
// screen, for potion effect offsets
|
||||
// etc
|
||||
{
|
||||
gui.guiLeft = (gui.width - gui.xSize) / 2;
|
||||
@@ -183,9 +179,9 @@ public class LayoutManager
|
||||
|
||||
for (Widget widget : controlWidgets) {
|
||||
widget.onGuiClick(mousex, mousey);
|
||||
if (widget.contains(mousex, mousey)
|
||||
? widget.handleClick(mousex, mousey, button)
|
||||
: widget.handleClickExt(mousex, mousey, button)) return true;
|
||||
if (widget.contains(mousex, mousey) ? widget.handleClick(mousex, mousey, button)
|
||||
: widget.handleClickExt(mousex, mousey, button))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -225,6 +221,11 @@ public class LayoutManager
|
||||
return true;
|
||||
}
|
||||
|
||||
if (NEIClientConfig.isKeyHashDown("gui.next_tooltip")) {
|
||||
GuiContainerManager.incrementTooltipPage();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isEnabled() && !isHidden()) {
|
||||
for (Widget widget : controlWidgets) if (inputFocused == null) widget.lastKeyTyped(keyID, keyChar);
|
||||
}
|
||||
@@ -279,6 +280,13 @@ public class LayoutManager
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postRenderTooltips(GuiContainer gui, int mousex, int mousey, List<String> tooltip) {
|
||||
if (!isHidden() && isEnabled()) {
|
||||
for (Widget widget : drawWidgets) widget.postDrawTooltips(mousex, mousey, tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) {
|
||||
if (!isHidden() && isEnabled() && GuiContainerManager.shouldShowTooltip(gui)) {
|
||||
@@ -304,8 +312,8 @@ public class LayoutManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(
|
||||
GuiContainer gui, ItemStack itemstack, int mousex, int mousey, List<String> currenttip) {
|
||||
public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey,
|
||||
List<String> currenttip) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@@ -350,6 +358,7 @@ public class LayoutManager
|
||||
searchField = new SearchField("search");
|
||||
|
||||
options = new ButtonCycled(3) {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
this.icons[0] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 32, 0, 16, 16).build();
|
||||
@@ -357,17 +366,22 @@ public class LayoutManager
|
||||
this.icons[2] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 64, 0, 16, 16).build();
|
||||
}
|
||||
|
||||
private boolean getIsAccessibleControlEventKey() {
|
||||
if (Minecraft.isRunningOnMac) {
|
||||
return Keyboard.getEventKey() == Keyboard.KEY_LMETA || Keyboard.getEventKey() == Keyboard.KEY_RMETA;
|
||||
}
|
||||
return Keyboard.getEventKey() == Keyboard.KEY_LCONTROL
|
||||
|| Keyboard.getEventKey() == Keyboard.KEY_RCONTROL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (!rightclick) {
|
||||
if (Keyboard.getEventKeyState()
|
||||
&& (Keyboard.getEventKey() == Keyboard.KEY_LCONTROL
|
||||
|| Keyboard.getEventKey() == Keyboard.KEY_RCONTROL)) {
|
||||
if (Keyboard.getEventKeyState() && getIsAccessibleControlEventKey()) {
|
||||
NEIClientConfig.cycleSetting("inventory.cheatmode", 3);
|
||||
} else {
|
||||
if (Keyboard.getEventKeyState()
|
||||
&& (Keyboard.getEventKey() == Keyboard.KEY_LSHIFT
|
||||
|| Keyboard.getEventKey() == Keyboard.KEY_RSHIFT)) {
|
||||
if (Keyboard.getEventKeyState() && (Keyboard.getEventKey() == Keyboard.KEY_LSHIFT
|
||||
|| Keyboard.getEventKey() == Keyboard.KEY_RSHIFT)) {
|
||||
GuiRecipeTab.loadHandlerInfo();
|
||||
RecipeCatalysts.loadCatalystInfo();
|
||||
}
|
||||
@@ -397,6 +411,7 @@ public class LayoutManager
|
||||
};
|
||||
|
||||
bookmarksButton = new ButtonCycled(2) {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
this.icons[0] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 0, 0, 16, 16).build();
|
||||
@@ -423,6 +438,7 @@ public class LayoutManager
|
||||
less = ItemPanels.itemPanel.less;
|
||||
quantity = ItemPanels.itemPanel.quantity;
|
||||
delete = new Button() {
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if ((state & 0x3) == 2) return false;
|
||||
@@ -450,16 +466,16 @@ public class LayoutManager
|
||||
|
||||
@Override
|
||||
public void postDraw(int mousex, int mousey) {
|
||||
if (contains(mousex, mousey) && getHeldItem() != null && (state & 0x3) != 2)
|
||||
GuiDraw.drawTip(
|
||||
mousex + 9,
|
||||
mousey,
|
||||
translate(
|
||||
"inventory.delete." + (shiftKey() ? "all" : "one"),
|
||||
GuiContainerManager.itemDisplayNameShort(getHeldItem())));
|
||||
if (contains(mousex, mousey) && getHeldItem() != null && (state & 0x3) != 2) GuiDraw.drawTip(
|
||||
mousex + 9,
|
||||
mousey,
|
||||
translate(
|
||||
"inventory.delete." + (shiftKey() ? "all" : "one"),
|
||||
GuiContainerManager.itemDisplayNameShort(getHeldItem())));
|
||||
}
|
||||
};
|
||||
gamemode = new ButtonCycled(3) {
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (!rightclick) {
|
||||
@@ -475,6 +491,7 @@ public class LayoutManager
|
||||
}
|
||||
};
|
||||
rain = new Button() {
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (handleDisabledButtonPress("rain", rightclick)) return true;
|
||||
@@ -491,6 +508,7 @@ public class LayoutManager
|
||||
}
|
||||
};
|
||||
magnet = new Button() {
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (!rightclick) {
|
||||
@@ -507,6 +525,7 @@ public class LayoutManager
|
||||
for (int i = 0; i < 4; i++) {
|
||||
final int zone = i;
|
||||
timeButtons[i] = new Button() {
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (handleDisabledButtonPress(NEIActions.timeZones[zone], rightclick)) return true;
|
||||
@@ -519,12 +538,13 @@ public class LayoutManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getButtonTip() {
|
||||
return getTimeTip(NEIActions.timeZones[zone], state);
|
||||
public void addTooltips(List<String> tooltip) {
|
||||
addTimeTip(NEIActions.timeZones[zone], state, tooltip);
|
||||
}
|
||||
};
|
||||
}
|
||||
heal = new Button() {
|
||||
|
||||
@Override
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (!rightclick) {
|
||||
@@ -552,9 +572,13 @@ public class LayoutManager
|
||||
return translate("inventory." + name + "." + sfx);
|
||||
}
|
||||
|
||||
private static String getTimeTip(String name, int state) {
|
||||
String sfx = (state & 0x3) == 2 ? "enable" : "set";
|
||||
return translate("inventory." + name + "." + sfx);
|
||||
private static void addTimeTip(String name, int state, List<String> tooltip) {
|
||||
if ((state & 0x3) == 2) {
|
||||
tooltip.add(translate("inventory." + name + ".enable"));
|
||||
} else {
|
||||
tooltip.add(translate("inventory." + name + ".set"));
|
||||
tooltip.add(EnumChatFormatting.GRAY + translate("inventory." + name + ".disable"));
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean handleDisabledButtonPress(String ident, boolean rightclick) {
|
||||
@@ -598,9 +622,9 @@ public class LayoutManager
|
||||
|
||||
NEIController.load(gui);
|
||||
|
||||
if (checkCreativeInv(gui)
|
||||
&& gui.mc.currentScreen instanceof GuiContainerCreative) // override creative with creative+
|
||||
gui.mc.displayGuiScreen(null); // close the screen and wait for the server to open it for us
|
||||
if (checkCreativeInv(gui) && gui.mc.currentScreen instanceof GuiContainerCreative) // override creative with
|
||||
// creative+
|
||||
gui.mc.displayGuiScreen(null); // close the screen and wait for the server to open it for us
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -730,10 +754,8 @@ public class LayoutManager
|
||||
@Override
|
||||
public void renderSlotOverlay(GuiContainer window, Slot slot) {
|
||||
ItemStack item = slot.getStack();
|
||||
if (world.nbt.getBoolean("searchinventories")
|
||||
&& (item == null
|
||||
? !getSearchExpression().equals("")
|
||||
: !((SearchField) searchField).getFilter().matches(item))) {
|
||||
if (world.nbt.getBoolean("searchinventories") && (item == null ? !getSearchExpression().equals("")
|
||||
: !((SearchField) searchField).getFilter().matches(item))) {
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glTranslatef(0, 0, 150);
|
||||
@@ -753,7 +775,7 @@ public class LayoutManager
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
if (!isDrawableResource) drawTexturedModalRect(x, y, image.x, image.y, image.width, image.height);
|
||||
else ((DrawableResource) image).draw(x, y);
|
||||
else((DrawableResource) image).draw(x, y);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,15 @@ import static codechicken.nei.NEIClientConfig.disabledActions;
|
||||
import static codechicken.nei.NEIClientConfig.getMagnetMode;
|
||||
import static codechicken.nei.NEIClientConfig.isEnabled;
|
||||
|
||||
import codechicken.nei.api.LayoutStyle;
|
||||
import codechicken.nei.drawable.DrawableBuilder;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.nei.api.LayoutStyle;
|
||||
import codechicken.nei.drawable.DrawableBuilder;
|
||||
|
||||
public class LayoutStyleMinecraft extends LayoutStyle {
|
||||
|
||||
public int buttonCount;
|
||||
public int leftSize;
|
||||
public int numButtons;
|
||||
@@ -88,9 +91,9 @@ public class LayoutStyleMinecraft extends LayoutStyle {
|
||||
|
||||
if (canPerformAction("delete")) layoutButton(delete);
|
||||
if (canPerformAction("rain")) layoutButton(rain);
|
||||
if (NEIClientUtils.isValidGamemode("creative")
|
||||
|| NEIClientUtils.isValidGamemode("creative+")
|
||||
|| NEIClientUtils.isValidGamemode("adventure")) layoutButton(gamemode);
|
||||
if (NEIClientUtils.isValidGamemode("creative") || NEIClientUtils.isValidGamemode("creative+")
|
||||
|| NEIClientUtils.isValidGamemode("adventure"))
|
||||
layoutButton(gamemode);
|
||||
if (canPerformAction("magnet")) layoutButton(magnet);
|
||||
if (canPerformAction("time")) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
@@ -124,8 +127,13 @@ public class LayoutStyleMinecraft extends LayoutStyle {
|
||||
presetsPanel.x = (gui.width - gui.xSize) / 2 + gui.xSize - presetsPanel.w;
|
||||
|
||||
searchField.h = 20;
|
||||
searchField.w = 150;
|
||||
searchField.x = (gui.width - searchField.w) / 2;
|
||||
if (NEIClientConfig.isSearchWidgetCentered()) {
|
||||
searchField.w = 150;
|
||||
searchField.x = (gui.width - searchField.w) / 2;
|
||||
} else {
|
||||
searchField.w = (int) (itemPanel.w * (NEIClientConfig.showItemQuantityWidget() ? 0.7 : 1));
|
||||
searchField.x = itemPanel.x;
|
||||
}
|
||||
searchField.y = gui.height - searchField.h - 2;
|
||||
|
||||
if (!visiblity.showItemSection) {
|
||||
@@ -150,10 +158,9 @@ public class LayoutStyleMinecraft extends LayoutStyle {
|
||||
|
||||
int tex;
|
||||
if ((b.state & 0x3) == 2) tex = 0;
|
||||
else if ((b.state & 0x4) == 0 && b.contains(mousex, mousey)
|
||||
|| // not a state button and mouseover
|
||||
else if ((b.state & 0x4) == 0 && b.contains(mousex, mousey) || // not a state button and mouseover
|
||||
(b.state & 0x3) == 1) // state active
|
||||
tex = 2;
|
||||
tex = 2;
|
||||
else tex = 1;
|
||||
LayoutManager.drawButtonBackground(b.x, b.y, b.w, b.h, true, tex);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class NEIActions {
|
||||
|
||||
public static final int protocol = 0;
|
||||
|
||||
public static HashMap<String, NEIActions> nameActionMap = new HashMap<>();
|
||||
@@ -61,8 +62,8 @@ public class NEIActions {
|
||||
canDisable.add("rain");
|
||||
}
|
||||
|
||||
public static final String[] timeZones = new String[] {"dawn", "noon", "dusk", "midnight"};
|
||||
public static final String[] gameModes = new String[] {"survival", "creative", "creative+", "adventure"};
|
||||
public static final String[] timeZones = new String[] { "dawn", "noon", "dusk", "midnight" };
|
||||
public static final String[] gameModes = new String[] { "survival", "creative", "creative+", "adventure" };
|
||||
|
||||
public String name;
|
||||
public String base;
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.core.ClientUtils;
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
import codechicken.lib.packet.PacketCustom.IClientPacketHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -12,7 +7,14 @@ import net.minecraft.network.play.INetHandlerPlayClient;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import codechicken.core.ClientUtils;
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
import codechicken.lib.packet.PacketCustom.IClientPacketHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class NEICPH implements IClientPacketHandler {
|
||||
|
||||
public static final String channel = "NEI";
|
||||
|
||||
@Override
|
||||
@@ -38,14 +40,14 @@ public class NEICPH implements IClientPacketHandler {
|
||||
break;
|
||||
case 21:
|
||||
ClientUtils.openSMPGui(
|
||||
packet.readUByte(), new GuiEnchantmentModifier(mc.thePlayer.inventory, mc.theWorld, 0, 0, 0));
|
||||
packet.readUByte(),
|
||||
new GuiEnchantmentModifier(mc.thePlayer.inventory, mc.theWorld, 0, 0, 0));
|
||||
break;
|
||||
case 23:
|
||||
if (packet.readBoolean())
|
||||
ClientUtils.openSMPGui(
|
||||
packet.readUByte(),
|
||||
new GuiExtendedCreativeInv(new ContainerCreativeInv(
|
||||
mc.thePlayer, new ExtendedCreativeInv(null, Side.CLIENT))));
|
||||
if (packet.readBoolean()) ClientUtils.openSMPGui(
|
||||
packet.readUByte(),
|
||||
new GuiExtendedCreativeInv(
|
||||
new ContainerCreativeInv(mc.thePlayer, new ExtendedCreativeInv(null, Side.CLIENT))));
|
||||
else mc.displayGuiScreen(new GuiInventory(mc.thePlayer));
|
||||
break;
|
||||
case 24:
|
||||
@@ -143,8 +145,7 @@ public class NEICPH implements IClientPacketHandler {
|
||||
|
||||
public static void sendRequestContainer() {
|
||||
PacketCustom packet = new PacketCustom(channel, 16);
|
||||
packet.writeInt(
|
||||
Minecraft.getMinecraft().thePlayer.openContainer.getInventory().size());
|
||||
packet.writeInt(Minecraft.getMinecraft().thePlayer.openContainer.getInventory().size());
|
||||
packet.sendToServer();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.nei.api.INEIGuiAdapter;
|
||||
import codechicken.nei.api.TaggedInventoryArea;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiChest;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.ContainerChest;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.nei.api.INEIGuiAdapter;
|
||||
import codechicken.nei.api.TaggedInventoryArea;
|
||||
|
||||
public class NEIChestGuiHandler extends INEIGuiAdapter {
|
||||
|
||||
public int chestSize(GuiContainer gui) {
|
||||
return ((ContainerChest) gui.inventorySlots).getLowerChestInventory().getSizeInventory();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,28 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.SaveFormatComparator;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import codechicken.core.CCUpdateChecker;
|
||||
import codechicken.core.ClassDiscoverer;
|
||||
import codechicken.core.ClientUtils;
|
||||
@@ -31,35 +54,19 @@ import codechicken.nei.recipe.IRecipeHandler;
|
||||
import codechicken.nei.recipe.RecipeCatalysts;
|
||||
import codechicken.nei.recipe.RecipeInfo;
|
||||
import codechicken.obfuscator.ObfuscationRun;
|
||||
import com.google.common.base.Objects;
|
||||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.SaveFormatComparator;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public class NEIClientConfig {
|
||||
private static boolean configLoaded;
|
||||
|
||||
private static boolean mainNEIConfigLoaded;
|
||||
private static boolean pluginNEIConfigLoaded;
|
||||
private static boolean enabledOverride;
|
||||
private static String worldPath;
|
||||
|
||||
public static Logger logger = LogManager.getLogger("NotEnoughItems");
|
||||
public static File configDir = new File(CommonUtils.getMinecraftDir(), "config/NEI/");
|
||||
public static ConfigSet global =
|
||||
new ConfigSet(new File("saves/NEI/client.dat"), new ConfigFile(new File(configDir, "client.cfg")));
|
||||
public static ConfigSet global = new ConfigSet(
|
||||
new File("saves/NEI/client.dat"),
|
||||
new ConfigFile(new File(configDir, "client.cfg")));
|
||||
public static ConfigSet world;
|
||||
public static final File handlerFile = new File(configDir, "handlers.csv");
|
||||
public static final File catalystFile = new File(configDir, "catalysts.csv");
|
||||
@@ -84,8 +91,8 @@ public class NEIClientConfig {
|
||||
|
||||
// Function that extracts the handler ID from a handler, with special logic for
|
||||
// TemplateRecipeHandler: prefer using the overlay ID if it exists.
|
||||
public static final Function<IRecipeHandler, String> HANDLER_ID_FUNCTION =
|
||||
handler -> Objects.firstNonNull(handler.getOverlayIdentifier(), handler.getHandlerId());
|
||||
public static final Function<IRecipeHandler, String> HANDLER_ID_FUNCTION = handler -> Objects
|
||||
.firstNonNull(handler.getOverlayIdentifier(), handler.getHandlerId());
|
||||
|
||||
public static int getHandlerOrder(IRecipeHandler handler) {
|
||||
if (handlerOrdering.get(handler.getOverlayIdentifier()) != null) {
|
||||
@@ -98,8 +105,8 @@ public class NEIClientConfig {
|
||||
}
|
||||
|
||||
// Comparator that compares handlers using the handlerOrdering map.
|
||||
public static final Comparator<IRecipeHandler> HANDLER_COMPARATOR =
|
||||
Comparator.comparingInt(NEIClientConfig::getHandlerOrder);
|
||||
public static final Comparator<IRecipeHandler> HANDLER_COMPARATOR = Comparator
|
||||
.comparingInt(NEIClientConfig::getHandlerOrder);
|
||||
|
||||
public static ItemStack[] creativeInv;
|
||||
|
||||
@@ -121,10 +128,8 @@ public class NEIClientConfig {
|
||||
tag.setComment(
|
||||
"Main configuration of NEI.\nMost of these options can be changed ingame.\nDeleting any element will restore it to it's default value");
|
||||
|
||||
tag.getTag("command")
|
||||
.useBraces()
|
||||
.setComment(
|
||||
"Change these options if you have a different mod installed on the server that handles the commands differently, Eg. Bukkit Essentials");
|
||||
tag.getTag("command").useBraces().setComment(
|
||||
"Change these options if you have a different mod installed on the server that handles the commands differently, Eg. Bukkit Essentials");
|
||||
tag.setNewLineMode(1);
|
||||
|
||||
tag.getTag("inventory.widgetsenabled").getBooleanValue(true);
|
||||
@@ -132,11 +137,11 @@ public class NEIClientConfig {
|
||||
|
||||
tag.getTag("inventory.hidden").getBooleanValue(false);
|
||||
tag.getTag("inventory.cheatmode").getIntValue(2);
|
||||
tag.getTag("inventory.lockmode")
|
||||
.setComment(
|
||||
"For those who can't help themselves.\nSet this to a mode and you will be unable to change it ingame")
|
||||
tag.getTag("inventory.lockmode").setComment(
|
||||
"For those who can't help themselves.\nSet this to a mode and you will be unable to change it ingame")
|
||||
.getIntValue(-1);
|
||||
API.addOption(new OptionCycled("inventory.cheatmode", 3) {
|
||||
|
||||
@Override
|
||||
public boolean optionValid(int index) {
|
||||
return getLockedMode() == -1 || getLockedMode() == index && NEIInfo.isValidMode(index);
|
||||
@@ -183,6 +188,7 @@ public class NEIClientConfig {
|
||||
|
||||
tag.getTag("inventory.invertMouseScrollTransfer").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.invertMouseScrollTransfer", true) {
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return isMouseScrollTransferEnabled();
|
||||
@@ -205,10 +211,10 @@ public class NEIClientConfig {
|
||||
tag.getTag("command.heal").setDefaultValue("");
|
||||
API.addOption(new OptionTextField("command.heal"));
|
||||
|
||||
tag.getTag("inventory.worldSpecificBookmarks")
|
||||
.setComment("Global or world specific bookmarks")
|
||||
tag.getTag("inventory.worldSpecificBookmarks").setComment("Global or world specific bookmarks")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.worldSpecificBookmarks", true) {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
super.onClick(button);
|
||||
@@ -217,10 +223,10 @@ public class NEIClientConfig {
|
||||
}
|
||||
});
|
||||
|
||||
tag.getTag("inventory.worldSpecificPresets")
|
||||
.setComment("Global or world specific presets")
|
||||
tag.getTag("inventory.worldSpecificPresets").setComment("Global or world specific presets")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.worldSpecificPresets", true) {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
super.onClick(button);
|
||||
@@ -229,60 +235,57 @@ public class NEIClientConfig {
|
||||
}
|
||||
});
|
||||
|
||||
tag.getTag("inventory.bookmarksEnabled")
|
||||
.setComment("Enable/disable bookmarks")
|
||||
.getBooleanValue(true);
|
||||
tag.getTag("inventory.bookmarksEnabled").setComment("Enable/disable bookmarks").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.bookmarksEnabled", true));
|
||||
tag.getTag("inventory.useNBTInBookmarks")
|
||||
.setComment("Use NBT in Bookmarks")
|
||||
.getBooleanValue(true);
|
||||
tag.getTag("inventory.useNBTInBookmarks").setComment("Use NBT in Bookmarks").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.useNBTInBookmarks", true));
|
||||
tag.getTag("inventory.bookmarksAnimationEnabled")
|
||||
.setComment("REI Style Animation in Bookmarks")
|
||||
tag.getTag("inventory.bookmarksAnimationEnabled").setComment("REI Style Animation in Bookmarks")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.bookmarksAnimationEnabled", true));
|
||||
tag.getTag("inventory.showRecipeMarker")
|
||||
.setComment("Show Recipe Marker")
|
||||
.getBooleanValue(false);
|
||||
tag.getTag("inventory.recipeTooltipsEnabled").setComment("Show recipe tooltips in Bookmarks")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.recipeTooltipsEnabled", true));
|
||||
tag.getTag("inventory.showRecipeMarker").setComment("Show Recipe Marker").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.showRecipeMarker", true));
|
||||
|
||||
tag.getTag("inventory.showItemQuantityWidget")
|
||||
.setComment("Show Item Quantity Widget")
|
||||
.getBooleanValue(true);
|
||||
tag.getTag("inventory.showItemQuantityWidget").setComment("Show Item Quantity Widget").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.showItemQuantityWidget", true));
|
||||
|
||||
tag.getTag("inventory.jei_style_tabs")
|
||||
.setComment("Enable/disable JEI Style Tabs")
|
||||
.getBooleanValue(true);
|
||||
tag.getTag("inventory.centerSearchWidget").setComment("Center Search Widget").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.centerSearchWidget", true));
|
||||
|
||||
tag.getTag("inventory.jei_style_tabs").setComment("Enable/disable JEI Style Tabs").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButtonBoubs("inventory.jei_style_tabs", true));
|
||||
tag.getTag("inventory.jei_style_item_presence_overlay")
|
||||
.setComment("Enable/disable JEI Style item presence overlay on ?-hover")
|
||||
.getBooleanValue(true);
|
||||
.setComment("Enable/disable JEI Style item presence overlay on ?-hover").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.jei_style_item_presence_overlay", true));
|
||||
tag.getTag("inventory.jei_style_recipe_catalyst")
|
||||
.setComment("Enable/disable JEI Style Recipe Catalysts")
|
||||
tag.getTag("inventory.jei_style_recipe_catalyst").setComment("Enable/disable JEI Style Recipe Catalysts")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.jei_style_recipe_catalyst", true));
|
||||
|
||||
tag.getTag("inventory.creative_tab_style")
|
||||
.setComment("Creative or JEI style tabs")
|
||||
.getBooleanValue(false);
|
||||
tag.getTag("inventory.creative_tab_style").setComment("Creative or JEI style tabs").getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.creative_tab_style", true));
|
||||
|
||||
tag.getTag("inventory.ignore_potion_overlap")
|
||||
.setComment("Ignore overlap with potion effect HUD")
|
||||
tag.getTag("inventory.ignore_potion_overlap").setComment("Ignore overlap with potion effect HUD")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.ignore_potion_overlap", true));
|
||||
|
||||
tag.getTag("inventory.optimize_gui_overlap_computation")
|
||||
.setComment("Optimize computation for GUI overlap")
|
||||
tag.getTag("inventory.optimize_gui_overlap_computation").setComment("Optimize computation for GUI overlap")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("inventory.optimize_gui_overlap_computation", true));
|
||||
|
||||
tag.getTag("tools.handler_load_from_config")
|
||||
.setComment("ADVANCED: Load handlers from config")
|
||||
tag.getTag("inventory.jei_style_cycled_ingredients").setComment("JEI styled cycled ingredients")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.jei_style_cycled_ingredients", true));
|
||||
|
||||
tag.getTag("inventory.shift_overlay_recipe")
|
||||
.setComment("Require holding shift to move items when overlaying recipe").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.shift_overlay_recipe", true));
|
||||
|
||||
tag.getTag("tools.handler_load_from_config").setComment("ADVANCED: Load handlers from config")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("tools.handler_load_from_config", true) {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
super.onClick(button);
|
||||
@@ -291,10 +294,10 @@ public class NEIClientConfig {
|
||||
}
|
||||
});
|
||||
|
||||
tag.getTag("tools.catalyst_load_from_config")
|
||||
.setComment("ADVANCED: Load catalysts from config")
|
||||
tag.getTag("tools.catalyst_load_from_config").setComment("ADVANCED: Load catalysts from config")
|
||||
.getBooleanValue(false);
|
||||
API.addOption(new OptionToggleButton("tools.catalyst_load_from_config", true) {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
super.onClick(button);
|
||||
@@ -308,6 +311,7 @@ public class NEIClientConfig {
|
||||
|
||||
private static void linkOptionList() {
|
||||
OptionList.setOptionList(new OptionList("nei.options") {
|
||||
|
||||
@Override
|
||||
public ConfigSet globalConfigSet() {
|
||||
return global;
|
||||
@@ -348,13 +352,15 @@ public class NEIClientConfig {
|
||||
API.addHashBind("gui.bookmark_recipe", Keyboard.KEY_A + NEIClientUtils.SHIFT_HASH);
|
||||
API.addHashBind("gui.bookmark_count", Keyboard.KEY_A + NEIClientUtils.CTRL_HASH);
|
||||
API.addHashBind(
|
||||
"gui.bookmark_recipe_count", Keyboard.KEY_A + NEIClientUtils.SHIFT_HASH + NEIClientUtils.CTRL_HASH);
|
||||
"gui.bookmark_recipe_count",
|
||||
Keyboard.KEY_A + NEIClientUtils.SHIFT_HASH + NEIClientUtils.CTRL_HASH);
|
||||
API.addHashBind("gui.overlay", Keyboard.KEY_S);
|
||||
API.addHashBind("gui.overlay_use", Keyboard.KEY_S + NEIClientUtils.SHIFT_HASH);
|
||||
API.addHashBind("gui.overlay_hide", Keyboard.KEY_S + NEIClientUtils.CTRL_HASH);
|
||||
API.addHashBind("gui.hide_bookmarks", Keyboard.KEY_B);
|
||||
API.addKeyBind("gui.getprevioussearch", Keyboard.KEY_UP);
|
||||
API.addKeyBind("gui.getnextsearch", Keyboard.KEY_DOWN);
|
||||
API.addHashBind("gui.next_tooltip", Keyboard.KEY_Z);
|
||||
|
||||
API.addKeyBind("world.chunkoverlay", Keyboard.KEY_F9);
|
||||
API.addKeyBind("world.moboverlay", Keyboard.KEY_F7);
|
||||
@@ -402,10 +408,8 @@ public class NEIClientConfig {
|
||||
ItemPanels.itemPanel.quantity.setText(Integer.toString(getItemQuantity()));
|
||||
SubsetWidget.loadHidden();
|
||||
|
||||
if (newWorld && Minecraft.getMinecraft().isSingleplayer())
|
||||
world.config
|
||||
.getTag("inventory.cheatmode")
|
||||
.setIntValue(NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
|
||||
if (newWorld && Minecraft.getMinecraft().isSingleplayer()) world.config.getTag("inventory.cheatmode")
|
||||
.setIntValue(NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
|
||||
|
||||
NEIInfo.load(ClientUtils.getWorld());
|
||||
}
|
||||
@@ -420,7 +424,7 @@ public class NEIClientConfig {
|
||||
}
|
||||
|
||||
public static int getKeyBinding(String string) {
|
||||
return getSetting("keys." + string).getIntValue();
|
||||
return getSetting("keys." + string).getIntValue(Keyboard.KEY_NONE);
|
||||
}
|
||||
|
||||
public static void setDefaultKeyBinding(String string, int key) {
|
||||
@@ -432,9 +436,40 @@ public class NEIClientConfig {
|
||||
return hash != Keyboard.CHAR_NONE && hash == NEIClientUtils.getKeyHash();
|
||||
}
|
||||
|
||||
public static void bootNEI(World world) {
|
||||
if (configLoaded) return;
|
||||
public static String getKeyName(int keyBind, boolean useHash) {
|
||||
return getKeyName(keyBind, useHash, false);
|
||||
}
|
||||
|
||||
public static String getKeyName(int keyBind, boolean useHash, boolean showOnlyHash) {
|
||||
String keyText = "";
|
||||
|
||||
if (useHash) {
|
||||
final String DELIMITER = " + ";
|
||||
if ((keyBind & NEIClientUtils.CTRL_HASH) != 0) {
|
||||
keyText += NEIClientUtils.translate(Minecraft.isRunningOnMac ? "key.ctrl.mac" : "key.ctrl") + DELIMITER;
|
||||
}
|
||||
if ((keyBind & NEIClientUtils.SHIFT_HASH) != 0) {
|
||||
keyText += "SHIFT" + DELIMITER;
|
||||
}
|
||||
if ((keyBind & NEIClientUtils.ALT_HASH) != 0) {
|
||||
keyText += "ALT" + DELIMITER;
|
||||
}
|
||||
}
|
||||
|
||||
if (!showOnlyHash) {
|
||||
keyText += Keyboard.getKeyName(unHashKey(keyBind));
|
||||
}
|
||||
return keyText;
|
||||
}
|
||||
|
||||
public static int unHashKey(int keyBind) {
|
||||
return keyBind & ~(NEIClientUtils.CTRL_HASH | NEIClientUtils.SHIFT_HASH | NEIClientUtils.ALT_HASH);
|
||||
}
|
||||
|
||||
public static void bootNEI(World world) {
|
||||
if (mainNEIConfigLoaded) return;
|
||||
|
||||
// main NEI config loading
|
||||
ItemInfo.load(world);
|
||||
GuiInfo.load();
|
||||
RecipeInfo.load();
|
||||
@@ -442,13 +477,16 @@ public class NEIClientConfig {
|
||||
NEIController.load();
|
||||
RecipeCatalysts.loadCatalystInfo();
|
||||
|
||||
configLoaded = true;
|
||||
mainNEIConfigLoaded = true;
|
||||
|
||||
new Thread("NEI Plugin Loader") {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
logger.debug("Started NEI plugin loading");
|
||||
ClassDiscoverer classDiscoverer = new ClassDiscoverer(
|
||||
test -> test.startsWith("NEI") && test.endsWith("Config.class"), IConfigureNEI.class);
|
||||
test -> test.startsWith("NEI") && test.endsWith("Config.class"),
|
||||
IConfigureNEI.class);
|
||||
|
||||
classDiscoverer.findClasses();
|
||||
|
||||
@@ -463,6 +501,13 @@ public class NEIClientConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// Set pluginNEIConfigLoaded here before posting the NEIConfigsLoadedEvent. This used to be the other
|
||||
// way around, but apparently if your modpack includes 800 mods the event poster might not return in
|
||||
// time and cause issues when loading a world for a second time as configLoaded is still false. This may
|
||||
// cause issues in case one of the event handler calls the (non-thread-safe) NEI API. I don't expect any
|
||||
// handler to do this, but who knows what modders have come up with...
|
||||
pluginNEIConfigLoaded = true;
|
||||
logger.debug("NEI plugin loading finished");
|
||||
MinecraftForge.EVENT_BUS.post(new NEIConfigsLoadedEvent());
|
||||
}
|
||||
}.start();
|
||||
@@ -517,6 +562,10 @@ public class NEIClientConfig {
|
||||
return getBooleanSetting("inventory.bookmarksAnimationEnabled");
|
||||
}
|
||||
|
||||
public static boolean showRecipeTooltips() {
|
||||
return getBooleanSetting("inventory.recipeTooltipsEnabled");
|
||||
}
|
||||
|
||||
public static boolean showRecipeMarker() {
|
||||
return getBooleanSetting("inventory.showRecipeMarker");
|
||||
}
|
||||
@@ -525,6 +574,10 @@ public class NEIClientConfig {
|
||||
return getBooleanSetting("inventory.showItemQuantityWidget");
|
||||
}
|
||||
|
||||
public static boolean isSearchWidgetCentered() {
|
||||
return getBooleanSetting("inventory.centerSearchWidget");
|
||||
}
|
||||
|
||||
public static boolean areJEIStyleTabsVisible() {
|
||||
return getBooleanSetting("inventory.jei_style_tabs");
|
||||
}
|
||||
@@ -549,10 +602,22 @@ public class NEIClientConfig {
|
||||
return getBooleanSetting("inventory.optimize_gui_overlap_computation");
|
||||
}
|
||||
|
||||
public static boolean useJEIStyledCycledIngredients() {
|
||||
return getBooleanSetting("inventory.jei_style_cycled_ingredients");
|
||||
}
|
||||
|
||||
public static boolean requireShiftForOverlayRecipe() {
|
||||
return getBooleanSetting("inventory.shift_overlay_recipe");
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return enabledOverride && getBooleanSetting("inventory.widgetsenabled");
|
||||
}
|
||||
|
||||
public static boolean isLoaded() {
|
||||
return mainNEIConfigLoaded && pluginNEIConfigLoaded;
|
||||
}
|
||||
|
||||
public static boolean loadHandlersFromJar() {
|
||||
return !getBooleanSetting("tools.handler_load_from_config");
|
||||
}
|
||||
|
||||
@@ -8,13 +8,6 @@ import static codechicken.nei.NEIClientConfig.hasSMPCounterPart;
|
||||
import static codechicken.nei.NEIClientConfig.invCreativeMode;
|
||||
import static codechicken.nei.NEIClientConfig.world;
|
||||
|
||||
import codechicken.lib.inventory.InventoryRange;
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.lib.util.LangProxy;
|
||||
import codechicken.nei.api.GuiInfo;
|
||||
import codechicken.nei.api.IInfiniteItemHandler;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import com.google.common.collect.Iterables;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.math.BigInteger;
|
||||
@@ -33,6 +26,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
@@ -46,9 +40,20 @@ import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import codechicken.lib.inventory.InventoryRange;
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.lib.util.LangProxy;
|
||||
import codechicken.nei.api.GuiInfo;
|
||||
import codechicken.nei.api.IInfiniteItemHandler;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
|
||||
public class NEIClientUtils extends NEIServerUtils {
|
||||
|
||||
public static LangProxy lang = new LangProxy("nei");
|
||||
|
||||
/** Formats a number with group separator and at most 2 fraction digits. */
|
||||
@@ -110,8 +115,7 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
}
|
||||
|
||||
public static void decreaseSlotStack(int slotNumber) {
|
||||
ItemStack stack = slotNumber == -999
|
||||
? getHeldItem()
|
||||
ItemStack stack = slotNumber == -999 ? getHeldItem()
|
||||
: mc().thePlayer.openContainer.getSlot(slotNumber).getStack();
|
||||
if (stack == null) return;
|
||||
|
||||
@@ -152,7 +156,7 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mode -1 = normal cheats, 0 = no infinites, 1 = replenish stack
|
||||
* @param mode -1 = normal cheats, 0 = no infinites, 1 = replenish stack
|
||||
*/
|
||||
public static void cheatItem(ItemStack stack, int button, int mode) {
|
||||
if (!canCheatItem(stack)) return;
|
||||
@@ -191,16 +195,14 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
ItemStack stack = copyStack(base, i);
|
||||
if (hasSMPCounterPart()) {
|
||||
ItemStack typestack = copyStack(stack, 1);
|
||||
if (!infinite
|
||||
&& !canItemFitInInventory(mc().thePlayer, stack)
|
||||
if (!infinite && !canItemFitInInventory(mc().thePlayer, stack)
|
||||
&& (mc().currentScreen instanceof GuiContainer)) {
|
||||
GuiContainer gui = getGuiContainer();
|
||||
final List<Iterable<Integer>> handlerSlots;
|
||||
try {
|
||||
GuiInfo.readLock.lock();
|
||||
handlerSlots = GuiInfo.guiHandlers.stream()
|
||||
.map(handler -> handler.getItemSpawnSlots(gui, typestack))
|
||||
.filter(x -> x != null)
|
||||
.map(handler -> handler.getItemSpawnSlots(gui, typestack)).filter(x -> x != null)
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
} finally {
|
||||
GuiInfo.readLock.unlock();
|
||||
@@ -225,7 +227,7 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
if (given > 0) NEICPH.sendGiveItem(copyStack(typestack, given), false, false);
|
||||
} else NEICPH.sendGiveItem(stack, infinite, true);
|
||||
} else {
|
||||
for (int given = 0; given < stack.stackSize; ) {
|
||||
for (int given = 0; given < stack.stackSize;) {
|
||||
int qty = Math.min(stack.stackSize - given, stack.getMaxStackSize());
|
||||
sendCommand(
|
||||
getStringSetting("command.item"),
|
||||
@@ -249,6 +251,9 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
}
|
||||
|
||||
public static boolean controlKey() {
|
||||
if (Minecraft.isRunningOnMac) {
|
||||
return Keyboard.isKeyDown(Keyboard.KEY_LMETA) || Keyboard.isKeyDown(Keyboard.KEY_RMETA);
|
||||
}
|
||||
return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
|
||||
}
|
||||
|
||||
@@ -261,9 +266,7 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
|
||||
public static boolean isValidGamemode(String s) {
|
||||
return s.equals("survival")
|
||||
|| canPerformAction(s)
|
||||
&& Arrays.asList(getStringArrSetting("inventory.gamemodes"))
|
||||
.contains(s);
|
||||
|| canPerformAction(s) && Arrays.asList(getStringArrSetting("inventory.gamemodes")).contains(s);
|
||||
}
|
||||
|
||||
public static int getNextGamemode() {
|
||||
@@ -282,11 +285,10 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
if (mode == nmode) return;
|
||||
|
||||
if (hasSMPCounterPart()) NEICPH.sendGamemode(nmode);
|
||||
else
|
||||
sendCommand(
|
||||
getStringSetting("command.creative"),
|
||||
getGameType(nmode),
|
||||
mc().thePlayer.getCommandSenderName());
|
||||
else sendCommand(
|
||||
getStringSetting("command.creative"),
|
||||
getGameType(nmode),
|
||||
mc().thePlayer.getCommandSenderName());
|
||||
}
|
||||
|
||||
public static long getTime() {
|
||||
@@ -311,9 +313,8 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
NumberFormat numberformat = NumberFormat.getIntegerInstance();
|
||||
numberformat.setGroupingUsed(false);
|
||||
MessageFormat messageformat = new MessageFormat(command);
|
||||
for (int i = 0; i < args.length; i++)
|
||||
if (args[i] instanceof Integer || args[i] instanceof Long)
|
||||
messageformat.setFormatByArgumentIndex(i, numberformat);
|
||||
for (int i = 0; i < args.length; i++) if (args[i] instanceof Integer || args[i] instanceof Long)
|
||||
messageformat.setFormatByArgumentIndex(i, numberformat);
|
||||
|
||||
mc().thePlayer.sendChatMessage(messageformat.format(args));
|
||||
}
|
||||
@@ -349,13 +350,13 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
continue;
|
||||
}
|
||||
if (next + 1 != i) {
|
||||
ranges.add(new int[] {start, next});
|
||||
ranges.add(new int[] { start, next });
|
||||
start = next = i;
|
||||
continue;
|
||||
}
|
||||
next = i;
|
||||
}
|
||||
ranges.add(new int[] {start, next});
|
||||
ranges.add(new int[] { start, next });
|
||||
return ranges;
|
||||
}
|
||||
|
||||
@@ -433,8 +434,7 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
if (Keyboard.getEventKeyState()) {
|
||||
final int keycode = Keyboard.getEventKey();
|
||||
|
||||
if (keycode != Keyboard.KEY_LSHIFT
|
||||
&& keycode != Keyboard.KEY_RSHIFT
|
||||
if (keycode != Keyboard.KEY_LSHIFT && keycode != Keyboard.KEY_RSHIFT
|
||||
&& keycode != Keyboard.KEY_LCONTROL
|
||||
&& keycode != Keyboard.KEY_RCONTROL
|
||||
&& keycode != Keyboard.KEY_LMENU
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
package codechicken.nei;
|
||||
|
||||
public class NEICompatibility {}
|
||||
public class NEICompatibility {
|
||||
}
|
||||
@@ -2,6 +2,16 @@ package codechicken.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.getMousePosition;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainerCreative;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.GuiInfo;
|
||||
import codechicken.nei.api.IInfiniteItemHandler;
|
||||
@@ -11,16 +21,9 @@ import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerInputHandler;
|
||||
import codechicken.nei.guihook.IContainerSlotClickHandler;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import java.awt.Point;
|
||||
import java.util.LinkedList;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainerCreative;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class NEIController implements IContainerSlotClickHandler, IContainerInputHandler {
|
||||
|
||||
private static final NEIController instance = new NEIController();
|
||||
|
||||
public static GuiContainerManager manager;
|
||||
@@ -82,16 +85,15 @@ public class NEIController implements IContainerSlotClickHandler, IContainerInpu
|
||||
public static void processCreativeCycling(InventoryPlayer inventory) {
|
||||
if (NEIClientConfig.invCreativeMode() && NEIClientUtils.controlKey()) {
|
||||
if (selectedItem != inventory.currentItem) {
|
||||
if (inventory.currentItem == selectedItem + 1
|
||||
|| (inventory.currentItem == 0 && selectedItem == 8)) // foward
|
||||
if (inventory.currentItem == selectedItem + 1 || (inventory.currentItem == 0 && selectedItem == 8)) // foward
|
||||
{
|
||||
NEICPH.sendCreativeScroll(1);
|
||||
inventory.currentItem = selectedItem;
|
||||
} else if (inventory.currentItem == selectedItem - 1
|
||||
|| (inventory.currentItem == 8 && selectedItem == 0)) {
|
||||
NEICPH.sendCreativeScroll(-1);
|
||||
inventory.currentItem = selectedItem;
|
||||
}
|
||||
NEICPH.sendCreativeScroll(-1);
|
||||
inventory.currentItem = selectedItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +108,8 @@ public class NEIController implements IContainerSlotClickHandler, IContainerInpu
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleSlotClick(
|
||||
GuiContainer gui, int slotIndex, int button, Slot slot, int modifier, boolean eventconsumed) {
|
||||
public boolean handleSlotClick(GuiContainer gui, int slotIndex, int button, Slot slot, int modifier,
|
||||
boolean eventconsumed) {
|
||||
if (eventconsumed || !NEIClientConfig.isEnabled() || isSpreading(gui)) return eventconsumed;
|
||||
|
||||
if (deleteMode && slotIndex >= 0 && slot != null) {
|
||||
@@ -123,12 +125,12 @@ public class NEIController implements IContainerSlotClickHandler, IContainerInpu
|
||||
if (button == 1 && slot instanceof SlotCrafting) // right click
|
||||
{
|
||||
for (int i1 = 0; i1 < 64; i1++) // click this slot 64 times
|
||||
manager.handleSlotClick(slot.slotNumber, button, 0);
|
||||
manager.handleSlotClick(slot.slotNumber, button, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (NEIClientUtils.controlKey()
|
||||
&& modifier != 4 // Drop key pressed: net.minecraft.client.gui.inventory.GuiContainer.keyTyped
|
||||
if (NEIClientUtils.controlKey() && modifier != 4 // Drop key pressed:
|
||||
// net.minecraft.client.gui.inventory.GuiContainer.keyTyped
|
||||
&& slot != null
|
||||
&& slot.getStack() != null
|
||||
&& slot.isItemValid(slot.getStack())) {
|
||||
@@ -138,8 +140,7 @@ public class NEIController implements IContainerSlotClickHandler, IContainerInpu
|
||||
|
||||
if (GuiInfo.hasCustomSlots(gui)) return false;
|
||||
|
||||
if (slotIndex >= 0
|
||||
&& NEIClientUtils.shiftKey()
|
||||
if (slotIndex >= 0 && NEIClientUtils.shiftKey()
|
||||
&& NEIClientUtils.getHeldItem() != null
|
||||
&& !slot.getHasStack()) {
|
||||
ItemStack held = NEIClientUtils.getHeldItem();
|
||||
@@ -167,8 +168,7 @@ public class NEIController implements IContainerSlotClickHandler, IContainerInpu
|
||||
if (firstheld != nowHeld) pickedUpFromSlot = slotIndex;
|
||||
|
||||
if (NEIClientConfig.canPerformAction("item") && NEIClientConfig.hasSMPCounterPart()) {
|
||||
if (heldStackInfinite != null
|
||||
&& slot != null
|
||||
if (heldStackInfinite != null && slot != null
|
||||
&& slot.inventory == NEIClientUtils.mc().thePlayer.inventory) {
|
||||
ItemStack stack = slot.getStack();
|
||||
if (stack != null) {
|
||||
@@ -214,9 +214,9 @@ public class NEIController implements IContainerSlotClickHandler, IContainerInpu
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {
|
||||
if (!NEIClientConfig.isEnabled()
|
||||
|| GuiInfo.hasCustomSlots(gui)
|
||||
|| !NEIClientConfig.isMouseScrollTransferEnabled()) return false;
|
||||
if (!NEIClientConfig.isEnabled() || GuiInfo.hasCustomSlots(gui)
|
||||
|| !NEIClientConfig.isMouseScrollTransferEnabled())
|
||||
return false;
|
||||
|
||||
// slot in GuiRecipe does not contain actual stack
|
||||
// and scroll should be handled by GuiRecipe, not here
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.nei.api.INEIGuiAdapter;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainerCreative;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
||||
import codechicken.nei.api.INEIGuiAdapter;
|
||||
|
||||
public class NEICreativeGuiHandler extends INEIGuiAdapter {
|
||||
|
||||
@Override
|
||||
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
|
||||
if (!(gui instanceof GuiContainerCreative)) return currentVisibility;
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.lib.inventory.ContainerExtended;
|
||||
import codechicken.lib.inventory.SlotDummy;
|
||||
import codechicken.nei.api.INEIGuiAdapter;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.lib.inventory.ContainerExtended;
|
||||
import codechicken.lib.inventory.SlotDummy;
|
||||
import codechicken.nei.api.INEIGuiAdapter;
|
||||
|
||||
public class NEIDummySlotHandler extends INEIGuiAdapter {
|
||||
|
||||
@Override
|
||||
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) {
|
||||
Slot slot = gui.getSlotAtPosition(mousex, mousey);
|
||||
if (slot instanceof SlotDummy
|
||||
&& slot.isItemValid(draggedStack)
|
||||
if (slot instanceof SlotDummy && slot.isItemValid(draggedStack)
|
||||
&& gui.inventorySlots instanceof ContainerExtended) {
|
||||
((SlotDummy) slot).slotClick(draggedStack, button, NEIClientUtils.shiftKey());
|
||||
NEICPH.sendDummySlotSet(slot.slotNumber, slot.getStack());
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.core.launch.CodeChickenCorePlugin;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
import codechicken.nei.asm.NEICorePlugin;
|
||||
import codechicken.nei.config.IMCHandler;
|
||||
import codechicken.nei.recipe.GuiRecipeTab;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import cpw.mods.fml.client.FMLFileResourcePack;
|
||||
import cpw.mods.fml.client.FMLFolderResourcePack;
|
||||
import cpw.mods.fml.common.DummyModContainer;
|
||||
@@ -21,11 +27,9 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.VersionParser;
|
||||
import cpw.mods.fml.common.versioning.VersionRange;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
public class NEIModContainer extends DummyModContainer {
|
||||
|
||||
public static LinkedList<IConfigureNEI> plugins = new LinkedList<>();
|
||||
|
||||
private static boolean gregTech5Loaded;
|
||||
@@ -37,13 +41,12 @@ public class NEIModContainer extends DummyModContainer {
|
||||
|
||||
private static ModMetadata getModMetadata() {
|
||||
final ModMetadata modMetadata = new ModMetadata();
|
||||
modMetadata.name = "GRADLETOKEN_MODNAME";
|
||||
modMetadata.modId = "GRADLETOKEN_MODID";
|
||||
modMetadata.version = "GRADLETOKEN_VERSION";
|
||||
modMetadata.name = "NotEnoughItems";
|
||||
modMetadata.modId = "NotEnoughItems";
|
||||
modMetadata.version = Tags.VERSION;
|
||||
modMetadata.authorList = Arrays.asList("ChickenBones", "mitchej123");
|
||||
modMetadata.url = "https://github.com/GTNewHorizons/NotEnoughItems";
|
||||
modMetadata.description =
|
||||
"Recipe Viewer, Inventory Manager, Item Spawner, Cheats and more; GTNH Version includes many enhancements.";
|
||||
modMetadata.description = "Recipe Viewer, Inventory Manager, Item Spawner, Cheats and more; GTNH Version includes many enhancements.";
|
||||
return modMetadata;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.api.INEIGuiAdapter;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.InventoryEffectRenderer;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.api.INEIGuiAdapter;
|
||||
|
||||
/**
|
||||
* Inspired by InventoryEffectRendererGuiHandler.java in JEI
|
||||
*/
|
||||
public class NEIPotionGuiHandler extends INEIGuiAdapter {
|
||||
|
||||
@Override
|
||||
public boolean hideItemPanelSlot(GuiContainer guiContainer, int slotX, int slotY, int slotW, int slotH) {
|
||||
if (NEIClientConfig.ignorePotionOverlap()) {
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.core.ServerUtils;
|
||||
import codechicken.lib.inventory.SlotDummy;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
import codechicken.lib.packet.PacketCustom.IServerPacketHandler;
|
||||
import codechicken.lib.vec.BlockCoord;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.InventoryBasic;
|
||||
@@ -19,7 +13,16 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.core.ServerUtils;
|
||||
import codechicken.lib.inventory.SlotDummy;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
import codechicken.lib.packet.PacketCustom.IServerPacketHandler;
|
||||
import codechicken.lib.vec.BlockCoord;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class NEISPH implements IServerPacketHandler {
|
||||
|
||||
@Override
|
||||
public void handlePacket(PacketCustom packet, EntityPlayerMP sender, INetHandlerPlayServer netHandler) {
|
||||
if (!NEIServerConfig.authenticatePacket(sender, packet)) return;
|
||||
@@ -120,7 +123,8 @@ public class NEISPH implements IServerPacketHandler {
|
||||
new ContainerCreativeInv(
|
||||
sender,
|
||||
new ExtendedCreativeInv(
|
||||
NEIServerConfig.forPlayer(sender.getCommandSenderName()), Side.SERVER)),
|
||||
NEIServerConfig.forPlayer(sender.getCommandSenderName()),
|
||||
Side.SERVER)),
|
||||
(player, windowId) -> {
|
||||
PacketCustom packet = new PacketCustom(channel, 23);
|
||||
packet.writeBoolean(true);
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.core.ServerUtils;
|
||||
import codechicken.lib.config.ConfigFile;
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.PrintWriter;
|
||||
@@ -16,6 +11,7 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -25,11 +21,20 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.core.ServerUtils;
|
||||
import codechicken.lib.config.ConfigFile;
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
|
||||
public class NEIServerConfig {
|
||||
|
||||
private static MinecraftServer server;
|
||||
|
||||
public static Logger logger = LogManager.getLogger("NotEnoughItems");
|
||||
@@ -73,8 +78,7 @@ public class NEIServerConfig {
|
||||
|
||||
serverConfig.setNewLineMode(1);
|
||||
serverConfig.getTag("permissions").useBraces();
|
||||
serverConfig
|
||||
.getTag("permissions")
|
||||
serverConfig.getTag("permissions")
|
||||
.setComment("List of players who can use these features.\nEg. time=CodeChicken, Friend1");
|
||||
|
||||
setDefaultFeature("time");
|
||||
@@ -93,7 +97,7 @@ public class NEIServerConfig {
|
||||
}
|
||||
|
||||
private static void setDefaultFeature(String featurename, String... names) {
|
||||
if (names.length == 0) names = new String[] {"OP"};
|
||||
if (names.length == 0) names = new String[] { "OP" };
|
||||
|
||||
StringBuilder list = new StringBuilder();
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
@@ -105,7 +109,11 @@ public class NEIServerConfig {
|
||||
|
||||
private static void saveWorld(int dim) {
|
||||
try {
|
||||
File file = new File(getSaveDir(DimensionManager.getWorld(dim)), "world.dat");
|
||||
final File saveDir = getSaveDir(DimensionManager.getWorld(dim));
|
||||
if (!saveDir.isDirectory()) {
|
||||
FileUtils.forceMkdir(saveDir);
|
||||
}
|
||||
File file = new File(saveDir, "world.dat");
|
||||
NEIServerUtils.writeNBT(dimTags.get(dim), file);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.core.ServerUtils;
|
||||
import codechicken.lib.inventory.InventoryRange;
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
import codechicken.nei.util.NBTHelper;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -19,6 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.zip.ZipException;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -41,9 +34,20 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.WorldSettings.GameType;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.core.ServerUtils;
|
||||
import codechicken.lib.inventory.InventoryRange;
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
import codechicken.nei.util.NBTHelper;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class NEIServerUtils {
|
||||
|
||||
public static boolean isRaining(World world) {
|
||||
return world.getWorldInfo().isRaining();
|
||||
}
|
||||
@@ -51,7 +55,7 @@ public class NEIServerUtils {
|
||||
public static void toggleRaining(World world, boolean notify) {
|
||||
boolean raining = !world.isRaining();
|
||||
if (!raining) // turn off
|
||||
((WorldServer) world).provider.resetRainAndThunder();
|
||||
((WorldServer) world).provider.resetRainAndThunder();
|
||||
else world.getWorldInfo().setRaining(!isRaining(world));
|
||||
|
||||
if (notify)
|
||||
@@ -114,17 +118,18 @@ public class NEIServerUtils {
|
||||
}
|
||||
|
||||
public static void sendNotice(ICommandSender sender, IChatComponent msg, String permission) {
|
||||
ChatComponentTranslation notice =
|
||||
new ChatComponentTranslation("chat.type.admin", sender.getCommandSenderName(), msg.createCopy());
|
||||
ChatComponentTranslation notice = new ChatComponentTranslation(
|
||||
"chat.type.admin",
|
||||
sender.getCommandSenderName(),
|
||||
msg.createCopy());
|
||||
notice.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(true);
|
||||
|
||||
if (NEIServerConfig.canPlayerPerformAction("CONSOLE", permission))
|
||||
MinecraftServer.getServer().addChatMessage(notice);
|
||||
|
||||
for (EntityPlayer p : ServerUtils.getPlayers())
|
||||
if (p == sender) p.addChatComponentMessage(msg);
|
||||
else if (NEIServerConfig.canPlayerPerformAction(p.getCommandSenderName(), permission))
|
||||
p.addChatComponentMessage(notice);
|
||||
for (EntityPlayer p : ServerUtils.getPlayers()) if (p == sender) p.addChatComponentMessage(msg);
|
||||
else if (NEIServerConfig.canPlayerPerformAction(p.getCommandSenderName(), permission))
|
||||
p.addChatComponentMessage(notice);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,8 +138,7 @@ public class NEIServerUtils {
|
||||
* @return whether the two items are the same in terms of damage and itemID.
|
||||
*/
|
||||
public static boolean areStacksSameType(ItemStack stack1, ItemStack stack2) {
|
||||
return stack1 != null
|
||||
&& stack2 != null
|
||||
return stack1 != null && stack2 != null
|
||||
&& (stack1.getItem() == stack2.getItem()
|
||||
&& (!stack2.getHasSubtypes() || stack2.getItemDamage() == stack1.getItemDamage())
|
||||
&& ItemStack.areItemStackTagsEqual(stack2, stack1));
|
||||
@@ -142,28 +146,28 @@ public class NEIServerUtils {
|
||||
|
||||
/**
|
||||
* NBT-friendly version of {@link #areStacksSameType(ItemStack, ItemStack)}
|
||||
*
|
||||
* @param stack1 The {@link ItemStack} being compared.
|
||||
* @param stack2 The {@link ItemStack} to compare to.
|
||||
* @return whether the two items are the same in terms of itemID, damage and NBT.
|
||||
*/
|
||||
public static boolean areStacksSameTypeWithNBT(ItemStack stack1, ItemStack stack2) {
|
||||
return stack1 != null
|
||||
&& stack2 != null
|
||||
return stack1 != null && stack2 != null
|
||||
&& stack1.getItem() == stack2.getItem()
|
||||
&& (!stack2.getHasSubtypes() || stack2.getItemDamage() == stack1.getItemDamage())
|
||||
&& NBTHelper.matchTag(stack1.getTagCompound(), stack2.getTagCompound());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link ItemStack}s with damage -1 are wildcards allowing all damages. Eg all colours of wool are allowed to create Beds.
|
||||
* {@link ItemStack}s with damage -1 are wildcards allowing all damages. Eg all colours of wool are allowed to
|
||||
* create Beds.
|
||||
*
|
||||
* @param stack1 The {@link ItemStack} being compared.
|
||||
* @param stack2 The {@link ItemStack} to compare to.
|
||||
* @return whether the two items are the same from the perspective of a crafting inventory.
|
||||
*/
|
||||
public static boolean areStacksSameTypeCrafting(ItemStack stack1, ItemStack stack2) {
|
||||
return stack1 != null
|
||||
&& stack2 != null
|
||||
return stack1 != null && stack2 != null
|
||||
&& stack1.getItem() == stack2.getItem()
|
||||
&& (stack1.getItemDamage() == stack2.getItemDamage()
|
||||
|| stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE
|
||||
@@ -173,13 +177,13 @@ public class NEIServerUtils {
|
||||
|
||||
/**
|
||||
* NBT-friendly version of {@link #areStacksSameTypeCrafting(ItemStack, ItemStack)}
|
||||
*
|
||||
* @param stack1 The {@link ItemStack} being compared.
|
||||
* @param stack2 The {@link ItemStack} to compare to.
|
||||
* @return whether the two items are the same from the perspective of a crafting inventory.
|
||||
*/
|
||||
public static boolean areStacksSameTypeCraftingWithNBT(ItemStack stack1, ItemStack stack2) {
|
||||
return stack1 != null
|
||||
&& stack2 != null
|
||||
return stack1 != null && stack2 != null
|
||||
&& stack1.getItem() == stack2.getItem()
|
||||
&& (stack1.getItemDamage() == stack2.getItemDamage()
|
||||
|| stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE
|
||||
@@ -276,18 +280,16 @@ public class NEIServerUtils {
|
||||
}
|
||||
|
||||
public static void setGamemode(EntityPlayerMP player, int mode) {
|
||||
if (mode < 0
|
||||
|| mode >= NEIActions.gameModes.length
|
||||
|| NEIActions.nameActionMap.containsKey(NEIActions.gameModes[mode])
|
||||
&& !NEIServerConfig.canPlayerPerformAction(
|
||||
player.getCommandSenderName(), NEIActions.gameModes[mode])) return;
|
||||
if (mode < 0 || mode >= NEIActions.gameModes.length
|
||||
|| NEIActions.nameActionMap.containsKey(NEIActions.gameModes[mode]) && !NEIServerConfig
|
||||
.canPlayerPerformAction(player.getCommandSenderName(), NEIActions.gameModes[mode]))
|
||||
return;
|
||||
|
||||
// creative+
|
||||
NEIServerConfig.forPlayer(player.getCommandSenderName()).enableAction("creative+", mode == 2);
|
||||
if (mode == 2
|
||||
&& !(player.openContainer
|
||||
instanceof ContainerCreativeInv)) // open the container immediately for the client
|
||||
NEISPH.processCreativeInv(player, true);
|
||||
if (mode == 2 && !(player.openContainer instanceof ContainerCreativeInv)) // open the container immediately for
|
||||
// the client
|
||||
NEISPH.processCreativeInv(player, true);
|
||||
|
||||
// change it on the server
|
||||
player.theItemInWorldManager.setGameType(getGameType(mode));
|
||||
@@ -331,11 +333,10 @@ public class NEIServerUtils {
|
||||
ArrayList<int[]> arraylist = new ArrayList<>();
|
||||
if (itemstack != null) {
|
||||
NBTTagList nbttaglist = itemstack.getEnchantmentTagList();
|
||||
if (nbttaglist != null)
|
||||
for (int i = 0; i < nbttaglist.tagCount(); i++) {
|
||||
NBTTagCompound tag = nbttaglist.getCompoundTagAt(i);
|
||||
arraylist.add(new int[] {tag.getShort("id"), tag.getShort("lvl")});
|
||||
}
|
||||
if (nbttaglist != null) for (int i = 0; i < nbttaglist.tagCount(); i++) {
|
||||
NBTTagCompound tag = nbttaglist.getCompoundTagAt(i);
|
||||
arraylist.add(new int[] { tag.getShort("id"), tag.getShort("lvl") });
|
||||
}
|
||||
}
|
||||
return arraylist;
|
||||
}
|
||||
@@ -368,7 +369,7 @@ public class NEIServerUtils {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ItemStack[] extractRecipeItems(Object obj) {
|
||||
if (obj instanceof ItemStack) return new ItemStack[] {(ItemStack) obj};
|
||||
if (obj instanceof ItemStack) return new ItemStack[] { (ItemStack) obj };
|
||||
if (obj instanceof ItemStack[]) return (ItemStack[]) obj;
|
||||
if (obj instanceof List) return ((List<ItemStack>) obj).toArray(new ItemStack[0]);
|
||||
|
||||
@@ -377,6 +378,7 @@ public class NEIServerUtils {
|
||||
|
||||
public static List<Integer> getRange(final int start, final int end) {
|
||||
return new AbstractList<Integer>() {
|
||||
|
||||
@Override
|
||||
public Integer get(int index) {
|
||||
return start + index;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.nei.api.IStackPositioner;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import codechicken.nei.api.IStackPositioner;
|
||||
|
||||
public class OffsetPositioner implements IStackPositioner {
|
||||
|
||||
public OffsetPositioner(int x, int y) {
|
||||
offsetx = x;
|
||||
offsety = y;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.ItemPanel.ItemPanelSlot;
|
||||
import codechicken.nei.api.GuiInfo;
|
||||
@@ -8,11 +14,9 @@ import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.GuiUsageRecipe;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class PanelWidget extends Widget {
|
||||
|
||||
protected static final int PADDING = 2;
|
||||
|
||||
public ItemStack draggedStack;
|
||||
@@ -36,6 +40,7 @@ public abstract class PanelWidget extends Widget {
|
||||
pageLabel = new Label("0/0", true);
|
||||
|
||||
pagePrev = new Button("Prev") {
|
||||
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (!rightclick) {
|
||||
grid.shiftPage(-1);
|
||||
@@ -50,6 +55,7 @@ public abstract class PanelWidget extends Widget {
|
||||
}
|
||||
};
|
||||
pageNext = new Button("Next") {
|
||||
|
||||
public boolean onButtonPress(boolean rightclick) {
|
||||
if (!rightclick) {
|
||||
grid.shiftPage(1);
|
||||
@@ -78,21 +84,24 @@ public abstract class PanelWidget extends Widget {
|
||||
public abstract int getHeight(GuiContainer gui);
|
||||
|
||||
public void resize(GuiContainer gui) {
|
||||
final Rectangle4i margin =
|
||||
new Rectangle4i(getMarginLeft(gui), getMarginTop(gui), getWidth(gui), getHeight(gui));
|
||||
final Rectangle4i margin = new Rectangle4i(
|
||||
getMarginLeft(gui),
|
||||
getMarginTop(gui),
|
||||
getWidth(gui),
|
||||
getHeight(gui));
|
||||
|
||||
final int minWidth = 5 * ItemsGrid.SLOT_SIZE;
|
||||
final int minHeight = 9 * ItemsGrid.SLOT_SIZE;
|
||||
|
||||
final String settingName = getPositioningSettingName();
|
||||
int paddingLeft = (int) Math.ceil(
|
||||
margin.w * NEIClientConfig.getSetting(settingName + ".left").getIntValue() / 100000.0);
|
||||
int paddingTop = (int) Math.ceil(
|
||||
margin.h * NEIClientConfig.getSetting(settingName + ".top").getIntValue() / 100000.0);
|
||||
int paddingRight = (int) Math.ceil(
|
||||
margin.w * NEIClientConfig.getSetting(settingName + ".right").getIntValue() / 100000.0);
|
||||
int paddingBottom = (int) Math.ceil(
|
||||
margin.h * NEIClientConfig.getSetting(settingName + ".bottom").getIntValue() / 100000.0);
|
||||
int paddingLeft = (int) Math
|
||||
.ceil(margin.w * NEIClientConfig.getSetting(settingName + ".left").getIntValue() / 100000.0);
|
||||
int paddingTop = (int) Math
|
||||
.ceil(margin.h * NEIClientConfig.getSetting(settingName + ".top").getIntValue() / 100000.0);
|
||||
int paddingRight = (int) Math
|
||||
.ceil(margin.w * NEIClientConfig.getSetting(settingName + ".right").getIntValue() / 100000.0);
|
||||
int paddingBottom = (int) Math
|
||||
.ceil(margin.h * NEIClientConfig.getSetting(settingName + ".bottom").getIntValue() / 100000.0);
|
||||
|
||||
int deltaHeight = Math.min(0, margin.h - paddingTop - paddingBottom - minHeight) / 2;
|
||||
|
||||
@@ -118,20 +127,19 @@ public abstract class PanelWidget extends Widget {
|
||||
int paddingLeft = 0;
|
||||
int paddingRight = 0;
|
||||
|
||||
while (paddingLeft < w
|
||||
&& GuiInfo.hideItemPanelSlot(
|
||||
gui, new Rectangle4i(x + paddingLeft, y, ItemsGrid.SLOT_SIZE, ItemsGrid.SLOT_SIZE))) {
|
||||
while (paddingLeft < w && GuiInfo.hideItemPanelSlot(
|
||||
gui,
|
||||
new Rectangle4i(x + paddingLeft, y, ItemsGrid.SLOT_SIZE, ItemsGrid.SLOT_SIZE))) {
|
||||
paddingLeft += ItemsGrid.SLOT_SIZE;
|
||||
}
|
||||
|
||||
while (paddingRight < w
|
||||
&& GuiInfo.hideItemPanelSlot(
|
||||
gui,
|
||||
new Rectangle4i(
|
||||
x + w - paddingRight - ItemsGrid.SLOT_SIZE,
|
||||
y,
|
||||
ItemsGrid.SLOT_SIZE,
|
||||
ItemsGrid.SLOT_SIZE))) {
|
||||
while (paddingRight < w && GuiInfo.hideItemPanelSlot(
|
||||
gui,
|
||||
new Rectangle4i(
|
||||
x + w - paddingRight - ItemsGrid.SLOT_SIZE,
|
||||
y,
|
||||
ItemsGrid.SLOT_SIZE,
|
||||
ItemsGrid.SLOT_SIZE))) {
|
||||
paddingRight += ItemsGrid.SLOT_SIZE;
|
||||
}
|
||||
|
||||
@@ -164,6 +172,11 @@ public abstract class PanelWidget extends Widget {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
grid.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mousex, int mousey) {
|
||||
grid.draw(mousex, mousey);
|
||||
@@ -178,10 +191,14 @@ public abstract class PanelWidget extends Widget {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postDrawTooltips(int mx, int my, List<String> tooltip) {
|
||||
grid.postDrawTooltips(mx, my, tooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(int mousex, int mousey, int button, long heldTime) {
|
||||
if (mouseDownSlot >= 0
|
||||
&& draggedStack == null
|
||||
if (mouseDownSlot >= 0 && draggedStack == null
|
||||
&& NEIClientUtils.getHeldItem() == null
|
||||
&& NEIClientConfig.hasSMPCounterPart()) {
|
||||
ItemPanelSlot mouseOverSlot = getSlotMouseOver(mousex, mousey);
|
||||
@@ -278,8 +295,7 @@ public abstract class PanelWidget extends Widget {
|
||||
}
|
||||
|
||||
final GuiContainer gui = NEIClientUtils.getGuiContainer();
|
||||
if (mouseX < gui.guiLeft
|
||||
|| mouseY < gui.guiTop
|
||||
if (mouseX < gui.guiLeft || mouseY < gui.guiTop
|
||||
|| mouseX >= gui.guiLeft + gui.xSize
|
||||
|| mouseY >= gui.guiTop + gui.ySize) {
|
||||
draggedStack = null;
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.core.ServerUtils;
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import codechicken.core.ServerUtils;
|
||||
import codechicken.lib.inventory.InventoryUtils;
|
||||
|
||||
public class PlayerSave {
|
||||
|
||||
public String username;
|
||||
|
||||
private File saveFile;
|
||||
|
||||
@@ -2,10 +2,12 @@ package codechicken.nei;
|
||||
|
||||
import static codechicken.nei.NEIClientConfig.canPerformAction;
|
||||
|
||||
import codechicken.nei.guihook.IContainerInputHandler;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
|
||||
import codechicken.nei.guihook.IContainerInputHandler;
|
||||
|
||||
public class PopupInputHandler implements IContainerInputHandler {
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) {
|
||||
return false;
|
||||
|
||||
@@ -2,16 +2,17 @@ package codechicken.nei;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
/**
|
||||
* Simply an {@link ItemStack} with position.
|
||||
* Mainly used in the recipe handlers.
|
||||
* Simply an {@link ItemStack} with position. Mainly used in the recipe handlers.
|
||||
*/
|
||||
public class PositionedStack {
|
||||
|
||||
public int relx;
|
||||
public int rely;
|
||||
public ItemStack[] items;
|
||||
@@ -43,7 +44,11 @@ public class PositionedStack {
|
||||
if (item.getItemDamage() == Short.MAX_VALUE) {
|
||||
List<ItemStack> permutations = ItemList.itemMap.get(item.getItem());
|
||||
if (!permutations.isEmpty()) {
|
||||
for (ItemStack stack : permutations) stacks.add(stack.copy());
|
||||
for (ItemStack stack : permutations) {
|
||||
ItemStack toAdd = stack.copy();
|
||||
toAdd.stackSize = item.stackSize;
|
||||
stacks.add(toAdd);
|
||||
}
|
||||
} else {
|
||||
ItemStack base = new ItemStack(item.getItem(), item.stackSize);
|
||||
base.stackTagCompound = item.stackTagCompound;
|
||||
@@ -56,7 +61,7 @@ public class PositionedStack {
|
||||
}
|
||||
items = stacks.toArray(new ItemStack[0]);
|
||||
|
||||
if (items.length == 0) items = new ItemStack[] {new ItemStack(Blocks.fire)};
|
||||
if (items.length == 0) items = new ItemStack[] { new ItemStack(Blocks.fire) };
|
||||
|
||||
permutated = true;
|
||||
setPermutationToRender(0);
|
||||
@@ -73,9 +78,9 @@ public class PositionedStack {
|
||||
public void setPermutationToRender(int index) {
|
||||
item = items[index].copy();
|
||||
if (item.getItem() == null) item = new ItemStack(Blocks.fire);
|
||||
else if (item.getItemDamage() == OreDictionary.WILDCARD_VALUE
|
||||
&& item.getItem() != null
|
||||
&& item.getItem().isRepairable()) item.setItemDamage(0);
|
||||
else if (item.getItemDamage() == OreDictionary.WILDCARD_VALUE && item.getItem() != null
|
||||
&& item.getItem().isRepairable())
|
||||
item.setItemDamage(0);
|
||||
}
|
||||
|
||||
public boolean contains(ItemStack ingredient) {
|
||||
|
||||
@@ -2,20 +2,6 @@ package codechicken.nei;
|
||||
|
||||
import static codechicken.nei.NEIClientUtils.translate;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.core.gui.GuiScrollSlot;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.ItemPanel.ItemPanelSlot;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.util.NBTJson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -27,15 +13,34 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.core.gui.GuiScrollSlot;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.ItemPanel.ItemPanelSlot;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.util.NBTJson;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class PresetsWidget extends Widget {
|
||||
|
||||
public static class PresetTag implements ItemFilter {
|
||||
|
||||
public String filename = null;
|
||||
public String displayName = "";
|
||||
public boolean whitelist = true;
|
||||
@@ -77,8 +82,7 @@ public class PresetsWidget extends Widget {
|
||||
}
|
||||
|
||||
final JsonParser parser = new JsonParser();
|
||||
final JsonObject metaObject =
|
||||
parser.parse(itemStrings.remove(0)).getAsJsonObject();
|
||||
final JsonObject metaObject = parser.parse(itemStrings.remove(0)).getAsJsonObject();
|
||||
final String displayName = metaObject.get("displayName").getAsString();
|
||||
final boolean whitelist = metaObject.get("whitelist").getAsBoolean();
|
||||
final HashSet<String> items = new HashSet<>();
|
||||
@@ -149,6 +153,7 @@ public class PresetsWidget extends Widget {
|
||||
}
|
||||
|
||||
protected static class SubsetListBox extends GuiScrollSlot {
|
||||
|
||||
protected final List<PresetTag> presets = new ArrayList<>();
|
||||
protected final List<PresetTag> selected = new ArrayList<>();
|
||||
protected int lastSelectedIndex = 0;
|
||||
@@ -159,12 +164,12 @@ public class PresetsWidget extends Widget {
|
||||
|
||||
try {
|
||||
|
||||
presets.addAll(ItemList.forkJoinPool
|
||||
.submit(() -> Arrays.asList(presetsDir.listFiles()).parallelStream()
|
||||
.map(f -> PresetTag.loadFromFile(f))
|
||||
.filter(p -> p != null)
|
||||
.collect(Collectors.toCollection(ArrayList::new)))
|
||||
.get());
|
||||
presets.addAll(
|
||||
ItemList.forkJoinPool.submit(
|
||||
() -> Arrays.asList(presetsDir.listFiles()).parallelStream()
|
||||
.map(f -> PresetTag.loadFromFile(f)).filter(p -> p != null)
|
||||
.collect(Collectors.toCollection(ArrayList::new)))
|
||||
.get());
|
||||
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
@@ -312,10 +317,10 @@ public class PresetsWidget extends Widget {
|
||||
final int directionState = direction.contains(x + mx, y + my) ? 1 : 2;
|
||||
final int deleteState = delete.contains(x + mx, y + my) ? 1 : 2;
|
||||
|
||||
final String displayName =
|
||||
NEIClientUtils.cropText(PresetsWidget.fontRenderer, tag.displayName, option.w - 6);
|
||||
final String dirName =
|
||||
tag.whitelist ? translate("presets.whitelist.label") : translate("presets.blacklist.label");
|
||||
final String displayName = NEIClientUtils
|
||||
.cropText(PresetsWidget.fontRenderer, tag.displayName, option.w - 6);
|
||||
final String dirName = tag.whitelist ? translate("presets.whitelist.label")
|
||||
: translate("presets.blacklist.label");
|
||||
|
||||
// blacklist or whitelist
|
||||
LayoutManager.getLayoutStyle()
|
||||
@@ -408,6 +413,7 @@ public class PresetsWidget extends Widget {
|
||||
}
|
||||
|
||||
protected static class MouseSelection {
|
||||
|
||||
public int startX = -1;
|
||||
public int startY = -1;
|
||||
public int startIndex = -1;
|
||||
@@ -520,8 +526,7 @@ public class PresetsWidget extends Widget {
|
||||
|
||||
@Override
|
||||
public String getRenderLabel() {
|
||||
return edit != null && edit.whitelist
|
||||
? translate("presets.whitelist.label")
|
||||
return edit != null && edit.whitelist ? translate("presets.whitelist.label")
|
||||
: translate("presets.blacklist.label");
|
||||
}
|
||||
|
||||
@@ -529,8 +534,7 @@ public class PresetsWidget extends Widget {
|
||||
public void addTooltips(List<String> tooltip) {
|
||||
if (edit != null) {
|
||||
tooltip.add(
|
||||
edit.whitelist
|
||||
? translate("presets.whitelist.tooltip")
|
||||
edit.whitelist ? translate("presets.whitelist.tooltip")
|
||||
: translate("presets.blacklist.tooltip"));
|
||||
}
|
||||
}
|
||||
@@ -627,8 +631,7 @@ public class PresetsWidget extends Widget {
|
||||
protected static String getModId(final ItemStack stack) {
|
||||
try {
|
||||
return GameRegistry.findUniqueIdentifierFor(stack.getItem()).modId;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -674,8 +677,7 @@ public class PresetsWidget extends Widget {
|
||||
final List<PresetTag> selected = listbox.getSelected();
|
||||
final int size = selected.size();
|
||||
|
||||
selectedValue.text = size > 1
|
||||
? translate("presets.label.selected", size)
|
||||
selectedValue.text = size > 1 ? translate("presets.label.selected", size)
|
||||
: (size == 1 ? selected.get(0).displayName : "");
|
||||
selectedValue.y = y;
|
||||
selectedValue.h = h;
|
||||
@@ -782,8 +784,7 @@ public class PresetsWidget extends Widget {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (selectedDisplayName.focused()
|
||||
&& (keyID == Keyboard.KEY_RETURN || keyID == Keyboard.KEY_NUMPADENTER)
|
||||
if (selectedDisplayName.focused() && (keyID == Keyboard.KEY_RETURN || keyID == Keyboard.KEY_NUMPADENTER)
|
||||
&& !selectedDisplayName.text().isEmpty()) {
|
||||
selectedDisplayName.handleKeyPress(keyID, keyChar);
|
||||
selectedDisplayName.setFocus(false);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package codechicken.nei;
|
||||
|
||||
public abstract class RestartableTask {
|
||||
|
||||
public final String name;
|
||||
private Thread thread;
|
||||
private volatile boolean restart;
|
||||
@@ -14,14 +15,13 @@ public abstract class RestartableTask {
|
||||
|
||||
private void start() {
|
||||
thread = new Thread(name) {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
do {
|
||||
while (stopped)
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
while (stopped) try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException ignored) {}
|
||||
if (!restart) execute();
|
||||
} while (!finish());
|
||||
}
|
||||
@@ -52,7 +52,8 @@ public abstract class RestartableTask {
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops execution until restart is called. If a thread is running, the restart flag will be set, and the thread will be paused once the execute method exits.
|
||||
* Stops execution until restart is called. If a thread is running, the restart flag will be set, and the thread
|
||||
* will be paused once the execute method exits.
|
||||
*/
|
||||
public synchronized void stop() {
|
||||
if (thread != null) {
|
||||
|
||||
@@ -2,6 +2,13 @@ package codechicken.nei;
|
||||
|
||||
import static codechicken.nei.NEIClientConfig.world;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.ItemList.AnyMultiItemFilter;
|
||||
import codechicken.nei.ItemList.EverythingItemFilter;
|
||||
@@ -10,17 +17,14 @@ import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
|
||||
import codechicken.nei.util.TextHistory;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
public class SearchField extends TextField implements ItemFilterProvider {
|
||||
|
||||
/**
|
||||
* Interface for returning a custom filter based on search field text
|
||||
*/
|
||||
public static interface ISearchProvider {
|
||||
|
||||
/**
|
||||
* @return false if this filter should only be used if no other non-default filters match the search string
|
||||
*/
|
||||
@@ -33,6 +37,7 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
}
|
||||
|
||||
private static class DefaultSearchProvider implements ISearchProvider {
|
||||
|
||||
@Override
|
||||
public boolean isPrimary() {
|
||||
return false;
|
||||
@@ -145,8 +150,7 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
Pattern pattern = null;
|
||||
try {
|
||||
pattern = Pattern.compile(search);
|
||||
} catch (PatternSyntaxException ignored) {
|
||||
}
|
||||
} catch (PatternSyntaxException ignored) {}
|
||||
return pattern == null || pattern.toString().length() == 0 ? null : pattern;
|
||||
}
|
||||
|
||||
@@ -178,12 +182,10 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
|
||||
private boolean handleNavigateHistory(TextHistory.Direction direction) {
|
||||
if (focused()) {
|
||||
return history.get(direction, text())
|
||||
.map(newText -> {
|
||||
setText(newText);
|
||||
return true;
|
||||
})
|
||||
.orElse(false);
|
||||
return history.get(direction, text()).map(newText -> {
|
||||
setText(newText);
|
||||
return true;
|
||||
}).orElse(false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import codechicken.lib.packet.PacketCustom;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
@@ -10,14 +18,9 @@ import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
public class ServerHandler {
|
||||
|
||||
private static ServerHandler instance;
|
||||
|
||||
public static void load() {
|
||||
@@ -32,11 +35,10 @@ public class ServerHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void tickEvent(TickEvent.WorldTickEvent event) {
|
||||
if (event.phase == Phase.START
|
||||
&& !event.world.isRemote
|
||||
&& NEIServerConfig.dimTags.containsKey(
|
||||
CommonUtils.getDimension(event.world))) // fake worlds that don't call Load
|
||||
processDisabledProperties(event.world);
|
||||
if (event.phase == Phase.START && !event.world.isRemote
|
||||
&& NEIServerConfig.dimTags.containsKey(CommonUtils.getDimension(event.world))) // fake worlds that don't
|
||||
// call Load
|
||||
processDisabledProperties(event.world);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -72,8 +74,8 @@ public class ServerHandler {
|
||||
double maxspeedy = 0.5;
|
||||
double speedxz = 0.05;
|
||||
double speedy = 0.07;
|
||||
List<EntityItem> items = player.worldObj.getEntitiesWithinAABB(
|
||||
EntityItem.class, player.boundingBox.expand(distancexz, distancey, distancexz));
|
||||
List<EntityItem> items = player.worldObj
|
||||
.getEntitiesWithinAABB(EntityItem.class, player.boundingBox.expand(distancexz, distancey, distancexz));
|
||||
for (EntityItem item : items) {
|
||||
if (item.delayBeforeCanPickup > 0) continue;
|
||||
if (!NEIServerUtils.canItemFitInInventory(player, item.getEntityItem())) continue;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package codechicken.nei;
|
||||
|
||||
public abstract class SlotOP {
|
||||
|
||||
public abstract String getDescription();
|
||||
|
||||
public abstract int[] getKeyBind();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.core.ClientUtils;
|
||||
import codechicken.lib.render.CCRenderState;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
@@ -13,10 +11,15 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import codechicken.core.ClientUtils;
|
||||
import codechicken.lib.render.CCRenderState;
|
||||
|
||||
public class SpawnerRenderer implements IItemRenderer {
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
|
||||
@@ -2,18 +2,6 @@ package codechicken.nei;
|
||||
|
||||
import static codechicken.nei.NEIClientUtils.translate;
|
||||
|
||||
import codechicken.core.gui.GuiScrollSlot;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.ItemList.AnyMultiItemFilter;
|
||||
import codechicken.nei.ItemList.ItemsLoadedCallback;
|
||||
import codechicken.nei.ItemList.NothingItemFilter;
|
||||
import codechicken.nei.SearchField.ISearchProvider;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -27,24 +15,42 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import codechicken.core.gui.GuiScrollSlot;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.ItemList.AnyMultiItemFilter;
|
||||
import codechicken.nei.ItemList.ItemsLoadedCallback;
|
||||
import codechicken.nei.ItemList.NothingItemFilter;
|
||||
import codechicken.nei.SearchField.ISearchProvider;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
|
||||
public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoadedCallback, ISearchProvider {
|
||||
|
||||
public static ReentrantReadWriteLock hiddenItemLock = new ReentrantReadWriteLock();
|
||||
public static Lock writeLock = hiddenItemLock.writeLock();
|
||||
public static Lock readLock = hiddenItemLock.readLock();
|
||||
|
||||
public static class SubsetState {
|
||||
|
||||
int state = 2;
|
||||
ArrayList<ItemStack> items = new ArrayList<>();
|
||||
}
|
||||
|
||||
public static class SubsetTag {
|
||||
|
||||
protected class SubsetSlot extends GuiScrollSlot {
|
||||
|
||||
public SubsetSlot() {
|
||||
super(0, 0, 0, 0);
|
||||
setSmoothScroll(false);
|
||||
@@ -190,10 +196,9 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
} else {
|
||||
String childname = name.substring(0, idx);
|
||||
SubsetTag child = children.get(childname.toLowerCase());
|
||||
if (child == null)
|
||||
children.put(
|
||||
childname.toLowerCase(),
|
||||
child = new SubsetTag(fullname == null ? childname : fullname + '.' + childname));
|
||||
if (child == null) children.put(
|
||||
childname.toLowerCase(),
|
||||
child = new SubsetTag(fullname == null ? childname : fullname + '.' + childname));
|
||||
recacheChildren();
|
||||
child.addTag(tag);
|
||||
}
|
||||
@@ -533,6 +538,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
}
|
||||
|
||||
private static final RestartableTask prepareDirtyHiddenItems = new RestartableTask("NEI Subset Save Thread") {
|
||||
|
||||
private List<ItemStack> getList() {
|
||||
try {
|
||||
if (readLock.tryLock(5, TimeUnit.SECONDS)) {
|
||||
@@ -566,6 +572,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
private static final UpdateStateTask updateState = new UpdateStateTask();
|
||||
|
||||
private static class UpdateStateTask extends RestartableTask {
|
||||
|
||||
private volatile boolean reallocate;
|
||||
|
||||
public UpdateStateTask() {
|
||||
@@ -599,9 +606,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
for (ItemStack item : ItemList.items) {
|
||||
if (interrupted()) return;
|
||||
if (ItemInfo.isHidden(item)) continue;
|
||||
for (SubsetTag tag : tags)
|
||||
if (tag.filter.matches(item))
|
||||
state.get(tag.fullname).items.add(item);
|
||||
for (SubsetTag tag : tags) if (tag.filter.matches(item)) state.get(tag.fullname).items.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@ package codechicken.nei;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public abstract class TextField extends Widget {
|
||||
|
||||
protected GuiTextField field;
|
||||
|
||||
private static final int maxSearchLength = 256;
|
||||
@@ -23,7 +25,7 @@ public abstract class TextField extends Widget {
|
||||
public TextField(String ident) {
|
||||
identifier = ident;
|
||||
initInternalTextField();
|
||||
// Keyboard.enableRepeatEvents(true);
|
||||
// Keyboard.enableRepeatEvents(true);
|
||||
}
|
||||
|
||||
public int getTextColour() {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
public class ThreadOperationTimer extends Thread {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class TimeoutException extends RuntimeException {
|
||||
|
||||
public final Object operation;
|
||||
|
||||
public TimeoutException(String msg, Object op) {
|
||||
@@ -48,10 +51,13 @@ public class ThreadOperationTimer extends Thread {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void run() {
|
||||
if (FMLCommonHandler.instance()
|
||||
.findContainerFor("NotEnoughItems")
|
||||
.getVersion()
|
||||
.contains("$")) return; // don't run this thread in a source environment
|
||||
if (FMLCommonHandler.instance().findContainerFor("NotEnoughItems").getVersion().contains("$")) return; // don't
|
||||
// run
|
||||
// this
|
||||
// thread
|
||||
// in a
|
||||
// source
|
||||
// environment
|
||||
|
||||
while (thread.isAlive()) {
|
||||
synchronized (this) {
|
||||
@@ -63,8 +69,7 @@ public class ThreadOperationTimer extends Thread {
|
||||
}
|
||||
try {
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException ie) {
|
||||
}
|
||||
} catch (InterruptedException ie) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package codechicken.nei;
|
||||
|
||||
public class VisiblityData {
|
||||
|
||||
public boolean showUtilityButtons = true;
|
||||
/**
|
||||
* Item panel and associated buttons
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
|
||||
public abstract class Widget {
|
||||
|
||||
public Widget() {}
|
||||
|
||||
public abstract void draw(int mx, int my);
|
||||
|
||||
public void postDraw(int mx, int my) {}
|
||||
|
||||
public void postDrawTooltips(int mx, int my, List<String> tooltip) {}
|
||||
|
||||
public boolean handleClick(int mx, int my, int button) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package codechicken.nei;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class WidgetZOrder implements Comparator<Widget> {
|
||||
|
||||
final boolean topfirst;
|
||||
|
||||
public WidgetZOrder(boolean topfirst) {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.lib.math.MathHelper;
|
||||
import codechicken.lib.render.RenderUtils;
|
||||
import codechicken.nei.KeyManager.IKeyStateTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.entity.passive.EntityPig;
|
||||
@@ -13,8 +11,12 @@ import net.minecraft.world.SpawnerAnimals;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.math.MathHelper;
|
||||
import codechicken.nei.KeyManager.IKeyStateTracker;
|
||||
|
||||
public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
|
||||
public static int chunkOverlay = 0;
|
||||
@@ -22,10 +24,13 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
public static int mobOverlay = 0;
|
||||
private static byte[] mobSpawnCache;
|
||||
private static long mobOverlayUpdateTime;
|
||||
private static String oregenPatternName;
|
||||
private static boolean hasOregenPatternBeenSet = false;
|
||||
|
||||
public static void reset() {
|
||||
mobOverlay = 0;
|
||||
chunkOverlay = 0;
|
||||
hasOregenPatternBeenSet = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,10 +45,19 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
public static void render(float frame) {
|
||||
GL11.glPushMatrix();
|
||||
Entity entity = Minecraft.getMinecraft().renderViewEntity;
|
||||
RenderUtils.translateToWorldCoords(entity, frame);
|
||||
|
||||
renderChunkBounds(entity);
|
||||
renderMobSpawnOverlay(entity);
|
||||
double interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * frame;
|
||||
double interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * frame;
|
||||
double interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * frame;
|
||||
|
||||
int intOffsetX = (int) interpPosX;
|
||||
int intOffsetY = (int) interpPosY;
|
||||
int intOffsetZ = (int) interpPosZ;
|
||||
|
||||
GL11.glTranslated(-interpPosX + intOffsetX, -interpPosY + intOffsetY, -interpPosZ + intOffsetZ);
|
||||
|
||||
renderChunkBounds(entity, intOffsetX, intOffsetY, intOffsetZ);
|
||||
renderMobSpawnOverlay(entity, intOffsetX, intOffsetY, intOffsetZ);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -84,7 +98,7 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
}
|
||||
}
|
||||
|
||||
private static void renderMobSpawnOverlay(Entity entity) {
|
||||
private static void renderMobSpawnOverlay(Entity entity, int intOffsetX, int intOffsetY, int intOffsetZ) {
|
||||
if (mobOverlay == 0) {
|
||||
if (mobSpawnCache != null) {
|
||||
mobSpawnCache = null;
|
||||
@@ -103,15 +117,17 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glLineWidth(1.5F);
|
||||
GL11.glBegin(GL11.GL_LINES);
|
||||
|
||||
GL11.glColor4f(1, 0, 0, 1);
|
||||
int curSpawnMode = 2;
|
||||
|
||||
World world = entity.worldObj;
|
||||
int x1 = (int) entity.posX;
|
||||
int z1 = (int) entity.posZ;
|
||||
int y1 = (int) MathHelper.clip(entity.posY, 16, world.getHeight() - 16);
|
||||
int x1 = (int) entity.posX - intOffsetX;
|
||||
int z1 = (int) entity.posZ - intOffsetZ;
|
||||
int y1 = (int) MathHelper.clip(entity.posY, 16, world.getHeight() - 16) - intOffsetY;
|
||||
|
||||
final Tessellator tess = Tessellator.instance;
|
||||
tess.startDrawing(GL11.GL_LINES);
|
||||
tess.setColorOpaque(255, 0, 0);
|
||||
|
||||
for (int i = 0; i <= 32; i++) {
|
||||
int x = x1 - 16 + i;
|
||||
@@ -130,22 +146,22 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
|
||||
if (spawnMode != curSpawnMode) {
|
||||
if (spawnMode == 1) {
|
||||
GL11.glColor4f(1, 1, 0, 1);
|
||||
tess.setColorOpaque(255, 255, 0);
|
||||
} else {
|
||||
GL11.glColor4f(1, 0, 0, 1);
|
||||
tess.setColorOpaque(255, 0, 0);
|
||||
}
|
||||
curSpawnMode = spawnMode;
|
||||
}
|
||||
|
||||
GL11.glVertex3d(x, y + 0.02, z);
|
||||
GL11.glVertex3d(x + 1, y + 0.02, z + 1);
|
||||
GL11.glVertex3d(x + 1, y + 0.02, z);
|
||||
GL11.glVertex3d(x, y + 0.02, z + 1);
|
||||
tess.addVertex(x, y + 0.02, z);
|
||||
tess.addVertex(x + 1, y + 0.02, z + 1);
|
||||
tess.addVertex(x + 1, y + 0.02, z);
|
||||
tess.addVertex(x, y + 0.02, z + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glEnd();
|
||||
tess.draw();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
@@ -155,8 +171,8 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
private static final AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0);
|
||||
|
||||
private static byte getSpawnMode(Chunk chunk, int x, int y, int z) {
|
||||
if (!SpawnerAnimals.canCreatureTypeSpawnAtLocation(EnumCreatureType.monster, chunk.worldObj, x, y, z)
|
||||
|| chunk.getSavedLightValue(EnumSkyBlock.Block, x & 15, y, z & 15) >= 8) {
|
||||
if (chunk.getSavedLightValue(EnumSkyBlock.Block, x & 15, y, z & 15) >= 8
|
||||
|| !SpawnerAnimals.canCreatureTypeSpawnAtLocation(EnumCreatureType.monster, chunk.worldObj, x, y, z)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -174,7 +190,7 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
return (byte) (chunk.getSavedLightValue(EnumSkyBlock.Sky, x & 15, y, z & 15) >= 8 ? 1 : 2);
|
||||
}
|
||||
|
||||
private static void renderChunkBounds(Entity entity) {
|
||||
private static void renderChunkBounds(Entity entity, int intOffsetX, int intOffsetY, int intOffsetZ) {
|
||||
if (chunkOverlay == 0) return;
|
||||
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
@@ -184,136 +200,161 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
GL11.glLineWidth(1.5F);
|
||||
GL11.glBegin(GL11.GL_LINES);
|
||||
|
||||
for (int cx = -4; cx <= 4; cx++)
|
||||
for (int cz = -4; cz <= 4; cz++) {
|
||||
double x1 = (entity.chunkCoordX + cx) << 4;
|
||||
double z1 = (entity.chunkCoordZ + cz) << 4;
|
||||
double x2 = x1 + 16;
|
||||
double z2 = z1 + 16;
|
||||
for (int cx = -4; cx <= 4; cx++) for (int cz = -4; cz <= 4; cz++) {
|
||||
double x1 = ((entity.chunkCoordX + cx) << 4) - intOffsetX;
|
||||
double z1 = ((entity.chunkCoordZ + cz) << 4) - intOffsetZ;
|
||||
double x2 = x1 + 16;
|
||||
double z2 = z1 + 16;
|
||||
|
||||
double dy = 128;
|
||||
double y1 = Math.floor(entity.posY - dy / 2);
|
||||
double y2 = y1 + dy;
|
||||
if (y1 < 0) {
|
||||
y1 = 0;
|
||||
y2 = dy;
|
||||
}
|
||||
double dy = 128;
|
||||
double y1 = Math.floor(entity.posY - dy / 2);
|
||||
double y2 = y1 + dy;
|
||||
if (y1 < 0) {
|
||||
y1 = 0;
|
||||
y2 = dy;
|
||||
}
|
||||
|
||||
if (y1 > entity.worldObj.getHeight()) {
|
||||
y2 = entity.worldObj.getHeight();
|
||||
y1 = y2 - dy;
|
||||
}
|
||||
if (y1 > entity.worldObj.getHeight()) {
|
||||
y2 = entity.worldObj.getHeight();
|
||||
y1 = y2 - dy;
|
||||
}
|
||||
|
||||
double dist = Math.pow(1.5, -(cx * cx + cz * cz));
|
||||
y1 -= intOffsetY;
|
||||
y2 -= intOffsetY;
|
||||
|
||||
GL11.glColor4d(0.9, 0, 0, dist);
|
||||
if (cx >= 0 && cz >= 0) {
|
||||
GL11.glVertex3d(x2, y1, z2);
|
||||
GL11.glVertex3d(x2, y2, z2);
|
||||
}
|
||||
if (cx >= 0 && cz <= 0) {
|
||||
GL11.glVertex3d(x2, y1, z1);
|
||||
GL11.glVertex3d(x2, y2, z1);
|
||||
}
|
||||
if (cx <= 0 && cz >= 0) {
|
||||
GL11.glVertex3d(x1, y1, z2);
|
||||
GL11.glVertex3d(x1, y2, z2);
|
||||
}
|
||||
if (cx <= 0 && cz <= 0) {
|
||||
GL11.glVertex3d(x1, y1, z1);
|
||||
GL11.glVertex3d(x1, y2, z1);
|
||||
}
|
||||
double dist = Math.pow(1.5, -(cx * cx + cz * cz));
|
||||
|
||||
if (cx == 0 && cz == 0) {
|
||||
if (chunkOverlay == 2) {
|
||||
dy = 32;
|
||||
y1 = Math.floor(entity.posY - dy / 2);
|
||||
y2 = y1 + dy;
|
||||
if (y1 < 0) {
|
||||
y1 = 0;
|
||||
y2 = dy;
|
||||
GL11.glColor4d(0.9, 0, 0, dist);
|
||||
if (cx >= 0 && cz >= 0) {
|
||||
GL11.glVertex3d(x2, y1, z2);
|
||||
GL11.glVertex3d(x2, y2, z2);
|
||||
}
|
||||
if (cx >= 0 && cz <= 0) {
|
||||
GL11.glVertex3d(x2, y1, z1);
|
||||
GL11.glVertex3d(x2, y2, z1);
|
||||
}
|
||||
if (cx <= 0 && cz >= 0) {
|
||||
GL11.glVertex3d(x1, y1, z2);
|
||||
GL11.glVertex3d(x1, y2, z2);
|
||||
}
|
||||
if (cx <= 0 && cz <= 0) {
|
||||
GL11.glVertex3d(x1, y1, z1);
|
||||
GL11.glVertex3d(x1, y2, z1);
|
||||
}
|
||||
|
||||
if (cx == 0 && cz == 0) {
|
||||
if (chunkOverlay == 2) {
|
||||
dy = 32;
|
||||
y1 = Math.floor(entity.posY - dy / 2);
|
||||
y2 = y1 + dy;
|
||||
if (y1 < 0) {
|
||||
y1 = 0;
|
||||
y2 = dy;
|
||||
}
|
||||
|
||||
if (y1 > entity.worldObj.getHeight()) {
|
||||
y2 = entity.worldObj.getHeight();
|
||||
y1 = y2 - dy;
|
||||
}
|
||||
|
||||
y1 -= intOffsetY;
|
||||
y2 -= intOffsetY;
|
||||
|
||||
GL11.glColor4d(0, 0.9, 0, 0.4);
|
||||
for (double y = (int) y1; y <= y2; y++) {
|
||||
GL11.glVertex3d(x2, y, z1);
|
||||
GL11.glVertex3d(x2, y, z2);
|
||||
GL11.glVertex3d(x1, y, z1);
|
||||
GL11.glVertex3d(x1, y, z2);
|
||||
GL11.glVertex3d(x1, y, z2);
|
||||
GL11.glVertex3d(x2, y, z2);
|
||||
GL11.glVertex3d(x1, y, z1);
|
||||
GL11.glVertex3d(x2, y, z1);
|
||||
}
|
||||
for (double h = 1; h <= 15; h++) {
|
||||
GL11.glVertex3d(x1 + h, y1, z1);
|
||||
GL11.glVertex3d(x1 + h, y2, z1);
|
||||
GL11.glVertex3d(x1 + h, y1, z2);
|
||||
GL11.glVertex3d(x1 + h, y2, z2);
|
||||
GL11.glVertex3d(x1, y1, z1 + h);
|
||||
GL11.glVertex3d(x1, y2, z1 + h);
|
||||
GL11.glVertex3d(x2, y1, z1 + h);
|
||||
GL11.glVertex3d(x2, y2, z1 + h);
|
||||
}
|
||||
} else if (chunkOverlay == 3) {
|
||||
if (!hasOregenPatternBeenSet) {
|
||||
try {
|
||||
oregenPatternName = ((Enum<?>) Class.forName("gregtech.common.GT_Worldgenerator")
|
||||
.getDeclaredField("oregenPattern").get(null)).name();
|
||||
} catch (Exception ignored) {
|
||||
oregenPatternName = "AXISSYMMETRICAL";
|
||||
}
|
||||
|
||||
if (y1 > entity.worldObj.getHeight()) {
|
||||
y2 = entity.worldObj.getHeight();
|
||||
y1 = y2 - dy;
|
||||
}
|
||||
|
||||
GL11.glColor4d(0, 0.9, 0, 0.4);
|
||||
for (double y = (int) y1; y <= y2; y++) {
|
||||
GL11.glVertex3d(x2, y, z1);
|
||||
GL11.glVertex3d(x2, y, z2);
|
||||
GL11.glVertex3d(x1, y, z1);
|
||||
GL11.glVertex3d(x1, y, z2);
|
||||
GL11.glVertex3d(x1, y, z2);
|
||||
GL11.glVertex3d(x2, y, z2);
|
||||
GL11.glVertex3d(x1, y, z1);
|
||||
GL11.glVertex3d(x2, y, z1);
|
||||
}
|
||||
for (double h = 1; h <= 15; h++) {
|
||||
GL11.glVertex3d(x1 + h, y1, z1);
|
||||
GL11.glVertex3d(x1 + h, y2, z1);
|
||||
GL11.glVertex3d(x1 + h, y1, z2);
|
||||
GL11.glVertex3d(x1 + h, y2, z2);
|
||||
GL11.glVertex3d(x1, y1, z1 + h);
|
||||
GL11.glVertex3d(x1, y2, z1 + h);
|
||||
GL11.glVertex3d(x2, y1, z1 + h);
|
||||
GL11.glVertex3d(x2, y2, z1 + h);
|
||||
}
|
||||
} else if (chunkOverlay == 3) {
|
||||
int gx1 = ((entity.chunkCoordX < 0 ? entity.chunkCoordX - 3 : entity.chunkCoordX) / 3 * 3) << 4;
|
||||
int gz1 = ((entity.chunkCoordZ < 0 ? entity.chunkCoordZ - 3 : entity.chunkCoordZ) / 3 * 3) << 4;
|
||||
hasOregenPatternBeenSet = true;
|
||||
}
|
||||
int gx1;
|
||||
int gz1;
|
||||
if (oregenPatternName.equals("EQUAL_SPACING")) {
|
||||
// gt oregen uses new regular pattern
|
||||
gx1 = ((Math.floorDiv(entity.chunkCoordX, 3) * 3) << 4) - intOffsetX;
|
||||
gz1 = ((Math.floorDiv(entity.chunkCoordZ, 3) * 3) << 4) - intOffsetZ;
|
||||
} else {
|
||||
// gt oregen uses old bugged pattern
|
||||
gx1 = (((entity.chunkCoordX < 0 ? entity.chunkCoordX - 3 : entity.chunkCoordX) / 3 * 3) << 4)
|
||||
- intOffsetX;
|
||||
gz1 = (((entity.chunkCoordZ < 0 ? entity.chunkCoordZ - 3 : entity.chunkCoordZ) / 3 * 3) << 4)
|
||||
- intOffsetZ;
|
||||
if (entity.chunkCoordX < 0) {
|
||||
gx1 += 16;
|
||||
}
|
||||
if (entity.chunkCoordZ < 0) {
|
||||
gz1 += 16;
|
||||
}
|
||||
int gx2 = gx1 + 48;
|
||||
int gz2 = gz1 + 48;
|
||||
|
||||
GL11.glColor4d(0, 0.9, 0, 0.4);
|
||||
for (double y = (int) y1; y <= y2; y++) {
|
||||
GL11.glVertex3d(gx2, y, gz1);
|
||||
GL11.glVertex3d(gx2, y, gz2);
|
||||
GL11.glVertex3d(gx1, y, gz1);
|
||||
GL11.glVertex3d(gx1, y, gz2);
|
||||
GL11.glVertex3d(gx1, y, gz2);
|
||||
GL11.glVertex3d(gx2, y, gz2);
|
||||
GL11.glVertex3d(gx1, y, gz1);
|
||||
GL11.glVertex3d(gx2, y, gz1);
|
||||
}
|
||||
for (double h = 4; h <= 44; h += 4) {
|
||||
if (h % 16 == 0) {
|
||||
continue;
|
||||
}
|
||||
GL11.glVertex3d(gx1 + h, y1, gz1);
|
||||
GL11.glVertex3d(gx1 + h, y2, gz1);
|
||||
GL11.glVertex3d(gx1 + h, y1, gz2);
|
||||
GL11.glVertex3d(gx1 + h, y2, gz2);
|
||||
GL11.glVertex3d(gx1, y1, gz1 + h);
|
||||
GL11.glVertex3d(gx1, y2, gz1 + h);
|
||||
GL11.glVertex3d(gx2, y1, gz1 + h);
|
||||
GL11.glVertex3d(gx2, y2, gz1 + h);
|
||||
}
|
||||
|
||||
GL11.glColor4d(0, 0, 0.9, 0.4);
|
||||
gx1 += 23;
|
||||
gz1 += 23;
|
||||
gx2 = gx1 + 1;
|
||||
gz2 = gz1 + 1;
|
||||
|
||||
GL11.glVertex3d(gx1, y1, gz1);
|
||||
GL11.glVertex3d(gx1, y2, gz1);
|
||||
GL11.glVertex3d(gx2, y1, gz1);
|
||||
GL11.glVertex3d(gx2, y2, gz1);
|
||||
GL11.glVertex3d(gx1, y1, gz2);
|
||||
GL11.glVertex3d(gx1, y2, gz2);
|
||||
GL11.glVertex3d(gx2, y1, gz2);
|
||||
GL11.glVertex3d(gx2, y2, gz2);
|
||||
}
|
||||
int gx2 = gx1 + 48;
|
||||
int gz2 = gz1 + 48;
|
||||
|
||||
GL11.glColor4d(0, 0.9, 0, 0.4);
|
||||
for (double y = (int) y1; y <= y2; y++) {
|
||||
GL11.glVertex3d(gx2, y, gz1);
|
||||
GL11.glVertex3d(gx2, y, gz2);
|
||||
GL11.glVertex3d(gx1, y, gz1);
|
||||
GL11.glVertex3d(gx1, y, gz2);
|
||||
GL11.glVertex3d(gx1, y, gz2);
|
||||
GL11.glVertex3d(gx2, y, gz2);
|
||||
GL11.glVertex3d(gx1, y, gz1);
|
||||
GL11.glVertex3d(gx2, y, gz1);
|
||||
}
|
||||
for (double h = 4; h <= 44; h += 4) {
|
||||
if (h % 16 == 0) {
|
||||
continue;
|
||||
}
|
||||
GL11.glVertex3d(gx1 + h, y1, gz1);
|
||||
GL11.glVertex3d(gx1 + h, y2, gz1);
|
||||
GL11.glVertex3d(gx1 + h, y1, gz2);
|
||||
GL11.glVertex3d(gx1 + h, y2, gz2);
|
||||
GL11.glVertex3d(gx1, y1, gz1 + h);
|
||||
GL11.glVertex3d(gx1, y2, gz1 + h);
|
||||
GL11.glVertex3d(gx2, y1, gz1 + h);
|
||||
GL11.glVertex3d(gx2, y2, gz1 + h);
|
||||
}
|
||||
|
||||
GL11.glColor4d(0, 0, 0.9, 0.4);
|
||||
gx1 += 23;
|
||||
gz1 += 23;
|
||||
gx2 = gx1 + 1;
|
||||
gz2 = gz1 + 1;
|
||||
|
||||
GL11.glVertex3d(gx1, y1, gz1);
|
||||
GL11.glVertex3d(gx1, y2, gz1);
|
||||
GL11.glVertex3d(gx2, y1, gz1);
|
||||
GL11.glVertex3d(gx2, y2, gz1);
|
||||
GL11.glVertex3d(gx1, y1, gz2);
|
||||
GL11.glVertex3d(gx1, y2, gz2);
|
||||
GL11.glVertex3d(gx2, y1, gz2);
|
||||
GL11.glVertex3d(gx2, y2, gz2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glEnd();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.ItemSorter;
|
||||
import codechicken.nei.ItemStackSet;
|
||||
@@ -24,23 +38,13 @@ import codechicken.nei.recipe.IUsageHandler;
|
||||
import codechicken.nei.recipe.RecipeCatalysts;
|
||||
import codechicken.nei.recipe.RecipeInfo;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
/**
|
||||
* This is the main class that handles item property configuration.
|
||||
* WARNING: DO NOT access this class until the world has been loaded
|
||||
* These methods should be called from INEIConfig implementors
|
||||
* This is the main class that handles item property configuration. WARNING: DO NOT access this class until the world
|
||||
* has been loaded These methods should be called from INEIConfig implementors
|
||||
*/
|
||||
public class API {
|
||||
|
||||
/**
|
||||
* Register a new Crafting Recipe handler;
|
||||
*
|
||||
@@ -63,8 +67,7 @@ public class API {
|
||||
* Add a gui to the default overlay renderer with the default position
|
||||
*
|
||||
* @param classz The class of your gui
|
||||
* @param ident The identification string, currently
|
||||
* {crafting, crafting2x2, smelting, fuel, brewing}
|
||||
* @param ident The identification string, currently {crafting, crafting2x2, smelting, fuel, brewing}
|
||||
*/
|
||||
public static void registerGuiOverlay(Class<? extends GuiContainer> classz, String ident) {
|
||||
registerGuiOverlay(classz, ident, 5, 11);
|
||||
@@ -74,8 +77,7 @@ public class API {
|
||||
* Add a gui to the default overlay renderer with an offset
|
||||
*
|
||||
* @param classz The class of your gui
|
||||
* @param ident The identification string, currently
|
||||
* {crafting, crafting2x2, smelting, fuel, brewing}
|
||||
* @param ident The identification string, currently {crafting, crafting2x2, smelting, fuel, brewing}
|
||||
* @param x x-offset
|
||||
* @param y y-offset
|
||||
*/
|
||||
@@ -87,12 +89,11 @@ public class API {
|
||||
* Add a gui to the default overlay renderer
|
||||
*
|
||||
* @param classz The class of your gui
|
||||
* @param ident The identification string, currently
|
||||
* {crafting, crafting2x2, smelting, fuel, brewing}
|
||||
* @param ident The identification string, currently {crafting, crafting2x2, smelting, fuel, brewing}
|
||||
* @param positioner A Stack Repositioner for moving the items to the right place
|
||||
*/
|
||||
public static void registerGuiOverlay(
|
||||
Class<? extends GuiContainer> classz, String ident, IStackPositioner positioner) {
|
||||
public static void registerGuiOverlay(Class<? extends GuiContainer> classz, String ident,
|
||||
IStackPositioner positioner) {
|
||||
RecipeInfo.registerGuiOverlay(classz, ident, positioner);
|
||||
}
|
||||
|
||||
@@ -101,13 +102,22 @@ public class API {
|
||||
* @param handler The handler to register
|
||||
* @param ident The recipe identification string
|
||||
*/
|
||||
public static void registerGuiOverlayHandler(
|
||||
Class<? extends GuiContainer> classz, IOverlayHandler handler, String ident) {
|
||||
public static void registerGuiOverlayHandler(Class<? extends GuiContainer> classz, IOverlayHandler handler,
|
||||
String ident) {
|
||||
RecipeInfo.registerOverlayHandler(classz, handler, ident);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the offset to be added to items to translate them into recipe coords on the actual gui, default is 5, 11. Primarily RecipeTransferRects
|
||||
* @param classz The class of your gui
|
||||
* @param ident The recipe identification string
|
||||
*/
|
||||
public static boolean hasGuiOverlayHandler(Class<? extends GuiContainer> classz, String ident) {
|
||||
return RecipeInfo.hasOverlayHandler(classz, ident);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the offset to be added to items to translate them into recipe coords on the actual gui, default is 5, 11.
|
||||
* Primarily RecipeTransferRects
|
||||
*
|
||||
* @param classz The class of your gui
|
||||
* @param x
|
||||
@@ -127,8 +137,8 @@ public class API {
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide an item from the item panel
|
||||
* Damage values of OreDictionary.WILDCARD_VALUE and ItemStackMap.WILDCARD_TAG tags function as wildcards for their respective variables
|
||||
* Hide an item from the item panel Damage values of OreDictionary.WILDCARD_VALUE and ItemStackMap.WILDCARD_TAG tags
|
||||
* function as wildcards for their respective variables
|
||||
*/
|
||||
public static void hideItem(ItemStack item) {
|
||||
if (!ItemInfo.hiddenItems.contains(item)) {
|
||||
@@ -149,6 +159,7 @@ public class API {
|
||||
|
||||
/**
|
||||
* Adds an item to the item panel. Any items added using this function will override the default search pattern.
|
||||
*
|
||||
* @param item an item with data
|
||||
*/
|
||||
public static void addItemListEntry(ItemStack item) {
|
||||
@@ -171,6 +182,7 @@ public class API {
|
||||
|
||||
/**
|
||||
* Add a custom KeyBinding to be configured in the Controls menu.
|
||||
*
|
||||
* @param ident An identifier for your key, eg "shoot"
|
||||
* @param defaultKey The default value, commonly obtained from {@link Keyboard}
|
||||
*/
|
||||
@@ -182,6 +194,7 @@ public class API {
|
||||
|
||||
/**
|
||||
* Add a custom KeyBinding to be configured in the Controls menu.
|
||||
*
|
||||
* @param ident An identifier for your key, eg "shoot"
|
||||
* @param defaultKey The default value, commonly obtained from {@link Keyboard}
|
||||
*/
|
||||
@@ -196,6 +209,7 @@ public class API {
|
||||
|
||||
/**
|
||||
* Add a new Layout Style for the NEI interface
|
||||
*
|
||||
* @param styleID The Unique ID to be used for storing your style in the config and cycling through avaliable styles
|
||||
* @param style The style to add.
|
||||
*/
|
||||
@@ -205,6 +219,7 @@ public class API {
|
||||
|
||||
/**
|
||||
* Registers a new Infinite Item Handler.
|
||||
*
|
||||
* @param handler The handler to be registered.
|
||||
*/
|
||||
public static void addInfiniteItemHandler(IInfiniteItemHandler handler) {
|
||||
@@ -213,6 +228,7 @@ public class API {
|
||||
|
||||
/**
|
||||
* Registers a new Infinite Item Handler.
|
||||
*
|
||||
* @param block The block to handle, null for all.
|
||||
* @param handler The handler to be registered.
|
||||
*/
|
||||
@@ -222,6 +238,7 @@ public class API {
|
||||
|
||||
/**
|
||||
* Tells NEI not to perform any Fast Transfer operations on slots of a particular class
|
||||
*
|
||||
* @param slotClass The class of slot to be exempted
|
||||
*/
|
||||
public static void addFastTransferExemptSlot(Class<? extends Slot> slotClass) {
|
||||
@@ -230,8 +247,10 @@ public class API {
|
||||
|
||||
/**
|
||||
* Register a new text handler for the block highlight tooltip with a layout specification (HEADER, BODY or FOOTER).
|
||||
*
|
||||
* @param handler The handler to be registered.
|
||||
* @param layout A HUDAugmenterRegistry.Layout entry. HEADER is displayed before BODY which is displayed before FOOTER.
|
||||
* @param layout A HUDAugmenterRegistry.Layout entry. HEADER is displayed before BODY which is displayed before
|
||||
* FOOTER.
|
||||
*/
|
||||
public static void registerHighlightHandler(IHighlightHandler handler, ItemInfo.Layout... layout) {
|
||||
ItemInfo.registerHighlightHandler(handler, layout);
|
||||
@@ -239,6 +258,7 @@ public class API {
|
||||
|
||||
/**
|
||||
* Register a mode handler for overriding NEI recipe/utility/cheat mode settings.
|
||||
*
|
||||
* @param handler The handler to be registered.
|
||||
*/
|
||||
public static void registerModeHandler(INEIModeHandler handler) {
|
||||
@@ -247,6 +267,7 @@ public class API {
|
||||
|
||||
/**
|
||||
* Register a filter provider for the item panel.
|
||||
*
|
||||
* @param filterProvider The filter provider to be registered.
|
||||
*/
|
||||
public static void addItemFilter(ItemFilterProvider filterProvider) {
|
||||
@@ -257,7 +278,8 @@ public class API {
|
||||
|
||||
/**
|
||||
* Adds a new tag to the item subset dropdown.
|
||||
* @param name The fully qualified name, Eg Blocks.MobSpawners. NOT case sensitive
|
||||
*
|
||||
* @param name The fully qualified name, Eg Blocks.MobSpawners. NOT case sensitive
|
||||
* @param filter A filter for matching items that fit in this subset
|
||||
*/
|
||||
public static void addSubset(String name, ItemFilter filter) {
|
||||
@@ -266,7 +288,8 @@ public class API {
|
||||
|
||||
/**
|
||||
* Adds a new tag to the item subset dropdown.
|
||||
* @param name The fully qualified name, Eg Blocks.MobSpawners. NOT case sensitive
|
||||
*
|
||||
* @param name The fully qualified name, Eg Blocks.MobSpawners. NOT case sensitive
|
||||
* @param items An iterable of itemstacks to be added as a subset
|
||||
*/
|
||||
public static void addSubset(String name, Iterable<ItemStack> items) {
|
||||
@@ -291,15 +314,19 @@ public class API {
|
||||
|
||||
/**
|
||||
* Adds a new sorting option to the item panel sort menu
|
||||
* @param name A unique id for this sort option. Will be used in the config for saving and translated in the options gui. Note that if the translation key name.tip exists, it will be used for a tooltip
|
||||
*
|
||||
* @param name A unique id for this sort option. Will be used in the config for saving and translated in the options
|
||||
* gui. Note that if the translation key name.tip exists, it will be used for a tooltip
|
||||
*/
|
||||
public static void addSortOption(String name, Comparator<ItemStack> comparator) {
|
||||
ItemSorter.add(name, comparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an additional item list entry for an item, sorted after the rest of the items are found through the normal process
|
||||
* @param item The item to add the variant for
|
||||
* Adds an additional item list entry for an item, sorted after the rest of the items are found through the normal
|
||||
* process
|
||||
*
|
||||
* @param item The item to add the variant for
|
||||
* @param variant The stack to appear in the item panel
|
||||
*/
|
||||
public static void addItemVariant(Item item, ItemStack variant) {
|
||||
@@ -314,10 +341,12 @@ public class API {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an association between an ingredient and what it can craft. (i.e. Furnace ItemStack -> Smelting and Fuel Recipes)
|
||||
* Allows players to see what ingredient they need to craft in order to make recipes from a recipe category.
|
||||
* @param stack the ingredient that can craft recipes (like a furnace or crafting table)
|
||||
* @param handler the recipe category handled by the ingredient
|
||||
* Adds an association between an ingredient and what it can craft. (i.e. Furnace ItemStack -> Smelting and Fuel
|
||||
* Recipes) Allows players to see what ingredient they need to craft in order to make recipes from a recipe
|
||||
* category.
|
||||
*
|
||||
* @param stack the ingredient that can craft recipes (like a furnace or crafting table)
|
||||
* @param handler the recipe category handled by the ingredient
|
||||
* @param priority higher priority comes first, default to 0
|
||||
*/
|
||||
public static void addRecipeCatalyst(ItemStack stack, IRecipeHandler handler, int priority) {
|
||||
@@ -333,11 +362,13 @@ public class API {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an association between an ingredient and what it can craft. (i.e. Furnace ItemStack -> Smelting and Fuel Recipes)
|
||||
* Allows players to see what ingredient they need to craft in order to make recipes from a recipe category.
|
||||
* @param stack the ingredient that can craft recipes (like a furnace or crafting table)
|
||||
* Adds an association between an ingredient and what it can craft. (i.e. Furnace ItemStack -> Smelting and Fuel
|
||||
* Recipes) Allows players to see what ingredient they need to craft in order to make recipes from a recipe
|
||||
* category.
|
||||
*
|
||||
* @param stack the ingredient that can craft recipes (like a furnace or crafting table)
|
||||
* @param handlerID recipe category identifier (see also {@link RecipeCatalysts#getRecipeID(IRecipeHandler)})
|
||||
* @param priority higher priority comes first, default to 0
|
||||
* @param priority higher priority comes first, default to 0
|
||||
*/
|
||||
public static void addRecipeCatalyst(ItemStack stack, String handlerID, int priority) {
|
||||
RecipeCatalysts.addRecipeCatalyst(handlerID, new CatalystInfo(stack, priority));
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class DefaultOverlayRenderer implements IRecipeOverlayRenderer {
|
||||
|
||||
public DefaultOverlayRenderer(List<PositionedStack> ai, IStackPositioner positioner) {
|
||||
positioner = this.positioner = positioner;
|
||||
ingreds = new ArrayList<>();
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainerCreative;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.NEIChestGuiHandler;
|
||||
import codechicken.nei.NEICreativeGuiHandler;
|
||||
@@ -9,15 +18,9 @@ import codechicken.nei.recipe.CheatItemHandler;
|
||||
import codechicken.nei.recipe.FillFluidContainerHandler;
|
||||
import codechicken.nei.recipe.GuiRecipeCatalyst;
|
||||
import codechicken.nei.recipe.SearchInputDropHandler;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainerCreative;
|
||||
|
||||
public class GuiInfo {
|
||||
|
||||
public static final LinkedList<INEIGuiHandler> guiHandlers = new LinkedList<>();
|
||||
public static final HashSet<Class<? extends GuiContainer>> customSlotGuis = new HashSet<>();
|
||||
public static ReentrantReadWriteLock guiHandlersLock = new ReentrantReadWriteLock();
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
/**
|
||||
* An nei configuration entry point should implement this class and have name "NEI<someting>Config"
|
||||
* loadConfig will only be called when NEI is installed.
|
||||
* An nei configuration entry point should implement this class and have name "NEI<someting>Config" loadConfig will only
|
||||
* be called when NEI is installed.
|
||||
*/
|
||||
public interface IConfigureNEI {
|
||||
|
||||
public void loadConfig();
|
||||
|
||||
public String getName();
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
|
||||
public interface IGuiContainerOverlay {
|
||||
|
||||
GuiContainer getFirstScreen();
|
||||
|
||||
default GuiScreen getFirstScreenGeneral() {
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IHighlightHandler {
|
||||
|
||||
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop);
|
||||
|
||||
public List<String> handleTextData(
|
||||
ItemStack itemStack,
|
||||
World world,
|
||||
EntityPlayer player,
|
||||
MovingObjectPosition mop,
|
||||
List<String> currenttip,
|
||||
ItemInfo.Layout layout);
|
||||
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop,
|
||||
List<String> currenttip, ItemInfo.Layout layout);
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IInfiniteItemHandler {
|
||||
|
||||
void onPickup(ItemStack heldItem);
|
||||
|
||||
void onPlaceInfinite(ItemStack heldItem);
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import codechicken.nei.VisiblityData;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import codechicken.nei.VisiblityData;
|
||||
|
||||
/**
|
||||
* Lets you just override those things you want to
|
||||
*/
|
||||
@@ -41,8 +43,7 @@ public class INEIGuiAdapter implements INEIGuiHandler {
|
||||
}
|
||||
|
||||
protected String formattingText(String displayName) {
|
||||
return SPECIAL_REGEX_CHARS
|
||||
.matcher(EnumChatFormatting.getTextWithoutFormattingCodes(displayName))
|
||||
return SPECIAL_REGEX_CHARS.matcher(EnumChatFormatting.getTextWithoutFormattingCodes(displayName))
|
||||
.replaceAll("\\\\$0");
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,22 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import codechicken.nei.VisiblityData;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.nei.VisiblityData;
|
||||
|
||||
/**
|
||||
* If this is implemented on a gui, it will be automatically registered
|
||||
*/
|
||||
public interface INEIGuiHandler {
|
||||
|
||||
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility);
|
||||
|
||||
/**
|
||||
* NEI will give the specified item to the InventoryRange returned if the player's inventory is full.
|
||||
* Should not return null, just an empty list
|
||||
* NEI will give the specified item to the InventoryRange returned if the player's inventory is full. Should not
|
||||
* return null, just an empty list
|
||||
*/
|
||||
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item);
|
||||
|
||||
@@ -23,20 +26,24 @@ public interface INEIGuiHandler {
|
||||
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui);
|
||||
|
||||
/**
|
||||
* Handles clicks while an itemstack has been dragged from the item panel. Use this to set configurable slots and the like.
|
||||
* Changes made to the stackSize of the dragged stack will be kept
|
||||
* @param gui The current gui instance
|
||||
* @param mousex The x position of the mouse
|
||||
* @param mousey The y position of the mouse
|
||||
* Handles clicks while an itemstack has been dragged from the item panel. Use this to set configurable slots and
|
||||
* the like. Changes made to the stackSize of the dragged stack will be kept
|
||||
*
|
||||
* @param gui The current gui instance
|
||||
* @param mousex The x position of the mouse
|
||||
* @param mousey The y position of the mouse
|
||||
* @param draggedStack The stack being dragged from the item panel
|
||||
* @param button The button presed
|
||||
* @return True if the drag n drop was handled. False to resume processing through other routes. The held stack will be deleted if draggedStack.stackSize == 0
|
||||
* @param button The button presed
|
||||
* @return True if the drag n drop was handled. False to resume processing through other routes. The held stack will
|
||||
* be deleted if draggedStack.stackSize == 0
|
||||
*/
|
||||
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button);
|
||||
|
||||
/**
|
||||
* Used to prevent the item panel from drawing on top of other gui elements.
|
||||
* This function will also be called with a 1x1 size rectangle on the mouse position for determining if the given coordinate should override item panel functions such as scrolling
|
||||
* Used to prevent the item panel from drawing on top of other gui elements. This function will also be called with
|
||||
* a 1x1 size rectangle on the mouse position for determining if the given coordinate should override item panel
|
||||
* functions such as scrolling
|
||||
*
|
||||
* @param x The x coordinate of the rectangle bounding the slot
|
||||
* @param y The y coordinate of the rectangle bounding the slot
|
||||
* @param w The w coordinate of the rectangle bounding the slot
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
public interface INEIModeHandler {
|
||||
|
||||
public boolean isModeValid(int mode);
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
|
||||
public interface IOverlayHandler {
|
||||
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift);
|
||||
|
||||
void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift);
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
|
||||
public interface IRecipeOverlayRenderer {
|
||||
|
||||
public void renderOverlay(GuiContainerManager gui, Slot slot);
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
|
||||
/**
|
||||
* For repositioning recipes in overlay renderers.
|
||||
*
|
||||
*/
|
||||
public interface IStackPositioner {
|
||||
|
||||
public ArrayList<PositionedStack> positionStacks(ArrayList<PositionedStack> ai);
|
||||
}
|
||||
@@ -3,10 +3,13 @@ package codechicken.nei.api;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ItemFilter {
|
||||
|
||||
/**
|
||||
* Provides an item filter. May be called from any thread. Returned filter should only reference objects with immutable state.
|
||||
* Provides an item filter. May be called from any thread. Returned filter should only reference objects with
|
||||
* immutable state.
|
||||
*/
|
||||
public static interface ItemFilterProvider {
|
||||
|
||||
public ItemFilter getFilter();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,5 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import codechicken.core.featurehack.GameDataManipulator;
|
||||
import codechicken.nei.InfiniteStackSizeHandler;
|
||||
import codechicken.nei.InfiniteToolHandler;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.ItemMobSpawner;
|
||||
import codechicken.nei.ItemStackMap;
|
||||
import codechicken.nei.ItemStackSet;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.PopupInputHandler;
|
||||
import codechicken.nei.config.ArrayDumper;
|
||||
import codechicken.nei.config.HandlerDumper;
|
||||
import codechicken.nei.config.ItemPanelDumper;
|
||||
import codechicken.nei.config.RegistryDumper;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.BrewingRecipeHandler;
|
||||
import codechicken.nei.recipe.RecipeItemInputHandler;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -28,6 +7,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -59,10 +39,34 @@ import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.common.IShearable;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
|
||||
import codechicken.core.featurehack.GameDataManipulator;
|
||||
import codechicken.nei.InfiniteStackSizeHandler;
|
||||
import codechicken.nei.InfiniteToolHandler;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.ItemMobSpawner;
|
||||
import codechicken.nei.ItemStackMap;
|
||||
import codechicken.nei.ItemStackSet;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.PopupInputHandler;
|
||||
import codechicken.nei.config.ArrayDumper;
|
||||
import codechicken.nei.config.HandlerDumper;
|
||||
import codechicken.nei.config.ItemPanelDumper;
|
||||
import codechicken.nei.config.RegistryDumper;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.BrewingRecipeHandler;
|
||||
import codechicken.nei.recipe.RecipeItemInputHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
|
||||
|
||||
/**
|
||||
* This is an internal class for storing information about items, to be accessed by the API
|
||||
*/
|
||||
public class ItemInfo {
|
||||
|
||||
public static enum Layout {
|
||||
HEADER,
|
||||
BODY,
|
||||
@@ -83,6 +87,7 @@ public class ItemInfo {
|
||||
public static final HashMap<Item, String> itemOwners = new HashMap<>();
|
||||
|
||||
private static class ItemStackKey {
|
||||
|
||||
public final ItemStack stack;
|
||||
|
||||
public ItemStackKey(ItemStack stack) {
|
||||
@@ -96,8 +101,7 @@ public class ItemInfo {
|
||||
hashCode = 31 * hashCode + stack.stackSize;
|
||||
hashCode = 31 * hashCode + Item.getIdFromItem(stack.getItem());
|
||||
hashCode = 31 * hashCode + stack.getItemDamage();
|
||||
hashCode = 31 * hashCode
|
||||
+ (!stack.hasTagCompound() ? 0 : stack.getTagCompound().hashCode());
|
||||
hashCode = 31 * hashCode + (!stack.hasTagCompound() ? 0 : stack.getTagCompound().hashCode());
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@@ -129,8 +133,7 @@ public class ItemInfo {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use field directly
|
||||
* @deprecated Use field directly
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<ItemStack> getItemOverrides(Item item) {
|
||||
@@ -176,22 +179,18 @@ public class ItemInfo {
|
||||
|
||||
private static void addIDDumps() {
|
||||
API.addOption(new RegistryDumper<Item>("tools.dump.item") {
|
||||
|
||||
@Override
|
||||
public String[] header() {
|
||||
return new String[] {"Name", "ID", "Has Block", "Mod", "Class", "Display Name"};
|
||||
return new String[] { "Name", "ID", "Has Block", "Mod", "Class", "Display Name" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] dump(Item item, int id, String name) {
|
||||
return new String[] {
|
||||
name,
|
||||
Integer.toString(id),
|
||||
Boolean.toString(Block.getBlockFromItem(item) != Blocks.air),
|
||||
ItemInfo.itemOwners.get(item),
|
||||
item.getClass().getCanonicalName(),
|
||||
EnumChatFormatting.getTextWithoutFormattingCodes(
|
||||
GuiContainerManager.itemDisplayNameShort(new ItemStack(item)))
|
||||
};
|
||||
return new String[] { name, Integer.toString(id),
|
||||
Boolean.toString(Block.getBlockFromItem(item) != Blocks.air), ItemInfo.itemOwners.get(item),
|
||||
item.getClass().getCanonicalName(), EnumChatFormatting.getTextWithoutFormattingCodes(
|
||||
GuiContainerManager.itemDisplayNameShort(new ItemStack(item))) };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,25 +199,19 @@ public class ItemInfo {
|
||||
}
|
||||
});
|
||||
API.addOption(new RegistryDumper<Block>("tools.dump.block") {
|
||||
|
||||
@Override
|
||||
public String[] header() {
|
||||
return new String[] {"Name", "ID", "Has Item", "Mod", "Class", "Display Name"};
|
||||
return new String[] { "Name", "ID", "Has Item", "Mod", "Class", "Display Name" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] dump(Block block, int id, String name) {
|
||||
final Item item = Item.getItemFromBlock(block);
|
||||
return new String[] {
|
||||
name,
|
||||
Integer.toString(id),
|
||||
Boolean.toString(item != null),
|
||||
ItemInfo.itemOwners.get(block),
|
||||
block.getClass().getCanonicalName(),
|
||||
item != null
|
||||
? EnumChatFormatting.getTextWithoutFormattingCodes(
|
||||
GuiContainerManager.itemDisplayNameShort(new ItemStack(item)))
|
||||
: "null"
|
||||
};
|
||||
return new String[] { name, Integer.toString(id), Boolean.toString(item != null),
|
||||
ItemInfo.itemOwners.get(block), block.getClass().getCanonicalName(),
|
||||
item != null ? EnumChatFormatting.getTextWithoutFormattingCodes(
|
||||
GuiContainerManager.itemDisplayNameShort(new ItemStack(item))) : "null" };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -227,15 +220,14 @@ public class ItemInfo {
|
||||
}
|
||||
});
|
||||
API.addOption(new ArrayDumper<Potion>("tools.dump.potion") {
|
||||
|
||||
public String[] header() {
|
||||
return new String[] {"ID", "Unlocalised name", "Class"};
|
||||
return new String[] { "ID", "Unlocalised name", "Class" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] dump(Potion potion, int id) {
|
||||
return new String[] {
|
||||
Integer.toString(id), potion.getName(), potion.getClass().getCanonicalName()
|
||||
};
|
||||
return new String[] { Integer.toString(id), potion.getName(), potion.getClass().getCanonicalName() };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -244,20 +236,16 @@ public class ItemInfo {
|
||||
}
|
||||
});
|
||||
API.addOption(new ArrayDumper<Enchantment>("tools.dump.enchantment") {
|
||||
|
||||
public String[] header() {
|
||||
return new String[] {"ID", "Unlocalised name", "Type", "Min Level", "Max Level", "Class"};
|
||||
return new String[] { "ID", "Unlocalised name", "Type", "Min Level", "Max Level", "Class" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] dump(Enchantment ench, int id) {
|
||||
return new String[] {
|
||||
Integer.toString(id),
|
||||
ench.getName(),
|
||||
ench.type.toString(),
|
||||
Integer.toString(ench.getMinLevel()),
|
||||
Integer.toString(ench.getMaxLevel()),
|
||||
ench.getClass().getCanonicalName()
|
||||
};
|
||||
return new String[] { Integer.toString(id), ench.getName(), ench.type.toString(),
|
||||
Integer.toString(ench.getMinLevel()), Integer.toString(ench.getMaxLevel()),
|
||||
ench.getClass().getCanonicalName() };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -266,19 +254,11 @@ public class ItemInfo {
|
||||
}
|
||||
});
|
||||
API.addOption(new ArrayDumper<BiomeGenBase>("tools.dump.biome") {
|
||||
|
||||
@Override
|
||||
public String[] header() {
|
||||
return new String[] {
|
||||
"ID",
|
||||
"Name",
|
||||
"Temperature",
|
||||
"Rainfall",
|
||||
"Spawn Chance",
|
||||
"Root Height",
|
||||
"Height Variation",
|
||||
"Types",
|
||||
"Class"
|
||||
};
|
||||
return new String[] { "ID", "Name", "Temperature", "Rainfall", "Spawn Chance", "Root Height",
|
||||
"Height Variation", "Types", "Class" };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -290,17 +270,11 @@ public class ItemInfo {
|
||||
s_types.append(t.name());
|
||||
}
|
||||
|
||||
return new String[] {
|
||||
Integer.toString(id),
|
||||
biome.biomeName,
|
||||
Float.toString(biome.getFloatTemperature(0, 0, 0)),
|
||||
Float.toString(biome.getFloatRainfall()),
|
||||
Float.toString(biome.getSpawningChance()),
|
||||
Float.toString(biome.rootHeight),
|
||||
Float.toString(biome.heightVariation),
|
||||
s_types.toString(),
|
||||
biome.getClass().getCanonicalName()
|
||||
};
|
||||
return new String[] { Integer.toString(id), biome.biomeName,
|
||||
Float.toString(biome.getFloatTemperature(0, 0, 0)), Float.toString(biome.getFloatRainfall()),
|
||||
Float.toString(biome.getSpawningChance()), Float.toString(biome.rootHeight),
|
||||
Float.toString(biome.heightVariation), s_types.toString(),
|
||||
biome.getClass().getCanonicalName() };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -319,8 +293,7 @@ public class ItemInfo {
|
||||
UniqueIdentifier ident = null;
|
||||
try {
|
||||
ident = GameRegistry.findUniqueIdentifierFor(item);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
if (ident == null) {
|
||||
NEIClientConfig.logger.error("Failed to find identifier for: " + item);
|
||||
@@ -410,8 +383,8 @@ public class ItemInfo {
|
||||
item.getSubItems(item, itemTab, stackList);
|
||||
for (ItemStack stack : stackList) set.add(stack);
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error(
|
||||
"Error loading sub-items for: " + item + ". Tab: " + itemTab.getTabLabel(), e);
|
||||
NEIClientConfig.logger
|
||||
.error("Error loading sub-items for: " + item + ". Tab: " + itemTab.getTabLabel(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -423,21 +396,20 @@ public class ItemInfo {
|
||||
else if (item instanceof ItemAxe) axes.with(item);
|
||||
else if (item instanceof ItemHoe) hoes.with(item);
|
||||
else if (item instanceof ItemSword) swords.with(item);
|
||||
else if (item instanceof ItemArmor)
|
||||
switch (((ItemArmor) item).armorType) {
|
||||
case 0:
|
||||
helmets.with(item);
|
||||
break;
|
||||
case 1:
|
||||
chest.with(item);
|
||||
break;
|
||||
case 2:
|
||||
legs.with(item);
|
||||
break;
|
||||
case 3:
|
||||
boots.with(item);
|
||||
break;
|
||||
}
|
||||
else if (item instanceof ItemArmor) switch (((ItemArmor) item).armorType) {
|
||||
case 0:
|
||||
helmets.with(item);
|
||||
break;
|
||||
case 1:
|
||||
chest.with(item);
|
||||
break;
|
||||
case 2:
|
||||
legs.with(item);
|
||||
break;
|
||||
case 3:
|
||||
boots.with(item);
|
||||
break;
|
||||
}
|
||||
else if (item == Items.arrow || item == Items.bow) ranged.with(item);
|
||||
else if (item == Items.fishing_rod || item == Items.flint_and_steel || item == Items.shears)
|
||||
other.with(item);
|
||||
@@ -517,8 +489,7 @@ public class ItemInfo {
|
||||
|
||||
try {
|
||||
items.addAll(mouseoverBlock.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
if (mouseoverBlock instanceof IShearable) {
|
||||
IShearable shearable = (IShearable) mouseoverBlock;
|
||||
if (shearable.isShearable(new ItemStack(Items.shears), world, x, y, z))
|
||||
@@ -531,12 +502,11 @@ public class ItemInfo {
|
||||
}
|
||||
|
||||
public static void registerHighlightHandler(IHighlightHandler handler, ItemInfo.Layout... layouts) {
|
||||
for (ItemInfo.Layout layout : layouts)
|
||||
ItemInfo.highlightHandlers.get(layout).add(handler);
|
||||
for (ItemInfo.Layout layout : layouts) ItemInfo.highlightHandlers.get(layout).add(handler);
|
||||
}
|
||||
|
||||
public static List<String> getText(
|
||||
ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop) {
|
||||
public static List<String> getText(ItemStack itemStack, World world, EntityPlayer player,
|
||||
MovingObjectPosition mop) {
|
||||
List<String> retString = new ArrayList<>();
|
||||
|
||||
for (ItemInfo.Layout layout : ItemInfo.Layout.values())
|
||||
@@ -550,7 +520,6 @@ public class ItemInfo {
|
||||
return itemSearchNames.computeIfAbsent(
|
||||
new ItemStackKey(stack),
|
||||
key -> EnumChatFormatting.getTextWithoutFormattingCodes(
|
||||
GuiContainerManager.concatenatedDisplayName(key.stack, true)
|
||||
.toLowerCase()));
|
||||
GuiContainerManager.concatenatedDisplayName(key.stack, true).toLowerCase()));
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
|
||||
import codechicken.nei.Button;
|
||||
import codechicken.nei.VisiblityData;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
|
||||
public abstract class LayoutStyle {
|
||||
|
||||
public abstract void init();
|
||||
|
||||
public abstract void reset();
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.config.OptionCycled;
|
||||
import java.util.LinkedList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class NEIInfo {
|
||||
|
||||
public static final LinkedList<INEIModeHandler> modeHandlers = new LinkedList<>();
|
||||
|
||||
public static void load(World world) {
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import codechicken.nei.ItemPanels;
|
||||
import codechicken.nei.LayoutManager;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
@@ -8,15 +15,15 @@ import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import codechicken.nei.recipe.GuiUsageRecipe;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
public abstract class ShortcutInputHandler {
|
||||
|
||||
public static boolean handleKeyEvent(ItemStack stackover) {
|
||||
|
||||
if (!NEIClientConfig.isLoaded()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NEIClientConfig.isKeyHashDown("gui.overlay_hide")) {
|
||||
return hideOverlayRecipe();
|
||||
}
|
||||
@@ -64,6 +71,10 @@ public abstract class ShortcutInputHandler {
|
||||
|
||||
public static boolean handleMouseClick(ItemStack stackover) {
|
||||
|
||||
if (!NEIClientConfig.isLoaded()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (stackover != null) {
|
||||
final int button = Mouse.getEventButton();
|
||||
stackover = stackover.copy();
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class TaggedInventoryArea {
|
||||
|
||||
public final HashSet<Integer> slots = new HashSet<>();
|
||||
public final String tagName;
|
||||
/**
|
||||
|
||||
@@ -3,11 +3,13 @@ package codechicken.nei.asm;
|
||||
import static org.objectweb.asm.Opcodes.POP;
|
||||
import static org.objectweb.asm.Opcodes.PUTSTATIC;
|
||||
|
||||
import codechicken.lib.asm.ASMHelper;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
|
||||
import codechicken.lib.asm.ASMHelper;
|
||||
|
||||
public class GuiContainerManagerAPITransformer extends ClassVisitor {
|
||||
|
||||
private final String tname;
|
||||
private boolean changed = false;
|
||||
|
||||
@@ -19,14 +21,18 @@ public class GuiContainerManagerAPITransformer extends ClassVisitor {
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String mname, String mdesc, String signature, String[] exceptions) {
|
||||
return new MethodVisitor(api, super.visitMethod(access, mname, mdesc, signature, exceptions)) {
|
||||
|
||||
@Override
|
||||
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
|
||||
if (opcode == PUTSTATIC
|
||||
&& "codechicken/nei/guihook/GuiContainerManager".equals(owner)
|
||||
if (opcode == PUTSTATIC && "codechicken/nei/guihook/GuiContainerManager".equals(owner)
|
||||
&& name.endsWith("Handlers")
|
||||
&& desc.equals("Ljava/util/LinkedList;")) {
|
||||
ASMHelper.logger.warn(
|
||||
"Found suspicious PUTSTATIC {} in {}#{}{}, replacing with POP!", name, tname, mname, mdesc);
|
||||
"Found suspicious PUTSTATIC {} in {}#{}{}, replacing with POP!",
|
||||
name,
|
||||
tname,
|
||||
mname,
|
||||
mdesc);
|
||||
changed = true;
|
||||
super.visitInsn(POP);
|
||||
} else {
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package codechicken.nei.asm;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
import codechicken.core.launch.CodeChickenCorePlugin;
|
||||
import codechicken.lib.asm.ASMInit;
|
||||
import cpw.mods.fml.relauncher.IFMLCallHook;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
@TransformerExclusions(value = {"codechicken.nei.asm"})
|
||||
@TransformerExclusions(value = { "codechicken.nei.asm" })
|
||||
@MCVersion("1.7.10")
|
||||
public class NEICorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
|
||||
public static File location;
|
||||
|
||||
public NEICorePlugin() {
|
||||
@@ -21,7 +23,7 @@ public class NEICorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
CodeChickenCorePlugin.versionCheck(CodeChickenCorePlugin.mcVersion, "NotEnoughItems");
|
||||
return new String[] {"codechicken.nei.asm.NEITransformer"};
|
||||
return new String[] { "codechicken.nei.asm.NEITransformer" };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,11 +40,7 @@ public class NEICorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
|
||||
public void injectData(Map<String, Object> data) {
|
||||
location = (File) data.get("coremodLocation");
|
||||
if (location == null)
|
||||
location = new File(getClass()
|
||||
.getProtectionDomain()
|
||||
.getCodeSource()
|
||||
.getLocation()
|
||||
.getPath());
|
||||
location = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,20 @@ import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES;
|
||||
import static org.objectweb.asm.ClassWriter.COMPUTE_MAXS;
|
||||
import static org.objectweb.asm.Opcodes.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.objectweb.asm.tree.InsnList;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import org.objectweb.asm.tree.VarInsnNode;
|
||||
|
||||
import codechicken.lib.asm.ASMBlock;
|
||||
import codechicken.lib.asm.ASMHelper;
|
||||
import codechicken.lib.asm.ASMInit;
|
||||
@@ -22,19 +36,9 @@ import codechicken.lib.asm.ModularASMTransformer.MethodTransformer;
|
||||
import codechicken.lib.asm.ModularASMTransformer.MethodWriter;
|
||||
import codechicken.lib.asm.ObfMapping;
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import java.util.Map;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.objectweb.asm.tree.InsnList;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import org.objectweb.asm.tree.VarInsnNode;
|
||||
|
||||
public class NEITransformer implements IClassTransformer {
|
||||
|
||||
static {
|
||||
ASMInit.init();
|
||||
}
|
||||
@@ -47,98 +51,114 @@ public class NEITransformer implements IClassTransformer {
|
||||
if (FMLLaunchHandler.side().isClient()) {
|
||||
// Generates method to set the placed position of a mob spawner for the item callback. More portable than
|
||||
// copying vanilla placement code
|
||||
transformer.add(new MethodWriter(
|
||||
ACC_PUBLIC,
|
||||
new ObfMapping(
|
||||
"net/minecraft/block/BlockMobSpawner",
|
||||
"func_149689_a",
|
||||
"(Lnet/minecraft/world/World;IIILnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/item/ItemStack;)V"),
|
||||
asmblocks.get("spawnerPlaced")));
|
||||
transformer.add(
|
||||
new MethodWriter(
|
||||
ACC_PUBLIC,
|
||||
new ObfMapping(
|
||||
"net/minecraft/block/BlockMobSpawner",
|
||||
"func_149689_a",
|
||||
"(Lnet/minecraft/world/World;IIILnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/item/ItemStack;)V"),
|
||||
asmblocks.get("spawnerPlaced")));
|
||||
|
||||
// Make MobSpawnerBaseLogic use getSpawnerWorld when creating new entities
|
||||
transformer.add(new MethodReplacer(
|
||||
new ObfMapping(
|
||||
"net/minecraft/tileentity/MobSpawnerBaseLogic",
|
||||
"func_98281_h",
|
||||
"()Lnet/minecraft/entity/Entity;"),
|
||||
asmblocks.get("d_spawnerWorld"),
|
||||
asmblocks.get("spawnerWorld")));
|
||||
transformer.add(
|
||||
new MethodReplacer(
|
||||
new ObfMapping(
|
||||
"net/minecraft/tileentity/MobSpawnerBaseLogic",
|
||||
"func_98281_h",
|
||||
"()Lnet/minecraft/entity/Entity;"),
|
||||
asmblocks.get("d_spawnerWorld"),
|
||||
asmblocks.get("spawnerWorld")));
|
||||
}
|
||||
|
||||
// Removes trailing seperators from NBTTagList/Compound.toString because OCD
|
||||
transformer.add(new MethodInjector(
|
||||
new ObfMapping("net/minecraft/nbt/NBTTagCompound", "toString", "()Ljava/lang/String;"),
|
||||
asmblocks.get("n_commaFix"),
|
||||
asmblocks.get("commaFix"),
|
||||
true));
|
||||
transformer.add(new MethodInjector(
|
||||
new ObfMapping("net/minecraft/nbt/NBTTagList", "toString", "()Ljava/lang/String;"),
|
||||
asmblocks.get("n_commaFix"),
|
||||
asmblocks.get("commaFix"),
|
||||
true));
|
||||
transformer.add(
|
||||
new MethodInjector(
|
||||
new ObfMapping("net/minecraft/nbt/NBTTagCompound", "toString", "()Ljava/lang/String;"),
|
||||
asmblocks.get("n_commaFix"),
|
||||
asmblocks.get("commaFix"),
|
||||
true));
|
||||
transformer.add(
|
||||
new MethodInjector(
|
||||
new ObfMapping("net/minecraft/nbt/NBTTagList", "toString", "()Ljava/lang/String;"),
|
||||
asmblocks.get("n_commaFix"),
|
||||
asmblocks.get("commaFix"),
|
||||
true));
|
||||
|
||||
// fix workbench container losing items on shift click output without room for the full stack
|
||||
transformer.add(
|
||||
new MethodTransformer(new ObfMapping(
|
||||
"net/minecraft/inventory/ContainerWorkbench",
|
||||
"func_82846_b",
|
||||
"(Lnet/minecraft/entity/player/EntityPlayer;I)Lnet/minecraft/item/ItemStack;")) {
|
||||
new MethodTransformer(
|
||||
new ObfMapping(
|
||||
"net/minecraft/inventory/ContainerWorkbench",
|
||||
"func_82846_b",
|
||||
"(Lnet/minecraft/entity/player/EntityPlayer;I)Lnet/minecraft/item/ItemStack;")) {
|
||||
|
||||
@Override
|
||||
public void transform(MethodNode mv) {
|
||||
ASMHelper.logger.debug("NEI: Applying workbench fix");
|
||||
InsnListSection key = findN(mv.instructions, asmblocks.get("n_workbenchFix").list)
|
||||
.get(0);
|
||||
InsnListSection key = findN(mv.instructions, asmblocks.get("n_workbenchFix").list).get(0);
|
||||
key.insertBefore(asmblocks.get("workbenchFix").rawListCopy());
|
||||
}
|
||||
});
|
||||
|
||||
// put glint alpha into the buffer correctly for exporting
|
||||
transformer.add(new MethodReplacer(
|
||||
new ObfMapping("net/minecraft/client/renderer/entity/RenderItem", "func_77018_a", "(IIIII)V"),
|
||||
asmblocks.get("d_glintAlphaFix"),
|
||||
asmblocks.get("glintAlphaFix")));
|
||||
transformer.add(
|
||||
new MethodReplacer(
|
||||
new ObfMapping("net/minecraft/client/renderer/entity/RenderItem", "func_77018_a", "(IIIII)V"),
|
||||
asmblocks.get("d_glintAlphaFix"),
|
||||
asmblocks.get("glintAlphaFix")));
|
||||
|
||||
String GuiContainer = "net/minecraft/client/gui/inventory/GuiContainer";
|
||||
// add manager field
|
||||
transformer.add(new FieldWriter(
|
||||
ACC_PUBLIC, new ObfMapping(GuiContainer, "manager", "Lcodechicken/nei/guihook/GuiContainerManager;")));
|
||||
transformer.add(
|
||||
new FieldWriter(
|
||||
ACC_PUBLIC,
|
||||
new ObfMapping(GuiContainer, "manager", "Lcodechicken/nei/guihook/GuiContainerManager;")));
|
||||
|
||||
// Fill out getManager in GuiContainerManager
|
||||
transformer.add(new MethodWriter(
|
||||
ACC_PUBLIC | ACC_STATIC,
|
||||
new ObfMapping(
|
||||
"codechicken/nei/guihook/GuiContainerManager",
|
||||
"getManager",
|
||||
"(Lnet/minecraft/client/gui/inventory/GuiContainer;)Lcodechicken/nei/guihook/GuiContainerManager;"),
|
||||
asmblocks.get("m_getManager")));
|
||||
transformer.add(
|
||||
new MethodWriter(
|
||||
ACC_PUBLIC | ACC_STATIC,
|
||||
new ObfMapping(
|
||||
"codechicken/nei/guihook/GuiContainerManager",
|
||||
"getManager",
|
||||
"(Lnet/minecraft/client/gui/inventory/GuiContainer;)Lcodechicken/nei/guihook/GuiContainerManager;"),
|
||||
asmblocks.get("m_getManager")));
|
||||
|
||||
// Generate load method
|
||||
transformer.add(new MethodWriter(
|
||||
ACC_PUBLIC,
|
||||
new ObfMapping(GuiContainer, "func_146280_a", "(Lnet/minecraft/client/Minecraft;II)V"),
|
||||
asmblocks.get("m_setWorldAndResolution")));
|
||||
transformer.add(
|
||||
new MethodWriter(
|
||||
ACC_PUBLIC,
|
||||
new ObfMapping(GuiContainer, "func_146280_a", "(Lnet/minecraft/client/Minecraft;II)V"),
|
||||
asmblocks.get("m_setWorldAndResolution")));
|
||||
|
||||
// Generate handleKeyboardInput method
|
||||
transformer.add(new MethodWriter(
|
||||
ACC_PUBLIC,
|
||||
new ObfMapping(GuiContainer, "func_146282_l", "()V"),
|
||||
asmblocks.get("m_handleKeyboardInput")));
|
||||
transformer.add(
|
||||
new MethodWriter(
|
||||
ACC_PUBLIC,
|
||||
new ObfMapping(GuiContainer, "func_146282_l", "()V"),
|
||||
asmblocks.get("m_handleKeyboardInput")));
|
||||
|
||||
// Generate handleKeyboardInput method
|
||||
transformer.add(new MethodWriter(
|
||||
ACC_PUBLIC,
|
||||
new ObfMapping(GuiContainer, "func_146282_l", "()V"),
|
||||
asmblocks.get("m_handleKeyboardInput")));
|
||||
transformer.add(
|
||||
new MethodWriter(
|
||||
ACC_PUBLIC,
|
||||
new ObfMapping(GuiContainer, "func_146282_l", "()V"),
|
||||
asmblocks.get("m_handleKeyboardInput")));
|
||||
|
||||
// Generate handleKeyboardInput method
|
||||
transformer.add(new MethodWriter(
|
||||
ACC_PUBLIC,
|
||||
new ObfMapping(GuiContainer, "func_146282_l", "()V"),
|
||||
asmblocks.get("m_handleKeyboardInput")));
|
||||
transformer.add(
|
||||
new MethodWriter(
|
||||
ACC_PUBLIC,
|
||||
new ObfMapping(GuiContainer, "func_146282_l", "()V"),
|
||||
asmblocks.get("m_handleKeyboardInput")));
|
||||
|
||||
// Generate handleMouseInput method
|
||||
transformer.add(new MethodWriter(
|
||||
ACC_PUBLIC, new ObfMapping(GuiContainer, "func_146274_d", "()V"), asmblocks.get("m_handleMouseInput")));
|
||||
transformer.add(
|
||||
new MethodWriter(
|
||||
ACC_PUBLIC,
|
||||
new ObfMapping(GuiContainer, "func_146274_d", "()V"),
|
||||
asmblocks.get("m_handleMouseInput")));
|
||||
|
||||
addProtectedForwarder(
|
||||
new ObfMapping(GuiContainer, "func_73869_a", "(CI)V"),
|
||||
@@ -155,86 +175,111 @@ public class NEITransformer implements IClassTransformer {
|
||||
"(Lnet/minecraft/client/gui/inventory/GuiContainer;Lnet/minecraft/inventory/Slot;III)V"));
|
||||
|
||||
// Inject preDraw at the start of drawScreen
|
||||
transformer.add(new MethodInjector(
|
||||
new ObfMapping(GuiContainer, "func_73863_a", "(IIF)V"), asmblocks.get("preDraw"), true));
|
||||
transformer.add(
|
||||
new MethodInjector(
|
||||
new ObfMapping(GuiContainer, "func_73863_a", "(IIF)V"),
|
||||
asmblocks.get("preDraw"),
|
||||
true));
|
||||
|
||||
// Inject objectUnderMouse check before drawing slot highlights
|
||||
transformer.add(new MethodInjector(
|
||||
new ObfMapping(GuiContainer, "func_73863_a", "(IIF)V"),
|
||||
asmblocks.get("n_objectUnderMouse"),
|
||||
asmblocks.get("objectUnderMouse"),
|
||||
false));
|
||||
transformer.add(
|
||||
new MethodInjector(
|
||||
new ObfMapping(GuiContainer, "func_73863_a", "(IIF)V"),
|
||||
asmblocks.get("n_objectUnderMouse"),
|
||||
asmblocks.get("objectUnderMouse"),
|
||||
false));
|
||||
|
||||
// Inject renderObjects after drawGuiContainerForegroundLayer
|
||||
transformer.add(new MethodInjector(
|
||||
new ObfMapping(GuiContainer, "func_73863_a", "(IIF)V"),
|
||||
asmblocks.get("n_renderObjects"),
|
||||
asmblocks.get("renderObjects"),
|
||||
false));
|
||||
transformer.add(
|
||||
new MethodInjector(
|
||||
new ObfMapping(GuiContainer, "func_73863_a", "(IIF)V"),
|
||||
asmblocks.get("n_renderObjects"),
|
||||
asmblocks.get("renderObjects"),
|
||||
false));
|
||||
|
||||
// Replace default renderToolTip with delegate
|
||||
transformer.add(new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_73863_a", "(IIF)V"),
|
||||
asmblocks.get("d_renderToolTip"),
|
||||
asmblocks.get("renderTooltips")));
|
||||
transformer.add(
|
||||
new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_73863_a", "(IIF)V"),
|
||||
asmblocks.get("d_renderToolTip"),
|
||||
asmblocks.get("renderTooltips")));
|
||||
|
||||
// Replace zLevel = 200 with zLevel = 500 in drawItemStack
|
||||
transformer.add(new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_146982_a", "(Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V"),
|
||||
asmblocks.get("d_zLevel"),
|
||||
asmblocks.get("zLevel")));
|
||||
transformer.add(
|
||||
new MethodReplacer(
|
||||
new ObfMapping(
|
||||
GuiContainer,
|
||||
"func_146982_a",
|
||||
"(Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V"),
|
||||
asmblocks.get("d_zLevel"),
|
||||
asmblocks.get("zLevel")));
|
||||
|
||||
// Replace default renderItem with delegate and slot overlay/underlay
|
||||
transformer.add(new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_146977_a", "(Lnet/minecraft/inventory/Slot;)V"),
|
||||
asmblocks.get("d_drawSlot"),
|
||||
asmblocks.get("drawSlot")));
|
||||
transformer.add(
|
||||
new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_146977_a", "(Lnet/minecraft/inventory/Slot;)V"),
|
||||
asmblocks.get("d_drawSlot"),
|
||||
asmblocks.get("drawSlot")));
|
||||
|
||||
// Inject mouseClicked hook at the start of mouseClicked
|
||||
transformer.add(new MethodInjector(
|
||||
new ObfMapping(GuiContainer, "func_73864_a", "(III)V"), asmblocks.get("mouseClicked"), true));
|
||||
transformer.add(
|
||||
new MethodInjector(
|
||||
new ObfMapping(GuiContainer, "func_73864_a", "(III)V"),
|
||||
asmblocks.get("mouseClicked"),
|
||||
true));
|
||||
|
||||
// Replace general handleMouseClicked call with delegate
|
||||
transformer.add(new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_73864_a", "(III)V"),
|
||||
asmblocks.get("d_handleMouseClick"),
|
||||
asmblocks.get("handleMouseClick"))); // mouseClicked
|
||||
transformer.add(new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_146273_a", "(IIIJ)V"),
|
||||
asmblocks.get("d_handleMouseClick"),
|
||||
asmblocks.get("handleMouseClick"))); // mouseClickMove
|
||||
transformer.add(new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_146286_b", "(III)V"),
|
||||
asmblocks.get("d_handleMouseClick"),
|
||||
asmblocks.get("handleMouseClick"))); // mouseMovedOrUp
|
||||
transformer.add(new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_73869_a", "(CI)V"),
|
||||
asmblocks.get("d_handleMouseClick"),
|
||||
asmblocks.get("handleMouseClick"))); // keyTyped
|
||||
transformer.add(new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_146983_a", "(I)Z"),
|
||||
asmblocks.get("d_handleMouseClick"),
|
||||
asmblocks.get("handleMouseClick"))); // checkHotbarKeys
|
||||
transformer.add(
|
||||
new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_73864_a", "(III)V"),
|
||||
asmblocks.get("d_handleMouseClick"),
|
||||
asmblocks.get("handleMouseClick"))); // mouseClicked
|
||||
transformer.add(
|
||||
new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_146273_a", "(IIIJ)V"),
|
||||
asmblocks.get("d_handleMouseClick"),
|
||||
asmblocks.get("handleMouseClick"))); // mouseClickMove
|
||||
transformer.add(
|
||||
new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_146286_b", "(III)V"),
|
||||
asmblocks.get("d_handleMouseClick"),
|
||||
asmblocks.get("handleMouseClick"))); // mouseMovedOrUp
|
||||
transformer.add(
|
||||
new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_73869_a", "(CI)V"),
|
||||
asmblocks.get("d_handleMouseClick"),
|
||||
asmblocks.get("handleMouseClick"))); // keyTyped
|
||||
transformer.add(
|
||||
new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_146983_a", "(I)Z"),
|
||||
asmblocks.get("d_handleMouseClick"),
|
||||
asmblocks.get("handleMouseClick"))); // checkHotbarKeys
|
||||
|
||||
// Write delegate for handleMouseClicked
|
||||
transformer.add(new MethodWriter(
|
||||
ACC_PUBLIC,
|
||||
new ObfMapping(GuiContainer, "managerHandleMouseClick", "(Lnet/minecraft/inventory/Slot;III)V"),
|
||||
asmblocks.get("m_managerHandleMouseClick")));
|
||||
transformer.add(
|
||||
new MethodWriter(
|
||||
ACC_PUBLIC,
|
||||
new ObfMapping(GuiContainer, "managerHandleMouseClick", "(Lnet/minecraft/inventory/Slot;III)V"),
|
||||
asmblocks.get("m_managerHandleMouseClick")));
|
||||
|
||||
// Inject mouseDragged hook after super call in mouseDragged
|
||||
transformer.add(new MethodInjector(
|
||||
new ObfMapping(GuiContainer, "func_146273_a", "(IIIJ)V"),
|
||||
asmblocks.get("n_mouseDragged"),
|
||||
asmblocks.get("mouseDragged"),
|
||||
false));
|
||||
transformer.add(
|
||||
new MethodInjector(
|
||||
new ObfMapping(GuiContainer, "func_146273_a", "(IIIJ)V"),
|
||||
asmblocks.get("n_mouseDragged"),
|
||||
asmblocks.get("mouseDragged"),
|
||||
false));
|
||||
|
||||
// Inject overrideMouseUp at the start of mouseMovedOrUp
|
||||
transformer.add(new MethodInjector(
|
||||
new ObfMapping(GuiContainer, "func_146286_b", "(III)V"), asmblocks.get("overrideMouseUp"), true));
|
||||
transformer.add(
|
||||
new MethodInjector(
|
||||
new ObfMapping(GuiContainer, "func_146286_b", "(III)V"),
|
||||
asmblocks.get("overrideMouseUp"),
|
||||
true));
|
||||
|
||||
// Inject mouseUp at the end of main elseif chain in mouseMovedOrUp
|
||||
transformer.add(new MethodTransformer(new ObfMapping(GuiContainer, "func_146286_b", "(III)V")) {
|
||||
|
||||
@Override
|
||||
public void transform(MethodNode mv) {
|
||||
ASMHelper.logger.debug("NEI: Injecting mouseUp call");
|
||||
@@ -252,50 +297,59 @@ public class NEITransformer implements IClassTransformer {
|
||||
});
|
||||
|
||||
// Replace general handleSlotClick call with delegate
|
||||
transformer.add(new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_146984_a", "(Lnet/minecraft/inventory/Slot;III)V"),
|
||||
asmblocks.get("d_handleSlotClick"),
|
||||
asmblocks.get("handleSlotClick")));
|
||||
transformer.add(
|
||||
new MethodReplacer(
|
||||
new ObfMapping(GuiContainer, "func_146984_a", "(Lnet/minecraft/inventory/Slot;III)V"),
|
||||
asmblocks.get("d_handleSlotClick"),
|
||||
asmblocks.get("handleSlotClick")));
|
||||
|
||||
// Inject lastKeyTyped at the start of keyTyped
|
||||
transformer.add(new MethodInjector(
|
||||
new ObfMapping(GuiContainer, "func_73869_a", "(CI)V"), asmblocks.get("lastKeyTyped"), true));
|
||||
transformer.add(
|
||||
new MethodInjector(
|
||||
new ObfMapping(GuiContainer, "func_73869_a", "(CI)V"),
|
||||
asmblocks.get("lastKeyTyped"),
|
||||
true));
|
||||
|
||||
// Inject updateScreen hook after super call
|
||||
transformer.add(new MethodInjector(
|
||||
new ObfMapping(GuiContainer, "func_73876_c", "()V"),
|
||||
asmblocks.get("n_updateScreen"),
|
||||
asmblocks.get("updateScreen"),
|
||||
false));
|
||||
transformer.add(
|
||||
new MethodInjector(
|
||||
new ObfMapping(GuiContainer, "func_73876_c", "()V"),
|
||||
asmblocks.get("n_updateScreen"),
|
||||
asmblocks.get("updateScreen"),
|
||||
false));
|
||||
|
||||
// Cancel tab click calls when tabs are obscured
|
||||
transformer.add(new MethodInjector(
|
||||
new ObfMapping(
|
||||
"net/minecraft/client/gui/inventory/GuiContainerCreative",
|
||||
"func_147049_a",
|
||||
"(Lnet/minecraft/creativetab/CreativeTabs;II)Z"),
|
||||
asmblocks.get("handleTabClick"),
|
||||
true));
|
||||
transformer.add(
|
||||
new MethodInjector(
|
||||
new ObfMapping(
|
||||
"net/minecraft/client/gui/inventory/GuiContainerCreative",
|
||||
"func_147049_a",
|
||||
"(Lnet/minecraft/creativetab/CreativeTabs;II)Z"),
|
||||
asmblocks.get("handleTabClick"),
|
||||
true));
|
||||
|
||||
// Cancel tab tooltip rendering when tabs are obscured
|
||||
transformer.add(new MethodInjector(
|
||||
new ObfMapping(
|
||||
"net/minecraft/client/gui/inventory/GuiContainerCreative",
|
||||
"func_147052_b",
|
||||
"(Lnet/minecraft/creativetab/CreativeTabs;II)Z"),
|
||||
asmblocks.get("renderTabTooltip"),
|
||||
true));
|
||||
transformer.add(
|
||||
new MethodInjector(
|
||||
new ObfMapping(
|
||||
"net/minecraft/client/gui/inventory/GuiContainerCreative",
|
||||
"func_147052_b",
|
||||
"(Lnet/minecraft/creativetab/CreativeTabs;II)Z"),
|
||||
asmblocks.get("renderTabTooltip"),
|
||||
true));
|
||||
|
||||
String[] buttons = new String[] {"CancelButton", "ConfirmButton", "PowerButton"};
|
||||
String[] this_fields = new String[] {"field_146146_o", "field_146147_o", "field_146150_o"};
|
||||
String[] buttons = new String[] { "CancelButton", "ConfirmButton", "PowerButton" };
|
||||
String[] this_fields = new String[] { "field_146146_o", "field_146147_o", "field_146150_o" };
|
||||
for (int i = 0; i < 3; i++) {
|
||||
ObfMapping m = new ObfMapping(
|
||||
"net/minecraft/client/gui/inventory/GuiBeacon$" + buttons[i], "func_146111_b", "(II)V");
|
||||
"net/minecraft/client/gui/inventory/GuiBeacon$" + buttons[i],
|
||||
"func_146111_b",
|
||||
"(II)V");
|
||||
InsnListSection l = asmblocks.get("beaconButtonObscured").list.copy();
|
||||
FieldInsnNode this_ref = ((FieldInsnNode) l.get(1));
|
||||
this_ref.owner = m.toClassloading().s_owner;
|
||||
if (ObfMapping.obfuscated) // missing srg mappings for inner outer reference fields
|
||||
this_ref.name = ObfMapping.obfMapper.mapFieldName(null, this_fields[i], null);
|
||||
this_ref.name = ObfMapping.obfMapper.mapFieldName(null, this_fields[i], null);
|
||||
transformer.add(new MethodInjector(m, l.list, true));
|
||||
}
|
||||
}
|
||||
@@ -321,8 +375,9 @@ public class NEITransformer implements IClassTransformer {
|
||||
transformer.add(new MethodWriter(ACC_PUBLIC, publicCall, forward2));
|
||||
}
|
||||
|
||||
private final ObfMapping c_GuiContainer =
|
||||
new ObfMapping("net/minecraft/client/gui/inventory/GuiContainer").toClassloading();
|
||||
private final ObfMapping c_GuiContainer = new ObfMapping("net/minecraft/client/gui/inventory/GuiContainer")
|
||||
.toClassloading();
|
||||
|
||||
/**
|
||||
* Adds super.updateScreen() to non implementing GuiContainer subclasses
|
||||
*/
|
||||
|
||||
@@ -10,49 +10,54 @@ import org.objectweb.asm.MethodVisitor;
|
||||
|
||||
/**
|
||||
* Code without this patch
|
||||
*
|
||||
* <pre>
|
||||
* public class OreDictionary {
|
||||
* public static int getOreID(String name) {
|
||||
* Integer val = nameToId.get(name);
|
||||
* if (val == null)
|
||||
* {
|
||||
* idToName.add(name);
|
||||
* val = idToName.size() - 1; //0 indexed
|
||||
* nameToId.put(name, val);
|
||||
* idToStack.add(new ArrayList<ItemStack>());
|
||||
* idToStackUn.add(new UnmodifiableArrayList(idToStack.get(val)));
|
||||
* }
|
||||
* return val;
|
||||
* }
|
||||
*
|
||||
* public static int getOreID(String name) {
|
||||
* Integer val = nameToId.get(name);
|
||||
* if (val == null) {
|
||||
* idToName.add(name);
|
||||
* val = idToName.size() - 1; // 0 indexed
|
||||
* nameToId.put(name, val);
|
||||
* idToStack.add(new ArrayList<ItemStack>());
|
||||
* idToStackUn.add(new UnmodifiableArrayList(idToStack.get(val)));
|
||||
* }
|
||||
* return val;
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* Code with this patch
|
||||
*
|
||||
* <pre>
|
||||
* public class OreDictionary {
|
||||
* private static final Object emptyEntryCreationLock = new Object();
|
||||
* public static int getOreID(String name) {
|
||||
* Integer val = nameToId.get(name);
|
||||
* if (val == null)
|
||||
* {
|
||||
* synchronized (emptyEntryCreationLock) {
|
||||
* if ((val = nameToId.get(name)) != null)
|
||||
* return val;
|
||||
* idToName.add(name);
|
||||
* val = idToName.size() - 1; //0 indexed
|
||||
* nameToId.put(name, val);
|
||||
* idToStack.add(new ArrayList<ItemStack>());
|
||||
* idToStackUn.add(new UnmodifiableArrayList(idToStack.get(val)));
|
||||
* }
|
||||
* }
|
||||
* return val;
|
||||
* }
|
||||
*
|
||||
* private static final Object emptyEntryCreationLock = new Object();
|
||||
*
|
||||
* public static int getOreID(String name) {
|
||||
* Integer val = nameToId.get(name);
|
||||
* if (val == null) {
|
||||
* synchronized (emptyEntryCreationLock) {
|
||||
* if ((val = nameToId.get(name)) != null) return val;
|
||||
* idToName.add(name);
|
||||
* val = idToName.size() - 1; // 0 indexed
|
||||
* nameToId.put(name, val);
|
||||
* idToStack.add(new ArrayList<ItemStack>());
|
||||
* idToStackUn.add(new UnmodifiableArrayList(idToStack.get(val)));
|
||||
* }
|
||||
* }
|
||||
* return val;
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public class OreDictionaryVisitor extends ClassVisitor {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger("OreDictionaryVisitor");
|
||||
|
||||
private static class GetOreIDVisitor extends MethodVisitor {
|
||||
|
||||
Label jumpEnd;
|
||||
Label catchStart = new Label();
|
||||
Label exitStart = new Label();
|
||||
@@ -118,6 +123,7 @@ public class OreDictionaryVisitor extends ClassVisitor {
|
||||
}
|
||||
|
||||
private static class ClassInitializerVisitor extends MethodVisitor {
|
||||
|
||||
public ClassInitializerVisitor(int api, MethodVisitor mv) {
|
||||
super(api, mv);
|
||||
}
|
||||
|
||||
Loaded 100 of 190 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user