mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-25 04:58:34 +01:00
Compare commits
No commits in common. "b991f8575ff56ab28df3792232001b7448117a80" and "bb221cb623062bc1508126e6fbcbdc06fc89f6c0" have entirely different histories.
b991f8575f
...
bb221cb623
71 changed files with 536 additions and 600 deletions
24
build.gradle
24
build.gradle
|
@ -1,11 +1,11 @@
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
|
maven { url = 'https://files.minecraftforge.net/maven' }
|
||||||
maven { url = 'https://maven.minecraftforge.net' }
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
|
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
apply plugin: 'net.minecraftforge.gradle'
|
apply plugin: 'net.minecraftforge.gradle'
|
||||||
|
@ -20,11 +20,10 @@ archivesBaseName = 'PrettyPipes'
|
||||||
if (System.getenv('BUILD_NUMBER') != null) {
|
if (System.getenv('BUILD_NUMBER') != null) {
|
||||||
version += "." + System.getenv('BUILD_NUMBER')
|
version += "." + System.getenv('BUILD_NUMBER')
|
||||||
}
|
}
|
||||||
|
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
|
||||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: 'official', version: '1.18'
|
mappings channel: 'snapshot', version: '20200723-1.16.1'
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
client {
|
client {
|
||||||
|
@ -99,19 +98,18 @@ configurations {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft 'net.minecraftforge:forge:1.18-38.0.8'
|
minecraft 'net.minecraftforge:forge:1.16.3-34.0.9'
|
||||||
embed 'org.jgrapht:jgrapht-core:1.5.1'
|
embed "org.jgrapht:jgrapht-core:1.4.0"
|
||||||
|
|
||||||
// TODO JEI?
|
compileOnly fg.deobf("mezz.jei:jei-1.16.2:7.3.2.25:api")
|
||||||
/* compileOnly fg.deobf("mezz.jei:jei-1.16.2:7.3.2.25:api")
|
runtimeOnly fg.deobf("mezz.jei:jei-1.16.2:7.3.2.25")
|
||||||
runtimeOnly fg.deobf("mezz.jei:jei-1.16.2:7.3.2.25")*/
|
|
||||||
|
|
||||||
// to test the rf requiring and crafting stuff
|
// to test the rf requiring and crafting stuff
|
||||||
/* runtimeOnly fg.deobf("curse.maven:powah-352656:3057732")
|
runtimeOnly fg.deobf("curse.maven:powah-352656:3057732")
|
||||||
runtimeOnly fg.deobf("curse.maven:lollipop-347954:3057731")
|
runtimeOnly fg.deobf("curse.maven:lollipop-347954:3057731")
|
||||||
runtimeOnly fg.deobf("curse.maven:mcjtylib-233105:3131241")
|
runtimeOnly fg.deobf("curse.maven:mcjtylib-233105:3131241")
|
||||||
runtimeOnly fg.deobf("curse.maven:rftools-base-326041:3140147")
|
runtimeOnly fg.deobf("curse.maven:rftools-base-326041:3140147")
|
||||||
runtimeOnly fg.deobf("curse.maven:rftools-utility-342466:3152948")*/
|
runtimeOnly fg.deobf("curse.maven:rftools-utility-342466:3152948")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example for how to get properties into the manifest for reading by the runtime..
|
// Example for how to get properties into the manifest for reading by the runtime..
|
||||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,6 @@
|
||||||
|
#Sun Oct 20 21:47:13 CEST 2019
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
|
||||||
|
|
286
gradlew
vendored
286
gradlew
vendored
|
@ -1,129 +1,78 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright © 2015-2021 the original authors.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
##
|
||||||
# Gradle start up script for POSIX generated by Gradle.
|
## Gradle start up script for UN*X
|
||||||
#
|
##
|
||||||
# Important for running:
|
|
||||||
#
|
|
||||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
||||||
# noncompliant, but you have some other compliant shell such as ksh or
|
|
||||||
# bash, then to run this script, type that shell name before the whole
|
|
||||||
# command line, like:
|
|
||||||
#
|
|
||||||
# ksh Gradle
|
|
||||||
#
|
|
||||||
# Busybox and similar reduced shells will NOT work, because this script
|
|
||||||
# requires all of these POSIX shell features:
|
|
||||||
# * functions;
|
|
||||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
||||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
||||||
# * compound commands having a testable exit status, especially «case»;
|
|
||||||
# * various built-in commands including «command», «set», and «ulimit».
|
|
||||||
#
|
|
||||||
# Important for patching:
|
|
||||||
#
|
|
||||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
||||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
||||||
#
|
|
||||||
# The "traditional" practice of packing multiple parameters into a
|
|
||||||
# space-separated string is a well documented source of bugs and security
|
|
||||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
||||||
# options in "$@", and eventually passing that to Java.
|
|
||||||
#
|
|
||||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
||||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
||||||
# see the in-line comments for details.
|
|
||||||
#
|
|
||||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
||||||
# Darwin, MinGW, and NonStop.
|
|
||||||
#
|
|
||||||
# (3) This script is generated from the Groovy template
|
|
||||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
||||||
# within the Gradle project.
|
|
||||||
#
|
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
||||||
#
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
app_path=$0
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
# Need this for daisy-chained symlinks.
|
while [ -h "$PRG" ] ; do
|
||||||
while
|
ls=`ls -ld "$PRG"`
|
||||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
[ -h "$app_path" ]
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
do
|
PRG="$link"
|
||||||
ls=$( ls -ld "$app_path" )
|
else
|
||||||
link=${ls#*' -> '}
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
case $link in #(
|
fi
|
||||||
/*) app_path=$link ;; #(
|
|
||||||
*) app_path=$APP_HOME$link ;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# 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"'
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD="maximum"
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
} >&2
|
}
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
} >&2
|
}
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "$( uname )" in #(
|
case "`uname`" in
|
||||||
CYGWIN* ) cygwin=true ;; #(
|
CYGWIN* )
|
||||||
Darwin* ) darwin=true ;; #(
|
cygwin=true
|
||||||
MSYS* | MINGW* ) msys=true ;; #(
|
;;
|
||||||
NONSTOP* ) nonstop=true ;;
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
else
|
else
|
||||||
JAVACMD=$JAVA_HOME/bin/java
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
@ -132,7 +81,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
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.
|
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
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
@ -140,95 +89,84 @@ location of your Java installation."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
case $MAX_FD in #(
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
max*)
|
if [ $? -eq 0 ] ; then
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
warn "Could not query maximum file descriptor limit"
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
esac
|
|
||||||
case $MAX_FD in #(
|
|
||||||
'' | soft) :;; #(
|
|
||||||
*)
|
|
||||||
ulimit -n "$MAX_FD" ||
|
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Collect all arguments for the java command, stacking in reverse order:
|
|
||||||
# * args from the command line
|
|
||||||
# * the main class name
|
|
||||||
# * -classpath
|
|
||||||
# * -D...appname settings
|
|
||||||
# * --module-path (only if needed)
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if "$cygwin" || "$msys" ; then
|
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
|
||||||
|
|
||||||
# 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
|
fi
|
||||||
# Roll the args list around exactly as many times as the number of
|
ulimit -n $MAX_FD
|
||||||
# args, so each arg winds up back in the position where it started, but
|
if [ $? -ne 0 ] ; then
|
||||||
# possibly modified.
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
#
|
fi
|
||||||
# NB: a `for` loop captures its iteration list before it begins, so
|
else
|
||||||
# changing the positional parameters here affects neither the number of
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
# iterations, nor the values presented in `arg`.
|
fi
|
||||||
shift # remove old arg
|
|
||||||
set -- "$@" "$arg" # push replacement arg
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
if $darwin; then
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
# double quotes to make sure that they get re-expanded; and
|
fi
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
|
||||||
|
|
||||||
set -- \
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
if $cygwin ; then
|
||||||
-classpath "$CLASSPATH" \
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
"$@"
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
#
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
SEP=""
|
||||||
#
|
for dir in $ROOTDIRSRAW ; do
|
||||||
# In Bash we could simply go:
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
#
|
SEP="|"
|
||||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
done
|
||||||
# set -- "${ARGS[@]}" "$@"
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
#
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
# character that might be a shell metacharacter, then use eval to reverse
|
fi
|
||||||
# that process (while maintaining the separation between arguments), and wrap
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
# the whole thing up as a single "set" statement.
|
i=0
|
||||||
#
|
for arg in "$@" ; do
|
||||||
# This will of course break if any of these variables contains a newline or
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
# an unmatched quote.
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
#
|
|
||||||
|
|
||||||
eval "set -- $(
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
xargs -n1 |
|
else
|
||||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
eval `echo args$i`="\"$arg\""
|
||||||
tr '\n' ' '
|
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" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|
43
gradlew.bat
vendored
43
gradlew.bat
vendored
|
@ -1,19 +1,3 @@
|
||||||
@rem
|
|
||||||
@rem Copyright 2015 the original author or authors.
|
|
||||||
@rem
|
|
||||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
@rem you may not use this file except in compliance with the License.
|
|
||||||
@rem You may obtain a copy of the License at
|
|
||||||
@rem
|
|
||||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
@rem
|
|
||||||
@rem Unless required by applicable law or agreed to in writing, software
|
|
||||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
@rem See the License for the specific language governing permissions and
|
|
||||||
@rem limitations under the License.
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
|
@ -29,18 +13,15 @@ if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
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.
|
@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"
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
@ -54,7 +35,7 @@ goto fail
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
@ -64,14 +45,28 @@ echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
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
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
|
|
@ -12,8 +12,8 @@ public final class PrettyPipes {
|
||||||
public static final String ID = "prettypipes";
|
public static final String ID = "prettypipes";
|
||||||
|
|
||||||
public PrettyPipes() {
|
public PrettyPipes() {
|
||||||
var bus = FMLJavaModLoadingContext.get().getModEventBus();
|
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
bus.addListener(Registry::setup);
|
bus.addListener(Registry::setup);
|
||||||
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> () -> bus.addListener(Registry.Client::setup));
|
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> bus.addListener(Registry.Client::setup));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ import de.ellpeck.prettypipes.pipe.modules.stacksize.StackSizeModuleItem;
|
||||||
import de.ellpeck.prettypipes.pressurizer.PressurizerBlock;
|
import de.ellpeck.prettypipes.pressurizer.PressurizerBlock;
|
||||||
import de.ellpeck.prettypipes.pressurizer.PressurizerContainer;
|
import de.ellpeck.prettypipes.pressurizer.PressurizerContainer;
|
||||||
import de.ellpeck.prettypipes.pressurizer.PressurizerGui;
|
import de.ellpeck.prettypipes.pressurizer.PressurizerGui;
|
||||||
import de.ellpeck.prettypipes.pressurizer.PressurizerBlockEntity;
|
import de.ellpeck.prettypipes.pressurizer.PressurizerTileEntity;
|
||||||
import de.ellpeck.prettypipes.terminal.CraftingTerminalBlock;
|
import de.ellpeck.prettypipes.terminal.CraftingTerminalBlock;
|
||||||
import de.ellpeck.prettypipes.terminal.CraftingTerminalTileEntity;
|
import de.ellpeck.prettypipes.terminal.CraftingTerminalTileEntity;
|
||||||
import de.ellpeck.prettypipes.terminal.ItemTerminalBlock;
|
import de.ellpeck.prettypipes.terminal.ItemTerminalBlock;
|
||||||
|
@ -57,7 +57,7 @@ import net.minecraft.inventory.container.ContainerType;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.INBT;
|
import net.minecraft.nbt.INBT;
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
@ -116,7 +116,7 @@ public final class Registry {
|
||||||
public static EntityType<PipeFrameEntity> pipeFrameEntity;
|
public static EntityType<PipeFrameEntity> pipeFrameEntity;
|
||||||
|
|
||||||
public static Block pressurizerBlock;
|
public static Block pressurizerBlock;
|
||||||
public static TileEntityType<PressurizerBlockEntity> pressurizerTileEntity;
|
public static TileEntityType<PressurizerTileEntity> pressurizerTileEntity;
|
||||||
public static ContainerType<PressurizerContainer> pressurizerContainer;
|
public static ContainerType<PressurizerContainer> pressurizerContainer;
|
||||||
|
|
||||||
public static ContainerType<ExtractionModuleContainer> extractionModuleContainer;
|
public static ContainerType<ExtractionModuleContainer> extractionModuleContainer;
|
||||||
|
@ -169,7 +169,7 @@ public final class Registry {
|
||||||
pipeTileEntity = (TileEntityType<PipeTileEntity>) TileEntityType.Builder.create(PipeTileEntity::new, pipeBlock).build(null).setRegistryName("pipe"),
|
pipeTileEntity = (TileEntityType<PipeTileEntity>) TileEntityType.Builder.create(PipeTileEntity::new, pipeBlock).build(null).setRegistryName("pipe"),
|
||||||
itemTerminalTileEntity = (TileEntityType<ItemTerminalTileEntity>) TileEntityType.Builder.create(ItemTerminalTileEntity::new, itemTerminalBlock).build(null).setRegistryName("item_terminal"),
|
itemTerminalTileEntity = (TileEntityType<ItemTerminalTileEntity>) TileEntityType.Builder.create(ItemTerminalTileEntity::new, itemTerminalBlock).build(null).setRegistryName("item_terminal"),
|
||||||
craftingTerminalTileEntity = (TileEntityType<CraftingTerminalTileEntity>) TileEntityType.Builder.create(CraftingTerminalTileEntity::new, craftingTerminalBlock).build(null).setRegistryName("crafting_terminal"),
|
craftingTerminalTileEntity = (TileEntityType<CraftingTerminalTileEntity>) TileEntityType.Builder.create(CraftingTerminalTileEntity::new, craftingTerminalBlock).build(null).setRegistryName("crafting_terminal"),
|
||||||
pressurizerTileEntity = (TileEntityType<PressurizerBlockEntity>) TileEntityType.Builder.create(PressurizerBlockEntity::new, pressurizerBlock).build(null).setRegistryName("pressurizer")
|
pressurizerTileEntity = (TileEntityType<PressurizerTileEntity>) TileEntityType.Builder.create(PressurizerTileEntity::new, pressurizerBlock).build(null).setRegistryName("pressurizer")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ public final class Registry {
|
||||||
|
|
||||||
private static <T extends AbstractPipeContainer<?>> ContainerType<T> createPipeContainer(String name) {
|
private static <T extends AbstractPipeContainer<?>> ContainerType<T> createPipeContainer(String name) {
|
||||||
return (ContainerType<T>) IForgeContainerType.create((windowId, inv, data) -> {
|
return (ContainerType<T>) IForgeContainerType.create((windowId, inv, data) -> {
|
||||||
PipeTileEntity tile = Utility.getBlockEntity(PipeTileEntity.class, inv.player.world, data.readBlockPos());
|
PipeTileEntity tile = Utility.getTileEntity(PipeTileEntity.class, inv.player.world, data.readBlockPos());
|
||||||
int moduleIndex = data.readInt();
|
int moduleIndex = data.readInt();
|
||||||
ItemStack moduleStack = tile.modules.getStackInSlot(moduleIndex);
|
ItemStack moduleStack = tile.modules.getStackInSlot(moduleIndex);
|
||||||
return ((IModule) moduleStack.getItem()).getContainer(moduleStack, tile, windowId, inv, inv.player, moduleIndex);
|
return ((IModule) moduleStack.getItem()).getContainer(moduleStack, tile, windowId, inv, inv.player, moduleIndex);
|
||||||
|
|
|
@ -1,29 +1,30 @@
|
||||||
package de.ellpeck.prettypipes;
|
package de.ellpeck.prettypipes;
|
||||||
|
|
||||||
import net.minecraft.ChatFormatting;
|
import de.ellpeck.prettypipes.items.IModule;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import de.ellpeck.prettypipes.network.PipeItem;
|
||||||
import net.minecraft.client.resources.language.I18n;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.network.chat.*;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.inventory.ISidedInventory;
|
||||||
import net.minecraft.world.Containers;
|
import net.minecraft.inventory.ISidedInventoryProvider;
|
||||||
import net.minecraft.world.WorldlyContainer;
|
import net.minecraft.inventory.InventoryHelper;
|
||||||
import net.minecraft.world.WorldlyContainerHolder;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.nbt.ListNBT;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.level.ChunkPos;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
import net.minecraft.util.math.ChunkPos;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.util.text.*;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraftforge.common.util.INBTSerializable;
|
import net.minecraftforge.common.util.INBTSerializable;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||||
|
@ -33,54 +34,56 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public final class Utility {
|
public final class Utility {
|
||||||
|
|
||||||
public static <T extends BlockEntity> T getBlockEntity(Class<T> type, LevelAccessor world, BlockPos pos) {
|
public static <T extends TileEntity> T getTileEntity(Class<T> type, IBlockReader world, BlockPos pos) {
|
||||||
var tile = world.getBlockEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
return type.isInstance(tile) ? (T) tile : null;
|
return type.isInstance(tile) ? (T) tile : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dropInventory(BlockEntity tile, IItemHandler inventory) {
|
public static void dropInventory(TileEntity tile, IItemHandler inventory) {
|
||||||
var pos = tile.getBlockPos();
|
BlockPos pos = tile.getPos();
|
||||||
for (var i = 0; i < inventory.getSlots(); i++) {
|
for (int i = 0; i < inventory.getSlots(); i++) {
|
||||||
var stack = inventory.getStackInSlot(i);
|
ItemStack stack = inventory.getStackInSlot(i);
|
||||||
if (!stack.isEmpty())
|
if (!stack.isEmpty())
|
||||||
Containers.dropItemStack(tile.getLevel(), pos.getX(), pos.getY(), pos.getZ(), stack);
|
InventoryHelper.spawnItemStack(tile.getWorld(), pos.getX(), pos.getY(), pos.getZ(), stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Direction getDirectionFromOffset(BlockPos pos, BlockPos other) {
|
public static Direction getDirectionFromOffset(BlockPos pos, BlockPos other) {
|
||||||
var diff = pos.subtract(other);
|
BlockPos diff = pos.subtract(other);
|
||||||
return Direction.fromNormal(diff.getX(), diff.getY(), diff.getZ());
|
return Direction.getFacingFromVector(diff.getX(), diff.getY(), diff.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addTooltip(String name, List<MutableComponent> tooltip) {
|
public static void addTooltip(String name, List<ITextComponent> tooltip) {
|
||||||
if (Screen.hasShiftDown()) {
|
if (Screen.hasShiftDown()) {
|
||||||
var content = I18n.get("info." + PrettyPipes.ID + "." + name).split("\n");
|
String[] content = I18n.format("info." + PrettyPipes.ID + "." + name).split("\n");
|
||||||
for (var s : content)
|
for (String s : content)
|
||||||
tooltip.add(new TextComponent(s).setStyle(Style.EMPTY.applyFormat(ChatFormatting.GRAY)));
|
tooltip.add(new StringTextComponent(s).setStyle(Style.EMPTY.setFormatting(TextFormatting.GRAY)));
|
||||||
} else {
|
} else {
|
||||||
tooltip.add(new TranslatableComponent("info." + PrettyPipes.ID + ".shift").setStyle(Style.EMPTY.applyFormat(ChatFormatting.DARK_GRAY)));
|
tooltip.add(new TranslationTextComponent("info." + PrettyPipes.ID + ".shift").setStyle(Style.EMPTY.setFormatting(TextFormatting.DARK_GRAY)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack transferStackInSlot(AbstractContainerMenu container, IMergeItemStack merge, Player player, int slotIndex, Function<ItemStack, Pair<Integer, Integer>> predicate) {
|
public static ItemStack transferStackInSlot(Container container, IMergeItemStack merge, PlayerEntity player, int slotIndex, Function<ItemStack, Pair<Integer, Integer>> predicate) {
|
||||||
var inventoryStart = (int) container.slots.stream().filter(slot -> slot.container != player.getInventory()).count();
|
int inventoryStart = (int) container.inventorySlots.stream().filter(slot -> slot.inventory != player.inventory).count();
|
||||||
var inventoryEnd = inventoryStart + 26;
|
int inventoryEnd = inventoryStart + 26;
|
||||||
var hotbarStart = inventoryEnd + 1;
|
int hotbarStart = inventoryEnd + 1;
|
||||||
var hotbarEnd = hotbarStart + 8;
|
int hotbarEnd = hotbarStart + 8;
|
||||||
|
|
||||||
var slot = container.slots.get(slotIndex);
|
Slot slot = container.inventorySlots.get(slotIndex);
|
||||||
if (slot != null && slot.hasItem()) {
|
if (slot != null && slot.getHasStack()) {
|
||||||
var newStack = slot.getItem();
|
ItemStack newStack = slot.getStack();
|
||||||
var currentStack = newStack.copy();
|
ItemStack currentStack = newStack.copy();
|
||||||
|
|
||||||
if (slotIndex >= inventoryStart) {
|
if (slotIndex >= inventoryStart) {
|
||||||
// shift into this container here
|
// shift into this container here
|
||||||
// mergeItemStack with the slots that newStack should go into
|
// mergeItemStack with the slots that newStack should go into
|
||||||
// return an empty stack if mergeItemStack fails
|
// return an empty stack if mergeItemStack fails
|
||||||
var slots = predicate.apply(newStack);
|
Pair<Integer, Integer> slots = predicate.apply(newStack);
|
||||||
if (slots != null) {
|
if (slots != null) {
|
||||||
if (!merge.mergeItemStack(newStack, slots.getLeft(), slots.getRight(), false))
|
if (!merge.mergeItemStack(newStack, slots.getLeft(), slots.getRight(), false))
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
|
@ -96,9 +99,9 @@ public final class Utility {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
if (newStack.isEmpty()) {
|
if (newStack.isEmpty()) {
|
||||||
slot.set(ItemStack.EMPTY);
|
slot.putStack(ItemStack.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
slot.setChanged();
|
slot.onSlotChanged();
|
||||||
}
|
}
|
||||||
if (newStack.getCount() == currentStack.getCount())
|
if (newStack.getCount() == currentStack.getCount())
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
|
@ -108,44 +111,42 @@ public final class Utility {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ListTag serializeAll(Collection<? extends INBTSerializable<CompoundTag>> items) {
|
public static ListNBT serializeAll(Collection<? extends INBTSerializable<CompoundNBT>> items) {
|
||||||
var list = new ListTag();
|
ListNBT list = new ListNBT();
|
||||||
for (INBTSerializable<CompoundTag> item : items)
|
for (INBTSerializable<CompoundNBT> item : items)
|
||||||
list.add(item.serializeNBT());
|
list.add(item.serializeNBT());
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendBlockEntityToClients(BlockEntity tile) {
|
public static void sendTileEntityToClients(TileEntity tile) {
|
||||||
var world = (ServerLevel) tile.getLevel();
|
ServerWorld world = (ServerWorld) tile.getWorld();
|
||||||
var entities = world.getChunkSource().chunkMap.getPlayers(new ChunkPos(tile.getBlockPos()), false);
|
Stream<ServerPlayerEntity> entities = world.getChunkProvider().chunkManager.getTrackingPlayers(new ChunkPos(tile.getPos()), false);
|
||||||
var packet = ClientboundBlockEntityDataPacket.create(tile, t -> t.save(new CompoundTag()));
|
SUpdateTileEntityPacket packet = new SUpdateTileEntityPacket(tile.getPos(), -1, tile.write(new CompoundNBT()));
|
||||||
for (var e : entities)
|
entities.forEach(e -> e.connection.sendPacket(packet));
|
||||||
e.connection.send(packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends INBTSerializable<CompoundTag>> List<T> deserializeAll(ListTag list, Function<CompoundTag, T> supplier) {
|
public static <T extends INBTSerializable<CompoundNBT>> List<T> deserializeAll(ListNBT list, Function<CompoundNBT, T> supplier) {
|
||||||
List<T> items = new ArrayList<>();
|
List<T> items = new ArrayList<>();
|
||||||
for (var i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
var item = supplier.apply(list.getCompound(i));
|
T item = supplier.apply(list.getCompound(i));
|
||||||
if (item != null)
|
if (item != null)
|
||||||
items.add(item);
|
items.add(item);
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IItemHandler getBlockItemHandler(Level world, BlockPos pos, Direction direction) {
|
public static IItemHandler getBlockItemHandler(World world, BlockPos pos, Direction direction) {
|
||||||
var state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
var block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (!(block instanceof WorldlyContainerHolder holder))
|
if (!(block instanceof ISidedInventoryProvider))
|
||||||
return null;
|
return null;
|
||||||
var inventory = holder.getContainer(state, world, pos);
|
ISidedInventory inventory = ((ISidedInventoryProvider) block).createInventory(state, world, pos);
|
||||||
if (inventory == null)
|
if (inventory == null)
|
||||||
return null;
|
return null;
|
||||||
return new SidedInvWrapper(inventory, direction);
|
return new SidedInvWrapper(inventory, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IMergeItemStack {
|
public interface IMergeItemStack {
|
||||||
|
|
||||||
boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection);
|
boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/*
|
|
||||||
package de.ellpeck.prettypipes.compat.jei;
|
package de.ellpeck.prettypipes.compat.jei;
|
||||||
|
|
||||||
import de.ellpeck.prettypipes.misc.ItemEquality;
|
import de.ellpeck.prettypipes.misc.ItemEquality;
|
||||||
|
@ -10,7 +9,7 @@ import mezz.jei.api.gui.ingredient.IGuiIngredient;
|
||||||
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
||||||
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -51,4 +50,3 @@ public class CraftingModuleTransferHandler implements IRecipeTransferHandler<Cra
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/*
|
|
||||||
package de.ellpeck.prettypipes.compat.jei;
|
package de.ellpeck.prettypipes.compat.jei;
|
||||||
|
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
|
@ -14,7 +13,7 @@ import mezz.jei.api.recipe.transfer.IRecipeTransferError;
|
||||||
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.inventory.container.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -40,4 +39,3 @@ public class CraftingTerminalTransferHandler implements IRecipeTransferHandler<C
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
|
||||||
package de.ellpeck.prettypipes.compat.jei;
|
package de.ellpeck.prettypipes.compat.jei;
|
||||||
|
|
||||||
import de.ellpeck.prettypipes.PrettyPipes;
|
import de.ellpeck.prettypipes.PrettyPipes;
|
||||||
import de.ellpeck.prettypipes.misc.PlayerPrefs;
|
import de.ellpeck.prettypipes.misc.PlayerPrefs;
|
||||||
|
import de.ellpeck.prettypipes.terminal.containers.CraftingTerminalGui;
|
||||||
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalGui;
|
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalGui;
|
||||||
import mezz.jei.api.IModPlugin;
|
import mezz.jei.api.IModPlugin;
|
||||||
import mezz.jei.api.JeiPlugin;
|
import mezz.jei.api.JeiPlugin;
|
||||||
|
@ -17,7 +17,7 @@ import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.client.renderer.Rectangle2d;
|
import net.minecraft.client.renderer.Rectangle2d;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
|
@ -25,11 +25,15 @@ import net.minecraftforge.client.event.GuiScreenEvent;
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent;
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.event.TickEvent;
|
||||||
import net.minecraftforge.event.TickEvent.ClientTickEvent;
|
import net.minecraftforge.event.TickEvent.ClientTickEvent;
|
||||||
|
import net.minecraftforge.event.world.PistonEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
@JeiPlugin
|
@JeiPlugin
|
||||||
public class JEIPrettyPipesPlugin implements IModPlugin {
|
public class JEIPrettyPipesPlugin implements IModPlugin {
|
||||||
|
@ -133,4 +137,3 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
|
@ -4,82 +4,74 @@ import de.ellpeck.prettypipes.Registry;
|
||||||
import de.ellpeck.prettypipes.network.NetworkLocation;
|
import de.ellpeck.prettypipes.network.NetworkLocation;
|
||||||
import de.ellpeck.prettypipes.network.PipeNetwork;
|
import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeBlock;
|
import de.ellpeck.prettypipes.pipe.PipeBlock;
|
||||||
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.item.ItemFrameEntity;
|
import net.minecraft.entity.item.ItemFrameEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.FilledMapItem;
|
import net.minecraft.item.FilledMapItem;
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
|
||||||
import net.minecraft.world.entity.EntityType;
|
|
||||||
import net.minecraft.world.entity.decoration.ItemFrame;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.network.IPacket;
|
import net.minecraft.network.IPacket;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.network.datasync.DataParameter;
|
import net.minecraft.network.datasync.DataParameter;
|
||||||
import net.minecraft.network.datasync.DataSerializers;
|
import net.minecraft.network.datasync.DataSerializers;
|
||||||
import net.minecraft.network.datasync.EntityDataManager;
|
import net.minecraft.network.datasync.EntityDataManager;
|
||||||
|
import net.minecraft.util.*;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.world.GameRules;
|
import net.minecraft.world.GameRules;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.storage.MapData;
|
import net.minecraft.world.storage.MapData;
|
||||||
import net.minecraftforge.entity.IEntityAdditionalSpawnData;
|
|
||||||
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
|
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawnData {
|
public class PipeFrameEntity extends ItemFrameEntity implements IEntityAdditionalSpawnData {
|
||||||
|
|
||||||
private static final EntityDataAccessor<Integer> AMOUNT = SynchedEntityData.defineId(PipeFrameEntity.class, EntityDataSerializers.INT);
|
private static final DataParameter<Integer> AMOUNT = EntityDataManager.createKey(PipeFrameEntity.class, DataSerializers.VARINT);
|
||||||
|
|
||||||
public PipeFrameEntity(EntityType<PipeFrameEntity> type, Level world) {
|
public PipeFrameEntity(EntityType<PipeFrameEntity> type, World world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PipeFrameEntity(EntityType<PipeFrameEntity> type, Level world, BlockPos pos, Direction dir) {
|
public PipeFrameEntity(EntityType<PipeFrameEntity> type, World world, BlockPos pos, Direction dir) {
|
||||||
this(type, world);
|
this(type, world);
|
||||||
this.pos = pos;
|
this.hangingPosition = pos;
|
||||||
this.setDirection(dir);
|
this.updateFacingWithBoundingBox(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void defineSynchedData() {
|
protected void registerData() {
|
||||||
super.defineSynchedData();
|
super.registerData();
|
||||||
this.entityData.define(AMOUNT, -1);
|
this.dataManager.register(AMOUNT, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
if (this.level.isClientSide)
|
if (this.world.isRemote)
|
||||||
return;
|
return;
|
||||||
if (this.tickCount % 40 != 0)
|
if (this.ticksExisted % 40 != 0)
|
||||||
return;
|
return;
|
||||||
PipeNetwork network = PipeNetwork.get(this.level);
|
PipeNetwork network = PipeNetwork.get(this.world);
|
||||||
BlockPos attached = getAttachedPipe(this.level, this.pos, this.direction);
|
BlockPos attached = getAttachedPipe(this.world, this.hangingPosition, this.facingDirection);
|
||||||
if (attached != null) {
|
if (attached != null) {
|
||||||
BlockPos node = network.getNodeFromPipe(attached);
|
BlockPos node = network.getNodeFromPipe(attached);
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
ItemStack stack = this.getItem();
|
ItemStack stack = this.getDisplayedItem();
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
List<NetworkLocation> items = network.getOrderedNetworkItems(node);
|
List<NetworkLocation> items = network.getOrderedNetworkItems(node);
|
||||||
int amount = items.stream().mapToInt(i -> i.getItemAmount(this.level, stack)).sum();
|
int amount = items.stream().mapToInt(i -> i.getItemAmount(this.world, stack)).sum();
|
||||||
this.entityData.set(AMOUNT, amount);
|
this.dataManager.set(AMOUNT, amount);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.entityData.set(AMOUNT, -1);
|
this.dataManager.set(AMOUNT, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,9 +79,9 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
|
||||||
return super.onValidSurface() && canPlace(this.world, this.hangingPosition, this.facingDirection);
|
return super.onValidSurface() && canPlace(this.world, this.hangingPosition, this.facingDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BlockPos getAttachedPipe(Level world, BlockPos pos, Direction direction) {
|
private static BlockPos getAttachedPipe(World world, BlockPos pos, Direction direction) {
|
||||||
for (int i = 1; i <= 2; i++) {
|
for (int i = 1; i <= 2; i++) {
|
||||||
BlockPos offset = pos.relative(direction.getOpposite(), i);
|
BlockPos offset = pos.offset(direction.getOpposite(), i);
|
||||||
BlockState state = world.getBlockState(offset);
|
BlockState state = world.getBlockState(offset);
|
||||||
if (state.getBlock() instanceof PipeBlock)
|
if (state.getBlock() instanceof PipeBlock)
|
||||||
return offset;
|
return offset;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -20,6 +20,7 @@ import net.minecraftforge.items.IItemHandler;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package de.ellpeck.prettypipes.items;
|
||||||
import de.ellpeck.prettypipes.Registry;
|
import de.ellpeck.prettypipes.Registry;
|
||||||
import de.ellpeck.prettypipes.Utility;
|
import de.ellpeck.prettypipes.Utility;
|
||||||
import de.ellpeck.prettypipes.entities.PipeFrameEntity;
|
import de.ellpeck.prettypipes.entities.PipeFrameEntity;
|
||||||
|
import de.ellpeck.prettypipes.pipe.PipeBlock;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
|
@ -11,9 +12,9 @@ import net.minecraft.entity.item.ItemFrameEntity;
|
||||||
import net.minecraft.entity.item.PaintingEntity;
|
import net.minecraft.entity.item.PaintingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.ItemUseContext;
|
import net.minecraft.item.ItemUseContext;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -42,9 +43,9 @@ public class PipeFrameItem extends Item {
|
||||||
World world = context.getWorld();
|
World world = context.getWorld();
|
||||||
HangingEntity hangingentity = new PipeFrameEntity(Registry.pipeFrameEntity, world, blockpos1, direction);
|
HangingEntity hangingentity = new PipeFrameEntity(Registry.pipeFrameEntity, world, blockpos1, direction);
|
||||||
|
|
||||||
CompoundTag CompoundTag = itemstack.getTag();
|
CompoundNBT compoundnbt = itemstack.getTag();
|
||||||
if (CompoundTag != null) {
|
if (compoundnbt != null) {
|
||||||
EntityType.applyItemNBT(world, playerentity, hangingentity, CompoundTag);
|
EntityType.applyItemNBT(world, playerentity, hangingentity, compoundnbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hangingentity.onValidSurface()) {
|
if (hangingentity.onValidSurface()) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class WrenchItem extends Item {
|
||||||
BlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
if (!(state.getBlock() instanceof PipeBlock))
|
if (!(state.getBlock() instanceof PipeBlock))
|
||||||
return ActionResultType.PASS;
|
return ActionResultType.PASS;
|
||||||
PipeTileEntity tile = Utility.getBlockEntity(PipeTileEntity.class, world, pos);
|
PipeTileEntity tile = Utility.getTileEntity(PipeTileEntity.class, world, pos);
|
||||||
if (tile == null)
|
if (tile == null)
|
||||||
return ActionResultType.FAIL;
|
return ActionResultType.FAIL;
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public class WrenchItem extends Item {
|
||||||
if (tile.cover != null) {
|
if (tile.cover != null) {
|
||||||
// remove the cover
|
// remove the cover
|
||||||
tile.removeCover(player, context.getHand());
|
tile.removeCover(player, context.getHand());
|
||||||
Utility.sendBlockEntityToClients(tile);
|
Utility.sendTileEntityToClients(tile);
|
||||||
} else {
|
} else {
|
||||||
// remove the pipe
|
// remove the pipe
|
||||||
PipeBlock.dropItems(world, pos, player);
|
PipeBlock.dropItems(world, pos, player);
|
||||||
|
@ -71,7 +71,7 @@ public class WrenchItem extends Item {
|
||||||
BlockState cover = block.getStateForPlacement(blockContext);
|
BlockState cover = block.getStateForPlacement(blockContext);
|
||||||
if (cover != null && !block.hasTileEntity(cover)) {
|
if (cover != null && !block.hasTileEntity(cover)) {
|
||||||
tile.cover = cover;
|
tile.cover = cover;
|
||||||
Utility.sendBlockEntityToClients(tile);
|
Utility.sendTileEntityToClients(tile);
|
||||||
offhand.shrink(1);
|
offhand.shrink(1);
|
||||||
world.playSound(null, pos, SoundEvents.ENTITY_ITEM_FRAME_ADD_ITEM, SoundCategory.PLAYERS, 1, 1);
|
world.playSound(null, pos, SoundEvents.ENTITY_ITEM_FRAME_ADD_ITEM, SoundCategory.PLAYERS, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.ellpeck.prettypipes.misc;
|
package de.ellpeck.prettypipes.misc;
|
||||||
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package de.ellpeck.prettypipes.misc;
|
||||||
|
|
||||||
import de.ellpeck.prettypipes.PrettyPipes;
|
import de.ellpeck.prettypipes.PrettyPipes;
|
||||||
import de.ellpeck.prettypipes.network.PipeNetwork;
|
import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
|
@ -3,7 +3,7 @@ package de.ellpeck.prettypipes.misc;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.inventory.container.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
package de.ellpeck.prettypipes.misc;
|
package de.ellpeck.prettypipes.misc;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class ItemEquality {
|
public class ItemEquality {
|
||||||
|
|
||||||
public static final ItemEquality DAMAGE = new ItemEquality((stack, filter) -> stack.getDamageValue() == filter.getDamageValue(), false, Type.DAMAGE);
|
public static final ItemEquality DAMAGE = new ItemEquality((stack, filter) -> stack.getDamage() == filter.getDamage(), false, Type.DAMAGE);
|
||||||
public static final ItemEquality NBT = new ItemEquality(ItemStack::isSameItemSameTags, false, Type.NBT);
|
public static final ItemEquality NBT = new ItemEquality(ItemStack::areItemStackTagsEqual, false, Type.NBT);
|
||||||
public static final ItemEquality MOD = new ItemEquality((stack, filter) -> stack.getItem().getCreatorModId(stack).equals(filter.getItem().getCreatorModId(filter)), true, Type.MOD);
|
public static final ItemEquality MOD = new ItemEquality((stack, filter) -> stack.getItem().getCreatorModId(stack).equals(filter.getItem().getCreatorModId(filter)), true, Type.MOD);
|
||||||
|
|
||||||
public final Type type;
|
public final Type type;
|
||||||
|
@ -28,10 +27,10 @@ public class ItemEquality {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean compareItems(ItemStack stack, ItemStack filter, ItemEquality... types) {
|
public static boolean compareItems(ItemStack stack, ItemStack filter, ItemEquality... types) {
|
||||||
var equal = ItemStack.isSameIgnoreDurability(stack, filter);
|
boolean equal = ItemStack.areItemsEqual(stack, filter);
|
||||||
if (types.length <= 0)
|
if (types.length <= 0)
|
||||||
return equal;
|
return equal;
|
||||||
for (var type : types) {
|
for (ItemEquality type : types) {
|
||||||
if (!type.ignoreItemEquality && !equal)
|
if (!type.ignoreItemEquality && !equal)
|
||||||
return false;
|
return false;
|
||||||
if (!type.filter.apply(stack, filter))
|
if (!type.filter.apply(stack, filter))
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
package de.ellpeck.prettypipes.misc;
|
package de.ellpeck.prettypipes.misc;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import de.ellpeck.prettypipes.PrettyPipes;
|
import de.ellpeck.prettypipes.PrettyPipes;
|
||||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import de.ellpeck.prettypipes.pipe.modules.modifier.FilterModifierModuleItem;
|
import de.ellpeck.prettypipes.pipe.modules.modifier.FilterModifierModuleItem;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.widget.Widget;
|
||||||
import net.minecraft.client.gui.components.Widget;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
@ -51,17 +53,17 @@ public class ItemFilter extends ItemStackHandler {
|
||||||
public List<Widget> getButtons(Screen gui, int x, int y) {
|
public List<Widget> getButtons(Screen gui, int x, int y) {
|
||||||
List<Widget> buttons = new ArrayList<>();
|
List<Widget> buttons = new ArrayList<>();
|
||||||
if (this.canModifyWhitelist) {
|
if (this.canModifyWhitelist) {
|
||||||
Supplier<TranslatableComponent> whitelistText = () -> new TranslatableComponent("info." + PrettyPipes.ID + "." + (this.isWhitelist ? "whitelist" : "blacklist"));
|
Supplier<TranslationTextComponent> whitelistText = () -> new TranslationTextComponent("info." + PrettyPipes.ID + "." + (this.isWhitelist ? "whitelist" : "blacklist"));
|
||||||
buttons.add(new Button(x, y, 70, 20, whitelistText.get(), button -> {
|
buttons.add(new Button(x, y, 70, 20, whitelistText.get(), button -> {
|
||||||
PacketButton.sendAndExecute(this.pipe.getPos(), PacketButton.ButtonResult.FILTER_CHANGE, 0);
|
PacketButton.sendAndExecute(this.pipe.getPos(), PacketButton.ButtonResult.FILTER_CHANGE, 0);
|
||||||
button.setMessage(whitelistText.get());
|
button.setMessage(whitelistText.get());
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
if (this.canPopulateFromInventories) {
|
if (this.canPopulateFromInventories) {
|
||||||
buttons.add(new Button(x + 72, y, 70, 20, new TranslatableComponent("info." + PrettyPipes.ID + ".populate"), button -> PacketButton.sendAndExecute(this.pipe.getPos(), PacketButton.ButtonResult.FILTER_CHANGE, 1)) {
|
buttons.add(new Button(x + 72, y, 70, 20, new TranslationTextComponent("info." + PrettyPipes.ID + ".populate"), button -> PacketButton.sendAndExecute(this.pipe.getPos(), PacketButton.ButtonResult.FILTER_CHANGE, 1)) {
|
||||||
@Override
|
@Override
|
||||||
public void renderToolTip(PoseStack matrix, int x, int y) {
|
public void renderToolTip(MatrixStack matrix, int x, int y) {
|
||||||
gui.renderTooltip(matrix, new TranslatableComponent("info." + PrettyPipes.ID + ".populate.description").withStyle(ChatFormatting.GRAY), x, y);
|
gui.renderTooltip(matrix, new TranslationTextComponent("info." + PrettyPipes.ID + ".populate.description").mergeStyle(TextFormatting.GRAY), x, y);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -125,15 +127,15 @@ public class ItemFilter extends ItemStackHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag serializeNBT() {
|
public CompoundNBT serializeNBT() {
|
||||||
CompoundTag nbt = super.serializeNBT();
|
CompoundNBT nbt = super.serializeNBT();
|
||||||
if (this.canModifyWhitelist)
|
if (this.canModifyWhitelist)
|
||||||
nbt.putBoolean("whitelist", this.isWhitelist);
|
nbt.putBoolean("whitelist", this.isWhitelist);
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deserializeNBT(CompoundTag nbt) {
|
public void deserializeNBT(CompoundNBT nbt) {
|
||||||
super.deserializeNBT(nbt);
|
super.deserializeNBT(nbt);
|
||||||
if (this.canModifyWhitelist)
|
if (this.canModifyWhitelist)
|
||||||
this.isWhitelist = nbt.getBoolean("whitelist");
|
this.isWhitelist = nbt.getBoolean("whitelist");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.ellpeck.prettypipes.misc;
|
package de.ellpeck.prettypipes.misc;
|
||||||
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ import net.minecraft.client.gui.FontRenderer;
|
||||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||||
import net.minecraft.client.gui.widget.Widget;
|
import net.minecraft.client.gui.widget.Widget;
|
||||||
import net.minecraft.client.renderer.ItemRenderer;
|
import net.minecraft.client.renderer.ItemRenderer;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraft.util.text.TextComponent;
|
import net.minecraft.util.text.TextComponent;
|
||||||
|
|
|
@ -2,6 +2,7 @@ package de.ellpeck.prettypipes.misc;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
import de.ellpeck.prettypipes.PrettyPipes;
|
import de.ellpeck.prettypipes.PrettyPipes;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
package de.ellpeck.prettypipes.network;
|
package de.ellpeck.prettypipes.network;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.ListNBT;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.nbt.NbtUtils;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraftforge.common.util.Constants;
|
||||||
import net.minecraftforge.common.util.INBTSerializable;
|
import net.minecraftforge.common.util.INBTSerializable;
|
||||||
import org.jgrapht.graph.DefaultWeightedEdge;
|
import org.jgrapht.graph.DefaultWeightedEdge;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class NetworkEdge extends DefaultWeightedEdge implements INBTSerializable<CompoundTag> {
|
public class NetworkEdge extends DefaultWeightedEdge implements INBTSerializable<CompoundNBT> {
|
||||||
|
|
||||||
public final List<BlockPos> pipes = new ArrayList<>();
|
public final List<BlockPos> pipes = new ArrayList<>();
|
||||||
|
|
||||||
public NetworkEdge() {
|
public NetworkEdge() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkEdge(CompoundTag nbt) {
|
public NetworkEdge(CompoundNBT nbt) {
|
||||||
this.deserializeNBT(nbt);
|
this.deserializeNBT(nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,20 +31,20 @@ public class NetworkEdge extends DefaultWeightedEdge implements INBTSerializable
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag serializeNBT() {
|
public CompoundNBT serializeNBT() {
|
||||||
CompoundTag nbt = new CompoundTag();
|
CompoundNBT nbt = new CompoundNBT();
|
||||||
ListTag list = new ListTag();
|
ListNBT list = new ListNBT();
|
||||||
for (BlockPos pos : this.pipes)
|
for (BlockPos pos : this.pipes)
|
||||||
list.add(NbtUtils.writeBlockPos(pos));
|
list.add(NBTUtil.writeBlockPos(pos));
|
||||||
nbt.put("pipes", list);
|
nbt.put("pipes", list);
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deserializeNBT(CompoundTag nbt) {
|
public void deserializeNBT(CompoundNBT nbt) {
|
||||||
this.pipes.clear();
|
this.pipes.clear();
|
||||||
ListTag list = nbt.getList("pipes", Tag.TAG_COMPOUND);
|
ListNBT list = nbt.getList("pipes", Constants.NBT.TAG_COMPOUND);
|
||||||
for (int i = 0; i < list.size(); i++)
|
for (int i = 0; i < list.size(); i++)
|
||||||
this.pipes.add(NbtUtils.readBlockPos(list.getCompound(i)));
|
this.pipes.add(NBTUtil.readBlockPos(list.getCompound(i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package de.ellpeck.prettypipes.network;
|
package de.ellpeck.prettypipes.network;
|
||||||
|
|
||||||
import de.ellpeck.prettypipes.misc.EquatableItemStack;
|
import de.ellpeck.prettypipes.misc.EquatableItemStack;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ package de.ellpeck.prettypipes.network;
|
||||||
|
|
||||||
import de.ellpeck.prettypipes.misc.ItemEquality;
|
import de.ellpeck.prettypipes.misc.ItemEquality;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.nbt.NBTUtil;
|
import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -17,7 +17,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class NetworkLocation implements INBTSerializable<CompoundTag> {
|
public class NetworkLocation implements INBTSerializable<CompoundNBT> {
|
||||||
|
|
||||||
public BlockPos pipePos;
|
public BlockPos pipePos;
|
||||||
public Direction direction;
|
public Direction direction;
|
||||||
|
@ -29,7 +29,7 @@ public class NetworkLocation implements INBTSerializable<CompoundTag> {
|
||||||
this.direction = direction;
|
this.direction = direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkLocation(CompoundTag nbt) {
|
public NetworkLocation(CompoundNBT nbt) {
|
||||||
this.deserializeNBT(nbt);
|
this.deserializeNBT(nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,15 +92,15 @@ public class NetworkLocation implements INBTSerializable<CompoundTag> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag serializeNBT() {
|
public CompoundNBT serializeNBT() {
|
||||||
CompoundTag nbt = new CompoundTag();
|
CompoundNBT nbt = new CompoundNBT();
|
||||||
nbt.put("pipe_pos", NBTUtil.writeBlockPos(this.pipePos));
|
nbt.put("pipe_pos", NBTUtil.writeBlockPos(this.pipePos));
|
||||||
nbt.putInt("direction", this.direction.getIndex());
|
nbt.putInt("direction", this.direction.getIndex());
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deserializeNBT(CompoundTag nbt) {
|
public void deserializeNBT(CompoundNBT nbt) {
|
||||||
this.pipePos = NBTUtil.readBlockPos(nbt.getCompound("pipe_pos"));
|
this.pipePos = NBTUtil.readBlockPos(nbt.getCompound("pipe_pos"));
|
||||||
this.direction = Direction.byIndex(nbt.getInt("direction"));
|
this.direction = Direction.byIndex(nbt.getInt("direction"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
package de.ellpeck.prettypipes.network;
|
package de.ellpeck.prettypipes.network;
|
||||||
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListNBT;
|
||||||
import net.minecraftforge.common.util.INBTSerializable;
|
import net.minecraftforge.common.util.INBTSerializable;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class NetworkLock implements INBTSerializable<CompoundTag> {
|
public class NetworkLock implements INBTSerializable<CompoundNBT> {
|
||||||
|
|
||||||
// identify locks by UUID since network locks can't be identified by location and locked item alone
|
// identify locks by UUID since network locks can't be identified by location and locked item alone
|
||||||
// (two locks could be set for the same item and the same amount if it exists twice in the chest)
|
// (two locks could be set for the same item and the same amount if it exists twice in the chest)
|
||||||
|
@ -21,21 +22,21 @@ public class NetworkLock implements INBTSerializable<CompoundTag> {
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkLock(CompoundTag nbt) {
|
public NetworkLock(CompoundNBT nbt) {
|
||||||
this.deserializeNBT(nbt);
|
this.deserializeNBT(nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag serializeNBT() {
|
public CompoundNBT serializeNBT() {
|
||||||
CompoundTag nbt = new CompoundTag();
|
CompoundNBT nbt = new CompoundNBT();
|
||||||
nbt.putUniqueId("id", this.lockId);
|
nbt.putUniqueId("id", this.lockId);
|
||||||
nbt.put("location", this.location.serializeNBT());
|
nbt.put("location", this.location.serializeNBT());
|
||||||
nbt.put("stack", this.stack.write(new CompoundTag()));
|
nbt.put("stack", this.stack.write(new CompoundNBT()));
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deserializeNBT(CompoundTag nbt) {
|
public void deserializeNBT(CompoundNBT nbt) {
|
||||||
this.lockId = nbt.getUniqueId("id");
|
this.lockId = nbt.getUniqueId("id");
|
||||||
this.location = new NetworkLocation(nbt.getCompound("location"));
|
this.location = new NetworkLocation(nbt.getCompound("location"));
|
||||||
this.stack = ItemStack.read(nbt.getCompound("stack"));
|
this.stack = ItemStack.read(nbt.getCompound("stack"));
|
||||||
|
|
|
@ -12,12 +12,12 @@ import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListNBT;
|
||||||
import net.minecraft.nbt.NBTUtil;
|
import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
|
@ -67,7 +67,7 @@ public class PipeItem implements IPipeItem {
|
||||||
this(TYPE, stack, speed);
|
this(TYPE, stack, speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PipeItem(ResourceLocation type, CompoundTag nbt) {
|
public PipeItem(ResourceLocation type, CompoundNBT nbt) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.path = new ArrayList<>();
|
this.path = new ArrayList<>();
|
||||||
this.deserializeNBT(nbt);
|
this.deserializeNBT(nbt);
|
||||||
|
@ -244,8 +244,8 @@ public class PipeItem implements IPipeItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag serializeNBT() {
|
public CompoundNBT serializeNBT() {
|
||||||
CompoundTag nbt = new CompoundTag();
|
CompoundNBT nbt = new CompoundNBT();
|
||||||
nbt.putString("type", this.type.toString());
|
nbt.putString("type", this.type.toString());
|
||||||
nbt.put("stack", this.stack.serializeNBT());
|
nbt.put("stack", this.stack.serializeNBT());
|
||||||
nbt.putFloat("speed", this.speed);
|
nbt.putFloat("speed", this.speed);
|
||||||
|
@ -257,7 +257,7 @@ public class PipeItem implements IPipeItem {
|
||||||
nbt.putFloat("x", this.x);
|
nbt.putFloat("x", this.x);
|
||||||
nbt.putFloat("y", this.y);
|
nbt.putFloat("y", this.y);
|
||||||
nbt.putFloat("z", this.z);
|
nbt.putFloat("z", this.z);
|
||||||
ListTag list = new ListTag();
|
ListNBT list = new ListNBT();
|
||||||
for (BlockPos pos : this.path)
|
for (BlockPos pos : this.path)
|
||||||
list.add(NBTUtil.writeBlockPos(pos));
|
list.add(NBTUtil.writeBlockPos(pos));
|
||||||
nbt.put("path", list);
|
nbt.put("path", list);
|
||||||
|
@ -265,7 +265,7 @@ public class PipeItem implements IPipeItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deserializeNBT(CompoundTag nbt) {
|
public void deserializeNBT(CompoundNBT nbt) {
|
||||||
this.stack = ItemStack.read(nbt.getCompound("stack"));
|
this.stack = ItemStack.read(nbt.getCompound("stack"));
|
||||||
this.speed = nbt.getFloat("speed");
|
this.speed = nbt.getFloat("speed");
|
||||||
this.startInventory = NBTUtil.readBlockPos(nbt.getCompound("start_inv"));
|
this.startInventory = NBTUtil.readBlockPos(nbt.getCompound("start_inv"));
|
||||||
|
@ -277,7 +277,7 @@ public class PipeItem implements IPipeItem {
|
||||||
this.y = nbt.getFloat("y");
|
this.y = nbt.getFloat("y");
|
||||||
this.z = nbt.getFloat("z");
|
this.z = nbt.getFloat("z");
|
||||||
this.path.clear();
|
this.path.clear();
|
||||||
ListTag list = nbt.getList("path", Constants.NBT.TAG_COMPOUND);
|
ListNBT list = nbt.getList("path", Constants.NBT.TAG_COMPOUND);
|
||||||
for (int i = 0; i < list.size(); i++)
|
for (int i = 0; i < list.size(); i++)
|
||||||
this.path.add(NBTUtil.readBlockPos(list.getCompound(i)));
|
this.path.add(NBTUtil.readBlockPos(list.getCompound(i)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,18 +13,13 @@ import de.ellpeck.prettypipes.pipe.IPipeItem;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeBlock;
|
import de.ellpeck.prettypipes.pipe.PipeBlock;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.nbt.*;
|
import net.minecraft.nbt.ListNBT;
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.ListTag;
|
|
||||||
import net.minecraft.nbt.NBTUtil;
|
import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
||||||
import net.minecraftforge.common.util.Constants.NBT;
|
import net.minecraftforge.common.util.Constants.NBT;
|
||||||
|
@ -51,7 +46,7 @@ import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class PipeNetwork implements ICapabilitySerializable<CompoundTag>, GraphListener<BlockPos, NetworkEdge> {
|
public class PipeNetwork implements ICapabilitySerializable<CompoundNBT>, GraphListener<BlockPos, NetworkEdge> {
|
||||||
|
|
||||||
public final ListenableGraph<BlockPos, NetworkEdge> graph;
|
public final ListenableGraph<BlockPos, NetworkEdge> graph;
|
||||||
private final DijkstraShortestPath<BlockPos, NetworkEdge> dijkstra;
|
private final DijkstraShortestPath<BlockPos, NetworkEdge> dijkstra;
|
||||||
|
@ -59,10 +54,10 @@ public class PipeNetwork implements ICapabilitySerializable<CompoundTag>, GraphL
|
||||||
private final Map<BlockPos, PipeTileEntity> tileCache = new HashMap<>();
|
private final Map<BlockPos, PipeTileEntity> tileCache = new HashMap<>();
|
||||||
private final ListMultimap<BlockPos, IPipeItem> pipeItems = ArrayListMultimap.create();
|
private final ListMultimap<BlockPos, IPipeItem> pipeItems = ArrayListMultimap.create();
|
||||||
private final ListMultimap<BlockPos, NetworkLock> networkLocks = ArrayListMultimap.create();
|
private final ListMultimap<BlockPos, NetworkLock> networkLocks = ArrayListMultimap.create();
|
||||||
private final Level world;
|
private final World world;
|
||||||
private final LazyOptional<PipeNetwork> lazyThis = LazyOptional.of(() -> this);
|
private final LazyOptional<PipeNetwork> lazyThis = LazyOptional.of(() -> this);
|
||||||
|
|
||||||
public PipeNetwork(Level world) {
|
public PipeNetwork(World world) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.graph = new DefaultListenableGraph<>(new SimpleWeightedGraph<>(NetworkEdge.class));
|
this.graph = new DefaultListenableGraph<>(new SimpleWeightedGraph<>(NetworkEdge.class));
|
||||||
this.graph.addGraphListener(this);
|
this.graph.addGraphListener(this);
|
||||||
|
@ -76,13 +71,13 @@ public class PipeNetwork implements ICapabilitySerializable<CompoundTag>, GraphL
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag serializeNBT() {
|
public CompoundNBT serializeNBT() {
|
||||||
CompoundTag nbt = new CompoundTag();
|
CompoundNBT nbt = new CompoundNBT();
|
||||||
ListTag nodes = new ListTag();
|
ListNBT nodes = new ListNBT();
|
||||||
for (BlockPos node : this.graph.vertexSet())
|
for (BlockPos node : this.graph.vertexSet())
|
||||||
nodes.add(NbtUtils.writeBlockPos(node));
|
nodes.add(NBTUtil.writeBlockPos(node));
|
||||||
nbt.put("nodes", nodes);
|
nbt.put("nodes", nodes);
|
||||||
ListTag edges = new ListTag();
|
ListNBT edges = new ListNBT();
|
||||||
for (NetworkEdge edge : this.graph.edgeSet())
|
for (NetworkEdge edge : this.graph.edgeSet())
|
||||||
edges.add(edge.serializeNBT());
|
edges.add(edge.serializeNBT());
|
||||||
nbt.put("edges", edges);
|
nbt.put("edges", edges);
|
||||||
|
@ -92,15 +87,15 @@ public class PipeNetwork implements ICapabilitySerializable<CompoundTag>, GraphL
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deserializeNBT(CompoundTag nbt) {
|
public void deserializeNBT(CompoundNBT nbt) {
|
||||||
this.graph.removeAllVertices(new ArrayList<>(this.graph.vertexSet()));
|
this.graph.removeAllVertices(new ArrayList<>(this.graph.vertexSet()));
|
||||||
this.pipeItems.clear();
|
this.pipeItems.clear();
|
||||||
this.networkLocks.clear();
|
this.networkLocks.clear();
|
||||||
|
|
||||||
ListTag nodes = nbt.getList("nodes", Tag.TAG_COMPOUND);
|
ListNBT nodes = nbt.getList("nodes", NBT.TAG_COMPOUND);
|
||||||
for (int i = 0; i < nodes.size(); i++)
|
for (int i = 0; i < nodes.size(); i++)
|
||||||
this.graph.addVertex(NBTUtil.readBlockPos(nodes.getCompound(i)));
|
this.graph.addVertex(NBTUtil.readBlockPos(nodes.getCompound(i)));
|
||||||
ListTag edges = nbt.getList("edges", Tag.TAG_COMPOUND);
|
ListNBT edges = nbt.getList("edges", NBT.TAG_COMPOUND);
|
||||||
for (int i = 0; i < edges.size(); i++)
|
for (int i = 0; i < edges.size(); i++)
|
||||||
this.addEdge(new NetworkEdge(edges.getCompound(i)));
|
this.addEdge(new NetworkEdge(edges.getCompound(i)));
|
||||||
for (IPipeItem item : Utility.deserializeAll(nbt.getList("items", NBT.TAG_COMPOUND), IPipeItem::load))
|
for (IPipeItem item : Utility.deserializeAll(nbt.getList("items", NBT.TAG_COMPOUND), IPipeItem::load))
|
||||||
|
@ -252,7 +247,7 @@ public class PipeNetwork implements ICapabilitySerializable<CompoundTag>, GraphL
|
||||||
public PipeTileEntity getPipe(BlockPos pos) {
|
public PipeTileEntity getPipe(BlockPos pos) {
|
||||||
PipeTileEntity tile = this.tileCache.get(pos);
|
PipeTileEntity tile = this.tileCache.get(pos);
|
||||||
if (tile == null || tile.isRemoved()) {
|
if (tile == null || tile.isRemoved()) {
|
||||||
tile = Utility.getBlockEntity(PipeTileEntity.class, this.world, pos);
|
tile = Utility.getTileEntity(PipeTileEntity.class, this.world, pos);
|
||||||
this.tileCache.put(pos, tile);
|
this.tileCache.put(pos, tile);
|
||||||
}
|
}
|
||||||
return tile;
|
return tile;
|
||||||
|
@ -522,7 +517,7 @@ public class PipeNetwork implements ICapabilitySerializable<CompoundTag>, GraphL
|
||||||
this.world.getProfiler().endSection();
|
this.world.getProfiler().endSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PipeNetwork get(Level world) {
|
public static PipeNetwork get(World world) {
|
||||||
return world.getCapability(Registry.pipeNetworkCapability).orElse(null);
|
return world.getCapability(Registry.pipeNetworkCapability).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
@ -77,7 +77,7 @@ public class PacketButton {
|
||||||
|
|
||||||
public enum ButtonResult {
|
public enum ButtonResult {
|
||||||
PIPE_TAB((pos, data, player) -> {
|
PIPE_TAB((pos, data, player) -> {
|
||||||
PipeTileEntity tile = Utility.getBlockEntity(PipeTileEntity.class, player.world, pos);
|
PipeTileEntity tile = Utility.getTileEntity(PipeTileEntity.class, player.world, pos);
|
||||||
if (data[0] < 0) {
|
if (data[0] < 0) {
|
||||||
NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
|
NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
|
||||||
} else {
|
} else {
|
||||||
|
@ -113,11 +113,11 @@ public class PacketButton {
|
||||||
StackSizeModuleItem.setMaxStackSize(container.moduleStack, data[0]);
|
StackSizeModuleItem.setMaxStackSize(container.moduleStack, data[0]);
|
||||||
}),
|
}),
|
||||||
CRAFT_TERMINAL_REQUEST((pos, data, player) -> {
|
CRAFT_TERMINAL_REQUEST((pos, data, player) -> {
|
||||||
CraftingTerminalTileEntity tile = Utility.getBlockEntity(CraftingTerminalTileEntity.class, player.world, pos);
|
CraftingTerminalTileEntity tile = Utility.getTileEntity(CraftingTerminalTileEntity.class, player.world, pos);
|
||||||
tile.requestCraftingItems(player, data[0]);
|
tile.requestCraftingItems(player, data[0]);
|
||||||
}),
|
}),
|
||||||
CANCEL_CRAFTING((pos, data, player) -> {
|
CANCEL_CRAFTING((pos, data, player) -> {
|
||||||
ItemTerminalTileEntity tile = Utility.getBlockEntity(ItemTerminalTileEntity.class, player.world, pos);
|
ItemTerminalTileEntity tile = Utility.getTileEntity(ItemTerminalTileEntity.class, player.world, pos);
|
||||||
tile.cancelCrafting();
|
tile.cancelCrafting();
|
||||||
}),
|
}),
|
||||||
TAG_FILTER((pos, data, player) -> {
|
TAG_FILTER((pos, data, player) -> {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package de.ellpeck.prettypipes.packets;
|
||||||
|
|
||||||
import de.ellpeck.prettypipes.pipe.modules.craft.CraftingModuleContainer;
|
import de.ellpeck.prettypipes.pipe.modules.craft.CraftingModuleContainer;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraftforge.fml.network.NetworkEvent;
|
import net.minecraftforge.fml.network.NetworkEvent;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
|
@ -6,11 +6,12 @@ import de.ellpeck.prettypipes.Utility;
|
||||||
import de.ellpeck.prettypipes.terminal.CraftingTerminalTileEntity;
|
import de.ellpeck.prettypipes.terminal.CraftingTerminalTileEntity;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.fml.network.NetworkEvent;
|
import net.minecraftforge.fml.network.NetworkEvent;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
@ -50,7 +51,7 @@ public class PacketGhostSlot {
|
||||||
@SuppressWarnings("Convert2Lambda")
|
@SuppressWarnings("Convert2Lambda")
|
||||||
public static void onMessage(PacketGhostSlot message, Supplier<NetworkEvent.Context> ctx) {
|
public static void onMessage(PacketGhostSlot message, Supplier<NetworkEvent.Context> ctx) {
|
||||||
Consumer<PlayerEntity> doIt = p -> {
|
Consumer<PlayerEntity> doIt = p -> {
|
||||||
CraftingTerminalTileEntity tile = Utility.getBlockEntity(CraftingTerminalTileEntity.class, p.world, message.pos);
|
CraftingTerminalTileEntity tile = Utility.getTileEntity(CraftingTerminalTileEntity.class, p.world, message.pos);
|
||||||
if (tile != null)
|
if (tile != null)
|
||||||
tile.setGhostItems(message.stacks);
|
tile.setGhostItems(message.stacks);
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@ package de.ellpeck.prettypipes.packets;
|
||||||
import de.ellpeck.prettypipes.PrettyPipes;
|
import de.ellpeck.prettypipes.PrettyPipes;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
|
@ -3,8 +3,9 @@ package de.ellpeck.prettypipes.packets;
|
||||||
import de.ellpeck.prettypipes.Utility;
|
import de.ellpeck.prettypipes.Utility;
|
||||||
import de.ellpeck.prettypipes.pipe.IPipeItem;
|
import de.ellpeck.prettypipes.pipe.IPipeItem;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
|
import de.ellpeck.prettypipes.network.PipeItem;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.fml.network.NetworkEvent;
|
import net.minecraftforge.fml.network.NetworkEvent;
|
||||||
|
@ -14,7 +15,7 @@ import java.util.function.Supplier;
|
||||||
public class PacketItemEnterPipe {
|
public class PacketItemEnterPipe {
|
||||||
|
|
||||||
private BlockPos tilePos;
|
private BlockPos tilePos;
|
||||||
private CompoundTag item;
|
private CompoundNBT item;
|
||||||
|
|
||||||
public PacketItemEnterPipe(BlockPos tilePos, IPipeItem item) {
|
public PacketItemEnterPipe(BlockPos tilePos, IPipeItem item) {
|
||||||
this.tilePos = tilePos;
|
this.tilePos = tilePos;
|
||||||
|
@ -46,7 +47,7 @@ public class PacketItemEnterPipe {
|
||||||
if (mc.world == null)
|
if (mc.world == null)
|
||||||
return;
|
return;
|
||||||
IPipeItem item = IPipeItem.load(message.item);
|
IPipeItem item = IPipeItem.load(message.item);
|
||||||
PipeTileEntity pipe = Utility.getBlockEntity(PipeTileEntity.class, mc.world, message.tilePos);
|
PipeTileEntity pipe = Utility.getTileEntity(PipeTileEntity.class, mc.world, message.tilePos);
|
||||||
if (pipe != null)
|
if (pipe != null)
|
||||||
pipe.getItems().add(item);
|
pipe.getItems().add(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
package de.ellpeck.prettypipes.packets;
|
package de.ellpeck.prettypipes.packets;
|
||||||
|
|
||||||
|
import de.ellpeck.prettypipes.Utility;
|
||||||
|
import de.ellpeck.prettypipes.misc.ItemOrder;
|
||||||
|
import de.ellpeck.prettypipes.network.PipeItem;
|
||||||
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
|
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalContainer;
|
||||||
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalGui;
|
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalGui;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.fml.network.NetworkEvent;
|
import net.minecraftforge.fml.network.NetworkEvent;
|
||||||
|
|
|
@ -3,7 +3,7 @@ package de.ellpeck.prettypipes.packets;
|
||||||
import de.ellpeck.prettypipes.Utility;
|
import de.ellpeck.prettypipes.Utility;
|
||||||
import de.ellpeck.prettypipes.terminal.ItemTerminalTileEntity;
|
import de.ellpeck.prettypipes.terminal.ItemTerminalTileEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.fml.network.NetworkEvent;
|
import net.minecraftforge.fml.network.NetworkEvent;
|
||||||
|
@ -46,7 +46,7 @@ public class PacketRequest {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PlayerEntity player = ctx.get().getSender();
|
PlayerEntity player = ctx.get().getSender();
|
||||||
ItemTerminalTileEntity tile = Utility.getBlockEntity(ItemTerminalTileEntity.class, player.world, message.pos);
|
ItemTerminalTileEntity tile = Utility.getTileEntity(ItemTerminalTileEntity.class, player.world, message.pos);
|
||||||
message.stack.setCount(message.amount);
|
message.stack.setCount(message.amount);
|
||||||
tile.requestItem(player, message.stack);
|
tile.requestItem(player, message.stack);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package de.ellpeck.prettypipes.pipe;
|
package de.ellpeck.prettypipes.pipe;
|
||||||
|
|
||||||
import net.minecraft.util.StringRepresentable;
|
import net.minecraft.util.IStringSerializable;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public enum ConnectionType implements StringRepresentable {
|
public enum ConnectionType implements IStringSerializable {
|
||||||
CONNECTED(true),
|
CONNECTED(true),
|
||||||
DISCONNECTED(false),
|
DISCONNECTED(false),
|
||||||
BLOCKED(false),
|
BLOCKED(false),
|
||||||
|
@ -23,7 +23,7 @@ public enum ConnectionType implements StringRepresentable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSerializedName() {
|
public String getString() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.ellpeck.prettypipes.pipe;
|
package de.ellpeck.prettypipes.pipe;
|
||||||
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import de.ellpeck.prettypipes.network.NetworkEdge;
|
import de.ellpeck.prettypipes.network.NetworkEdge;
|
||||||
import de.ellpeck.prettypipes.network.PipeItem;
|
import de.ellpeck.prettypipes.network.PipeItem;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
@ -22,9 +22,9 @@ import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
public interface IPipeItem extends INBTSerializable<CompoundTag> {
|
public interface IPipeItem extends INBTSerializable<CompoundNBT> {
|
||||||
|
|
||||||
Map<ResourceLocation, BiFunction<ResourceLocation, CompoundTag, IPipeItem>> TYPES = new HashMap<>(
|
Map<ResourceLocation, BiFunction<ResourceLocation, CompoundNBT, IPipeItem>> TYPES = new HashMap<>(
|
||||||
Collections.singletonMap(PipeItem.TYPE, PipeItem::new));
|
Collections.singletonMap(PipeItem.TYPE, PipeItem::new));
|
||||||
|
|
||||||
ItemStack getContent();
|
ItemStack getContent();
|
||||||
|
@ -46,13 +46,13 @@ public interface IPipeItem extends INBTSerializable<CompoundTag> {
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
void render(PipeTileEntity tile, MatrixStack matrixStack, Random random, float partialTicks, int light, int overlay, IRenderTypeBuffer buffer);
|
void render(PipeTileEntity tile, MatrixStack matrixStack, Random random, float partialTicks, int light, int overlay, IRenderTypeBuffer buffer);
|
||||||
|
|
||||||
static IPipeItem load(CompoundTag nbt) {
|
static IPipeItem load(CompoundNBT nbt) {
|
||||||
// TODO legacy compat, remove eventually
|
// TODO legacy compat, remove eventually
|
||||||
if (!nbt.contains("type"))
|
if (!nbt.contains("type"))
|
||||||
nbt.putString("type", PipeItem.TYPE.toString());
|
nbt.putString("type", PipeItem.TYPE.toString());
|
||||||
|
|
||||||
ResourceLocation type = new ResourceLocation(nbt.getString("type"));
|
ResourceLocation type = new ResourceLocation(nbt.getString("type"));
|
||||||
BiFunction<ResourceLocation, CompoundTag, IPipeItem> func = TYPES.get(type);
|
BiFunction<ResourceLocation, CompoundNBT, IPipeItem> func = TYPES.get(type);
|
||||||
return func != null ? func.apply(type, nbt) : null;
|
return func != null ? func.apply(type, nbt) : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,19 +7,13 @@ import de.ellpeck.prettypipes.items.IModule;
|
||||||
import de.ellpeck.prettypipes.network.PipeNetwork;
|
import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.fluid.FluidState;
|
import net.minecraft.fluid.FluidState;
|
||||||
import net.minecraft.fluid.Fluids;
|
import net.minecraft.fluid.Fluids;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.InteractionHand;
|
|
||||||
import net.minecraft.world.InteractionResult;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.state.EnumProperty;
|
import net.minecraft.state.EnumProperty;
|
||||||
import net.minecraft.state.StateContainer;
|
import net.minecraft.state.StateContainer;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
|
@ -37,21 +31,10 @@ import net.minecraft.util.math.shapes.VoxelShapes;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.block.BaseEntityBlock;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.SoundType;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
|
||||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
|
||||||
import net.minecraft.world.level.material.Material;
|
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import net.minecraftforge.network.NetworkHooks;
|
|
||||||
import org.apache.commons.lang3.mutable.MutableObject;
|
import org.apache.commons.lang3.mutable.MutableObject;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
@ -60,57 +43,57 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class PipeBlock extends BaseEntityBlock {
|
public class PipeBlock extends ContainerBlock {
|
||||||
|
|
||||||
public static final Map<Direction, EnumProperty<ConnectionType>> DIRECTIONS = new HashMap<>();
|
public static final Map<Direction, EnumProperty<ConnectionType>> DIRECTIONS = new HashMap<>();
|
||||||
private static final Map<Pair<BlockState, BlockState>, VoxelShape> SHAPE_CACHE = new HashMap<>();
|
private static final Map<Pair<BlockState, BlockState>, VoxelShape> SHAPE_CACHE = new HashMap<>();
|
||||||
private static final Map<Pair<BlockState, BlockState>, VoxelShape> COLL_SHAPE_CACHE = new HashMap<>();
|
private static final Map<Pair<BlockState, BlockState>, VoxelShape> COLL_SHAPE_CACHE = new HashMap<>();
|
||||||
private static final VoxelShape CENTER_SHAPE = box(5, 5, 5, 11, 11, 11);
|
private static final VoxelShape CENTER_SHAPE = makeCuboidShape(5, 5, 5, 11, 11, 11);
|
||||||
public static final Map<Direction, VoxelShape> DIR_SHAPES = ImmutableMap.<Direction, VoxelShape>builder()
|
public static final Map<Direction, VoxelShape> DIR_SHAPES = ImmutableMap.<Direction, VoxelShape>builder()
|
||||||
.put(Direction.UP, box(5, 10, 5, 11, 16, 11))
|
.put(Direction.UP, makeCuboidShape(5, 10, 5, 11, 16, 11))
|
||||||
.put(Direction.DOWN, box(5, 0, 5, 11, 6, 11))
|
.put(Direction.DOWN, makeCuboidShape(5, 0, 5, 11, 6, 11))
|
||||||
.put(Direction.NORTH, box(5, 5, 0, 11, 11, 6))
|
.put(Direction.NORTH, makeCuboidShape(5, 5, 0, 11, 11, 6))
|
||||||
.put(Direction.SOUTH, box(5, 5, 10, 11, 11, 16))
|
.put(Direction.SOUTH, makeCuboidShape(5, 5, 10, 11, 11, 16))
|
||||||
.put(Direction.EAST, box(10, 5, 5, 16, 11, 11))
|
.put(Direction.EAST, makeCuboidShape(10, 5, 5, 16, 11, 11))
|
||||||
.put(Direction.WEST, box(0, 5, 5, 6, 11, 11))
|
.put(Direction.WEST, makeCuboidShape(0, 5, 5, 6, 11, 11))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (Direction dir : Direction.values())
|
for (Direction dir : Direction.values())
|
||||||
DIRECTIONS.put(dir, EnumProperty.create(dir.getName(), ConnectionType.class));
|
DIRECTIONS.put(dir, EnumProperty.create(dir.getName2(), ConnectionType.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public PipeBlock() {
|
public PipeBlock() {
|
||||||
super(Block.Properties.of(Material.STONE).strength(2).sound(SoundType.STONE).noOcclusion());
|
super(Block.Properties.create(Material.ROCK).hardnessAndResistance(2).sound(SoundType.STONE).notSolid());
|
||||||
|
|
||||||
BlockState state = this.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false);
|
BlockState state = this.getDefaultState().with(BlockStateProperties.WATERLOGGED, false);
|
||||||
for (EnumProperty<ConnectionType> prop : DIRECTIONS.values())
|
for (EnumProperty<ConnectionType> prop : DIRECTIONS.values())
|
||||||
state = state.setValue(prop, ConnectionType.DISCONNECTED);
|
state = state.with(prop, ConnectionType.DISCONNECTED);
|
||||||
this.registerDefaultState(state);
|
this.setDefaultState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult result) {
|
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult result) {
|
||||||
PipeTileEntity tile = Utility.getBlockEntity(PipeTileEntity.class, worldIn, pos);
|
PipeTileEntity tile = Utility.getTileEntity(PipeTileEntity.class, worldIn, pos);
|
||||||
if (tile == null)
|
if (tile == null)
|
||||||
return InteractionResult.PASS;
|
return ActionResultType.PASS;
|
||||||
if (!tile.canHaveModules())
|
if (!tile.canHaveModules())
|
||||||
return InteractionResult.PASS;
|
return ActionResultType.PASS;
|
||||||
ItemStack stack = player.getItemInHand(handIn);
|
ItemStack stack = player.getHeldItem(handIn);
|
||||||
if (stack.getItem() instanceof IModule) {
|
if (stack.getItem() instanceof IModule) {
|
||||||
ItemStack copy = stack.copy();
|
ItemStack copy = stack.copy();
|
||||||
copy.setCount(1);
|
copy.setCount(1);
|
||||||
ItemStack remain = ItemHandlerHelper.insertItem(tile.modules, copy, false);
|
ItemStack remain = ItemHandlerHelper.insertItem(tile.modules, copy, false);
|
||||||
if (remain.isEmpty()) {
|
if (remain.isEmpty()) {
|
||||||
stack.shrink(1);
|
stack.shrink(1);
|
||||||
return InteractionResult.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
} else if (handIn == InteractionHand.MAIN_HAND && stack.isEmpty()) {
|
} else if (handIn == Hand.MAIN_HAND && stack.isEmpty()) {
|
||||||
if (!worldIn.isClientSide)
|
if (!worldIn.isRemote)
|
||||||
NetworkHooks.openGui((ServerPlayer) player, tile, pos);
|
NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
|
||||||
return InteractionResult.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
return InteractionResult.PASS;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -169,7 +152,7 @@ public class PipeBlock extends BaseEntityBlock {
|
||||||
private VoxelShape cacheAndGetShape(BlockState state, IBlockReader worldIn, BlockPos pos, Function<BlockState, VoxelShape> coverShapeSelector, Map<Pair<BlockState, BlockState>, VoxelShape> cache, Function<VoxelShape, VoxelShape> shapeModifier) {
|
private VoxelShape cacheAndGetShape(BlockState state, IBlockReader worldIn, BlockPos pos, Function<BlockState, VoxelShape> coverShapeSelector, Map<Pair<BlockState, BlockState>, VoxelShape> cache, Function<VoxelShape, VoxelShape> shapeModifier) {
|
||||||
VoxelShape coverShape = null;
|
VoxelShape coverShape = null;
|
||||||
BlockState cover = null;
|
BlockState cover = null;
|
||||||
PipeTileEntity tile = Utility.getBlockEntity(PipeTileEntity.class, worldIn, pos);
|
PipeTileEntity tile = Utility.getTileEntity(PipeTileEntity.class, worldIn, pos);
|
||||||
if (tile != null && tile.cover != null) {
|
if (tile != null && tile.cover != null) {
|
||||||
cover = tile.cover;
|
cover = tile.cover;
|
||||||
// try catch since the block might expect to find itself at the position
|
// try catch since the block might expect to find itself at the position
|
||||||
|
@ -247,7 +230,7 @@ public class PipeBlock extends BaseEntityBlock {
|
||||||
|
|
||||||
public static void onStateChanged(World world, BlockPos pos, BlockState newState) {
|
public static void onStateChanged(World world, BlockPos pos, BlockState newState) {
|
||||||
// wait a few ticks before checking if we have to drop our modules, so that things like iron -> gold chest work
|
// wait a few ticks before checking if we have to drop our modules, so that things like iron -> gold chest work
|
||||||
PipeTileEntity tile = Utility.getBlockEntity(PipeTileEntity.class, world, pos);
|
PipeTileEntity tile = Utility.getTileEntity(PipeTileEntity.class, world, pos);
|
||||||
if (tile != null)
|
if (tile != null)
|
||||||
tile.moduleDropCheck = 5;
|
tile.moduleDropCheck = 5;
|
||||||
|
|
||||||
|
@ -297,7 +280,7 @@ public class PipeBlock extends BaseEntityBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) {
|
public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) {
|
||||||
PipeTileEntity pipe = Utility.getBlockEntity(PipeTileEntity.class, worldIn, pos);
|
PipeTileEntity pipe = Utility.getTileEntity(PipeTileEntity.class, worldIn, pos);
|
||||||
if (pipe == null)
|
if (pipe == null)
|
||||||
return 0;
|
return 0;
|
||||||
return Math.min(15, pipe.getItems().size());
|
return Math.min(15, pipe.getItems().size());
|
||||||
|
@ -315,7 +298,7 @@ public class PipeBlock extends BaseEntityBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dropItems(World worldIn, BlockPos pos, PlayerEntity player) {
|
public static void dropItems(World worldIn, BlockPos pos, PlayerEntity player) {
|
||||||
PipeTileEntity tile = Utility.getBlockEntity(PipeTileEntity.class, worldIn, pos);
|
PipeTileEntity tile = Utility.getTileEntity(PipeTileEntity.class, worldIn, pos);
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
Utility.dropInventory(tile, tile.modules);
|
Utility.dropInventory(tile, tile.modules);
|
||||||
for (IPipeItem item : tile.getItems())
|
for (IPipeItem item : tile.getItems())
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
package de.ellpeck.prettypipes.pipe;
|
package de.ellpeck.prettypipes.pipe;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||||
|
import de.ellpeck.prettypipes.Registry;
|
||||||
|
import de.ellpeck.prettypipes.network.PipeItem;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.BlockModelRenderer;
|
import net.minecraft.client.renderer.BlockModelRenderer;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
|
|
|
@ -9,19 +9,17 @@ import de.ellpeck.prettypipes.misc.ItemFilter;
|
||||||
import de.ellpeck.prettypipes.network.NetworkLock;
|
import de.ellpeck.prettypipes.network.NetworkLock;
|
||||||
import de.ellpeck.prettypipes.network.PipeNetwork;
|
import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||||
import de.ellpeck.prettypipes.pipe.containers.MainPipeContainer;
|
import de.ellpeck.prettypipes.pipe.containers.MainPipeContainer;
|
||||||
import de.ellpeck.prettypipes.pressurizer.PressurizerBlockEntity;
|
import de.ellpeck.prettypipes.pressurizer.PressurizerTileEntity;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NbtUtils;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.nbt.ListNBT;
|
||||||
import net.minecraft.nbt.ListTag;
|
|
||||||
import net.minecraft.nbt.NBTUtil;
|
import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
||||||
|
@ -35,8 +33,6 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
@ -57,14 +53,15 @@ import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class PipeTileEntity extends BlockEntity implements INamedContainerProvider, ITickableTileEntity, IPipeConnectable {
|
public class PipeTileEntity extends TileEntity implements INamedContainerProvider, ITickableTileEntity, IPipeConnectable {
|
||||||
|
|
||||||
public final ItemStackHandler modules = new ItemStackHandler(3) {
|
public final ItemStackHandler modules = new ItemStackHandler(3) {
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack) {
|
public boolean isItemValid(int slot, @Nonnull ItemStack stack) {
|
||||||
var item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
if (!(item instanceof IModule module))
|
if (!(item instanceof IModule))
|
||||||
return false;
|
return false;
|
||||||
|
IModule module = (IModule) item;
|
||||||
return PipeTileEntity.this.streamModules().allMatch(m -> module.isCompatible(stack, PipeTileEntity.this, m.getRight()) && m.getRight().isCompatible(m.getLeft(), PipeTileEntity.this, module));
|
return PipeTileEntity.this.streamModules().allMatch(m -> module.isCompatible(stack, PipeTileEntity.this, m.getRight()) && m.getRight().isCompatible(m.getLeft(), PipeTileEntity.this, module));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,66 +72,74 @@ public class PipeTileEntity extends BlockEntity implements INamedContainerProvid
|
||||||
};
|
};
|
||||||
public final Queue<NetworkLock> craftIngredientRequests = new LinkedList<>();
|
public final Queue<NetworkLock> craftIngredientRequests = new LinkedList<>();
|
||||||
public final List<Pair<BlockPos, ItemStack>> craftResultRequests = new ArrayList<>();
|
public final List<Pair<BlockPos, ItemStack>> craftResultRequests = new ArrayList<>();
|
||||||
public PressurizerBlockEntity pressurizer;
|
public PressurizerTileEntity pressurizer;
|
||||||
public BlockState cover;
|
public BlockState cover;
|
||||||
public int moduleDropCheck;
|
public int moduleDropCheck;
|
||||||
protected List<IPipeItem> items;
|
protected List<IPipeItem> items;
|
||||||
private int lastItemAmount;
|
private int lastItemAmount;
|
||||||
private int priority;
|
private int priority;
|
||||||
private final LazyOptional<PipeTileEntity> lazyThis = LazyOptional.of(() -> this);
|
private final LazyOptional<PipeTileEntity> lazyThis = LazyOptional.of(() -> this);
|
||||||
private final Lazy<Integer> workRandomizer = Lazy.of(() -> this.level.random.nextInt(200));
|
private final Lazy<Integer> workRandomizer = Lazy.of(() -> this.world.rand.nextInt(200));
|
||||||
|
|
||||||
@Override
|
public PipeTileEntity() {
|
||||||
public void onChunkUnloaded() {
|
this(Registry.pipeTileEntity);
|
||||||
PipeNetwork.get(this.level).uncachePipe(this.worldPosition);
|
}
|
||||||
|
|
||||||
|
protected PipeTileEntity(TileEntityType<?> type) {
|
||||||
|
super(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag save(CompoundTag compound) {
|
public void onChunkUnloaded() {
|
||||||
|
PipeNetwork.get(this.world).uncachePipe(this.pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundNBT write(CompoundNBT compound) {
|
||||||
compound.put("modules", this.modules.serializeNBT());
|
compound.put("modules", this.modules.serializeNBT());
|
||||||
compound.putInt("module_drop_check", this.moduleDropCheck);
|
compound.putInt("module_drop_check", this.moduleDropCheck);
|
||||||
compound.put("requests", Utility.serializeAll(this.craftIngredientRequests));
|
compound.put("requests", Utility.serializeAll(this.craftIngredientRequests));
|
||||||
if (this.cover != null)
|
if (this.cover != null)
|
||||||
compound.put("cover", NbtUtils.writeBlockState(this.cover));
|
compound.put("cover", NBTUtil.writeBlockState(this.cover));
|
||||||
ListTag results = new ListTag();
|
ListNBT results = new ListNBT();
|
||||||
for (Pair<BlockPos, ItemStack> triple : this.craftResultRequests) {
|
for (Pair<BlockPos, ItemStack> triple : this.craftResultRequests) {
|
||||||
CompoundTag nbt = new CompoundTag();
|
CompoundNBT nbt = new CompoundNBT();
|
||||||
nbt.putLong("dest_pipe", triple.getLeft().asLong());
|
nbt.putLong("dest_pipe", triple.getLeft().toLong());
|
||||||
nbt.put("item", triple.getRight().serializeNBT());
|
nbt.put("item", triple.getRight().serializeNBT());
|
||||||
results.add(nbt);
|
results.add(nbt);
|
||||||
}
|
}
|
||||||
compound.put("craft_results", results);
|
compound.put("craft_results", results);
|
||||||
return super.save(compound);
|
return super.write(compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(CompoundTag compound) {
|
public void read(BlockState state, CompoundNBT compound) {
|
||||||
this.modules.deserializeNBT(compound.getCompound("modules"));
|
this.modules.deserializeNBT(compound.getCompound("modules"));
|
||||||
this.moduleDropCheck = compound.getInt("module_drop_check");
|
this.moduleDropCheck = compound.getInt("module_drop_check");
|
||||||
this.cover = compound.contains("cover") ? NbtUtils.readBlockState(compound.getCompound("cover")) : null;
|
this.cover = compound.contains("cover") ? NBTUtil.readBlockState(compound.getCompound("cover")) : null;
|
||||||
this.craftIngredientRequests.clear();
|
this.craftIngredientRequests.clear();
|
||||||
this.craftIngredientRequests.addAll(Utility.deserializeAll(compound.getList("requests", NBT.TAG_COMPOUND), NetworkLock::new));
|
this.craftIngredientRequests.addAll(Utility.deserializeAll(compound.getList("requests", NBT.TAG_COMPOUND), NetworkLock::new));
|
||||||
this.craftResultRequests.clear();
|
this.craftResultRequests.clear();
|
||||||
ListTag results = compound.getList("craft_results", NBT.TAG_COMPOUND);
|
ListNBT results = compound.getList("craft_results", NBT.TAG_COMPOUND);
|
||||||
for (int i = 0; i < results.size(); i++) {
|
for (int i = 0; i < results.size(); i++) {
|
||||||
CompoundTag nbt = results.getCompound(i);
|
CompoundNBT nbt = results.getCompound(i);
|
||||||
this.craftResultRequests.add(Pair.of(
|
this.craftResultRequests.add(Pair.of(
|
||||||
BlockPos.of(nbt.getLong("dest_pipe")),
|
BlockPos.fromLong(nbt.getLong("dest_pipe")),
|
||||||
ItemStack.of(nbt.getCompound("item"))));
|
ItemStack.read(nbt.getCompound("item"))));
|
||||||
}
|
}
|
||||||
super.load(compound);
|
super.read(state, compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getUpdateTag() {
|
public CompoundNBT getUpdateTag() {
|
||||||
// sync pipe items on load
|
// sync pipe items on load
|
||||||
CompoundTag nbt = this.write(new CompoundTag());
|
CompoundNBT nbt = this.write(new CompoundNBT());
|
||||||
nbt.put("items", Utility.serializeAll(this.getItems()));
|
nbt.put("items", Utility.serializeAll(this.getItems()));
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleUpdateTag(BlockState state, CompoundTag nbt) {
|
public void handleUpdateTag(BlockState state, CompoundNBT nbt) {
|
||||||
this.read(state, nbt);
|
this.read(state, nbt);
|
||||||
List<IPipeItem> items = this.getItems();
|
List<IPipeItem> items = this.getItems();
|
||||||
items.clear();
|
items.clear();
|
||||||
|
|
|
@ -9,7 +9,7 @@ import net.minecraft.inventory.container.ClickType;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.inventory.container.ContainerType;
|
import net.minecraft.inventory.container.ContainerType;
|
||||||
import net.minecraft.inventory.container.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ public abstract class AbstractPipeContainer<T extends IModule> extends Container
|
||||||
|
|
||||||
public AbstractPipeContainer(@Nullable ContainerType<?> type, int id, PlayerEntity player, BlockPos pos, int moduleIndex) {
|
public AbstractPipeContainer(@Nullable ContainerType<?> type, int id, PlayerEntity player, BlockPos pos, int moduleIndex) {
|
||||||
super(type, id);
|
super(type, id);
|
||||||
this.tile = Utility.getBlockEntity(PipeTileEntity.class, player.world, pos);
|
this.tile = Utility.getTileEntity(PipeTileEntity.class, player.world, pos);
|
||||||
this.moduleStack = moduleIndex < 0 ? null : this.tile.modules.getStackInSlot(moduleIndex);
|
this.moduleStack = moduleIndex < 0 ? null : this.tile.modules.getStackInSlot(moduleIndex);
|
||||||
this.module = moduleIndex < 0 ? null : (T) this.moduleStack.getItem();
|
this.module = moduleIndex < 0 ? null : (T) this.moduleStack.getItem();
|
||||||
this.moduleIndex = moduleIndex;
|
this.moduleIndex = moduleIndex;
|
||||||
|
|
|
@ -11,8 +11,8 @@ import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||||
import net.minecraft.client.gui.widget.Widget;
|
import net.minecraft.client.gui.widget.Widget;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.container.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.SoundEvents;
|
import net.minecraft.util.SoundEvents;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import de.ellpeck.prettypipes.items.IModule;
|
||||||
import de.ellpeck.prettypipes.items.ModuleItem;
|
import de.ellpeck.prettypipes.items.ModuleItem;
|
||||||
import de.ellpeck.prettypipes.items.ModuleTier;
|
import de.ellpeck.prettypipes.items.ModuleTier;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class HighPriorityModuleItem extends ModuleItem {
|
public class HighPriorityModuleItem extends ModuleItem {
|
||||||
private final int priority;
|
private final int priority;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import de.ellpeck.prettypipes.items.IModule;
|
||||||
import de.ellpeck.prettypipes.items.ModuleItem;
|
import de.ellpeck.prettypipes.items.ModuleItem;
|
||||||
import de.ellpeck.prettypipes.items.ModuleTier;
|
import de.ellpeck.prettypipes.items.ModuleTier;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class LowPriorityModuleItem extends ModuleItem {
|
public class LowPriorityModuleItem extends ModuleItem {
|
||||||
private final int priority;
|
private final int priority;
|
||||||
|
|
|
@ -3,7 +3,7 @@ package de.ellpeck.prettypipes.pipe.modules;
|
||||||
import de.ellpeck.prettypipes.items.IModule;
|
import de.ellpeck.prettypipes.items.IModule;
|
||||||
import de.ellpeck.prettypipes.items.ModuleItem;
|
import de.ellpeck.prettypipes.items.ModuleItem;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class RedstoneModuleItem extends ModuleItem {
|
public class RedstoneModuleItem extends ModuleItem {
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package de.ellpeck.prettypipes.pipe.modules;
|
||||||
import de.ellpeck.prettypipes.items.IModule;
|
import de.ellpeck.prettypipes.items.IModule;
|
||||||
import de.ellpeck.prettypipes.items.ModuleItem;
|
import de.ellpeck.prettypipes.items.ModuleItem;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import de.ellpeck.prettypipes.items.IModule;
|
||||||
import de.ellpeck.prettypipes.items.ModuleItem;
|
import de.ellpeck.prettypipes.items.ModuleItem;
|
||||||
import de.ellpeck.prettypipes.items.ModuleTier;
|
import de.ellpeck.prettypipes.items.ModuleTier;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class SpeedModuleItem extends ModuleItem {
|
public class SpeedModuleItem extends ModuleItem {
|
||||||
private final float speedIncrease;
|
private final float speedIncrease;
|
||||||
|
|
|
@ -15,8 +15,8 @@ import de.ellpeck.prettypipes.terminal.CraftingTerminalTileEntity;
|
||||||
import de.ellpeck.prettypipes.terminal.ItemTerminalTileEntity;
|
import de.ellpeck.prettypipes.terminal.ItemTerminalTileEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
@ -208,7 +208,7 @@ public class CraftingModuleItem extends ModuleItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(ItemStackHandler input, ItemStackHandler output, ItemStack module) {
|
public void save(ItemStackHandler input, ItemStackHandler output, ItemStack module) {
|
||||||
CompoundTag tag = module.getOrCreateTag();
|
CompoundNBT tag = module.getOrCreateTag();
|
||||||
if (input != null)
|
if (input != null)
|
||||||
tag.put("input", input.serializeNBT());
|
tag.put("input", input.serializeNBT());
|
||||||
if (output != null)
|
if (output != null)
|
||||||
|
|
|
@ -10,7 +10,7 @@ import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class FilterIncreaseModuleItem extends ModuleItem {
|
public class FilterIncreaseModuleItem extends ModuleItem {
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class FilterModuleItem extends ModuleItem {
|
public class FilterModuleItem extends ModuleItem {
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ import de.ellpeck.prettypipes.misc.ItemFilter;
|
||||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.inventory.container.ContainerType;
|
import net.minecraft.inventory.container.ContainerType;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import de.ellpeck.prettypipes.packets.PacketButton;
|
||||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeGui;
|
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeGui;
|
||||||
import net.minecraft.client.audio.SimpleSound;
|
import net.minecraft.client.audio.SimpleSound;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.SoundEvents;
|
import net.minecraft.util.SoundEvents;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
|
|
@ -10,8 +10,8 @@ import joptsimple.internal.Strings;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
public class StackSizeModuleItem extends ModuleItem {
|
public class StackSizeModuleItem extends ModuleItem {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package de.ellpeck.prettypipes.pressurizer;
|
package de.ellpeck.prettypipes.pressurizer;
|
||||||
|
|
||||||
import de.ellpeck.prettypipes.Utility;
|
import de.ellpeck.prettypipes.Utility;
|
||||||
|
import de.ellpeck.prettypipes.pipe.ConnectionType;
|
||||||
|
import de.ellpeck.prettypipes.pipe.IPipeConnectable;
|
||||||
|
import de.ellpeck.prettypipes.terminal.ItemTerminalTileEntity;
|
||||||
import net.minecraft.block.BlockRenderType;
|
import net.minecraft.block.BlockRenderType;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.ContainerBlock;
|
import net.minecraft.block.ContainerBlock;
|
||||||
|
@ -9,7 +12,7 @@ import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
@ -31,7 +34,7 @@ public class PressurizerBlock extends ContainerBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult result) {
|
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult result) {
|
||||||
PressurizerBlockEntity tile = Utility.getBlockEntity(PressurizerBlockEntity.class, worldIn, pos);
|
PressurizerTileEntity tile = Utility.getTileEntity(PressurizerTileEntity.class, worldIn, pos);
|
||||||
if (tile == null)
|
if (tile == null)
|
||||||
return ActionResultType.PASS;
|
return ActionResultType.PASS;
|
||||||
if (!worldIn.isRemote)
|
if (!worldIn.isRemote)
|
||||||
|
@ -41,7 +44,7 @@ public class PressurizerBlock extends ContainerBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(IBlockReader worldIn) {
|
public TileEntity createNewTileEntity(IBlockReader worldIn) {
|
||||||
return new PressurizerBlockEntity();
|
return new PressurizerTileEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,32 +1,29 @@
|
||||||
package de.ellpeck.prettypipes.pressurizer;
|
package de.ellpeck.prettypipes.pressurizer;
|
||||||
|
|
||||||
import de.ellpeck.prettypipes.Utility;
|
import de.ellpeck.prettypipes.Utility;
|
||||||
import net.minecraft.core.BlockPos;
|
import de.ellpeck.prettypipes.terminal.ItemTerminalTileEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.inventory.container.ContainerType;
|
import net.minecraft.inventory.container.ContainerType;
|
||||||
import net.minecraft.inventory.container.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
|
||||||
import net.minecraft.world.inventory.MenuType;
|
|
||||||
import net.minecraft.world.inventory.Slot;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class PressurizerContainer extends AbstractContainerMenu {
|
public class PressurizerContainer extends Container {
|
||||||
public final PressurizerBlockEntity tile;
|
public final PressurizerTileEntity tile;
|
||||||
|
|
||||||
public PressurizerContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos) {
|
public PressurizerContainer(@Nullable ContainerType<?> type, int id, PlayerEntity player, BlockPos pos) {
|
||||||
super(type, id);
|
super(type, id);
|
||||||
this.tile = Utility.getBlockEntity(PressurizerBlockEntity.class, player.level, pos);
|
this.tile = Utility.getTileEntity(PressurizerTileEntity.class, player.world, pos);
|
||||||
|
|
||||||
for (int l = 0; l < 3; ++l)
|
for (int l = 0; l < 3; ++l)
|
||||||
for (int j1 = 0; j1 < 9; ++j1)
|
for (int j1 = 0; j1 < 9; ++j1)
|
||||||
this.addSlot(new Slot(player.getInventory(), j1 + l * 9 + 9, 8 + j1 * 18, 55 + l * 18));
|
this.addSlot(new Slot(player.inventory, j1 + l * 9 + 9, 8 + j1 * 18, 55 + l * 18));
|
||||||
for (int i1 = 0; i1 < 9; ++i1)
|
for (int i1 = 0; i1 < 9; ++i1)
|
||||||
this.addSlot(new Slot(player.getInventory(), i1, 8 + i1 * 18, 113));
|
this.addSlot(new Slot(player.inventory, i1, 8 + i1 * 18, 113));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,7 +5,7 @@ import de.ellpeck.prettypipes.PrettyPipes;
|
||||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||||
import net.minecraft.client.gui.widget.Widget;
|
import net.minecraft.client.gui.widget.Widget;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,14 @@ import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||||
import de.ellpeck.prettypipes.pipe.ConnectionType;
|
import de.ellpeck.prettypipes.pipe.ConnectionType;
|
||||||
import de.ellpeck.prettypipes.pipe.IPipeConnectable;
|
import de.ellpeck.prettypipes.pipe.IPipeConnectable;
|
||||||
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
|
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalContainer;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
||||||
import net.minecraft.tileentity.ITickableTileEntity;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
@ -24,7 +25,6 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
|
@ -33,14 +33,14 @@ import net.minecraftforge.energy.IEnergyStorage;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class PressurizerBlockEntity extends BlockEntity implements INamedContainerProvider, ITickableTileEntity, IPipeConnectable {
|
public class PressurizerTileEntity extends TileEntity implements INamedContainerProvider, ITickableTileEntity, IPipeConnectable {
|
||||||
|
|
||||||
private final ModifiableEnergyStorage storage = new ModifiableEnergyStorage(64000, 512, 0);
|
private final ModifiableEnergyStorage storage = new ModifiableEnergyStorage(64000, 512, 0);
|
||||||
private final LazyOptional<IEnergyStorage> lazyStorage = LazyOptional.of(() -> this.storage);
|
private final LazyOptional<IEnergyStorage> lazyStorage = LazyOptional.of(() -> this.storage);
|
||||||
private final LazyOptional<IPipeConnectable> lazyThis = LazyOptional.of(() -> this);
|
private final LazyOptional<IPipeConnectable> lazyThis = LazyOptional.of(() -> this);
|
||||||
private int lastEnergy;
|
private int lastEnergy;
|
||||||
|
|
||||||
public PressurizerBlockEntity() {
|
public PressurizerTileEntity() {
|
||||||
super(Registry.pressurizerTileEntity);
|
super(Registry.pressurizerTileEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,24 +62,24 @@ public class PressurizerBlockEntity extends BlockEntity implements INamedContain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag write(CompoundTag compound) {
|
public CompoundNBT write(CompoundNBT compound) {
|
||||||
compound.putInt("energy", this.getEnergy());
|
compound.putInt("energy", this.getEnergy());
|
||||||
return super.write(compound);
|
return super.write(compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(BlockState state, CompoundTag nbt) {
|
public void read(BlockState state, CompoundNBT nbt) {
|
||||||
this.storage.setEnergyStored(nbt.getInt("energy"));
|
this.storage.setEnergyStored(nbt.getInt("energy"));
|
||||||
super.read(state, nbt);
|
super.read(state, nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getUpdateTag() {
|
public CompoundNBT getUpdateTag() {
|
||||||
return this.write(new CompoundTag());
|
return this.write(new CompoundNBT());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleUpdateTag(BlockState state, CompoundTag tag) {
|
public void handleUpdateTag(BlockState state, CompoundNBT tag) {
|
||||||
this.read(state, tag);
|
this.read(state, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ public class PressurizerBlockEntity extends BlockEntity implements INamedContain
|
||||||
// send energy update
|
// send energy update
|
||||||
if (this.lastEnergy != this.storage.getEnergyStored() && this.world.getGameTime() % 10 == 0) {
|
if (this.lastEnergy != this.storage.getEnergyStored() && this.world.getGameTime() % 10 == 0) {
|
||||||
this.lastEnergy = this.storage.getEnergyStored();
|
this.lastEnergy = this.storage.getEnergyStored();
|
||||||
Utility.sendBlockEntityToClients(this);
|
Utility.sendTileEntityToClients(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
@ -136,13 +136,13 @@ public class CraftingTerminalTileEntity extends ItemTerminalTileEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag write(CompoundTag compound) {
|
public CompoundNBT write(CompoundNBT compound) {
|
||||||
compound.put("craft_items", this.craftItems.serializeNBT());
|
compound.put("craft_items", this.craftItems.serializeNBT());
|
||||||
return super.write(compound);
|
return super.write(compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(BlockState state, CompoundTag compound) {
|
public void read(BlockState state, CompoundNBT compound) {
|
||||||
this.craftItems.deserializeNBT(compound.getCompound("craft_items"));
|
this.craftItems.deserializeNBT(compound.getCompound("craft_items"));
|
||||||
super.read(state, compound);
|
super.read(state, compound);
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ public class CraftingTerminalTileEntity extends ItemTerminalTileEntity {
|
||||||
@Override
|
@Override
|
||||||
public ItemStack insertItem(BlockPos pipePos, Direction direction, ItemStack remain, boolean simulate) {
|
public ItemStack insertItem(BlockPos pipePos, Direction direction, ItemStack remain, boolean simulate) {
|
||||||
BlockPos pos = pipePos.offset(direction);
|
BlockPos pos = pipePos.offset(direction);
|
||||||
CraftingTerminalTileEntity tile = Utility.getBlockEntity(CraftingTerminalTileEntity.class, this.world, pos);
|
CraftingTerminalTileEntity tile = Utility.getTileEntity(CraftingTerminalTileEntity.class, this.world, pos);
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
remain = remain.copy();
|
remain = remain.copy();
|
||||||
int lowestSlot = -1;
|
int lowestSlot = -1;
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package de.ellpeck.prettypipes.terminal;
|
package de.ellpeck.prettypipes.terminal;
|
||||||
|
|
||||||
import de.ellpeck.prettypipes.Utility;
|
import de.ellpeck.prettypipes.Utility;
|
||||||
|
import de.ellpeck.prettypipes.network.PipeItem;
|
||||||
|
import de.ellpeck.prettypipes.pipe.ConnectionType;
|
||||||
|
import de.ellpeck.prettypipes.pipe.IPipeConnectable;
|
||||||
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import net.minecraft.block.BlockRenderType;
|
import net.minecraft.block.BlockRenderType;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.ContainerBlock;
|
import net.minecraft.block.ContainerBlock;
|
||||||
|
@ -9,7 +13,7 @@ import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
@ -22,6 +26,8 @@ import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -35,7 +41,7 @@ public class ItemTerminalBlock extends ContainerBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult result) {
|
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult result) {
|
||||||
ItemTerminalTileEntity tile = Utility.getBlockEntity(ItemTerminalTileEntity.class, worldIn, pos);
|
ItemTerminalTileEntity tile = Utility.getTileEntity(ItemTerminalTileEntity.class, worldIn, pos);
|
||||||
if (tile == null)
|
if (tile == null)
|
||||||
return ActionResultType.PASS;
|
return ActionResultType.PASS;
|
||||||
String reason = tile.getInvalidTerminalReason();
|
String reason = tile.getInvalidTerminalReason();
|
||||||
|
@ -54,7 +60,7 @@ public class ItemTerminalBlock extends ContainerBlock {
|
||||||
@Override
|
@Override
|
||||||
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||||
if (state.getBlock() != newState.getBlock()) {
|
if (state.getBlock() != newState.getBlock()) {
|
||||||
ItemTerminalTileEntity tile = Utility.getBlockEntity(ItemTerminalTileEntity.class, worldIn, pos);
|
ItemTerminalTileEntity tile = Utility.getTileEntity(ItemTerminalTileEntity.class, worldIn, pos);
|
||||||
if (tile != null)
|
if (tile != null)
|
||||||
Utility.dropInventory(tile, tile.items);
|
Utility.dropInventory(tile, tile.items);
|
||||||
super.onReplaced(state, worldIn, pos, newState, isMoving);
|
super.onReplaced(state, worldIn, pos, newState, isMoving);
|
||||||
|
|
|
@ -20,8 +20,8 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.tileentity.ITickableTileEntity;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
|
@ -230,14 +230,14 @@ public class ItemTerminalTileEntity extends TileEntity implements INamedContaine
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag write(CompoundTag compound) {
|
public CompoundNBT write(CompoundNBT compound) {
|
||||||
compound.put("items", this.items.serializeNBT());
|
compound.put("items", this.items.serializeNBT());
|
||||||
compound.put("requests", Utility.serializeAll(this.existingRequests));
|
compound.put("requests", Utility.serializeAll(this.existingRequests));
|
||||||
return super.write(compound);
|
return super.write(compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(BlockState state, CompoundTag compound) {
|
public void read(BlockState state, CompoundNBT compound) {
|
||||||
this.items.deserializeNBT(compound.getCompound("items"));
|
this.items.deserializeNBT(compound.getCompound("items"));
|
||||||
this.existingRequests.clear();
|
this.existingRequests.clear();
|
||||||
this.existingRequests.addAll(Utility.deserializeAll(compound.getList("requests", NBT.TAG_COMPOUND), NetworkLock::new));
|
this.existingRequests.addAll(Utility.deserializeAll(compound.getList("requests", NBT.TAG_COMPOUND), NetworkLock::new));
|
||||||
|
@ -270,7 +270,7 @@ public class ItemTerminalTileEntity extends TileEntity implements INamedContaine
|
||||||
@Override
|
@Override
|
||||||
public ItemStack insertItem(BlockPos pipePos, Direction direction, ItemStack stack, boolean simulate) {
|
public ItemStack insertItem(BlockPos pipePos, Direction direction, ItemStack stack, boolean simulate) {
|
||||||
BlockPos pos = pipePos.offset(direction);
|
BlockPos pos = pipePos.offset(direction);
|
||||||
ItemTerminalTileEntity tile = Utility.getBlockEntity(ItemTerminalTileEntity.class, world, pos);
|
ItemTerminalTileEntity tile = Utility.getTileEntity(ItemTerminalTileEntity.class, world, pos);
|
||||||
if (tile != null)
|
if (tile != null)
|
||||||
return ItemHandlerHelper.insertItemStacked(tile.items, stack, simulate);
|
return ItemHandlerHelper.insertItemStacked(tile.items, stack, simulate);
|
||||||
return stack;
|
return stack;
|
||||||
|
|
|
@ -11,7 +11,7 @@ import net.minecraft.inventory.container.ClickType;
|
||||||
import net.minecraft.inventory.container.ContainerType;
|
import net.minecraft.inventory.container.ContainerType;
|
||||||
import net.minecraft.inventory.container.CraftingResultSlot;
|
import net.minecraft.inventory.container.CraftingResultSlot;
|
||||||
import net.minecraft.inventory.container.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.ICraftingRecipe;
|
import net.minecraft.item.crafting.ICraftingRecipe;
|
||||||
import net.minecraft.item.crafting.IRecipeType;
|
import net.minecraft.item.crafting.IRecipeType;
|
||||||
import net.minecraft.network.play.server.SSetSlotPacket;
|
import net.minecraft.network.play.server.SSetSlotPacket;
|
||||||
|
|
|
@ -13,8 +13,8 @@ import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.container.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package de.ellpeck.prettypipes.terminal.containers;
|
package de.ellpeck.prettypipes.terminal.containers;
|
||||||
|
|
||||||
import de.ellpeck.prettypipes.Utility;
|
import de.ellpeck.prettypipes.Utility;
|
||||||
|
import de.ellpeck.prettypipes.network.NetworkItem;
|
||||||
|
import de.ellpeck.prettypipes.packets.PacketHandler;
|
||||||
|
import de.ellpeck.prettypipes.packets.PacketNetworkItems;
|
||||||
|
import de.ellpeck.prettypipes.pipe.PipeTileEntity;
|
||||||
import de.ellpeck.prettypipes.terminal.ItemTerminalTileEntity;
|
import de.ellpeck.prettypipes.terminal.ItemTerminalTileEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
|
@ -8,13 +12,16 @@ import net.minecraft.inventory.container.ClickType;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.inventory.container.ContainerType;
|
import net.minecraft.inventory.container.ContainerType;
|
||||||
import net.minecraft.inventory.container.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ItemTerminalContainer extends Container {
|
public class ItemTerminalContainer extends Container {
|
||||||
|
|
||||||
|
@ -22,7 +29,7 @@ public class ItemTerminalContainer extends Container {
|
||||||
|
|
||||||
public ItemTerminalContainer(@Nullable ContainerType<?> type, int id, PlayerEntity player, BlockPos pos) {
|
public ItemTerminalContainer(@Nullable ContainerType<?> type, int id, PlayerEntity player, BlockPos pos) {
|
||||||
super(type, id);
|
super(type, id);
|
||||||
this.tile = Utility.getBlockEntity(ItemTerminalTileEntity.class, player.world, pos);
|
this.tile = Utility.getTileEntity(ItemTerminalTileEntity.class, player.world, pos);
|
||||||
|
|
||||||
this.addOwnSlots(player);
|
this.addOwnSlots(player);
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ import net.minecraft.client.gui.widget.button.Button;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.util.InputMappings;
|
import net.minecraft.client.util.InputMappings;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.inventory.CraftingInventory;
|
import net.minecraft.inventory.CraftingInventory;
|
||||||
import net.minecraft.inventory.ItemStackHelper;
|
import net.minecraft.inventory.ItemStackHelper;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.RecipeItemHelper;
|
import net.minecraft.item.crafting.RecipeItemHelper;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue