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