Move to 1.16.5 official mappings
This commit is contained in:
42
build.gradle
42
build.gradle
@@ -4,14 +4,10 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true
|
||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'info.solidsoft.pitest' version '1.5.1'
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url = "https://dvs1.progwml6.com/files/maven/"
|
||||
@@ -30,13 +26,8 @@ repositories {
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'info.solidsoft.pitest'
|
||||
|
||||
pitest {
|
||||
junit5PluginVersion = "0.12"
|
||||
}
|
||||
|
||||
version = '1.9.17'
|
||||
version = '1.10.0'
|
||||
def env = System.getenv()
|
||||
if (env.BUILD_NUMBER) {
|
||||
version = version + "+" + "${env.BUILD_NUMBER}"
|
||||
@@ -47,7 +38,7 @@ archivesBaseName = 'refinedstorage'
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
|
||||
|
||||
minecraft {
|
||||
mappings channel: 'snapshot', version: '20210309-1.16.5'
|
||||
mappings channel: 'official', version: '1.16.5'
|
||||
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
|
||||
runs {
|
||||
@@ -99,20 +90,13 @@ sourceSets {
|
||||
|
||||
processResources {
|
||||
inputs.property 'version', project.version
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'META-INF/mods.toml'
|
||||
|
||||
filesMatching('META-INF/mods.toml') {
|
||||
expand 'version': project.version
|
||||
}
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'META-INF/mods.toml'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft 'net.minecraftforge:forge:1.16.5-36.1.31'
|
||||
minecraft 'net.minecraftforge:forge:1.16.5-36.1.31'
|
||||
|
||||
compileOnly fg.deobf("mezz.jei:jei-1.16.5:7.7.0.106:api")
|
||||
runtimeOnly fg.deobf("mezz.jei:jei-1.16.5:7.7.0.106")
|
||||
@@ -124,9 +108,21 @@ dependencies {
|
||||
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.16.5-4.0.5.2")
|
||||
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.16.5-4.0.5.2:api")
|
||||
|
||||
/*minecraft 'net.minecraftforge:forge:1.18.1-39.0.0'
|
||||
|
||||
compileOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.41:api")
|
||||
runtimeOnly fg.deobf("mezz.jei:jei-1.18.1:9.1.0.41")
|
||||
|
||||
compileOnly fg.deobf('curse.maven:mouse-tweaks-60089:3546383')
|
||||
|
||||
compileOnly fg.deobf('curse.maven:crafting-tweaks-233071:3545611')
|
||||
|
||||
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18-5.0.2.4")
|
||||
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18-5.0.2.4:api")*/
|
||||
|
||||
testImplementation('org.junit.jupiter:junit-jupiter-api:5.6.2')
|
||||
testRuntime('org.junit.jupiter:junit-jupiter-engine:5.6.2')
|
||||
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.16.1'
|
||||
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.6.2')
|
||||
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.16.1'
|
||||
}
|
||||
|
||||
jar {
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
269
gradlew
vendored
269
gradlew
vendored
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright <20> 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -17,67 +17,101 @@
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## 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 <20>$var<61>, <20>${var}<7D>, <20>${var:-default}<7D>, <20>${var+SET}<7D>,
|
||||
# <20>${var#prefix}<7D>, <20>${var%suffix}<7D>, and <20>$( cmd )<29>;
|
||||
# * compound commands having a testable exit status, especially <20>case<73>;
|
||||
# * various built-in commands including <20>command<6E>, <20>set<65>, and <20>ulimit<69>.
|
||||
#
|
||||
# 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='"-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
|
||||
@@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
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
|
||||
@@ -98,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
|
||||
@@ -106,80 +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 or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $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" )
|
||||
|
||||
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" "$@"
|
||||
|
@@ -85,9 +85,9 @@ public final class RSBlocks {
|
||||
}
|
||||
|
||||
GRID.registerBlocks("grid", () -> new GridBlock(GridType.NORMAL));
|
||||
CRAFTING_GRID.registerBlocks(GridType.CRAFTING.getString() + GRID_SUFFIX, () -> new GridBlock(GridType.CRAFTING));
|
||||
PATTERN_GRID.registerBlocks(GridType.PATTERN.getString() + GRID_SUFFIX, () -> new GridBlock(GridType.PATTERN));
|
||||
FLUID_GRID.registerBlocks(GridType.FLUID.getString() + GRID_SUFFIX, () -> new GridBlock(GridType.FLUID));
|
||||
CRAFTING_GRID.registerBlocks(GridType.CRAFTING.getSerializedName() + GRID_SUFFIX, () -> new GridBlock(GridType.CRAFTING));
|
||||
PATTERN_GRID.registerBlocks(GridType.PATTERN.getSerializedName() + GRID_SUFFIX, () -> new GridBlock(GridType.PATTERN));
|
||||
FLUID_GRID.registerBlocks(GridType.FLUID.getSerializedName() + GRID_SUFFIX, () -> new GridBlock(GridType.FLUID));
|
||||
CONTROLLER.registerBlocks("controller", () -> new ControllerBlock(NetworkType.NORMAL));
|
||||
CREATIVE_CONTROLLER.registerBlocks("creative_controller", () -> new ControllerBlock(NetworkType.CREATIVE));
|
||||
NETWORK_RECEIVER.registerBlocks("network_receiver", NetworkReceiverBlock::new);
|
||||
|
@@ -167,13 +167,13 @@ public final class RSItems {
|
||||
LATE_REGISTRATION.add(() -> {
|
||||
RSBlocks.CONTROLLER.forEach((color, block) -> {
|
||||
if (color != ColorMap.DEFAULT_COLOR) {
|
||||
CONTROLLER.put(color, ITEMS.register(RSBlocks.CONTROLLER.get(color).getId().getPath(), () -> new ControllerBlockItem(RSBlocks.CONTROLLER.get(color).get(), color, new TranslationTextComponent(RSBlocks.CONTROLLER.get(ColorMap.DEFAULT_COLOR).get().getTranslationKey()))));
|
||||
CONTROLLER.put(color, ITEMS.register(RSBlocks.CONTROLLER.get(color).getId().getPath(), () -> new ControllerBlockItem(RSBlocks.CONTROLLER.get(color).get(), color, new TranslationTextComponent(RSBlocks.CONTROLLER.get(ColorMap.DEFAULT_COLOR).get().getDescriptionId()))));
|
||||
}
|
||||
});
|
||||
|
||||
RSBlocks.CREATIVE_CONTROLLER.forEach((color, block) -> {
|
||||
if (color != ColorMap.DEFAULT_COLOR) {
|
||||
CREATIVE_CONTROLLER.put(color, ITEMS.register(RSBlocks.CREATIVE_CONTROLLER.get(color).getId().getPath(), () -> new ControllerBlockItem(RSBlocks.CREATIVE_CONTROLLER.get(color).get(), color, new TranslationTextComponent(RSBlocks.CREATIVE_CONTROLLER.get(ColorMap.DEFAULT_COLOR).get().getTranslationKey()))));
|
||||
CREATIVE_CONTROLLER.put(color, ITEMS.register(RSBlocks.CREATIVE_CONTROLLER.get(color).getId().getPath(), () -> new ControllerBlockItem(RSBlocks.CREATIVE_CONTROLLER.get(color).get(), color, new TranslationTextComponent(RSBlocks.CREATIVE_CONTROLLER.get(ColorMap.DEFAULT_COLOR).get().getDescriptionId()))));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -207,7 +207,7 @@ public final class RSItems {
|
||||
}
|
||||
|
||||
private static <T extends BaseBlock> RegistryObject<BlockItem> registerBlockItemFor(RegistryObject<T> block) {
|
||||
return ITEMS.register(block.getId().getPath(), () -> new BaseBlockItem(block.get(), new Item.Properties().group(RS.MAIN_GROUP)));
|
||||
return ITEMS.register(block.getId().getPath(), () -> new BaseBlockItem(block.get(), new Item.Properties().tab(RS.MAIN_GROUP)));
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
|
@@ -27,28 +27,28 @@ public final class RSKeyBindings {
|
||||
public static final KeyBinding OPEN_WIRELESS_GRID = new KeyBinding(
|
||||
"key.refinedstorage.openWirelessGrid",
|
||||
KeyConflictContext.IN_GAME,
|
||||
InputMappings.INPUT_INVALID,
|
||||
InputMappings.UNKNOWN,
|
||||
RS.NAME
|
||||
);
|
||||
|
||||
public static final KeyBinding OPEN_WIRELESS_FLUID_GRID = new KeyBinding(
|
||||
"key.refinedstorage.openWirelessFluidGrid",
|
||||
KeyConflictContext.IN_GAME,
|
||||
InputMappings.INPUT_INVALID,
|
||||
InputMappings.UNKNOWN,
|
||||
RS.NAME
|
||||
);
|
||||
|
||||
public static final KeyBinding OPEN_WIRELESS_CRAFTING_MONITOR = new KeyBinding(
|
||||
"key.refinedstorage.openWirelessCraftingMonitor",
|
||||
KeyConflictContext.IN_GAME,
|
||||
InputMappings.INPUT_INVALID,
|
||||
InputMappings.UNKNOWN,
|
||||
RS.NAME
|
||||
);
|
||||
|
||||
public static final KeyBinding OPEN_PORTABLE_GRID = new KeyBinding(
|
||||
"key.refinedstorage.openPortableGrid",
|
||||
KeyConflictContext.IN_GAME,
|
||||
InputMappings.INPUT_INVALID,
|
||||
InputMappings.UNKNOWN,
|
||||
RS.NAME
|
||||
);
|
||||
|
||||
|
@@ -202,7 +202,7 @@ public interface ICraftingPatternContainer {
|
||||
boolean success = current == null && stacks.isEmpty();
|
||||
|
||||
if (!success && action == Action.PERFORM) {
|
||||
LogManager.getLogger().warn("Inventory unexpectedly didn't accept {}, the remainder has been voided!", current != null ? current.getTranslationKey() : null);
|
||||
LogManager.getLogger().warn("Inventory unexpectedly didn't accept {}, the remainder has been voided!", current != null ? current.getDescriptionId() : null);
|
||||
}
|
||||
|
||||
return success;
|
||||
|
@@ -36,7 +36,7 @@ public enum GridType implements IStringSerializable {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getString() {
|
||||
public String getSerializedName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@@ -130,12 +130,12 @@ public class API implements IRSAPI {
|
||||
|
||||
@Override
|
||||
public INetworkNodeManager getNetworkNodeManager(ServerWorld world) {
|
||||
return world.getSavedData().getOrCreate(() -> new NetworkNodeManager(NetworkNodeManager.NAME, world), NetworkNodeManager.NAME);
|
||||
return world.getDataStorage().computeIfAbsent(() -> new NetworkNodeManager(NetworkNodeManager.NAME, world), NetworkNodeManager.NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public INetworkManager getNetworkManager(ServerWorld world) {
|
||||
return world.getSavedData().getOrCreate(() -> new NetworkManager(NetworkManager.NAME, world), NetworkManager.NAME);
|
||||
return world.getDataStorage().computeIfAbsent(() -> new NetworkManager(NetworkManager.NAME, world), NetworkManager.NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -195,9 +195,9 @@ public class API implements IRSAPI {
|
||||
@Nonnull
|
||||
@Override
|
||||
public IStorageDiskManager getStorageDiskManager(ServerWorld anyWorld) {
|
||||
ServerWorld world = anyWorld.getServer().func_241755_D_(); // Get the overworld
|
||||
ServerWorld world = anyWorld.getServer().overworld(); // Get the overworld
|
||||
|
||||
return world.getSavedData().getOrCreate(() -> new StorageDiskManager(StorageDiskManager.NAME, world), StorageDiskManager.NAME);
|
||||
return world.getDataStorage().computeIfAbsent(() -> new StorageDiskManager(StorageDiskManager.NAME, world), StorageDiskManager.NAME);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -209,9 +209,9 @@ public class API implements IRSAPI {
|
||||
@Nonnull
|
||||
@Override
|
||||
public IStorageTrackerManager getStorageTrackerManager(ServerWorld anyWorld) {
|
||||
ServerWorld world = anyWorld.getServer().func_241755_D_(); // Get the overworld
|
||||
ServerWorld world = anyWorld.getServer().overworld(); // Get the overworld
|
||||
|
||||
return world.getSavedData().getOrCreate(() -> new StorageTrackerManager(StorageTrackerManager.NAME), StorageTrackerManager.NAME);
|
||||
return world.getDataStorage().computeIfAbsent(() -> new StorageTrackerManager(StorageTrackerManager.NAME), StorageTrackerManager.NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -295,7 +295,7 @@ public class API implements IRSAPI {
|
||||
}
|
||||
|
||||
private int getHashCode(CompoundNBT tag, int result) {
|
||||
for (String key : tag.keySet()) {
|
||||
for (String key : tag.getAllKeys()) {
|
||||
result = 31 * result + key.hashCode();
|
||||
result = getHashCode(tag.get(key), result);
|
||||
}
|
||||
|
@@ -92,10 +92,10 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
CraftingInventory inv = new DummyCraftingInventory();
|
||||
|
||||
for (int i = 0; i < took.size(); ++i) {
|
||||
inv.setInventorySlotContents(i, took.get(i));
|
||||
inv.setItem(i, took.get(i));
|
||||
}
|
||||
|
||||
ItemStack result = recipe.getCraftingResult(inv);
|
||||
ItemStack result = recipe.assemble(inv);
|
||||
if (result.isEmpty()) {
|
||||
throw new IllegalStateException("Cannot have empty result");
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
CraftingInventory inv = new DummyCraftingInventory();
|
||||
|
||||
for (int i = 0; i < took.size(); ++i) {
|
||||
inv.setInventorySlotContents(i, took.get(i));
|
||||
inv.setItem(i, took.get(i));
|
||||
}
|
||||
|
||||
NonNullList<ItemStack> remainingItems = recipe.getRemainingItems(inv);
|
||||
@@ -269,7 +269,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
public DummyCraftingInventory() {
|
||||
super(new Container(null, 0) {
|
||||
@Override
|
||||
public boolean canInteractWith(PlayerEntity player) {
|
||||
public boolean stillValid(PlayerEntity player) {
|
||||
return true;
|
||||
}
|
||||
}, 3, 3);
|
||||
|
@@ -55,13 +55,13 @@ public class CraftingPatternFactory {
|
||||
fillCraftingInputs(inv, stack, inputs, i);
|
||||
}
|
||||
|
||||
Optional<ICraftingRecipe> foundRecipe = world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, inv, world);
|
||||
Optional<ICraftingRecipe> foundRecipe = world.getRecipeManager().getRecipeFor(IRecipeType.CRAFTING, inv, world);
|
||||
if (foundRecipe.isPresent()) {
|
||||
recipe = foundRecipe.get();
|
||||
|
||||
byproducts = recipe.getRemainingItems(inv);
|
||||
|
||||
ItemStack output = recipe.getCraftingResult(inv);
|
||||
ItemStack output = recipe.assemble(inv);
|
||||
|
||||
if (!output.isEmpty()) {
|
||||
outputs.add(output);
|
||||
@@ -102,7 +102,7 @@ public class CraftingPatternFactory {
|
||||
possibilities.add(input.copy());
|
||||
|
||||
if (allowedTagList != null) {
|
||||
Collection<ResourceLocation> tagsOfItem = ItemTags.getCollection().getOwningTags(input.getItem());
|
||||
Collection<ResourceLocation> tagsOfItem = ItemTags.getAllTags().getMatchingTags(input.getItem());
|
||||
Set<ResourceLocation> declaredAllowedTags = allowedTagList.getAllowedItemTags().get(i);
|
||||
|
||||
for (ResourceLocation declaredAllowedTag : declaredAllowedTags) {
|
||||
@@ -111,11 +111,11 @@ public class CraftingPatternFactory {
|
||||
new TranslationTextComponent(
|
||||
"misc.refinedstorage.pattern.error.tag_no_longer_applicable",
|
||||
declaredAllowedTag.toString(),
|
||||
input.getDisplayName()
|
||||
input.getHoverName()
|
||||
)
|
||||
);
|
||||
} else {
|
||||
for (Item element : ItemTags.getCollection().get(declaredAllowedTag).getAllElements()) {
|
||||
for (Item element : ItemTags.getAllTags().getTag(declaredAllowedTag).getValues()) {
|
||||
possibilities.add(new ItemStack(element, input.getCount()));
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ public class CraftingPatternFactory {
|
||||
possibilities.add(input.copy());
|
||||
|
||||
if (allowedTagList != null) {
|
||||
Collection<ResourceLocation> tagsOfFluid = FluidTags.getCollection().getOwningTags(input.getFluid());
|
||||
Collection<ResourceLocation> tagsOfFluid = FluidTags.getAllTags().getMatchingTags(input.getFluid());
|
||||
Set<ResourceLocation> declaredAllowedTags = allowedTagList.getAllowedFluidTags().get(i);
|
||||
|
||||
for (ResourceLocation declaredAllowedTag : declaredAllowedTags) {
|
||||
@@ -154,7 +154,7 @@ public class CraftingPatternFactory {
|
||||
)
|
||||
);
|
||||
} else {
|
||||
for (Fluid element : FluidTags.getCollection().get(declaredAllowedTag).getAllElements()) {
|
||||
for (Fluid element : FluidTags.getAllTags().getTag(declaredAllowedTag).getValues()) {
|
||||
possibilities.add(new FluidStack(element, input.getAmount()));
|
||||
}
|
||||
}
|
||||
@@ -173,9 +173,9 @@ public class CraftingPatternFactory {
|
||||
private void fillCraftingInputs(CraftingInventory inv, ItemStack stack, List<NonNullList<ItemStack>> inputs, int i) {
|
||||
ItemStack input = PatternItem.getInputSlot(stack, i);
|
||||
|
||||
inputs.add(input.isEmpty() ? NonNullList.create() : NonNullList.from(ItemStack.EMPTY, input));
|
||||
inputs.add(input.isEmpty() ? NonNullList.create() : NonNullList.of(ItemStack.EMPTY, input));
|
||||
|
||||
inv.setInventorySlotContents(i, input);
|
||||
inv.setItem(i, input);
|
||||
}
|
||||
|
||||
private void modifyCraftingInputsToUseAlternatives(ICraftingRecipe recipe, List<NonNullList<ItemStack>> inputs) {
|
||||
@@ -183,7 +183,7 @@ public class CraftingPatternFactory {
|
||||
inputs.clear();
|
||||
|
||||
for (int i = 0; i < recipe.getIngredients().size(); ++i) {
|
||||
inputs.add(i, NonNullList.from(ItemStack.EMPTY, recipe.getIngredients().get(i).getMatchingStacks()));
|
||||
inputs.add(i, NonNullList.of(ItemStack.EMPTY, recipe.getIngredients().get(i).getItems()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ public class ErrorCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
@Override
|
||||
public void write(PacketBuffer buf) {
|
||||
buf.writeResourceLocation(base.getId());
|
||||
buf.writeString(message);
|
||||
buf.writeUtf(message);
|
||||
|
||||
base.write(buf);
|
||||
}
|
||||
|
@@ -58,42 +58,42 @@ public class FluidCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
|
||||
drawers.getFluidDrawer().draw(matrixStack, x + 4, y + 6, stack);
|
||||
|
||||
float scale = Minecraft.getInstance().getForceUnicodeFont() ? 1F : 0.5F;
|
||||
float scale = Minecraft.getInstance().isEnforceUnicode() ? 1F : 0.5F;
|
||||
|
||||
matrixStack.push();
|
||||
matrixStack.pushPose();
|
||||
matrixStack.scale(scale, scale, 1);
|
||||
|
||||
int yy = y + 7;
|
||||
|
||||
if (stored > 0) {
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.format("gui.refinedstorage.crafting_monitor.stored", API.instance().getQuantityFormatter().formatInBucketForm(stored)));
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.get("gui.refinedstorage.crafting_monitor.stored", API.instance().getQuantityFormatter().formatInBucketForm(stored)));
|
||||
|
||||
yy += 7;
|
||||
}
|
||||
|
||||
if (missing > 0) {
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.format("gui.refinedstorage.crafting_monitor.missing", API.instance().getQuantityFormatter().formatInBucketForm(missing)));
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.get("gui.refinedstorage.crafting_monitor.missing", API.instance().getQuantityFormatter().formatInBucketForm(missing)));
|
||||
|
||||
yy += 7;
|
||||
}
|
||||
|
||||
if (processing > 0) {
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.format("gui.refinedstorage.crafting_monitor.processing", API.instance().getQuantityFormatter().formatInBucketForm(processing)));
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.get("gui.refinedstorage.crafting_monitor.processing", API.instance().getQuantityFormatter().formatInBucketForm(processing)));
|
||||
|
||||
yy += 7;
|
||||
}
|
||||
|
||||
if (scheduled > 0) {
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.format("gui.refinedstorage.crafting_monitor.scheduled", API.instance().getQuantityFormatter().formatInBucketForm(scheduled)));
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.get("gui.refinedstorage.crafting_monitor.scheduled", API.instance().getQuantityFormatter().formatInBucketForm(scheduled)));
|
||||
|
||||
yy += 7;
|
||||
}
|
||||
|
||||
if (crafting > 0) {
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.format("gui.refinedstorage.crafting_monitor.crafting", API.instance().getQuantityFormatter().formatInBucketForm(crafting)));
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.get("gui.refinedstorage.crafting_monitor.crafting", API.instance().getQuantityFormatter().formatInBucketForm(crafting)));
|
||||
}
|
||||
|
||||
matrixStack.pop();
|
||||
matrixStack.popPose();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -58,42 +58,42 @@ public class ItemCraftingMonitorElement implements ICraftingMonitorElement {
|
||||
|
||||
drawers.getItemDrawer().draw(matrixStack, x + 4, y + 6, stack);
|
||||
|
||||
float scale = Minecraft.getInstance().getForceUnicodeFont() ? 1F : 0.5F;
|
||||
float scale = Minecraft.getInstance().isEnforceUnicode() ? 1F : 0.5F;
|
||||
|
||||
matrixStack.push();
|
||||
matrixStack.pushPose();
|
||||
matrixStack.scale(scale, scale, 1);
|
||||
|
||||
int yy = y + 7;
|
||||
|
||||
if (stored > 0) {
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.format("gui.refinedstorage.crafting_monitor.stored", stored));
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.get("gui.refinedstorage.crafting_monitor.stored", stored));
|
||||
|
||||
yy += 7;
|
||||
}
|
||||
|
||||
if (missing > 0) {
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.format("gui.refinedstorage.crafting_monitor.missing", missing));
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.get("gui.refinedstorage.crafting_monitor.missing", missing));
|
||||
|
||||
yy += 7;
|
||||
}
|
||||
|
||||
if (processing > 0) {
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.format("gui.refinedstorage.crafting_monitor.processing", processing));
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.get("gui.refinedstorage.crafting_monitor.processing", processing));
|
||||
|
||||
yy += 7;
|
||||
}
|
||||
|
||||
if (scheduled > 0) {
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.format("gui.refinedstorage.crafting_monitor.scheduled", scheduled));
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.get("gui.refinedstorage.crafting_monitor.scheduled", scheduled));
|
||||
|
||||
yy += 7;
|
||||
}
|
||||
|
||||
if (crafting > 0) {
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.format("gui.refinedstorage.crafting_monitor.crafting", crafting));
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy, scale), I18n.get("gui.refinedstorage.crafting_monitor.crafting", crafting));
|
||||
}
|
||||
|
||||
matrixStack.pop();
|
||||
matrixStack.popPose();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -37,7 +37,7 @@ public class ErrorCraftingPreviewElement implements ICraftingPreviewElement {
|
||||
@Override
|
||||
public void write(PacketBuffer buf) {
|
||||
buf.writeInt(type.ordinal());
|
||||
buf.writeItemStack(recursedPattern);
|
||||
buf.writeItem(recursedPattern);
|
||||
}
|
||||
|
||||
public CalculationResultType getType() {
|
||||
@@ -47,7 +47,7 @@ public class ErrorCraftingPreviewElement implements ICraftingPreviewElement {
|
||||
public static ErrorCraftingPreviewElement read(PacketBuffer buf) {
|
||||
int errorIdx = buf.readInt();
|
||||
CalculationResultType error = errorIdx >= 0 && errorIdx < CalculationResultType.values().length ? CalculationResultType.values()[errorIdx] : CalculationResultType.TOO_COMPLEX;
|
||||
ItemStack stack = buf.readItemStack();
|
||||
ItemStack stack = buf.readItem();
|
||||
|
||||
return new ErrorCraftingPreviewElement(error, stack);
|
||||
}
|
||||
|
@@ -67,25 +67,25 @@ public class FluidCraftingPreviewElement implements ICraftingPreviewElement {
|
||||
|
||||
drawers.getFluidDrawer().draw(matrixStack, x, y, getStack());
|
||||
|
||||
float scale = Minecraft.getInstance().getForceUnicodeFont() ? 1F : 0.5F;
|
||||
float scale = Minecraft.getInstance().isEnforceUnicode() ? 1F : 0.5F;
|
||||
|
||||
y += 2;
|
||||
|
||||
matrixStack.push();
|
||||
matrixStack.pushPose();
|
||||
matrixStack.scale(scale, scale, 1);
|
||||
|
||||
if (toCraft > 0) {
|
||||
String format = doesDisableTaskStarting() ? "gui.refinedstorage.crafting_preview.missing" : "gui.refinedstorage.crafting_preview.to_craft";
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 23, scale), RenderUtils.getOffsetOnScale(y, scale), I18n.format(format, API.instance().getQuantityFormatter().formatInBucketForm(toCraft)));
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 23, scale), RenderUtils.getOffsetOnScale(y, scale), I18n.get(format, API.instance().getQuantityFormatter().formatInBucketForm(toCraft)));
|
||||
|
||||
y += 7;
|
||||
}
|
||||
|
||||
if (available > 0) {
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 23, scale), RenderUtils.getOffsetOnScale(y, scale), I18n.format("gui.refinedstorage.crafting_preview.available", API.instance().getQuantityFormatter().formatInBucketForm(available)));
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 23, scale), RenderUtils.getOffsetOnScale(y, scale), I18n.get("gui.refinedstorage.crafting_preview.available", API.instance().getQuantityFormatter().formatInBucketForm(available)));
|
||||
}
|
||||
|
||||
matrixStack.pop();
|
||||
matrixStack.popPose();
|
||||
}
|
||||
|
||||
public void addAvailable(int amount) {
|
||||
|
@@ -40,14 +40,14 @@ public class ItemCraftingPreviewElement implements ICraftingPreviewElement {
|
||||
|
||||
@Override
|
||||
public void write(PacketBuffer buf) {
|
||||
buf.writeItemStack(stack);
|
||||
buf.writeItem(stack);
|
||||
buf.writeInt(available);
|
||||
buf.writeBoolean(missing);
|
||||
buf.writeInt(toCraft);
|
||||
}
|
||||
|
||||
public static ItemCraftingPreviewElement read(PacketBuffer buf) {
|
||||
ItemStack stack = buf.readItemStack();
|
||||
ItemStack stack = buf.readItem();
|
||||
int available = buf.readInt();
|
||||
boolean missing = buf.readBoolean();
|
||||
int toCraft = buf.readInt();
|
||||
@@ -67,25 +67,25 @@ public class ItemCraftingPreviewElement implements ICraftingPreviewElement {
|
||||
|
||||
drawers.getItemDrawer().draw(matrixStack, x, y, stack);
|
||||
|
||||
float scale = Minecraft.getInstance().getForceUnicodeFont() ? 1F : 0.5F;
|
||||
float scale = Minecraft.getInstance().isEnforceUnicode() ? 1F : 0.5F;
|
||||
|
||||
y += 2;
|
||||
|
||||
matrixStack.push();
|
||||
matrixStack.pushPose();
|
||||
matrixStack.scale(scale, scale, 1);
|
||||
|
||||
if (toCraft > 0) {
|
||||
String format = doesDisableTaskStarting() ? "gui.refinedstorage.crafting_preview.missing" : "gui.refinedstorage.crafting_preview.to_craft";
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 23, scale), RenderUtils.getOffsetOnScale(y, scale), I18n.format(format, toCraft));
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 23, scale), RenderUtils.getOffsetOnScale(y, scale), I18n.get(format, toCraft));
|
||||
|
||||
y += 7;
|
||||
}
|
||||
|
||||
if (available > 0) {
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 23, scale), RenderUtils.getOffsetOnScale(y, scale), I18n.format("gui.refinedstorage.crafting_preview.available", available));
|
||||
drawers.getStringDrawer().draw(matrixStack, RenderUtils.getOffsetOnScale(x + 23, scale), RenderUtils.getOffsetOnScale(y, scale), I18n.get("gui.refinedstorage.crafting_preview.available", available));
|
||||
}
|
||||
|
||||
matrixStack.pop();
|
||||
matrixStack.popPose();
|
||||
}
|
||||
|
||||
public void addAvailable(int amount) {
|
||||
|
@@ -92,7 +92,7 @@ public class CraftingTask implements ICraftingTask, NodeListener {
|
||||
this.requested = API.instance().createCraftingRequestInfo(tag.getCompound(NBT_REQUESTED));
|
||||
this.quantity = tag.getInt(NBT_QUANTITY);
|
||||
this.pattern = SerializationUtil.readPatternFromNbt(tag.getCompound(NBT_PATTERN), network.getWorld());
|
||||
this.id = tag.getUniqueId(NBT_ID);
|
||||
this.id = tag.getUUID(NBT_ID);
|
||||
this.nodes = new NodeList();
|
||||
|
||||
this.ticks = tag.getInt(NBT_TICKS);
|
||||
@@ -119,7 +119,7 @@ public class CraftingTask implements ICraftingTask, NodeListener {
|
||||
tag.putInt(NBT_QUANTITY, quantity);
|
||||
tag.put(NBT_PATTERN, SerializationUtil.writePatternToNbt(pattern));
|
||||
tag.putInt(NBT_TICKS, ticks);
|
||||
tag.putUniqueId(NBT_ID, id);
|
||||
tag.putUUID(NBT_ID, id);
|
||||
tag.putLong(NBT_EXECUTION_STARTED, startTime);
|
||||
tag.put(NBT_INTERNAL_STORAGE, internalStorage.writeToNbt());
|
||||
tag.put(NBT_INTERNAL_FLUID_STORAGE, internalFluidStorage.writeToNbt());
|
||||
|
@@ -80,18 +80,18 @@ public class SerializationUtil {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
|
||||
tag.put(NBT_PATTERN_STACK, pattern.getStack().serializeNBT());
|
||||
tag.putLong(NBT_PATTERN_CONTAINER_POS, pattern.getContainer().getPosition().toLong());
|
||||
tag.putLong(NBT_PATTERN_CONTAINER_POS, pattern.getContainer().getPosition().asLong());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static ICraftingPattern readPatternFromNbt(CompoundNBT tag, World world) throws CraftingTaskReadException {
|
||||
BlockPos containerPos = BlockPos.fromLong(tag.getLong(NBT_PATTERN_CONTAINER_POS));
|
||||
BlockPos containerPos = BlockPos.of(tag.getLong(NBT_PATTERN_CONTAINER_POS));
|
||||
|
||||
INetworkNode node = API.instance().getNetworkNodeManager((ServerWorld) world).getNode(containerPos);
|
||||
|
||||
if (node instanceof ICraftingPatternContainer) {
|
||||
ItemStack stack = ItemStack.read(tag.getCompound(NBT_PATTERN_STACK));
|
||||
ItemStack stack = ItemStack.of(tag.getCompound(NBT_PATTERN_STACK));
|
||||
|
||||
if (stack.getItem() instanceof ICraftingPatternProvider) {
|
||||
return ((ICraftingPatternProvider) stack.getItem()).create(world, stack, (ICraftingPatternContainer) node);
|
||||
|
@@ -105,7 +105,7 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
this.type = type;
|
||||
this.root = new RootNetworkNode(this, world, pos);
|
||||
this.nodeGraph.addListener(() -> {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
TileEntity tile = world.getBlockEntity(pos);
|
||||
|
||||
if (tile instanceof ControllerTile) {
|
||||
((ControllerTile) tile).getDataManager().sendParameterToWatchers(ControllerTile.NODES);
|
||||
@@ -148,16 +148,16 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (!world.isRemote) {
|
||||
long tickStart = Util.nanoTime();
|
||||
if (!world.isClientSide) {
|
||||
long tickStart = Util.getNanos();
|
||||
|
||||
if (ticks == 0) {
|
||||
redstonePowered = world.isBlockPowered(pos);
|
||||
redstonePowered = world.hasNeighborSignal(pos);
|
||||
}
|
||||
|
||||
++ticks;
|
||||
|
||||
amILoaded = world.isBlockPresent(pos);
|
||||
amILoaded = world.isLoaded(pos);
|
||||
|
||||
updateEnergyUsage();
|
||||
|
||||
@@ -205,11 +205,11 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
|
||||
BlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock() instanceof ControllerBlock) {
|
||||
world.setBlockState(pos, state.with(ControllerBlock.ENERGY_TYPE, energyType));
|
||||
world.setBlockAndUpdate(pos, state.setValue(ControllerBlock.ENERGY_TYPE, energyType));
|
||||
}
|
||||
}
|
||||
|
||||
tickTimes[tickCounter % tickTimes.length] = Util.nanoTime() - tickStart;
|
||||
tickTimes[tickCounter % tickTimes.length] = Util.getNanos() - tickStart;
|
||||
tickCounter++;
|
||||
}
|
||||
}
|
||||
@@ -506,7 +506,7 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
craftingManager.readFromNbt(tag);
|
||||
|
||||
if (tag.contains(NBT_ITEM_STORAGE_TRACKER_ID)) {
|
||||
this.itemStorageTrackerId = tag.getUniqueId(NBT_ITEM_STORAGE_TRACKER_ID);
|
||||
this.itemStorageTrackerId = tag.getUUID(NBT_ITEM_STORAGE_TRACKER_ID);
|
||||
} else {
|
||||
if (tag.contains(NBT_ITEM_STORAGE_TRACKER)) { //TODO: remove next version
|
||||
getItemStorageTracker().readFromNbt(tag.getList(NBT_ITEM_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
||||
@@ -514,7 +514,7 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
}
|
||||
|
||||
if (tag.contains(NBT_FLUID_STORAGE_TRACKER_ID)) {
|
||||
this.fluidStorageTrackerId = tag.getUniqueId(NBT_FLUID_STORAGE_TRACKER_ID);
|
||||
this.fluidStorageTrackerId = tag.getUUID(NBT_FLUID_STORAGE_TRACKER_ID);
|
||||
} else {
|
||||
if (tag.contains(NBT_FLUID_STORAGE_TRACKER)) { //TODO: remove next version
|
||||
getFluidStorageTracker().readFromNbt(tag.getList(NBT_FLUID_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
||||
@@ -532,11 +532,11 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
|
||||
craftingManager.writeToNbt(tag);
|
||||
if (itemStorageTrackerId != null) {
|
||||
tag.putUniqueId(NBT_ITEM_STORAGE_TRACKER_ID, itemStorageTrackerId);
|
||||
tag.putUUID(NBT_ITEM_STORAGE_TRACKER_ID, itemStorageTrackerId);
|
||||
}
|
||||
|
||||
if (fluidStorageTrackerId != null) {
|
||||
tag.putUniqueId(NBT_FLUID_STORAGE_TRACKER_ID, fluidStorageTrackerId);
|
||||
tag.putUUID(NBT_FLUID_STORAGE_TRACKER_ID, fluidStorageTrackerId);
|
||||
}
|
||||
|
||||
return tag;
|
||||
|
@@ -10,22 +10,22 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
public class NetworkListener {
|
||||
@SubscribeEvent
|
||||
public void onWorldTick(TickEvent.WorldTickEvent e) {
|
||||
if (!e.world.isRemote() && e.phase == TickEvent.Phase.END) {
|
||||
e.world.getProfiler().startSection("network ticking");
|
||||
if (!e.world.isClientSide() && e.phase == TickEvent.Phase.END) {
|
||||
e.world.getProfiler().push("network ticking");
|
||||
|
||||
for (INetwork network : API.instance().getNetworkManager((ServerWorld) e.world).all()) {
|
||||
network.update();
|
||||
}
|
||||
|
||||
e.world.getProfiler().endSection();
|
||||
e.world.getProfiler().pop();
|
||||
|
||||
e.world.getProfiler().startSection("network node ticking");
|
||||
e.world.getProfiler().push("network node ticking");
|
||||
|
||||
for (INetworkNode node : API.instance().getNetworkNodeManager((ServerWorld) e.world).all()) {
|
||||
node.update();
|
||||
}
|
||||
|
||||
e.world.getProfiler().endSection();
|
||||
e.world.getProfiler().pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ public class NetworkManager extends RSWorldSavedData implements INetworkManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT tag) {
|
||||
public void load(CompoundNBT tag) {
|
||||
if (tag.contains(NBT_NETWORKS)) {
|
||||
ListNBT networksTag = tag.getList(NBT_NETWORKS, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
@@ -47,7 +47,7 @@ public class NetworkManager extends RSWorldSavedData implements INetworkManager
|
||||
CompoundNBT networkTag = networksTag.getCompound(i);
|
||||
|
||||
CompoundNBT data = networkTag.getCompound(NBT_DATA);
|
||||
BlockPos pos = BlockPos.fromLong(networkTag.getLong(NBT_POS));
|
||||
BlockPos pos = BlockPos.of(networkTag.getLong(NBT_POS));
|
||||
int type = networkTag.getInt(NBT_TYPE);
|
||||
|
||||
INetwork network = new Network(world, pos, NetworkType.values()[type]);
|
||||
@@ -64,14 +64,14 @@ public class NetworkManager extends RSWorldSavedData implements INetworkManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
public CompoundNBT save(CompoundNBT tag) {
|
||||
ListNBT list = new ListNBT();
|
||||
|
||||
for (INetwork network : all()) {
|
||||
try {
|
||||
CompoundNBT networkTag = new CompoundNBT();
|
||||
|
||||
networkTag.putLong(NBT_POS, network.getPosition().toLong());
|
||||
networkTag.putLong(NBT_POS, network.getPosition().asLong());
|
||||
networkTag.put(NBT_DATA, network.writeToNbt(new CompoundNBT()));
|
||||
networkTag.putInt(NBT_TYPE, network.getType().ordinal());
|
||||
|
||||
@@ -121,6 +121,6 @@ public class NetworkManager extends RSWorldSavedData implements INetworkManager
|
||||
|
||||
@Override
|
||||
public void markForSaving() {
|
||||
markDirty();
|
||||
setDirty();
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,8 @@ import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.network.INetworkNodeVisitor.Operator;
|
||||
|
||||
public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
private final INetwork network;
|
||||
private Set<INetworkNodeGraphEntry> entries = Sets.newConcurrentHashSet();
|
||||
@@ -34,7 +36,7 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
|
||||
Operator operator = new Operator(action);
|
||||
|
||||
INetworkNode originNode = NetworkUtils.getNodeFromTile(world.getTileEntity(origin));
|
||||
INetworkNode originNode = NetworkUtils.getNodeFromTile(world.getBlockEntity(origin));
|
||||
if (originNode instanceof INetworkNodeVisitor) {
|
||||
((INetworkNodeVisitor) originNode).visit(operator);
|
||||
}
|
||||
@@ -113,7 +115,7 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
|
||||
@Override
|
||||
public void apply(World world, BlockPos pos, @Nullable Direction side) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
TileEntity tile = world.getBlockEntity(pos);
|
||||
|
||||
INetworkNode otherNode = NetworkUtils.getNodeFromTile(tile);
|
||||
if (otherNode != null) {
|
||||
@@ -144,7 +146,7 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
|
||||
private void dropConflictingBlock(World world, BlockPos pos) {
|
||||
if (!network.getPosition().equals(pos)) {
|
||||
Block.spawnDrops(world.getBlockState(pos), world, pos, world.getTileEntity(pos));
|
||||
Block.dropResources(world.getBlockState(pos), world, pos, world.getBlockEntity(pos));
|
||||
|
||||
world.removeBlock(pos, false);
|
||||
}
|
||||
@@ -181,7 +183,7 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
INetworkNode nodeOnSide = NetworkUtils.getNodeFromTile(tile);
|
||||
|
||||
if (nodeOnSide == node) {
|
||||
operator.apply(world, pos.offset(checkSide), checkSide.getOpposite());
|
||||
operator.apply(world, pos.relative(checkSide), checkSide.getOpposite());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ public class NetworkNodeGraphEntry implements INetworkNodeGraphEntry {
|
||||
|
||||
NetworkNodeGraphEntry otherItem = (NetworkNodeGraphEntry) other;
|
||||
|
||||
if (node.getWorld().getDimensionKey() != otherItem.node.getWorld().getDimensionKey()) {
|
||||
if (node.getWorld().dimension() != otherItem.node.getWorld().dimension()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class NetworkNodeGraphEntry implements INetworkNodeGraphEntry {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = node.getPos().hashCode();
|
||||
result = 31 * result + node.getWorld().getDimensionKey().hashCode();
|
||||
result = 31 * result + node.getWorld().dimension().hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -17,14 +17,14 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
public class NetworkNodeListener {
|
||||
@SubscribeEvent
|
||||
public void onBlockPlace(BlockEvent.EntityPlaceEvent e) {
|
||||
if (!e.getWorld().isRemote() && e.getEntity() instanceof PlayerEntity) {
|
||||
if (!e.getWorld().isClientSide() && e.getEntity() instanceof PlayerEntity) {
|
||||
PlayerEntity player = (PlayerEntity) e.getEntity();
|
||||
|
||||
INetworkNode placed = NetworkUtils.getNodeFromTile(e.getWorld().getTileEntity(e.getPos()));
|
||||
INetworkNode placed = NetworkUtils.getNodeFromTile(e.getWorld().getBlockEntity(e.getPos()));
|
||||
|
||||
if (placed != null) {
|
||||
for (Direction facing : Direction.values()) {
|
||||
INetworkNode node = NetworkUtils.getNodeFromTile(e.getWorld().getTileEntity(e.getBlockSnapshot().getPos().offset(facing)));
|
||||
INetworkNode node = NetworkUtils.getNodeFromTile(e.getWorld().getBlockEntity(e.getBlockSnapshot().getPos().relative(facing)));
|
||||
|
||||
if (node != null && node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, player)) {
|
||||
WorldUtils.sendNoPermissionMessage(player);
|
||||
@@ -47,7 +47,7 @@ public class NetworkNodeListener {
|
||||
|
||||
private void discoverNode(IWorld world, BlockPos pos) {
|
||||
for (Direction facing : Direction.values()) {
|
||||
INetworkNode node = NetworkUtils.getNodeFromTile(world.getTileEntity(pos.offset(facing)));
|
||||
INetworkNode node = NetworkUtils.getNodeFromTile(world.getBlockEntity(pos.relative(facing)));
|
||||
|
||||
if (node != null && node.getNetwork() != null) {
|
||||
node.getNetwork().getNodeGraph().invalidate(Action.PERFORM, node.getNetwork().getWorld(), node.getNetwork().getPosition());
|
||||
@@ -59,8 +59,8 @@ public class NetworkNodeListener {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBlockBreak(BlockEvent.BreakEvent e) {
|
||||
if (!e.getWorld().isRemote()) {
|
||||
INetworkNode node = NetworkUtils.getNodeFromTile(e.getWorld().getTileEntity(e.getPos()));
|
||||
if (!e.getWorld().isClientSide()) {
|
||||
INetworkNode node = NetworkUtils.getNodeFromTile(e.getWorld().getBlockEntity(e.getPos()));
|
||||
|
||||
if (node != null && node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, e.getPlayer())) {
|
||||
WorldUtils.sendNoPermissionMessage(e.getPlayer());
|
||||
|
@@ -39,7 +39,7 @@ public class NetworkNodeManager extends RSWorldSavedData implements INetworkNode
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT tag) {
|
||||
public void load(CompoundNBT tag) {
|
||||
if (tag.contains(NBT_NODES)) {
|
||||
ListNBT nodesTag = tag.getList(NBT_NODES, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class NetworkNodeManager extends RSWorldSavedData implements INetworkNode
|
||||
|
||||
ResourceLocation id = new ResourceLocation(nodeTag.getString(NBT_NODE_ID));
|
||||
CompoundNBT data = nodeTag.getCompound(NBT_NODE_DATA);
|
||||
BlockPos pos = BlockPos.fromLong(nodeTag.getLong(NBT_NODE_POS));
|
||||
BlockPos pos = BlockPos.of(nodeTag.getLong(NBT_NODE_POS));
|
||||
|
||||
INetworkNodeFactory factory = API.instance().getNetworkNodeRegistry().get(id);
|
||||
|
||||
@@ -74,7 +74,7 @@ public class NetworkNodeManager extends RSWorldSavedData implements INetworkNode
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
public CompoundNBT save(CompoundNBT tag) {
|
||||
ListNBT list = new ListNBT();
|
||||
|
||||
for (INetworkNode node : all()) {
|
||||
@@ -82,7 +82,7 @@ public class NetworkNodeManager extends RSWorldSavedData implements INetworkNode
|
||||
CompoundNBT nodeTag = new CompoundNBT();
|
||||
|
||||
nodeTag.putString(NBT_NODE_ID, node.getId().toString());
|
||||
nodeTag.putLong(NBT_NODE_POS, node.getPos().toLong());
|
||||
nodeTag.putLong(NBT_NODE_POS, node.getPos().asLong());
|
||||
nodeTag.put(NBT_NODE_DATA, node.write(new CompoundNBT()));
|
||||
|
||||
list.add(nodeTag);
|
||||
@@ -131,6 +131,6 @@ public class NetworkNodeManager extends RSWorldSavedData implements INetworkNode
|
||||
|
||||
@Override
|
||||
public void markForSaving() {
|
||||
markDirty();
|
||||
setDirty();
|
||||
}
|
||||
}
|
||||
|
@@ -37,25 +37,25 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
|
||||
CraftingInventory matrix = grid.getCraftingMatrix();
|
||||
|
||||
for (int i = 0; i < grid.getCraftingMatrix().getSizeInventory(); ++i) {
|
||||
ItemStack slot = matrix.getStackInSlot(i);
|
||||
for (int i = 0; i < grid.getCraftingMatrix().getContainerSize(); ++i) {
|
||||
ItemStack slot = matrix.getItem(i);
|
||||
|
||||
// Do we have a remainder?
|
||||
if (i < remainder.size() && !remainder.get(i).isEmpty()) {
|
||||
// If there is no space for the remainder, dump it in the player inventory.
|
||||
if (!slot.isEmpty() && slot.getCount() > 1) {
|
||||
if (!player.inventory.addItemStackToInventory(remainder.get(i).copy())) { // If there is no space in the player inventory, try to dump it in the network.
|
||||
if (!player.inventory.add(remainder.get(i).copy())) { // If there is no space in the player inventory, try to dump it in the network.
|
||||
ItemStack remainderStack = network == null ? remainder.get(i).copy() : network.insertItem(remainder.get(i).copy(), remainder.get(i).getCount(), Action.PERFORM);
|
||||
|
||||
// If there is no space in the network, just dump it in the world.
|
||||
if (!remainderStack.isEmpty()) {
|
||||
InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosX(), player.getPosY(), player.getPosZ(), remainderStack);
|
||||
InventoryHelper.dropItemStack(player.getCommandSenderWorld(), player.getX(), player.getY(), player.getZ(), remainderStack);
|
||||
}
|
||||
}
|
||||
|
||||
matrix.decrStackSize(i, 1);
|
||||
matrix.removeItem(i, 1);
|
||||
} else {
|
||||
matrix.setInventorySlotContents(i, remainder.get(i).copy());
|
||||
matrix.setItem(i, remainder.get(i).copy());
|
||||
}
|
||||
} else if (!slot.isEmpty()) { // We don't have a remainder, but the slot is not empty.
|
||||
if (slot.getCount() == 1 && network != null && grid.isGridActive()) { // Attempt to refill the slot with the same item from the network, only if we have a network and only if it's the last item.
|
||||
@@ -72,13 +72,13 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
}
|
||||
}
|
||||
|
||||
matrix.setInventorySlotContents(i, refill);
|
||||
matrix.setItem(i, refill);
|
||||
|
||||
if (!refill.isEmpty()) {
|
||||
network.getItemStorageTracker().changed(player, refill.copy());
|
||||
}
|
||||
} else { // We don't have a network, or, the slot still has more than 1 items in it. Just decrement then.
|
||||
matrix.decrStackSize(i, 1);
|
||||
matrix.removeItem(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
CraftingInventory matrix = grid.getCraftingMatrix();
|
||||
INetwork network = grid.getNetwork();
|
||||
List<ItemStack> craftedItemsList = new ArrayList<>();
|
||||
ItemStack crafted = grid.getCraftingResult().getStackInSlot(0);
|
||||
ItemStack crafted = grid.getCraftingResult().getItem(0);
|
||||
|
||||
int maxCrafted = crafted.getMaxStackSize();
|
||||
|
||||
@@ -116,14 +116,14 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
craftedItemsList.add(crafted.copy());
|
||||
|
||||
amountCrafted += crafted.getCount();
|
||||
} while (API.instance().getComparer().isEqual(crafted, grid.getCraftingResult().getStackInSlot(0)) && amountCrafted < maxCrafted && amountCrafted + crafted.getCount() <= maxCrafted);
|
||||
} while (API.instance().getComparer().isEqual(crafted, grid.getCraftingResult().getItem(0)) && amountCrafted < maxCrafted && amountCrafted + crafted.getCount() <= maxCrafted);
|
||||
|
||||
if (useNetwork) {
|
||||
usedItems.getStacks().forEach(stack -> network.extractItem(stack.getStack(), stack.getStack().getCount(), Action.PERFORM));
|
||||
}
|
||||
|
||||
for (ItemStack craftedItem : craftedItemsList) {
|
||||
if (!player.inventory.addItemStackToInventory(craftedItem.copy())) {
|
||||
if (!player.inventory.add(craftedItem.copy())) {
|
||||
|
||||
ItemStack remainder = craftedItem;
|
||||
|
||||
@@ -132,7 +132,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
}
|
||||
|
||||
if (!remainder.isEmpty()) {
|
||||
InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosX(), player.getPosY(), player.getPosZ(), remainder);
|
||||
InventoryHelper.dropItemStack(player.getCommandSenderWorld(), player.getX(), player.getY(), player.getZ(), remainder);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,14 +140,14 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
// @Volatile: This is some logic copied from CraftingResultSlot#onCrafting. We call this manually for shift clicking because
|
||||
// otherwise it's not being called.
|
||||
// For regular crafting, this is already called in ResultCraftingGridSlot#onTake -> onCrafting(stack)
|
||||
crafted.onCrafting(player.world, player, amountCrafted);
|
||||
crafted.onCraftedBy(player.level, player, amountCrafted);
|
||||
BasicEventHooks.firePlayerCraftingEvent(player, ItemHandlerHelper.copyStackWithSize(crafted, amountCrafted), grid.getCraftingMatrix());
|
||||
ForgeHooks.setCraftingPlayer(null);
|
||||
}
|
||||
|
||||
private void filterDuplicateStacks(INetwork network, CraftingInventory matrix, IStackList<ItemStack> availableItems) {
|
||||
for (int i = 0; i < matrix.getSizeInventory(); ++i) {
|
||||
ItemStack stack = network.getItemStorageCache().getList().get(matrix.getStackInSlot(i));
|
||||
for (int i = 0; i < matrix.getContainerSize(); ++i) {
|
||||
ItemStack stack = network.getItemStorageCache().getList().get(matrix.getItem(i));
|
||||
|
||||
//Don't add the same item twice into the list. Items may appear twice in a recipe but not in storage.
|
||||
if (stack != null && availableItems.get(stack) == null) {
|
||||
@@ -165,8 +165,8 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
}
|
||||
|
||||
// First try to empty the crafting matrix
|
||||
for (int i = 0; i < grid.getCraftingMatrix().getSizeInventory(); ++i) {
|
||||
ItemStack slot = grid.getCraftingMatrix().getStackInSlot(i);
|
||||
for (int i = 0; i < grid.getCraftingMatrix().getContainerSize(); ++i) {
|
||||
ItemStack slot = grid.getCraftingMatrix().getItem(i);
|
||||
|
||||
if (!slot.isEmpty()) {
|
||||
// Only if we are a crafting grid. Pattern grids can just be emptied.
|
||||
@@ -182,19 +182,19 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
}
|
||||
} else {
|
||||
// If we aren't connected, try to insert into player inventory. If it fails, stop.
|
||||
if (!player.inventory.addItemStackToInventory(slot.copy())) {
|
||||
if (!player.inventory.add(slot.copy())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
grid.getCraftingMatrix().setInventorySlotContents(i, ItemStack.EMPTY);
|
||||
grid.getCraftingMatrix().setItem(i, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
AtomicReference<Map<Item, ItemStack>> playerItems = new AtomicReference<>();
|
||||
// Now let's fill the matrix
|
||||
for (int i = 0; i < grid.getCraftingMatrix().getSizeInventory(); ++i) {
|
||||
for (int i = 0; i < grid.getCraftingMatrix().getContainerSize(); ++i) {
|
||||
if (recipe[i] != null) {
|
||||
ItemStack[] possibilities = recipe[i];
|
||||
|
||||
@@ -214,7 +214,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
ItemStack took = network.extractItem(possibility, 1, IComparer.COMPARE_NBT, Action.PERFORM);
|
||||
|
||||
if (!took.isEmpty()) {
|
||||
grid.getCraftingMatrix().setInventorySlotContents(i, took);
|
||||
grid.getCraftingMatrix().setItem(i, took);
|
||||
|
||||
network.getItemStorageTracker().changed(player, took.copy());
|
||||
|
||||
@@ -228,11 +228,11 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
// If we haven't found anything in the network (or we are disconnected), go look in the player inventory
|
||||
if (!found) {
|
||||
for (ItemStack possibility : possibilities) {
|
||||
for (int j = 0; j < player.inventory.getSizeInventory(); ++j) {
|
||||
if (API.instance().getComparer().isEqual(possibility, player.inventory.getStackInSlot(j), IComparer.COMPARE_NBT)) {
|
||||
grid.getCraftingMatrix().setInventorySlotContents(i, ItemHandlerHelper.copyStackWithSize(player.inventory.getStackInSlot(j), 1));
|
||||
for (int j = 0; j < player.inventory.getContainerSize(); ++j) {
|
||||
if (API.instance().getComparer().isEqual(possibility, player.inventory.getItem(j), IComparer.COMPARE_NBT)) {
|
||||
grid.getCraftingMatrix().setItem(i, ItemHandlerHelper.copyStackWithSize(player.inventory.getItem(j), 1));
|
||||
|
||||
player.inventory.decrStackSize(j, 1);
|
||||
player.inventory.removeItem(j, 1);
|
||||
|
||||
found = true;
|
||||
|
||||
@@ -247,7 +247,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
}
|
||||
} else if (grid.getGridType() == GridType.PATTERN) {
|
||||
// If we are a pattern grid we can just set the slot
|
||||
grid.getCraftingMatrix().setInventorySlotContents(i, possibilities.length == 0 ? ItemStack.EMPTY : possibilities[0]);
|
||||
grid.getCraftingMatrix().setItem(i, possibilities.length == 0 ? ItemStack.EMPTY : possibilities[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -284,8 +284,8 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
|
||||
private Map<Item, ItemStack> makePlayerInventoryMap(PlayerEntity player, INetwork network) {
|
||||
Map<Item, ItemStack> playerItems = new HashMap<>();
|
||||
for (int j = 0; j < player.inventory.getSizeInventory(); j++) {
|
||||
ItemStack inventoryStack = player.inventory.getStackInSlot(j);
|
||||
for (int j = 0; j < player.inventory.getContainerSize(); j++) {
|
||||
ItemStack inventoryStack = player.inventory.getItem(j);
|
||||
|
||||
if (inventoryStack.getItem() instanceof ICraftingPatternProvider) {
|
||||
ICraftingPattern pattern = PatternItem.fromCache(network.getWorld(), inventoryStack);
|
||||
|
@@ -53,7 +53,7 @@ public class GridManager implements IGridManager {
|
||||
|
||||
buf.writeBoolean(stack != null);
|
||||
if (stack != null) {
|
||||
buf.writeItemStack(stack);
|
||||
buf.writeItem(stack);
|
||||
}
|
||||
|
||||
slot.writePlayerSlot(buf);
|
||||
@@ -70,7 +70,7 @@ public class GridManager implements IGridManager {
|
||||
}
|
||||
|
||||
IGrid grid = null;
|
||||
TileEntity tile = factory.getRelevantTile(player.world, pos);
|
||||
TileEntity tile = factory.getRelevantTile(player.level, pos);
|
||||
|
||||
if (factory.getType() == GridFactoryType.STACK) {
|
||||
grid = factory.createFromStack(player, stack, slot);
|
||||
|
@@ -47,7 +47,7 @@ public class GridTab implements IGridTab {
|
||||
@Override
|
||||
public void drawIcon(MatrixStack matrixStack, int x, int y, IElementDrawer<ItemStack> itemDrawer, IElementDrawer<FluidStack> fluidDrawer) {
|
||||
if (!icon.isEmpty()) {
|
||||
RenderHelper.setupGui3DDiffuseLighting();
|
||||
RenderHelper.setupFor3DItems();
|
||||
|
||||
itemDrawer.draw(matrixStack, x, y, icon);
|
||||
} else {
|
||||
|
@@ -27,7 +27,7 @@ public class GridBlockGridFactory implements IGridFactory {
|
||||
@Override
|
||||
@Nullable
|
||||
public IGrid createFromBlock(PlayerEntity player, BlockPos pos) {
|
||||
TileEntity tile = getRelevantTile(player.getEntityWorld(), pos);
|
||||
TileEntity tile = getRelevantTile(player.getCommandSenderWorld(), pos);
|
||||
|
||||
if (tile instanceof GridTile) {
|
||||
return ((GridTile) tile).getNode();
|
||||
@@ -39,7 +39,7 @@ public class GridBlockGridFactory implements IGridFactory {
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity getRelevantTile(World world, BlockPos pos) {
|
||||
return world.getTileEntity(pos);
|
||||
return world.getBlockEntity(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -27,7 +27,7 @@ public class PortableGridBlockGridFactory implements IGridFactory {
|
||||
@Override
|
||||
@Nullable
|
||||
public IGrid createFromBlock(PlayerEntity player, BlockPos pos) {
|
||||
TileEntity tile = getRelevantTile(player.world, pos);
|
||||
TileEntity tile = getRelevantTile(player.level, pos);
|
||||
|
||||
if (tile instanceof PortableGridTile) {
|
||||
return (PortableGridTile) tile;
|
||||
@@ -39,7 +39,7 @@ public class PortableGridBlockGridFactory implements IGridFactory {
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity getRelevantTile(World world, BlockPos pos) {
|
||||
return world.getTileEntity(pos);
|
||||
return world.getBlockEntity(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -48,12 +48,12 @@ public class FluidGridHandler implements IFluidGridHandler {
|
||||
fluidHandler.fill(extracted, IFluidHandler.FluidAction.EXECUTE);
|
||||
|
||||
if (shift) {
|
||||
if (!player.inventory.addItemStackToInventory(fluidHandler.getContainer().copy())) {
|
||||
InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosX(), player.getPosY(), player.getPosZ(), fluidHandler.getContainer());
|
||||
if (!player.inventory.add(fluidHandler.getContainer().copy())) {
|
||||
InventoryHelper.dropItemStack(player.getCommandSenderWorld(), player.getX(), player.getY(), player.getZ(), fluidHandler.getContainer());
|
||||
}
|
||||
} else {
|
||||
player.inventory.setItemStack(fluidHandler.getContainer());
|
||||
player.updateHeldItem();
|
||||
player.inventory.setCarried(fluidHandler.getContainer());
|
||||
player.broadcastCarriedItem();
|
||||
}
|
||||
|
||||
network.getNetworkItemManager().drainEnergy(player, RS.SERVER_CONFIG.getWirelessFluidGrid().getExtractUsage());
|
||||
@@ -86,8 +86,8 @@ public class FluidGridHandler implements IFluidGridHandler {
|
||||
|
||||
@Override
|
||||
public void onInsertHeldContainer(ServerPlayerEntity player) {
|
||||
player.inventory.setItemStack(onInsert(player, player.inventory.getItemStack()));
|
||||
player.updateHeldItem();
|
||||
player.inventory.setCarried(onInsert(player, player.inventory.getCarried()));
|
||||
player.broadcastCarriedItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -58,13 +58,13 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
|
||||
boolean single = (flags & EXTRACT_SINGLE) == EXTRACT_SINGLE;
|
||||
|
||||
ItemStack held = player.inventory.getItemStack();
|
||||
ItemStack held = player.inventory.getCarried();
|
||||
|
||||
if (single) {
|
||||
if (!held.isEmpty() && (!API.instance().getComparer().isEqualNoQuantity(item, held) || held.getCount() + 1 > held.getMaxStackSize())) {
|
||||
return;
|
||||
}
|
||||
} else if (!player.inventory.getItemStack().isEmpty()) {
|
||||
} else if (!player.inventory.getCarried().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -119,10 +119,10 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
if (single && !held.isEmpty()) {
|
||||
held.grow(1);
|
||||
} else {
|
||||
player.inventory.setItemStack(took);
|
||||
player.inventory.setCarried(took);
|
||||
}
|
||||
|
||||
player.updateHeldItem();
|
||||
player.broadcastCarriedItem();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,11 +157,11 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
|
||||
@Override
|
||||
public void onInsertHeldItem(ServerPlayerEntity player, boolean single) {
|
||||
if (player.inventory.getItemStack().isEmpty() || !network.getSecurityManager().hasPermission(Permission.INSERT, player) || !network.canRun()) {
|
||||
if (player.inventory.getCarried().isEmpty() || !network.getSecurityManager().hasPermission(Permission.INSERT, player) || !network.canRun()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack stack = player.inventory.getItemStack();
|
||||
ItemStack stack = player.inventory.getCarried();
|
||||
int size = single ? 1 : stack.getCount();
|
||||
|
||||
network.getItemStorageTracker().changed(player, stack.copy());
|
||||
@@ -173,10 +173,10 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
stack.shrink(size);
|
||||
}
|
||||
} else {
|
||||
player.inventory.setItemStack(network.insertItem(stack, size, Action.PERFORM));
|
||||
player.inventory.setCarried(network.insertItem(stack, size, Action.PERFORM));
|
||||
}
|
||||
|
||||
player.updateHeldItem();
|
||||
player.broadcastCarriedItem();
|
||||
|
||||
network.getNetworkItemManager().drainEnergy(player, RS.SERVER_CONFIG.getWirelessGrid().getInsertUsage());
|
||||
}
|
||||
@@ -253,7 +253,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
}
|
||||
|
||||
public static void onInventoryScroll(IItemGridHandler gridHandler, ServerPlayerEntity player, int slot, boolean shift, boolean up, @Nullable INetwork network) {
|
||||
if (player == null || !(player.openContainer instanceof GridContainer)) {
|
||||
if (player == null || !(player.containerMenu instanceof GridContainer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -262,15 +262,15 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
}
|
||||
|
||||
int flags = EXTRACT_SINGLE;
|
||||
ItemStack stackInSlot = player.inventory.getStackInSlot(slot);
|
||||
ItemStack stackOnCursor = player.inventory.getItemStack();
|
||||
ItemStack stackInSlot = player.inventory.getItem(slot);
|
||||
ItemStack stackOnCursor = player.inventory.getCarried();
|
||||
|
||||
if (shift) { // shift
|
||||
flags |= EXTRACT_SHIFT;
|
||||
|
||||
if (!stackInSlot.isEmpty()) {
|
||||
if (up) { // scroll up
|
||||
player.inventory.setInventorySlotContents(slot, gridHandler.onInsert(player, stackInSlot, true));
|
||||
player.inventory.setItem(slot, gridHandler.onInsert(player, stackInSlot, true));
|
||||
} else { // scroll down
|
||||
gridHandler.onExtract(player, stackInSlot, slot, flags);
|
||||
}
|
||||
@@ -279,7 +279,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
if (up) { // scroll up
|
||||
if (!stackOnCursor.isEmpty()) {
|
||||
gridHandler.onInsert(player, stackOnCursor, true);
|
||||
player.updateHeldItem();
|
||||
player.broadcastCarriedItem();
|
||||
}
|
||||
} else { //scroll down
|
||||
if (stackOnCursor.isEmpty()) {
|
||||
@@ -297,7 +297,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
}
|
||||
|
||||
public static void onGridScroll(IItemGridHandler gridHandler, ServerPlayerEntity player, @Nullable UUID id, boolean shift, boolean up, @Nullable INetwork network) {
|
||||
if (player == null || !(player.openContainer instanceof GridContainer)) {
|
||||
if (player == null || !(player.containerMenu instanceof GridContainer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
IGrid grid = ((GridContainer) player.openContainer).getGrid();
|
||||
IGrid grid = ((GridContainer) player.containerMenu).getGrid();
|
||||
|
||||
int flags = EXTRACT_SINGLE;
|
||||
|
||||
@@ -317,9 +317,9 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < player.inventory.mainInventory.size(); i++) {
|
||||
if (API.instance().getComparer().isEqual(player.inventory.getStackInSlot(i), cache.getList().get(id), IComparer.COMPARE_NBT)) {
|
||||
gridHandler.onInsert(player, player.inventory.getStackInSlot(i), true);
|
||||
for (int i = 0; i < player.inventory.items.size(); i++) {
|
||||
if (API.instance().getComparer().isEqual(player.inventory.getItem(i), cache.getList().get(id), IComparer.COMPARE_NBT)) {
|
||||
gridHandler.onInsert(player, player.inventory.getItem(i), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -331,9 +331,9 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
if (!up && id != null) { //scroll down, extract hovering item
|
||||
gridHandler.onExtract(player, id, -1, flags);
|
||||
|
||||
} else if (up && !player.inventory.getItemStack().isEmpty()) { // insert stack from cursor
|
||||
gridHandler.onInsert(player, player.inventory.getItemStack(), true);
|
||||
player.updateHeldItem();
|
||||
} else if (up && !player.inventory.getCarried().isEmpty()) { // insert stack from cursor
|
||||
gridHandler.onInsert(player, player.inventory.getCarried(), true);
|
||||
player.broadcastCarriedItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -40,13 +40,13 @@ public class PortableFluidGridHandler implements IFluidGridHandler {
|
||||
|
||||
ItemStack bucket = ItemStack.EMPTY;
|
||||
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
|
||||
ItemStack slot = player.inventory.getStackInSlot(i);
|
||||
for (int i = 0; i < player.inventory.getContainerSize(); ++i) {
|
||||
ItemStack slot = player.inventory.getItem(i);
|
||||
|
||||
if (API.instance().getComparer().isEqualNoQuantity(StackUtils.EMPTY_BUCKET, slot)) {
|
||||
bucket = StackUtils.EMPTY_BUCKET.copy();
|
||||
|
||||
player.inventory.decrStackSize(i, 1);
|
||||
player.inventory.removeItem(i, 1);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -59,12 +59,12 @@ public class PortableFluidGridHandler implements IFluidGridHandler {
|
||||
fluidHandler.fill(portableGrid.getFluidStorage().extract(stack, FluidAttributes.BUCKET_VOLUME, IComparer.COMPARE_NBT, Action.PERFORM), IFluidHandler.FluidAction.EXECUTE);
|
||||
|
||||
if (shift) {
|
||||
if (!player.inventory.addItemStackToInventory(fluidHandler.getContainer().copy())) {
|
||||
InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosX(), player.getPosY(), player.getPosZ(), fluidHandler.getContainer());
|
||||
if (!player.inventory.add(fluidHandler.getContainer().copy())) {
|
||||
InventoryHelper.dropItemStack(player.getCommandSenderWorld(), player.getX(), player.getY(), player.getZ(), fluidHandler.getContainer());
|
||||
}
|
||||
} else {
|
||||
player.inventory.setItemStack(fluidHandler.getContainer());
|
||||
player.updateHeldItem();
|
||||
player.inventory.setCarried(fluidHandler.getContainer());
|
||||
player.broadcastCarriedItem();
|
||||
}
|
||||
|
||||
portableGrid.drainEnergy(RS.SERVER_CONFIG.getPortableGrid().getExtractUsage());
|
||||
@@ -98,8 +98,8 @@ public class PortableFluidGridHandler implements IFluidGridHandler {
|
||||
|
||||
@Override
|
||||
public void onInsertHeldContainer(ServerPlayerEntity player) {
|
||||
player.inventory.setItemStack(onInsert(player, player.inventory.getItemStack()));
|
||||
player.updateHeldItem();
|
||||
player.inventory.setCarried(onInsert(player, player.inventory.getCarried()));
|
||||
player.broadcastCarriedItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -56,13 +56,13 @@ public class PortableItemGridHandler implements IItemGridHandler {
|
||||
|
||||
boolean single = (flags & EXTRACT_SINGLE) == EXTRACT_SINGLE;
|
||||
|
||||
ItemStack held = player.inventory.getItemStack();
|
||||
ItemStack held = player.inventory.getCarried();
|
||||
|
||||
if (single) {
|
||||
if (!held.isEmpty() && (!API.instance().getComparer().isEqualNoQuantity(item, held) || held.getCount() + 1 > held.getMaxStackSize())) {
|
||||
return;
|
||||
}
|
||||
} else if (!player.inventory.getItemStack().isEmpty()) {
|
||||
} else if (!player.inventory.getCarried().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -116,10 +116,10 @@ public class PortableItemGridHandler implements IItemGridHandler {
|
||||
if (single && !held.isEmpty()) {
|
||||
held.grow(1);
|
||||
} else {
|
||||
player.inventory.setItemStack(took);
|
||||
player.inventory.setCarried(took);
|
||||
}
|
||||
|
||||
player.updateHeldItem();
|
||||
player.broadcastCarriedItem();
|
||||
}
|
||||
|
||||
portableGrid.drainEnergy(RS.SERVER_CONFIG.getPortableGrid().getExtractUsage());
|
||||
@@ -152,11 +152,11 @@ public class PortableItemGridHandler implements IItemGridHandler {
|
||||
|
||||
@Override
|
||||
public void onInsertHeldItem(ServerPlayerEntity player, boolean single) {
|
||||
if (player.inventory.getItemStack().isEmpty() || portableGrid.getStorage() == null || !grid.isGridActive()) {
|
||||
if (player.inventory.getCarried().isEmpty() || portableGrid.getStorage() == null || !grid.isGridActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack stack = player.inventory.getItemStack();
|
||||
ItemStack stack = player.inventory.getCarried();
|
||||
int size = single ? 1 : stack.getCount();
|
||||
|
||||
portableGrid.getItemStorageTracker().changed(player, stack.copy());
|
||||
@@ -168,10 +168,10 @@ public class PortableItemGridHandler implements IItemGridHandler {
|
||||
stack.shrink(size);
|
||||
}
|
||||
} else {
|
||||
player.inventory.setItemStack(portableGrid.getItemStorage().insert(stack, size, Action.PERFORM));
|
||||
player.inventory.setCarried(portableGrid.getItemStorage().insert(stack, size, Action.PERFORM));
|
||||
}
|
||||
|
||||
player.updateHeldItem();
|
||||
player.broadcastCarriedItem();
|
||||
|
||||
portableGrid.drainEnergy(RS.SERVER_CONFIG.getPortableGrid().getInsertUsage());
|
||||
}
|
||||
|
@@ -34,12 +34,12 @@ public class NetworkItemManager implements INetworkItemManager {
|
||||
if (node instanceof IWirelessTransmitter &&
|
||||
network.canRun() &&
|
||||
node.isActive() &&
|
||||
((IWirelessTransmitter) node).getDimension() == player.getEntityWorld().getDimensionKey()) {
|
||||
((IWirelessTransmitter) node).getDimension() == player.getCommandSenderWorld().dimension()) {
|
||||
IWirelessTransmitter transmitter = (IWirelessTransmitter) node;
|
||||
|
||||
Vector3d pos = player.getPositionVec();
|
||||
Vector3d pos = player.position();
|
||||
|
||||
double distance = Math.sqrt(Math.pow(transmitter.getOrigin().getX() - pos.getX(), 2) + Math.pow(transmitter.getOrigin().getY() - pos.getY(), 2) + Math.pow(transmitter.getOrigin().getZ() - pos.getZ(), 2));
|
||||
double distance = Math.sqrt(Math.pow(transmitter.getOrigin().getX() - pos.x(), 2) + Math.pow(transmitter.getOrigin().getY() - pos.y(), 2) + Math.pow(transmitter.getOrigin().getZ() - pos.z(), 2));
|
||||
|
||||
if (distance < transmitter.getRange()) {
|
||||
inRange = true;
|
||||
@@ -50,7 +50,7 @@ public class NetworkItemManager implements INetworkItemManager {
|
||||
}
|
||||
|
||||
if (!inRange) {
|
||||
player.sendMessage(new TranslationTextComponent("misc.refinedstorage.network_item.out_of_range"), player.getUniqueID());
|
||||
player.sendMessage(new TranslationTextComponent("misc.refinedstorage.network_item.out_of_range"), player.getUUID());
|
||||
|
||||
return;
|
||||
}
|
||||
|
@@ -77,7 +77,7 @@ public class WirelessCraftingMonitorNetworkItem implements INetworkItem {
|
||||
if (energyStorage.getEnergyStored() <= 0) {
|
||||
handler.close(player);
|
||||
|
||||
player.closeScreen();
|
||||
player.closeContainer();
|
||||
|
||||
sendOutOfEnergyMessage();
|
||||
}
|
||||
@@ -86,6 +86,6 @@ public class WirelessCraftingMonitorNetworkItem implements INetworkItem {
|
||||
}
|
||||
|
||||
private void sendOutOfEnergyMessage() {
|
||||
player.sendMessage(new TranslationTextComponent("misc.refinedstorage.network_item.out_of_energy", new TranslationTextComponent(stack.getItem().getTranslationKey())), player.getUniqueID());
|
||||
player.sendMessage(new TranslationTextComponent("misc.refinedstorage.network_item.out_of_energy", new TranslationTextComponent(stack.getItem().getDescriptionId())), player.getUUID());
|
||||
}
|
||||
}
|
@@ -70,7 +70,7 @@ public class WirelessFluidGridNetworkItem implements INetworkItem {
|
||||
if (energyStorage.getEnergyStored() <= 0) {
|
||||
handler.close(player);
|
||||
|
||||
player.closeScreen();
|
||||
player.closeContainer();
|
||||
|
||||
sendOutOfEnergyMessage();
|
||||
}
|
||||
@@ -79,6 +79,6 @@ public class WirelessFluidGridNetworkItem implements INetworkItem {
|
||||
}
|
||||
|
||||
private void sendOutOfEnergyMessage() {
|
||||
player.sendMessage(new TranslationTextComponent("misc.refinedstorage.network_item.out_of_energy", new TranslationTextComponent(stack.getItem().getTranslationKey())), player.getUniqueID());
|
||||
player.sendMessage(new TranslationTextComponent("misc.refinedstorage.network_item.out_of_energy", new TranslationTextComponent(stack.getItem().getDescriptionId())), player.getUUID());
|
||||
}
|
||||
}
|
@@ -70,7 +70,7 @@ public class WirelessGridNetworkItem implements INetworkItem {
|
||||
if (energyStorage.getEnergyStored() <= 0) {
|
||||
handler.close(player);
|
||||
|
||||
player.closeScreen();
|
||||
player.closeContainer();
|
||||
|
||||
sendOutOfEnergyMessage();
|
||||
}
|
||||
@@ -79,6 +79,6 @@ public class WirelessGridNetworkItem implements INetworkItem {
|
||||
}
|
||||
|
||||
private void sendOutOfEnergyMessage() {
|
||||
player.sendMessage(new TranslationTextComponent("misc.refinedstorage.network_item.out_of_energy", new TranslationTextComponent(stack.getItem().getTranslationKey())), player.getUniqueID());
|
||||
player.sendMessage(new TranslationTextComponent("misc.refinedstorage.network_item.out_of_energy", new TranslationTextComponent(stack.getItem().getDescriptionId())), player.getUUID());
|
||||
}
|
||||
}
|
@@ -45,6 +45,8 @@ import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
|
||||
public class ConstructorNetworkNode extends NetworkNode implements IComparable, IType, ICoverable {
|
||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "constructor");
|
||||
|
||||
@@ -82,7 +84,7 @@ public class ConstructorNetworkNode extends NetworkNode implements IComparable,
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (canUpdate() && ticks % upgrades.getSpeed(BASE_SPEED, 4) == 0 && world.isBlockPresent(pos)) {
|
||||
if (canUpdate() && ticks % upgrades.getSpeed(BASE_SPEED, 4) == 0 && world.isLoaded(pos)) {
|
||||
if (type == IType.ITEMS && !itemFilters.getStackInSlot(0).isEmpty()) {
|
||||
ItemStack stack = itemFilters.getStackInSlot(0);
|
||||
|
||||
@@ -100,7 +102,7 @@ public class ConstructorNetworkNode extends NetworkNode implements IComparable,
|
||||
}
|
||||
|
||||
private void extractAndPlaceFluid(FluidStack stack) {
|
||||
BlockPos front = pos.offset(getDirection());
|
||||
BlockPos front = pos.relative(getDirection());
|
||||
|
||||
if (network.extractFluid(stack, FluidAttributes.BUCKET_VOLUME, compare, Action.SIMULATE).getAmount() < FluidAttributes.BUCKET_VOLUME) {
|
||||
if (upgrades.hasUpgrade(UpgradeItem.Type.CRAFTING)) {
|
||||
@@ -123,7 +125,7 @@ public class ConstructorNetworkNode extends NetworkNode implements IComparable,
|
||||
);
|
||||
|
||||
ActionResultType result = ForgeHooks.onPlaceItemIntoWorld(ctx);
|
||||
if (result.isSuccessOrConsume()) {
|
||||
if (result.consumesAction()) {
|
||||
network.extractItem(stack, 1, Action.PERFORM);
|
||||
}
|
||||
} else if (upgrades.hasUpgrade(UpgradeItem.Type.CRAFTING)) {
|
||||
@@ -137,7 +139,7 @@ public class ConstructorNetworkNode extends NetworkNode implements IComparable,
|
||||
ItemStack took = network.extractItem(stack, upgrades.getStackInteractCount(), compare, Action.PERFORM);
|
||||
|
||||
if (!took.isEmpty()) {
|
||||
DefaultDispenseItemBehavior.doDispense(world, took, 6, getDirection(), new Position(getDispensePositionX(), getDispensePositionY(), getDispensePositionZ()));
|
||||
DefaultDispenseItemBehavior.spawnItem(world, took, 6, getDirection(), new Position(getDispensePositionX(), getDispensePositionY(), getDispensePositionZ()));
|
||||
} else if (upgrades.hasUpgrade(UpgradeItem.Type.CRAFTING)) {
|
||||
network.getCraftingManager().request(this, stack, 1);
|
||||
}
|
||||
@@ -147,20 +149,20 @@ public class ConstructorNetworkNode extends NetworkNode implements IComparable,
|
||||
ItemStack took = network.extractItem(stack, 1, compare, Action.PERFORM);
|
||||
|
||||
if (!took.isEmpty()) {
|
||||
world.addEntity(new FireworkRocketEntity(world, getDispensePositionX(), getDispensePositionY(), getDispensePositionZ(), took));
|
||||
world.addFreshEntity(new FireworkRocketEntity(world, getDispensePositionX(), getDispensePositionY(), getDispensePositionZ(), took));
|
||||
}
|
||||
}
|
||||
|
||||
private double getDispensePositionX() {
|
||||
return (double) pos.getX() + 0.5D + 0.8D * (double) getDirection().getXOffset();
|
||||
return (double) pos.getX() + 0.5D + 0.8D * (double) getDirection().getStepX();
|
||||
}
|
||||
|
||||
private double getDispensePositionY() {
|
||||
return (double) pos.getY() + (getDirection() == Direction.DOWN ? 0.45D : 0.5D) + 0.8D * (double) getDirection().getYOffset();
|
||||
return (double) pos.getY() + (getDirection() == Direction.DOWN ? 0.45D : 0.5D) + 0.8D * (double) getDirection().getStepY();
|
||||
}
|
||||
|
||||
private double getDispensePositionZ() {
|
||||
return (double) pos.getZ() + 0.5D + 0.8D * (double) getDirection().getZOffset();
|
||||
return (double) pos.getZ() + 0.5D + 0.8D * (double) getDirection().getStepZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -259,7 +261,7 @@ public class ConstructorNetworkNode extends NetworkNode implements IComparable,
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isRemote ? ConstructorTile.TYPE.getValue() : type;
|
||||
return world.isClientSide ? ConstructorTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -35,7 +35,7 @@ public class CrafterManagerNetworkNode extends NetworkNode {
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return world.isRemote ? CrafterManagerTile.SIZE.getValue() : size;
|
||||
return world.isClientSide ? CrafterManagerTile.SIZE.getValue() : size;
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
@@ -66,7 +66,7 @@ public class CrafterManagerNetworkNode extends NetworkNode {
|
||||
}
|
||||
|
||||
public int getSearchBoxMode() {
|
||||
return world.isRemote ? CrafterManagerTile.SEARCH_BOX_MODE.getValue() : searchBoxMode;
|
||||
return world.isClientSide ? CrafterManagerTile.SEARCH_BOX_MODE.getValue() : searchBoxMode;
|
||||
}
|
||||
|
||||
public void setSearchBoxMode(int searchBoxMode) {
|
||||
@@ -77,7 +77,7 @@ public class CrafterManagerNetworkNode extends NetworkNode {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
|
||||
if (state.getBlock() instanceof CrafterManagerBlock) {
|
||||
return state.get(NetworkNodeBlock.CONNECTED);
|
||||
return state.getValue(NetworkNodeBlock.CONNECTED);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -84,7 +84,7 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener((handler, slot, reading) -> {
|
||||
if (!reading) {
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@@ -145,8 +145,8 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
invalidate();
|
||||
}
|
||||
|
||||
if (mode == CrafterMode.PULSE_INSERTS_NEXT_SET && world.isBlockPresent(pos)) {
|
||||
if (world.isBlockPowered(pos)) {
|
||||
if (mode == CrafterMode.PULSE_INSERTS_NEXT_SET && world.isLoaded(pos)) {
|
||||
if (world.hasNeighborSignal(pos)) {
|
||||
this.wasPowered = true;
|
||||
|
||||
markDirty();
|
||||
@@ -195,11 +195,11 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
StackUtils.readItems(upgrades, 1, tag);
|
||||
|
||||
if (tag.contains(NBT_DISPLAY_NAME)) {
|
||||
displayName = ITextComponent.Serializer.getComponentFromJson(tag.getString(NBT_DISPLAY_NAME));
|
||||
displayName = ITextComponent.Serializer.fromJson(tag.getString(NBT_DISPLAY_NAME));
|
||||
}
|
||||
|
||||
if (tag.hasUniqueId(NBT_UUID)) {
|
||||
uuid = tag.getUniqueId(NBT_UUID);
|
||||
if (tag.hasUUID(NBT_UUID)) {
|
||||
uuid = tag.getUUID(NBT_UUID);
|
||||
}
|
||||
|
||||
if (tag.contains(NBT_MODE)) {
|
||||
@@ -232,7 +232,7 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
}
|
||||
|
||||
if (uuid != null) {
|
||||
tag.putUniqueId(NBT_UUID, uuid);
|
||||
tag.putUUID(NBT_UUID, uuid);
|
||||
}
|
||||
|
||||
tag.putInt(NBT_MODE, mode.ordinal());
|
||||
@@ -314,12 +314,12 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity getFacingTile() {
|
||||
BlockPos facingPos = pos.offset(getDirection());
|
||||
if (!world.isBlockPresent(facingPos)) {
|
||||
BlockPos facingPos = pos.relative(getDirection());
|
||||
if (!world.isLoaded(facingPos)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return world.getTileEntity(facingPos);
|
||||
return world.getBlockEntity(facingPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -346,7 +346,7 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
}
|
||||
|
||||
if (facing != null) {
|
||||
return new TranslationTextComponent(world.getBlockState(facing.getPos()).getBlock().getTranslationKey());
|
||||
return new TranslationTextComponent(world.getBlockState(facing.getBlockPos()).getBlock().getDescriptionId());
|
||||
}
|
||||
|
||||
return DEFAULT_NAME;
|
||||
@@ -394,7 +394,7 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
return null;
|
||||
}
|
||||
|
||||
INetworkNode facing = API.instance().getNetworkNodeManager((ServerWorld) world).getNode(pos.offset(getDirection()));
|
||||
INetworkNode facing = API.instance().getNetworkNodeManager((ServerWorld) world).getNode(pos.relative(getDirection()));
|
||||
if (!(facing instanceof ICraftingPatternContainer) || facing.getNetwork() != network) {
|
||||
return this;
|
||||
}
|
||||
@@ -438,9 +438,9 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
case IGNORE:
|
||||
return false;
|
||||
case SIGNAL_LOCKS_AUTOCRAFTING:
|
||||
return world.isBlockPowered(pos);
|
||||
return world.hasNeighborSignal(pos);
|
||||
case SIGNAL_UNLOCKS_AUTOCRAFTING:
|
||||
return !world.isBlockPowered(pos);
|
||||
return !world.hasNeighborSignal(pos);
|
||||
case PULSE_INSERTS_NEXT_SET:
|
||||
return locked;
|
||||
default:
|
||||
|
@@ -82,7 +82,7 @@ public class CraftingMonitorNetworkNode extends NetworkNode implements ICrafting
|
||||
BlockState state = world.getBlockState(pos);
|
||||
|
||||
if (state.getBlock() instanceof CraftingMonitorBlock) {
|
||||
return state.get(NetworkNodeBlock.CONNECTED);
|
||||
return state.getValue(NetworkNodeBlock.CONNECTED);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -94,7 +94,7 @@ public class CraftingMonitorNetworkNode extends NetworkNode implements ICrafting
|
||||
|
||||
tag.putInt(NBT_TAB_PAGE, tabPage);
|
||||
|
||||
tabSelected.ifPresent(uuid -> tag.putUniqueId(NBT_TAB_SELECTED, uuid));
|
||||
tabSelected.ifPresent(uuid -> tag.putUUID(NBT_TAB_SELECTED, uuid));
|
||||
|
||||
return tag;
|
||||
}
|
||||
@@ -107,8 +107,8 @@ public class CraftingMonitorNetworkNode extends NetworkNode implements ICrafting
|
||||
tabPage = tag.getInt(NBT_TAB_PAGE);
|
||||
}
|
||||
|
||||
if (tag.hasUniqueId(NBT_TAB_SELECTED)) {
|
||||
tabSelected = Optional.of(tag.getUniqueId(NBT_TAB_SELECTED));
|
||||
if (tag.hasUUID(NBT_TAB_SELECTED)) {
|
||||
tabSelected = Optional.of(tag.getUUID(NBT_TAB_SELECTED));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,12 +127,12 @@ public class CraftingMonitorNetworkNode extends NetworkNode implements ICrafting
|
||||
|
||||
@Override
|
||||
public Optional<UUID> getTabSelected() {
|
||||
return world.isRemote ? CraftingMonitorTile.TAB_SELECTED.getValue() : tabSelected;
|
||||
return world.isClientSide ? CraftingMonitorTile.TAB_SELECTED.getValue() : tabSelected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTabPage() {
|
||||
return world.isRemote ? CraftingMonitorTile.TAB_PAGE.getValue() : tabPage;
|
||||
return world.isClientSide ? CraftingMonitorTile.TAB_PAGE.getValue() : tabPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -89,7 +89,7 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (canUpdate() && ticks % upgrades.getSpeed(BASE_SPEED, 4) == 0 && world.isBlockPresent(pos)) {
|
||||
if (canUpdate() && ticks % upgrades.getSpeed(BASE_SPEED, 4) == 0 && world.isLoaded(pos)) {
|
||||
if (type == IType.ITEMS) {
|
||||
if (pickupItem) {
|
||||
pickupItems();
|
||||
@@ -103,12 +103,12 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
}
|
||||
|
||||
private void pickupItems() {
|
||||
BlockPos front = pos.offset(getDirection());
|
||||
BlockPos front = pos.relative(getDirection());
|
||||
|
||||
List<Entity> droppedItems = new ArrayList<>();
|
||||
|
||||
Chunk chunk = world.getChunkAt(front);
|
||||
chunk.getEntitiesWithinAABBForEntity(null, new AxisAlignedBB(front), droppedItems, null);
|
||||
chunk.getEntities((Entity)null, new AxisAlignedBB(front), droppedItems, null);
|
||||
|
||||
for (Entity entity : droppedItems) {
|
||||
if (entity instanceof ItemEntity) {
|
||||
@@ -127,7 +127,7 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
}
|
||||
|
||||
private void breakBlock() {
|
||||
BlockPos front = pos.offset(getDirection());
|
||||
BlockPos front = pos.relative(getDirection());
|
||||
BlockState frontBlockState = world.getBlockState(front);
|
||||
Block frontBlock = frontBlockState.getBlock();
|
||||
ItemStack frontStack = frontBlock.getPickBlock(
|
||||
@@ -140,12 +140,12 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
|
||||
if (!frontStack.isEmpty() &&
|
||||
IWhitelistBlacklist.acceptsItem(itemFilters, mode, compare, frontStack) &&
|
||||
frontBlockState.getBlockHardness(world, front) != -1.0) {
|
||||
frontBlockState.getDestroySpeed(world, front) != -1.0) {
|
||||
List<ItemStack> drops = Block.getDrops(
|
||||
frontBlockState,
|
||||
(ServerWorld) world,
|
||||
front,
|
||||
world.getTileEntity(front),
|
||||
world.getBlockEntity(front),
|
||||
WorldUtils.getFakePlayer((ServerWorld) world, getOwner()),
|
||||
tool
|
||||
);
|
||||
@@ -159,7 +159,7 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
BlockEvent.BreakEvent e = new BlockEvent.BreakEvent(world, front, frontBlockState, WorldUtils.getFakePlayer((ServerWorld) world, getOwner()));
|
||||
|
||||
if (!MinecraftForge.EVENT_BUS.post(e)) {
|
||||
frontBlock.onBlockHarvested(world, front, frontBlockState, WorldUtils.getFakePlayer((ServerWorld) world, getOwner()));
|
||||
frontBlock.playerWillDestroy(world, front, frontBlockState, WorldUtils.getFakePlayer((ServerWorld) world, getOwner()));
|
||||
|
||||
world.removeBlock(front, false);
|
||||
|
||||
@@ -167,7 +167,7 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
// We check if the controller isn't null here because when a destructor faces a node and removes it
|
||||
// it will essentially remove this block itself from the network without knowing
|
||||
if (network == null) {
|
||||
InventoryHelper.spawnItemStack(world, front.getX(), front.getY(), front.getZ(), drop);
|
||||
InventoryHelper.dropItemStack(world, front.getX(), front.getY(), front.getZ(), drop);
|
||||
} else {
|
||||
network.insertItemTracked(drop, drop.getCount());
|
||||
}
|
||||
@@ -177,13 +177,13 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
}
|
||||
|
||||
private void breakFluid() {
|
||||
BlockPos front = pos.offset(getDirection());
|
||||
BlockPos front = pos.relative(getDirection());
|
||||
BlockState frontBlockState = world.getBlockState(front);
|
||||
Block frontBlock = frontBlockState.getBlock();
|
||||
|
||||
if (frontBlock instanceof FlowingFluidBlock) {
|
||||
// @Volatile: Logic from FlowingFluidBlock#pickupFluid
|
||||
if (frontBlockState.get(FlowingFluidBlock.LEVEL) == 0) {
|
||||
if (frontBlockState.getValue(FlowingFluidBlock.LEVEL) == 0) {
|
||||
Fluid fluid = ((FlowingFluidBlock) frontBlock).getFluid();
|
||||
|
||||
FluidStack stack = new FluidStack(fluid, FluidAttributes.BUCKET_VOLUME);
|
||||
@@ -192,7 +192,7 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
network.insertFluid(stack, stack.getAmount(), Action.SIMULATE).isEmpty()) {
|
||||
network.insertFluidTracked(stack, stack.getAmount());
|
||||
|
||||
world.setBlockState(front, Blocks.AIR.getDefaultState(), 11);
|
||||
world.setBlock(front, Blocks.AIR.defaultBlockState(), 11);
|
||||
}
|
||||
}
|
||||
} else if (frontBlock instanceof IFluidBlock) {
|
||||
@@ -215,13 +215,13 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
ItemStack newTool = new ItemStack(Items.DIAMOND_PICKAXE);
|
||||
|
||||
if (upgrades.hasUpgrade(UpgradeItem.Type.SILK_TOUCH)) {
|
||||
newTool.addEnchantment(Enchantments.SILK_TOUCH, 1);
|
||||
newTool.enchant(Enchantments.SILK_TOUCH, 1);
|
||||
} else if (upgrades.hasUpgrade(UpgradeItem.Type.FORTUNE_3)) {
|
||||
newTool.addEnchantment(Enchantments.FORTUNE, 3);
|
||||
newTool.enchant(Enchantments.BLOCK_FORTUNE, 3);
|
||||
} else if (upgrades.hasUpgrade(UpgradeItem.Type.FORTUNE_2)) {
|
||||
newTool.addEnchantment(Enchantments.FORTUNE, 2);
|
||||
newTool.enchant(Enchantments.BLOCK_FORTUNE, 2);
|
||||
} else if (upgrades.hasUpgrade(UpgradeItem.Type.FORTUNE_1)) {
|
||||
newTool.addEnchantment(Enchantments.FORTUNE, 1);
|
||||
newTool.enchant(Enchantments.BLOCK_FORTUNE, 1);
|
||||
}
|
||||
|
||||
return newTool;
|
||||
@@ -332,7 +332,7 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isRemote ? DestructorTile.TYPE.getValue() : type;
|
||||
return world.isClientSide ? DestructorTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -62,11 +62,11 @@ public class DetectorNetworkNode extends NetworkNode implements IComparable, ITy
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (powered != wasPowered && world.isBlockPresent(pos)) {
|
||||
if (powered != wasPowered && world.isLoaded(pos)) {
|
||||
wasPowered = powered;
|
||||
|
||||
world.setBlockState(pos, world.getBlockState(pos).with(DetectorBlock.POWERED, powered));
|
||||
world.notifyNeighborsOfStateChange(pos, world.getBlockState(pos).getBlock());
|
||||
world.setBlockAndUpdate(pos, world.getBlockState(pos).setValue(DetectorBlock.POWERED, powered));
|
||||
world.updateNeighborsAt(pos, world.getBlockState(pos).getBlock());
|
||||
}
|
||||
|
||||
if (canUpdate() && ticks % SPEED == 0) {
|
||||
@@ -215,7 +215,7 @@ public class DetectorNetworkNode extends NetworkNode implements IComparable, ITy
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isRemote ? DetectorTile.TYPE.getValue() : type;
|
||||
return world.isClientSide ? DetectorTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -90,7 +90,7 @@ public class ExporterNetworkNode extends NetworkNode implements IComparable, ITy
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (canUpdate() && ticks % upgrades.getSpeed() == 0 && world.isBlockPresent(pos)) {
|
||||
if (canUpdate() && ticks % upgrades.getSpeed() == 0 && world.isLoaded(pos)) {
|
||||
if (type == IType.ITEMS) {
|
||||
IItemHandler handler = WorldUtils.getItemHandler(getFacingTile(), getDirection().getOpposite());
|
||||
|
||||
@@ -311,7 +311,7 @@ public class ExporterNetworkNode extends NetworkNode implements IComparable, ITy
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isRemote ? ExporterTile.TYPE.getValue() : type;
|
||||
return world.isClientSide ? ExporterTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -90,7 +90,7 @@ public class ExternalStorageNetworkNode extends NetworkNode implements IStorageP
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (canUpdate() && world.isBlockPresent(pos)) {
|
||||
if (canUpdate() && world.isLoaded(pos)) {
|
||||
if (networkTicks++ == 0) {
|
||||
updateStorage(network, InvalidateCause.INITIAL_TICK_INVALIDATION);
|
||||
|
||||
@@ -293,7 +293,7 @@ public class ExternalStorageNetworkNode extends NetworkNode implements IStorageP
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isRemote ? ExternalStorageTile.TYPE.getValue() : type;
|
||||
return world.isClientSide ? ExternalStorageTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -45,8 +45,8 @@ public class FluidInterfaceNetworkNode extends NetworkNode {
|
||||
protected void onContentsChanged() {
|
||||
super.onContentsChanged();
|
||||
|
||||
if (!world.isRemote) {
|
||||
((FluidInterfaceTile) world.getTileEntity(pos)).getDataManager().sendParameterToWatchers(FluidInterfaceTile.TANK_IN);
|
||||
if (!world.isClientSide) {
|
||||
((FluidInterfaceTile) world.getBlockEntity(pos)).getDataManager().sendParameterToWatchers(FluidInterfaceTile.TANK_IN);
|
||||
}
|
||||
|
||||
markDirty();
|
||||
@@ -155,7 +155,7 @@ public class FluidInterfaceNetworkNode extends NetworkNode {
|
||||
|
||||
private boolean isActingAsStorage() {
|
||||
for (Direction facing : Direction.values()) {
|
||||
INetworkNode facingNode = API.instance().getNetworkNodeManager((ServerWorld) world).getNode(pos.offset(facing));
|
||||
INetworkNode facingNode = API.instance().getNetworkNodeManager((ServerWorld) world).getNode(pos.relative(facing));
|
||||
|
||||
if (facingNode instanceof ExternalStorageNetworkNode &&
|
||||
facingNode.isActive() &&
|
||||
@@ -250,8 +250,8 @@ public class FluidInterfaceNetworkNode extends NetworkNode {
|
||||
}
|
||||
|
||||
private void onTankOutChanged() {
|
||||
if (!world.isRemote && world.isBlockPresent(pos)) {
|
||||
((FluidInterfaceTile) world.getTileEntity(pos)).getDataManager().sendParameterToWatchers(FluidInterfaceTile.TANK_OUT);
|
||||
if (!world.isClientSide && world.isLoaded(pos)) {
|
||||
((FluidInterfaceTile) world.getBlockEntity(pos)).getDataManager().sendParameterToWatchers(FluidInterfaceTile.TANK_OUT);
|
||||
}
|
||||
|
||||
markDirty();
|
||||
|
@@ -85,13 +85,13 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
|
||||
private final Container craftingContainer = new Container(ContainerType.CRAFTING, 0) {
|
||||
@Override
|
||||
public boolean canInteractWith(PlayerEntity player) {
|
||||
public boolean stillValid(PlayerEntity player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory inventory) {
|
||||
if (!world.isRemote) {
|
||||
public void slotsChanged(IInventory inventory) {
|
||||
if (!world.isClientSide) {
|
||||
onCraftingMatrixChanged();
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
matrix.setInventorySlotContents(i, PatternItem.getInputSlot(pattern, i));
|
||||
matrix.setItem(i, PatternItem.getInputSlot(pattern, i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
private void updateAllowedTags() {
|
||||
markDirty();
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
TileEntity tile = world.getBlockEntity(pos);
|
||||
|
||||
if (tile instanceof GridTile) {
|
||||
((GridTile) tile).getDataManager().sendParameterToWatchers(GridTile.ALLOWED_ITEM_TAGS);
|
||||
@@ -280,7 +280,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
}
|
||||
|
||||
public boolean isProcessingPattern() {
|
||||
return world.isRemote ? GridTile.PROCESSING_PATTERN.getValue() : processingPattern;
|
||||
return world.isClientSide ? GridTile.PROCESSING_PATTERN.getValue() : processingPattern;
|
||||
}
|
||||
|
||||
public void setProcessingPattern(boolean processingPattern) {
|
||||
@@ -383,13 +383,13 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
@Override
|
||||
public void onCraftingMatrixChanged() {
|
||||
if (currentRecipe == null || !currentRecipe.matches(matrix, world)) {
|
||||
currentRecipe = world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, matrix, world).orElse(null);
|
||||
currentRecipe = world.getRecipeManager().getRecipeFor(IRecipeType.CRAFTING, matrix, world).orElse(null);
|
||||
}
|
||||
|
||||
if (currentRecipe == null) {
|
||||
result.setInventorySlotContents(0, ItemStack.EMPTY);
|
||||
result.setItem(0, ItemStack.EMPTY);
|
||||
} else {
|
||||
result.setInventorySlotContents(0, currentRecipe.getCraftingResult(matrix));
|
||||
result.setItem(0, currentRecipe.assemble(matrix));
|
||||
}
|
||||
|
||||
craftingListeners.forEach(ICraftingGridListener::onCraftingMatrixChanged);
|
||||
@@ -413,8 +413,8 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
processingMatrixFluids.setFluid(i, FluidStack.EMPTY);
|
||||
}
|
||||
|
||||
for (int i = 0; i < matrix.getSizeInventory(); ++i) {
|
||||
matrix.setInventorySlotContents(i, ItemStack.EMPTY);
|
||||
for (int i = 0; i < matrix.getContainerSize(); ++i) {
|
||||
matrix.setItem(i, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
BlockState state = world.getBlockState(pos);
|
||||
|
||||
if (state.getBlock() instanceof GridBlock) {
|
||||
return state.get(NetworkNodeBlock.CONNECTED);
|
||||
return state.getValue(NetworkNodeBlock.CONNECTED);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -448,21 +448,21 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
public void onClear(PlayerEntity player) {
|
||||
if (type == GridType.CRAFTING) {
|
||||
if (network != null && network.canRun() && network.getSecurityManager().hasPermission(Permission.INSERT, player)) {
|
||||
for (int i = 0; i < matrix.getSizeInventory(); ++i) {
|
||||
ItemStack slot = matrix.getStackInSlot(i);
|
||||
for (int i = 0; i < matrix.getContainerSize(); ++i) {
|
||||
ItemStack slot = matrix.getItem(i);
|
||||
|
||||
if (!slot.isEmpty()) {
|
||||
matrix.setInventorySlotContents(i, network.insertItem(slot, slot.getCount(), Action.PERFORM));
|
||||
matrix.setItem(i, network.insertItem(slot, slot.getCount(), Action.PERFORM));
|
||||
|
||||
network.getItemStorageTracker().changed(player, slot.copy());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < matrix.getSizeInventory(); i++) {
|
||||
ItemStack slot = matrix.getStackInSlot(i);
|
||||
for (int i = 0; i < matrix.getContainerSize(); i++) {
|
||||
ItemStack slot = matrix.getItem(i);
|
||||
|
||||
if (!slot.isEmpty()) {
|
||||
player.inventory.addItemStackToInventory(matrix.getStackInSlot(i));
|
||||
player.inventory.add(matrix.getItem(i));
|
||||
}
|
||||
|
||||
onCraftingMatrixChanged();
|
||||
@@ -517,7 +517,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
ItemStack ingredient = matrix.getStackInSlot(i);
|
||||
ItemStack ingredient = matrix.getItem(i);
|
||||
|
||||
if (!ingredient.isEmpty()) {
|
||||
PatternItem.setInputSlot(pattern, i, ingredient);
|
||||
@@ -564,43 +564,43 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
|
||||
return inputsFilled > 0 && outputsFilled > 0;
|
||||
} else {
|
||||
return !result.getStackInSlot(0).isEmpty() && isPatternAvailable();
|
||||
return !result.getItem(0).isEmpty() && isPatternAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewType() {
|
||||
return world.isRemote ? GridTile.VIEW_TYPE.getValue() : viewType;
|
||||
return world.isClientSide ? GridTile.VIEW_TYPE.getValue() : viewType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSortingDirection() {
|
||||
return world.isRemote ? GridTile.SORTING_DIRECTION.getValue() : sortingDirection;
|
||||
return world.isClientSide ? GridTile.SORTING_DIRECTION.getValue() : sortingDirection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSortingType() {
|
||||
return world.isRemote ? GridTile.SORTING_TYPE.getValue() : sortingType;
|
||||
return world.isClientSide ? GridTile.SORTING_TYPE.getValue() : sortingType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSearchBoxMode() {
|
||||
return world.isRemote ? GridTile.SEARCH_BOX_MODE.getValue() : searchBoxMode;
|
||||
return world.isClientSide ? GridTile.SEARCH_BOX_MODE.getValue() : searchBoxMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return world.isRemote ? GridTile.SIZE.getValue() : size;
|
||||
return world.isClientSide ? GridTile.SIZE.getValue() : size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTabSelected() {
|
||||
return world.isRemote ? GridTile.TAB_SELECTED.getValue() : tabSelected;
|
||||
return world.isClientSide ? GridTile.TAB_SELECTED.getValue() : tabSelected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTabPage() {
|
||||
return world.isRemote ? GridTile.TAB_PAGE.getValue() : Math.min(tabPage, getTotalTabPages());
|
||||
return world.isClientSide ? GridTile.TAB_PAGE.getValue() : Math.min(tabPage, getTotalTabPages());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -647,7 +647,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isRemote ? GridTile.PROCESSING_TYPE.getValue() : processingType;
|
||||
return world.isClientSide ? GridTile.PROCESSING_TYPE.getValue() : processingType;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -65,7 +65,7 @@ public class ImporterNetworkNode extends NetworkNode implements IComparable, IWh
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (!canUpdate() || !world.isBlockPresent(pos)) {
|
||||
if (!canUpdate() || !world.isLoaded(pos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ public class ImporterNetworkNode extends NetworkNode implements IComparable, IWh
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isRemote ? ImporterTile.TYPE.getValue() : type;
|
||||
return world.isClientSide ? ImporterTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -129,7 +129,7 @@ public class InterfaceNetworkNode extends NetworkNode implements IComparable {
|
||||
|
||||
private boolean isActingAsStorage() {
|
||||
for (Direction facing : Direction.values()) {
|
||||
INetworkNode facingNode = API.instance().getNetworkNodeManager((ServerWorld) world).getNode(pos.offset(facing));
|
||||
INetworkNode facingNode = API.instance().getNetworkNodeManager((ServerWorld) world).getNode(pos.relative(facing));
|
||||
|
||||
if (facingNode instanceof ExternalStorageNetworkNode &&
|
||||
facingNode.isActive() &&
|
||||
|
@@ -24,6 +24,8 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.network.INetworkNodeVisitor.Operator;
|
||||
|
||||
public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
private static final String NBT_OWNER = "Owner";
|
||||
private static final String NBT_VERSION = "Version";
|
||||
@@ -84,7 +86,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return new ItemStack(Item.BLOCK_TO_ITEM.get(world.getBlockState(pos).getBlock()), 1);
|
||||
return new ItemStack(Item.BY_BLOCK.get(world.getBlockState(pos).getBlock()), 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,7 +109,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
API.instance().getNetworkNodeManager((ServerWorld) world).markForSaving();
|
||||
}
|
||||
}
|
||||
@@ -140,7 +142,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
@Override
|
||||
public void update() {
|
||||
if (ticks == 0) {
|
||||
redstonePowered = world.isBlockPowered(pos);
|
||||
redstonePowered = world.hasNeighborSignal(pos);
|
||||
}
|
||||
|
||||
++ticks;
|
||||
@@ -158,7 +160,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
BlockState blockState = world.getBlockState(pos);
|
||||
|
||||
if (blockState.getBlock() instanceof NetworkNodeBlock && ((NetworkNodeBlock) blockState.getBlock()).hasConnectedState()) {
|
||||
world.setBlockState(pos, world.getBlockState(pos).with(NetworkNodeBlock.CONNECTED, canUpdate));
|
||||
world.setBlockAndUpdate(pos, world.getBlockState(pos).setValue(NetworkNodeBlock.CONNECTED, canUpdate));
|
||||
}
|
||||
|
||||
if (network != null) {
|
||||
@@ -177,7 +179,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
if (owner != null) {
|
||||
tag.putUniqueId(NBT_OWNER, owner);
|
||||
tag.putUUID(NBT_OWNER, owner);
|
||||
}
|
||||
|
||||
tag.putInt(NBT_VERSION, CURRENT_VERSION);
|
||||
@@ -194,8 +196,8 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
}
|
||||
|
||||
public void read(CompoundNBT tag) {
|
||||
if (tag.hasUniqueId(NBT_OWNER)) {
|
||||
owner = tag.getUniqueId(NBT_OWNER);
|
||||
if (tag.hasUUID(NBT_OWNER)) {
|
||||
owner = tag.getUUID(NBT_OWNER);
|
||||
}
|
||||
|
||||
if (tag.contains(NBT_VERSION)) {
|
||||
@@ -234,19 +236,19 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
@Override
|
||||
public void visit(Operator operator) {
|
||||
for (Direction facing : Direction.values()) {
|
||||
INetworkNode oppositeNode = NetworkUtils.getNodeFromTile(world.getTileEntity(pos.offset(facing)));
|
||||
INetworkNode oppositeNode = NetworkUtils.getNodeFromTile(world.getBlockEntity(pos.relative(facing)));
|
||||
if (oppositeNode == null) {
|
||||
continue;
|
||||
}
|
||||
if (canConduct(facing) && oppositeNode.canReceive(facing.getOpposite())) {
|
||||
operator.apply(world, pos.offset(facing), facing.getOpposite());
|
||||
operator.apply(world, pos.relative(facing), facing.getOpposite());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TileEntity getFacingTile() {
|
||||
return world.getTileEntity(pos.offset(getDirection()));
|
||||
return world.getBlockEntity(pos.relative(getDirection()));
|
||||
}
|
||||
|
||||
public Direction getDirection() {
|
||||
@@ -254,7 +256,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
|
||||
if (state.getBlock() instanceof BaseBlock) {
|
||||
direction = state.get(((BaseBlock) state.getBlock()).getDirection().getProperty());
|
||||
direction = state.getValue(((BaseBlock) state.getBlock()).getDirection().getProperty());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -98,7 +98,7 @@ public class NetworkTransmitterNetworkNode extends NetworkNode {
|
||||
}
|
||||
|
||||
public boolean isSameDimension() {
|
||||
return world.getDimensionKey() == receiverDimension;
|
||||
return world.dimension() == receiverDimension;
|
||||
}
|
||||
|
||||
private boolean canTransmit() {
|
||||
@@ -116,13 +116,13 @@ public class NetworkTransmitterNetworkNode extends NetworkNode {
|
||||
|
||||
if (canTransmit()) {
|
||||
if (!isSameDimension()) {
|
||||
World dimensionWorld = world.getServer().getWorld(receiverDimension);
|
||||
World dimensionWorld = world.getServer().getLevel(receiverDimension);
|
||||
|
||||
if (dimensionWorld != null && dimensionWorld.getTileEntity(receiver) instanceof NetworkReceiverTile) {
|
||||
if (dimensionWorld != null && dimensionWorld.getBlockEntity(receiver) instanceof NetworkReceiverTile) {
|
||||
operator.apply(dimensionWorld, receiver, null);
|
||||
}
|
||||
} else {
|
||||
if (world.getTileEntity(receiver) instanceof NetworkReceiverTile) {
|
||||
if (world.getBlockEntity(receiver) instanceof NetworkReceiverTile) {
|
||||
operator.apply(world, receiver, null);
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,8 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.network.INetworkNodeVisitor.Operator;
|
||||
|
||||
public class RootNetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
private final INetwork network;
|
||||
private final World world;
|
||||
@@ -54,7 +56,7 @@ public class RootNetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Item item = Item.getItemFromBlock(state.getBlock());
|
||||
Item item = Item.byBlock(state.getBlock());
|
||||
|
||||
return new ItemStack(item, 1);
|
||||
}
|
||||
@@ -107,7 +109,7 @@ public class RootNetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
@Override
|
||||
public void visit(Operator operator) {
|
||||
for (Direction facing : Direction.values()) {
|
||||
operator.apply(world, pos.offset(facing), facing.getOpposite());
|
||||
operator.apply(world, pos.relative(facing), facing.getOpposite());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class SecurityManagerNetworkNode extends NetworkNode implements ISecurity
|
||||
.addValidator(new ItemValidator(RSItems.SECURITY_CARD.get()))
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener(((handler, slot, reading) -> {
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
@@ -109,11 +109,11 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
||||
long insertedAt = deposit.getValue();
|
||||
|
||||
if (System.currentTimeMillis() - insertedAt < DEPOSIT_ALL_MAX_DELAY) {
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
|
||||
ItemStack toInsert = player.inventory.getStackInSlot(i);
|
||||
for (int i = 0; i < player.inventory.getContainerSize(); ++i) {
|
||||
ItemStack toInsert = player.inventory.getItem(i);
|
||||
|
||||
if (API.instance().getComparer().isEqual(inserted, toInsert, compare)) {
|
||||
player.inventory.setInventorySlotContents(i, network.insertItemTracked(toInsert, toInsert.getCount()));
|
||||
player.inventory.setItem(i, network.insertItemTracked(toInsert, toInsert.getCount()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,7 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
||||
ItemStack filter = itemFilter.getStackInSlot(0);
|
||||
|
||||
if (!filter.isEmpty() && API.instance().getComparer().isEqual(filter, toInsert, compare)) {
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, network.insertItemTracked(toInsert, toInsert.getCount()));
|
||||
player.inventory.setItem(player.inventory.selected, network.insertItemTracked(toInsert, toInsert.getCount()));
|
||||
|
||||
deposits.put(player.getGameProfile().getName(), Pair.of(toInsert, System.currentTimeMillis()));
|
||||
}
|
||||
@@ -165,11 +165,11 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
||||
|
||||
network.insertFluidTracked(result.getValue(), result.getValue().getAmount());
|
||||
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
|
||||
player.inventory.setItem(player.inventory.selected, ItemStack.EMPTY);
|
||||
|
||||
ItemStack container = result.getLeft();
|
||||
if (!player.inventory.addItemStackToInventory(container.copy())) {
|
||||
InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosX(), player.getPosY(), player.getPosZ(), container);
|
||||
if (!player.inventory.add(container.copy())) {
|
||||
InventoryHelper.dropItemStack(player.getCommandSenderWorld(), player.getX(), player.getY(), player.getZ(), container);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,8 +198,8 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
||||
if (!filter.isEmpty()) {
|
||||
ItemStack result = network.extractItem(filter, toExtract, compare, Action.PERFORM);
|
||||
|
||||
if (!result.isEmpty() && !player.inventory.addItemStackToInventory(result.copy())) {
|
||||
InventoryHelper.spawnItemStack(world, player.getPosX(), player.getPosY(), player.getPosZ(), result);
|
||||
if (!result.isEmpty() && !player.inventory.add(result.copy())) {
|
||||
InventoryHelper.dropItemStack(world, player.getX(), player.getY(), player.getZ(), result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -223,8 +223,8 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
||||
|
||||
fluidHandler.fill(network.extractFluid(stack, FluidAttributes.BUCKET_VOLUME, Action.PERFORM), IFluidHandler.FluidAction.EXECUTE);
|
||||
|
||||
if (!player.inventory.addItemStackToInventory(fluidHandler.getContainer().copy())) {
|
||||
InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosX(), player.getPosY(), player.getPosZ(), fluidHandler.getContainer());
|
||||
if (!player.inventory.add(fluidHandler.getContainer().copy())) {
|
||||
InventoryHelper.dropItemStack(player.getCommandSenderWorld(), player.getX(), player.getY(), player.getZ(), fluidHandler.getContainer());
|
||||
}
|
||||
}));
|
||||
}
|
||||
@@ -318,7 +318,7 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isRemote ? StorageMonitorTile.TYPE.getValue() : type;
|
||||
return world.isClientSide ? StorageMonitorTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -15,6 +15,8 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import com.refinedmods.refinedstorage.api.network.INetworkNodeVisitor.Operator;
|
||||
|
||||
public class WirelessTransmitterNetworkNode extends NetworkNode implements IWirelessTransmitter {
|
||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "wireless_transmitter");
|
||||
|
||||
@@ -62,7 +64,7 @@ public class WirelessTransmitterNetworkNode extends NetworkNode implements IWire
|
||||
|
||||
@Override
|
||||
public RegistryKey<World> getDimension() {
|
||||
return world.getDimensionKey();
|
||||
return world.dimension();
|
||||
}
|
||||
|
||||
public BaseItemHandler getUpgrades() {
|
||||
@@ -81,6 +83,6 @@ public class WirelessTransmitterNetworkNode extends NetworkNode implements IWire
|
||||
|
||||
@Override
|
||||
public void visit(Operator operator) {
|
||||
operator.apply(world, pos.offset(Direction.DOWN), Direction.UP);
|
||||
operator.apply(world, pos.relative(Direction.DOWN), Direction.UP);
|
||||
}
|
||||
}
|
||||
|
@@ -92,11 +92,11 @@ public class CoverManager {
|
||||
|
||||
public void readFromNbt(CompoundNBT nbt) {
|
||||
covers.clear();
|
||||
for (String s : nbt.keySet()) {
|
||||
for (String s : nbt.getAllKeys()) {
|
||||
CompoundNBT tag = nbt.getCompound(s);
|
||||
if (tag.contains(NBT_DIRECTION) && tag.contains(NBT_ITEM)) {
|
||||
Direction direction = Direction.byIndex(tag.getInt(NBT_DIRECTION));
|
||||
ItemStack item = ItemStack.read(tag.getCompound(NBT_ITEM));
|
||||
Direction direction = Direction.from3DDataValue(tag.getInt(NBT_DIRECTION));
|
||||
ItemStack item = ItemStack.of(tag.getCompound(NBT_ITEM));
|
||||
int type = tag.contains(NBT_TYPE) ? tag.getInt(NBT_TYPE) : 0;
|
||||
|
||||
if (type >= CoverType.values().length) {
|
||||
@@ -151,16 +151,16 @@ public class CoverManager {
|
||||
|
||||
BlockState state = getBlockState(item);
|
||||
|
||||
return block != null && state != null && isModelSupported(state) && !block.ticksRandomly(state)
|
||||
&& !block.hasTileEntity(state) && !state.isTransparent(); //Changed from 1.12: to use 1.16 methods
|
||||
return block != null && state != null && isModelSupported(state) && !block.isRandomlyTicking(state)
|
||||
&& !block.hasTileEntity(state) && !state.useShapeForLightOcclusion(); //Changed from 1.12: to use 1.16 methods
|
||||
}
|
||||
|
||||
private static boolean isModelSupported(BlockState state) {
|
||||
if (state.getRenderType() != BlockRenderType.MODEL) {
|
||||
if (state.getRenderShape() != BlockRenderType.MODEL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return state.isSolid();
|
||||
return state.canOcclude();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -169,7 +169,7 @@ public class CoverManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
Block block = Block.getBlockFromItem(item.getItem());
|
||||
Block block = Block.byItem(item.getItem());
|
||||
|
||||
if (block == Blocks.AIR) {
|
||||
return null;
|
||||
@@ -187,7 +187,7 @@ public class CoverManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
return block.getDefaultState();
|
||||
return block.defaultBlockState();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -64,7 +64,7 @@ public class DiskDriveNetworkNode extends NetworkNode implements IStorageProvide
|
||||
.addValidator(new StorageDiskItemValidator())
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener((handler, slot, reading) -> {
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
StackUtils.createStorages(
|
||||
(ServerWorld) world,
|
||||
handler.getStackInSlot(slot),
|
||||
@@ -328,7 +328,7 @@ public class DiskDriveNetworkNode extends NetworkNode implements IStorageProvide
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isRemote ? DiskDriveTile.TYPE.getValue() : type;
|
||||
return world.isClientSide ? DiskDriveTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -76,7 +76,7 @@ public class DiskManipulatorNetworkNode extends NetworkNode implements IComparab
|
||||
.addValidator(new StorageDiskItemValidator())
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener((handler, slot, reading) -> {
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
StackUtils.createStorages(
|
||||
(ServerWorld) world,
|
||||
handler.getStackInSlot(slot),
|
||||
@@ -97,7 +97,7 @@ public class DiskManipulatorNetworkNode extends NetworkNode implements IComparab
|
||||
.addValidator(new StorageDiskItemValidator())
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener(((handler, slot, reading) -> {
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
StackUtils.createStorages(
|
||||
(ServerWorld) world,
|
||||
handler.getStackInSlot(slot),
|
||||
@@ -420,7 +420,7 @@ public class DiskManipulatorNetworkNode extends NetworkNode implements IComparab
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isRemote ? DiskManipulatorTile.TYPE.getValue() : type;
|
||||
return world.isClientSide ? DiskManipulatorTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -140,7 +140,7 @@ public class FluidStorageNetworkNode extends NetworkNode implements IStorageScre
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
tag.putUniqueId(NBT_ID, storageId);
|
||||
tag.putUUID(NBT_ID, storageId);
|
||||
|
||||
return tag;
|
||||
}
|
||||
@@ -149,8 +149,8 @@ public class FluidStorageNetworkNode extends NetworkNode implements IStorageScre
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
if (tag.hasUniqueId(NBT_ID)) {
|
||||
storageId = tag.getUniqueId(NBT_ID);
|
||||
if (tag.hasUUID(NBT_ID)) {
|
||||
storageId = tag.getUUID(NBT_ID);
|
||||
|
||||
loadStorage(null);
|
||||
}
|
||||
|
@@ -140,7 +140,7 @@ public class StorageNetworkNode extends NetworkNode implements IStorageScreen, I
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
tag.putUniqueId(NBT_ID, storageId);
|
||||
tag.putUUID(NBT_ID, storageId);
|
||||
|
||||
return tag;
|
||||
}
|
||||
@@ -149,8 +149,8 @@ public class StorageNetworkNode extends NetworkNode implements IStorageScreen, I
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
if (tag.hasUniqueId(NBT_ID)) {
|
||||
storageId = tag.getUniqueId(NBT_ID);
|
||||
if (tag.hasUUID(NBT_ID)) {
|
||||
storageId = tag.getUUID(NBT_ID);
|
||||
|
||||
loadStorage(null);
|
||||
}
|
||||
|
@@ -24,9 +24,9 @@ public class SecurityManager implements ISecurityManager {
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Permission permission, PlayerEntity player) {
|
||||
OpList ops = player.getServer().getPlayerList().getOppedPlayers();
|
||||
OpList ops = player.getServer().getPlayerList().getOps();
|
||||
|
||||
if (ops.getEntry(player.getGameProfile()) != null) {
|
||||
if (ops.get(player.getGameProfile()) != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -60,7 +60,7 @@ public class FluidStorageDisk implements IStorageDisk<FluidStack> {
|
||||
tag.putInt(NBT_CAPACITY, capacity);
|
||||
|
||||
if (owner != null) {
|
||||
tag.putUniqueId(NBT_OWNER, owner);
|
||||
tag.putUUID(NBT_OWNER, owner);
|
||||
}
|
||||
|
||||
return tag;
|
||||
|
@@ -62,7 +62,7 @@ public class ItemStorageDisk implements IStorageDisk<ItemStack> {
|
||||
tag.putInt(NBT_CAPACITY, capacity);
|
||||
|
||||
if (owner != null) {
|
||||
tag.putUniqueId(NBT_OWNER, owner);
|
||||
tag.putUUID(NBT_OWNER, owner);
|
||||
}
|
||||
|
||||
return tag;
|
||||
|
@@ -90,18 +90,18 @@ public class StorageDiskManager extends RSWorldSavedData implements IStorageDisk
|
||||
|
||||
@Override
|
||||
public void markForSaving() {
|
||||
markDirty();
|
||||
setDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT tag) {
|
||||
public void load(CompoundNBT tag) {
|
||||
if (tag.contains(NBT_DISKS)) {
|
||||
ListNBT disksTag = tag.getList(NBT_DISKS, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < disksTag.size(); ++i) {
|
||||
CompoundNBT diskTag = disksTag.getCompound(i);
|
||||
|
||||
UUID id = diskTag.getUniqueId(NBT_DISK_ID);
|
||||
UUID id = diskTag.getUUID(NBT_DISK_ID);
|
||||
CompoundNBT data = diskTag.getCompound(NBT_DISK_DATA);
|
||||
String type = diskTag.getString(NBT_DISK_TYPE);
|
||||
|
||||
@@ -114,13 +114,13 @@ public class StorageDiskManager extends RSWorldSavedData implements IStorageDisk
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
public CompoundNBT save(CompoundNBT tag) {
|
||||
ListNBT disksTag = new ListNBT();
|
||||
|
||||
for (Map.Entry<UUID, IStorageDisk> entry : disks.entrySet()) {
|
||||
CompoundNBT diskTag = new CompoundNBT();
|
||||
|
||||
diskTag.putUniqueId(NBT_DISK_ID, entry.getKey());
|
||||
diskTag.putUUID(NBT_DISK_ID, entry.getKey());
|
||||
diskTag.put(NBT_DISK_DATA, entry.getValue().writeToNbt());
|
||||
diskTag.putString(NBT_DISK_TYPE, entry.getValue().getFactoryId().toString());
|
||||
|
||||
|
@@ -26,7 +26,7 @@ public class FluidStorageDiskFactory implements IStorageDiskFactory<FluidStack>
|
||||
FluidStorageDisk disk = new FluidStorageDisk(
|
||||
world,
|
||||
tag.getInt(FluidStorageDisk.NBT_CAPACITY),
|
||||
tag.contains(FluidStorageDisk.NBT_OWNER) ? tag.getUniqueId(FluidStorageDisk.NBT_OWNER) : null
|
||||
tag.contains(FluidStorageDisk.NBT_OWNER) ? tag.getUUID(FluidStorageDisk.NBT_OWNER) : null
|
||||
);
|
||||
|
||||
ListNBT list = tag.getList(FluidStorageDisk.NBT_FLUIDS, Constants.NBT.TAG_COMPOUND);
|
||||
|
@@ -26,7 +26,7 @@ public class ItemStorageDiskFactory implements IStorageDiskFactory<ItemStack> {
|
||||
ItemStorageDisk disk = new ItemStorageDisk(
|
||||
world,
|
||||
tag.getInt(ItemStorageDisk.NBT_CAPACITY),
|
||||
tag.contains(ItemStorageDisk.NBT_OWNER) ? tag.getUniqueId(ItemStorageDisk.NBT_OWNER) : null
|
||||
tag.contains(ItemStorageDisk.NBT_OWNER) ? tag.getUUID(ItemStorageDisk.NBT_OWNER) : null
|
||||
);
|
||||
|
||||
ListNBT list = tag.getList(ItemStorageDisk.NBT_ITEMS, Constants.NBT.TAG_COMPOUND);
|
||||
|
@@ -21,7 +21,7 @@ public class FluidExternalStorageProvider implements IExternalStorageProvider<Fl
|
||||
@Override
|
||||
public IExternalStorage<FluidStack> provide(IExternalStorageContext context, TileEntity tile, Direction direction) {
|
||||
return new FluidExternalStorage(context, () -> {
|
||||
if (!tile.getWorld().isBlockPresent(tile.getPos())) {
|
||||
if (!tile.getLevel().isLoaded(tile.getBlockPos())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -30,7 +30,7 @@ public class ItemExternalStorageProvider implements IExternalStorageProvider<Ite
|
||||
@Override
|
||||
public IExternalStorage<ItemStack> provide(IExternalStorageContext context, TileEntity tile, Direction direction) {
|
||||
return new ItemExternalStorage(context, () -> {
|
||||
if (!tile.getWorld().isBlockPresent(tile.getPos())) {
|
||||
if (!tile.getLevel().isLoaded(tile.getBlockPos())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,7 @@ public class StorageTrackerManager extends RSWorldSavedData implements IStorageT
|
||||
|
||||
@Override
|
||||
public void markForSaving() {
|
||||
this.markDirty();
|
||||
this.setDirty();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,14 +55,14 @@ public class StorageTrackerManager extends RSWorldSavedData implements IStorageT
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT nbt) {
|
||||
public void load(CompoundNBT nbt) {
|
||||
if (nbt.contains(NBT_TRACKERS)) {
|
||||
ListNBT trackerTags = nbt.getList(NBT_TRACKERS, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < trackerTags.size(); ++i) {
|
||||
CompoundNBT trackerTag = trackerTags.getCompound(i);
|
||||
|
||||
UUID id = trackerTag.getUniqueId(NBT_TRACKER_ID);
|
||||
UUID id = trackerTag.getUUID(NBT_TRACKER_ID);
|
||||
ListNBT data = trackerTag.getList(NBT_TRACKER_DATA, Constants.NBT.TAG_COMPOUND);
|
||||
StorageType type = StorageType.values()[trackerTag.getInt(NBT_TRACKER_TYPE)];
|
||||
|
||||
@@ -73,13 +73,13 @@ public class StorageTrackerManager extends RSWorldSavedData implements IStorageT
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT compound) {
|
||||
public CompoundNBT save(CompoundNBT compound) {
|
||||
ListNBT trackerListTag = new ListNBT();
|
||||
|
||||
for (Map.Entry<UUID, IStorageTracker<?>> entry : trackers.entrySet()) {
|
||||
CompoundNBT trackerTag = new CompoundNBT();
|
||||
|
||||
trackerTag.putUniqueId(NBT_TRACKER_ID, entry.getKey());
|
||||
trackerTag.putUUID(NBT_TRACKER_ID, entry.getKey());
|
||||
trackerTag.put(NBT_TRACKER_DATA, entry.getValue().serializeNbt());
|
||||
trackerTag.putInt(NBT_TRACKER_TYPE, entry.getValue() instanceof ItemStorageTracker ? StorageType.ITEM.ordinal() : StorageType.FLUID.ordinal());
|
||||
|
||||
|
@@ -13,11 +13,11 @@ public class Comparer implements IComparer {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!ItemStack.areItemsEqual(left, right)) {
|
||||
if (!ItemStack.isSame(left, right)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((flags & COMPARE_NBT) == COMPARE_NBT && !ItemStack.areItemStackTagsEqual(left, right)) {
|
||||
if ((flags & COMPARE_NBT) == COMPARE_NBT && !ItemStack.tagMatches(left, right)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -19,10 +19,10 @@ public abstract class RSWorldSavedData extends WorldSavedData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void read(CompoundNBT nbt);
|
||||
public abstract void load(CompoundNBT nbt);
|
||||
|
||||
@Override
|
||||
public abstract CompoundNBT write(CompoundNBT compound);
|
||||
public abstract CompoundNBT save(CompoundNBT compound);
|
||||
|
||||
@Override
|
||||
public void save(File fileIn) {
|
||||
@@ -31,8 +31,8 @@ public abstract class RSWorldSavedData extends WorldSavedData {
|
||||
File tempFile = fileIn.toPath().getParent().resolve(fileIn.getName() + ".temp").toFile();
|
||||
|
||||
CompoundNBT compoundnbt = new CompoundNBT();
|
||||
compoundnbt.put("data", this.write(new CompoundNBT()));
|
||||
compoundnbt.putInt("DataVersion", SharedConstants.getVersion().getWorldVersion());
|
||||
compoundnbt.put("data", this.save(new CompoundNBT()));
|
||||
compoundnbt.putInt("DataVersion", SharedConstants.getCurrentVersion().getWorldVersion());
|
||||
|
||||
try {
|
||||
CompressedStreamTools.writeCompressed(compoundnbt, tempFile);
|
||||
|
@@ -8,6 +8,8 @@ import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraft.block.AbstractBlock.Properties;
|
||||
|
||||
public abstract class BaseBlock extends Block {
|
||||
protected BaseBlock(Properties properties) {
|
||||
super(properties);
|
||||
@@ -22,9 +24,9 @@ public abstract class BaseBlock extends Block {
|
||||
public BlockState rotate(BlockState state, Rotation rot) {
|
||||
BlockDirection dir = getDirection();
|
||||
if (dir != BlockDirection.NONE) {
|
||||
Direction newDirection = dir.cycle(state.get(dir.getProperty()));
|
||||
Direction newDirection = dir.cycle(state.getValue(dir.getProperty()));
|
||||
|
||||
return state.with(dir.getProperty(), newDirection);
|
||||
return state.setValue(dir.getProperty(), newDirection);
|
||||
}
|
||||
|
||||
return super.rotate(state, rot);
|
||||
@@ -36,8 +38,8 @@ public abstract class BaseBlock extends Block {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
super.onReplaced(state, world, pos, newState, isMoving);
|
||||
public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
super.onRemove(state, world, pos, newState, isMoving);
|
||||
|
||||
checkIfDirectionHasChanged(state, world, pos, newState);
|
||||
}
|
||||
@@ -45,14 +47,14 @@ public abstract class BaseBlock extends Block {
|
||||
protected void checkIfDirectionHasChanged(BlockState state, World world, BlockPos pos, BlockState newState) {
|
||||
if (getDirection() != BlockDirection.NONE &&
|
||||
state.getBlock() == newState.getBlock() &&
|
||||
state.get(getDirection().getProperty()) != newState.get(getDirection().getProperty())) {
|
||||
onDirectionChanged(world, pos, newState.get(getDirection().getProperty()));
|
||||
state.getValue(getDirection().getProperty()) != newState.getValue(getDirection().getProperty())) {
|
||||
onDirectionChanged(world, pos, newState.getValue(getDirection().getProperty()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
|
||||
BlockDirection dir = getDirection();
|
||||
if (dir != BlockDirection.NONE) {
|
||||
|
@@ -31,7 +31,7 @@ public enum BlockDirection {
|
||||
case ANY_FACE_PLAYER:
|
||||
return DirectionUtils.getFacingFromEntity(pos, entity);
|
||||
case HORIZONTAL:
|
||||
return entity.getHorizontalFacing().getOpposite();
|
||||
return entity.getDirection().getOpposite();
|
||||
default:
|
||||
throw new IllegalStateException("Unknown direction type");
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public enum BlockDirection {
|
||||
case ANY_FACE_PLAYER:
|
||||
return previous.ordinal() + 1 >= Direction.values().length ? Direction.values()[0] : Direction.values()[previous.ordinal() + 1];
|
||||
case HORIZONTAL:
|
||||
return previous.rotateYCCW();
|
||||
return previous.getCounterClockWise();
|
||||
default:
|
||||
throw new IllegalStateException("Unknown direction type");
|
||||
}
|
||||
|
@@ -34,6 +34,8 @@ import net.minecraft.world.World;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.block.AbstractBlock.Properties;
|
||||
|
||||
public class CableBlock extends NetworkNodeBlock implements IWaterLoggable {
|
||||
private static final BooleanProperty NORTH = BooleanProperty.create("north");
|
||||
private static final BooleanProperty EAST = BooleanProperty.create("east");
|
||||
@@ -43,40 +45,40 @@ public class CableBlock extends NetworkNodeBlock implements IWaterLoggable {
|
||||
private static final BooleanProperty DOWN = BooleanProperty.create("down");
|
||||
private static final BooleanProperty WATERLOGGED = BooleanProperty.create("waterlogged");
|
||||
|
||||
protected static final VoxelShape HOLDER_NORTH = makeCuboidShape(7, 7, 2, 9, 9, 6);
|
||||
protected static final VoxelShape HOLDER_EAST = makeCuboidShape(10, 7, 7, 14, 9, 9);
|
||||
protected static final VoxelShape HOLDER_SOUTH = makeCuboidShape(7, 7, 10, 9, 9, 14);
|
||||
protected static final VoxelShape HOLDER_WEST = makeCuboidShape(2, 7, 7, 6, 9, 9);
|
||||
protected static final VoxelShape HOLDER_UP = makeCuboidShape(7, 10, 7, 9, 14, 9);
|
||||
protected static final VoxelShape HOLDER_DOWN = makeCuboidShape(7, 2, 7, 9, 6, 9);
|
||||
protected static final VoxelShape HOLDER_NORTH = box(7, 7, 2, 9, 9, 6);
|
||||
protected static final VoxelShape HOLDER_EAST = box(10, 7, 7, 14, 9, 9);
|
||||
protected static final VoxelShape HOLDER_SOUTH = box(7, 7, 10, 9, 9, 14);
|
||||
protected static final VoxelShape HOLDER_WEST = box(2, 7, 7, 6, 9, 9);
|
||||
protected static final VoxelShape HOLDER_UP = box(7, 10, 7, 9, 14, 9);
|
||||
protected static final VoxelShape HOLDER_DOWN = box(7, 2, 7, 9, 6, 9);
|
||||
|
||||
private static final VoxelShape SHAPE_CORE = makeCuboidShape(6, 6, 6, 10, 10, 10);
|
||||
private static final VoxelShape SHAPE_NORTH = makeCuboidShape(6, 6, 0, 10, 10, 6);
|
||||
private static final VoxelShape SHAPE_EAST = makeCuboidShape(10, 6, 6, 16, 10, 10);
|
||||
private static final VoxelShape SHAPE_SOUTH = makeCuboidShape(6, 6, 10, 10, 10, 16);
|
||||
private static final VoxelShape SHAPE_WEST = makeCuboidShape(0, 6, 6, 6, 10, 10);
|
||||
private static final VoxelShape SHAPE_UP = makeCuboidShape(6, 10, 6, 10, 16, 10);
|
||||
private static final VoxelShape SHAPE_DOWN = makeCuboidShape(6, 0, 6, 10, 6, 10);
|
||||
private static final VoxelShape SHAPE_CORE = box(6, 6, 6, 10, 10, 10);
|
||||
private static final VoxelShape SHAPE_NORTH = box(6, 6, 0, 10, 10, 6);
|
||||
private static final VoxelShape SHAPE_EAST = box(10, 6, 6, 16, 10, 10);
|
||||
private static final VoxelShape SHAPE_SOUTH = box(6, 6, 10, 10, 10, 16);
|
||||
private static final VoxelShape SHAPE_WEST = box(0, 6, 6, 6, 10, 10);
|
||||
private static final VoxelShape SHAPE_UP = box(6, 10, 6, 10, 16, 10);
|
||||
private static final VoxelShape SHAPE_DOWN = box(6, 0, 6, 10, 6, 10);
|
||||
|
||||
public CableBlock(Properties props) {
|
||||
super(props);
|
||||
this.setDefaultState(getDefaultState().with(WATERLOGGED, false));
|
||||
this.registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false));
|
||||
}
|
||||
|
||||
public CableBlock() {
|
||||
super(BlockUtils.DEFAULT_GLASS_PROPERTIES);
|
||||
|
||||
this.setDefaultState(getDefaultState().with(NORTH, false).with(EAST, false).with(SOUTH, false).with(WEST, false).with(UP, false).with(DOWN, false).with(WATERLOGGED, false));
|
||||
this.registerDefaultState(defaultBlockState().setValue(NORTH, false).setValue(EAST, false).setValue(SOUTH, false).setValue(WEST, false).setValue(UP, false).setValue(DOWN, false).setValue(WATERLOGGED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockState updatePostPlacement(BlockState state, Direction dir, BlockState facingState, IWorld world, BlockPos pos, BlockPos facingPos) {
|
||||
public BlockState updateShape(BlockState state, Direction dir, BlockState facingState, IWorld world, BlockPos pos, BlockPos facingPos) {
|
||||
return getState(state, world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowsMovement(BlockState state, IBlockReader worldIn, BlockPos pos, PathType type) {
|
||||
public boolean isPathfindable(BlockState state, IBlockReader worldIn, BlockPos pos, PathType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -89,27 +91,27 @@ public class CableBlock extends NetworkNodeBlock implements IWaterLoggable {
|
||||
protected static VoxelShape getCableShape(BlockState state) {
|
||||
VoxelShape shape = SHAPE_CORE;
|
||||
|
||||
if (Boolean.TRUE.equals(state.get(NORTH))) {
|
||||
if (Boolean.TRUE.equals(state.getValue(NORTH))) {
|
||||
shape = VoxelShapes.or(shape, SHAPE_NORTH);
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(state.get(EAST))) {
|
||||
if (Boolean.TRUE.equals(state.getValue(EAST))) {
|
||||
shape = VoxelShapes.or(shape, SHAPE_EAST);
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(state.get(SOUTH))) {
|
||||
if (Boolean.TRUE.equals(state.getValue(SOUTH))) {
|
||||
shape = VoxelShapes.or(shape, SHAPE_SOUTH);
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(state.get(WEST))) {
|
||||
if (Boolean.TRUE.equals(state.getValue(WEST))) {
|
||||
shape = VoxelShapes.or(shape, SHAPE_WEST);
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(state.get(UP))) {
|
||||
if (Boolean.TRUE.equals(state.getValue(UP))) {
|
||||
shape = VoxelShapes.or(shape, SHAPE_UP);
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(state.get(DOWN))) {
|
||||
if (Boolean.TRUE.equals(state.getValue(DOWN))) {
|
||||
shape = VoxelShapes.or(shape, SHAPE_DOWN);
|
||||
}
|
||||
|
||||
@@ -125,15 +127,15 @@ public class CableBlock extends NetworkNodeBlock implements IWaterLoggable {
|
||||
// This is already checked in hasNode().
|
||||
// But since rotate() doesn't invalidate that connection, we need to do it here.
|
||||
// Ideally, this code would be in rotate(). But rotate() doesn't have any data about the position and world, so we need to do it here.
|
||||
world.setBlockState(pos, getState(world.getBlockState(pos), world, pos));
|
||||
world.setBlockAndUpdate(pos, getState(world.getBlockState(pos), world, pos));
|
||||
|
||||
|
||||
//when rotating skip rotations blocked by covers
|
||||
BlockDirection dir = getDirection();
|
||||
if (dir != BlockDirection.NONE) {
|
||||
if (isSideCovered(world.getTileEntity(pos), newDirection)) {
|
||||
if (isSideCovered(world.getBlockEntity(pos), newDirection)) {
|
||||
BlockState newState = rotate(world.getBlockState(pos), Rotation.CLOCKWISE_90);
|
||||
world.setBlockState(pos, newState);
|
||||
world.setBlockAndUpdate(pos, newState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,45 +145,45 @@ public class CableBlock extends NetworkNodeBlock implements IWaterLoggable {
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
|
||||
super.neighborChanged(state, world, pos, blockIn, fromPos, isMoving);
|
||||
world.setBlockState(pos, getState(world.getBlockState(pos), world, pos));
|
||||
world.setBlockAndUpdate(pos, getState(world.getBlockState(pos), world, pos));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext ctx) {
|
||||
return getState(getDefaultState(), ctx.getWorld(), ctx.getPos());
|
||||
return getState(defaultBlockState(), ctx.getLevel(), ctx.getClickedPos());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public FluidState getFluidState(BlockState state) {
|
||||
return Boolean.TRUE.equals(state.get(WATERLOGGED)) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state);
|
||||
return Boolean.TRUE.equals(state.getValue(WATERLOGGED)) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean receiveFluid(IWorld worldIn, BlockPos pos, BlockState state, FluidState fluidStateIn) {
|
||||
return IWaterLoggable.super.receiveFluid(worldIn, pos, state, fluidStateIn);
|
||||
public boolean placeLiquid(IWorld worldIn, BlockPos pos, BlockState state, FluidState fluidStateIn) {
|
||||
return IWaterLoggable.super.placeLiquid(worldIn, pos, state, fluidStateIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canContainFluid(IBlockReader worldIn, BlockPos pos, BlockState state, Fluid fluidIn) {
|
||||
return IWaterLoggable.super.canContainFluid(worldIn, pos, state, fluidIn);
|
||||
public boolean canPlaceLiquid(IBlockReader worldIn, BlockPos pos, BlockState state, Fluid fluidIn) {
|
||||
return IWaterLoggable.super.canPlaceLiquid(worldIn, pos, state, fluidIn);
|
||||
}
|
||||
|
||||
private boolean hasNodeConnection(IWorld world, BlockPos pos, BlockState state, Direction direction) {
|
||||
// Prevent the "holder" of a cable block conflicting with a cable connection.
|
||||
if (getDirection() != BlockDirection.NONE && state.get(getDirection().getProperty()).getOpposite() == direction) {
|
||||
if (getDirection() != BlockDirection.NONE && state.getValue(getDirection().getProperty()).getOpposite() == direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
TileEntity tile = world.getBlockEntity(pos);
|
||||
if (tile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY, direction).isPresent()
|
||||
&& !isSideCovered(tile, direction)
|
||||
&& !isSideCovered(world.getTileEntity(pos.offset(direction)), direction.getOpposite());
|
||||
&& !isSideCovered(world.getBlockEntity(pos.relative(direction)), direction.getOpposite());
|
||||
}
|
||||
|
||||
private boolean isSideCovered(TileEntity tile, Direction direction) {
|
||||
@@ -204,20 +206,20 @@ public class CableBlock extends NetworkNodeBlock implements IWaterLoggable {
|
||||
}
|
||||
|
||||
private BlockState getState(BlockState currentState, IWorld world, BlockPos pos) {
|
||||
boolean north = hasNodeConnection(world, pos.offset(Direction.NORTH), currentState, Direction.SOUTH);
|
||||
boolean east = hasNodeConnection(world, pos.offset(Direction.EAST), currentState, Direction.WEST);
|
||||
boolean south = hasNodeConnection(world, pos.offset(Direction.SOUTH), currentState, Direction.NORTH);
|
||||
boolean west = hasNodeConnection(world, pos.offset(Direction.WEST), currentState, Direction.EAST);
|
||||
boolean up = hasNodeConnection(world, pos.offset(Direction.UP), currentState, Direction.DOWN);
|
||||
boolean down = hasNodeConnection(world, pos.offset(Direction.DOWN), currentState, Direction.UP);
|
||||
boolean north = hasNodeConnection(world, pos.relative(Direction.NORTH), currentState, Direction.SOUTH);
|
||||
boolean east = hasNodeConnection(world, pos.relative(Direction.EAST), currentState, Direction.WEST);
|
||||
boolean south = hasNodeConnection(world, pos.relative(Direction.SOUTH), currentState, Direction.NORTH);
|
||||
boolean west = hasNodeConnection(world, pos.relative(Direction.WEST), currentState, Direction.EAST);
|
||||
boolean up = hasNodeConnection(world, pos.relative(Direction.UP), currentState, Direction.DOWN);
|
||||
boolean down = hasNodeConnection(world, pos.relative(Direction.DOWN), currentState, Direction.UP);
|
||||
|
||||
return currentState
|
||||
.with(NORTH, north)
|
||||
.with(EAST, east)
|
||||
.with(SOUTH, south)
|
||||
.with(WEST, west)
|
||||
.with(UP, up)
|
||||
.with(DOWN, down);
|
||||
.setValue(NORTH, north)
|
||||
.setValue(EAST, east)
|
||||
.setValue(SOUTH, south)
|
||||
.setValue(WEST, west)
|
||||
.setValue(UP, up)
|
||||
.setValue(DOWN, down);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -227,8 +229,8 @@ public class CableBlock extends NetworkNodeBlock implements IWaterLoggable {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
|
||||
builder.add(NORTH, EAST, SOUTH, WEST, UP, DOWN, WATERLOGGED);
|
||||
}
|
||||
@@ -236,17 +238,17 @@ public class CableBlock extends NetworkNodeBlock implements IWaterLoggable {
|
||||
public static boolean hasVisualConnectionOnSide(BlockState state, Direction direction) {
|
||||
switch (direction) {
|
||||
case DOWN:
|
||||
return state.get(DOWN);
|
||||
return state.getValue(DOWN);
|
||||
case UP:
|
||||
return state.get(UP);
|
||||
return state.getValue(UP);
|
||||
case NORTH:
|
||||
return state.get(NORTH);
|
||||
return state.getValue(NORTH);
|
||||
case SOUTH:
|
||||
return state.get(SOUTH);
|
||||
return state.getValue(SOUTH);
|
||||
case WEST:
|
||||
return state.get(WEST);
|
||||
return state.getValue(WEST);
|
||||
case EAST:
|
||||
return state.get(EAST);
|
||||
return state.getValue(EAST);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -4,6 +4,8 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraft.block.AbstractBlock.Properties;
|
||||
|
||||
public class ColoredNetworkBlock extends NetworkNodeBlock {
|
||||
public ColoredNetworkBlock(Properties props) {
|
||||
super(props);
|
||||
@@ -11,11 +13,11 @@ public class ColoredNetworkBlock extends NetworkNodeBlock {
|
||||
|
||||
// Don't do block drops if we change the color.
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.getBlock().getClass().equals(newState.getBlock().getClass())) {
|
||||
checkIfDirectionHasChanged(state, world, pos, newState);
|
||||
} else {
|
||||
super.onReplaced(state, world, pos, newState, isMoving);
|
||||
super.onRemove(state, world, pos, newState, isMoving);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -28,12 +28,12 @@ import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ConstructorBlock extends CableBlock {
|
||||
private static final VoxelShape HEAD_NORTH = VoxelShapes.or(makeCuboidShape(2, 2, 0, 14, 14, 2), HOLDER_NORTH);
|
||||
private static final VoxelShape HEAD_EAST = VoxelShapes.or(makeCuboidShape(14, 2, 2, 16, 14, 14), HOLDER_EAST);
|
||||
private static final VoxelShape HEAD_SOUTH = VoxelShapes.or(makeCuboidShape(2, 2, 14, 14, 14, 16), HOLDER_SOUTH);
|
||||
private static final VoxelShape HEAD_WEST = VoxelShapes.or(makeCuboidShape(0, 2, 2, 2, 14, 14), HOLDER_WEST);
|
||||
private static final VoxelShape HEAD_DOWN = VoxelShapes.or(makeCuboidShape(2, 0, 2, 14, 2, 14), HOLDER_DOWN);
|
||||
private static final VoxelShape HEAD_UP = VoxelShapes.or(makeCuboidShape(2, 14, 2, 14, 16, 14), HOLDER_UP);
|
||||
private static final VoxelShape HEAD_NORTH = VoxelShapes.or(box(2, 2, 0, 14, 14, 2), HOLDER_NORTH);
|
||||
private static final VoxelShape HEAD_EAST = VoxelShapes.or(box(14, 2, 2, 16, 14, 14), HOLDER_EAST);
|
||||
private static final VoxelShape HEAD_SOUTH = VoxelShapes.or(box(2, 2, 14, 14, 14, 16), HOLDER_SOUTH);
|
||||
private static final VoxelShape HEAD_WEST = VoxelShapes.or(box(0, 2, 2, 2, 14, 14), HOLDER_WEST);
|
||||
private static final VoxelShape HEAD_DOWN = VoxelShapes.or(box(2, 0, 2, 14, 2, 14), HOLDER_DOWN);
|
||||
private static final VoxelShape HEAD_UP = VoxelShapes.or(box(2, 14, 2, 14, 16, 14), HOLDER_UP);
|
||||
|
||||
public ConstructorBlock() {
|
||||
super(BlockUtils.DEFAULT_GLASS_PROPERTIES);
|
||||
@@ -62,7 +62,7 @@ public class ConstructorBlock extends CableBlock {
|
||||
}
|
||||
|
||||
private VoxelShape getHeadShape(BlockState state) {
|
||||
Direction direction = state.get(getDirection().getProperty());
|
||||
Direction direction = state.getValue(getDirection().getProperty());
|
||||
|
||||
if (direction == Direction.NORTH) {
|
||||
return HEAD_NORTH;
|
||||
@@ -93,8 +93,8 @@ public class ConstructorBlock extends CableBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
if (!world.isRemote && CollisionUtils.isInBounds(getHeadShape(state), pos, hit.getHitVec())) {
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
if (!world.isClientSide && CollisionUtils.isInBounds(getHeadShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
new PositionalTileContainerProvider<ConstructorTile>(
|
||||
|
@@ -52,7 +52,7 @@ public class ControllerBlock extends BaseBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString() {
|
||||
public String getSerializedName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -70,12 +70,12 @@ public class ControllerBlock extends BaseBlock {
|
||||
super(BlockUtils.DEFAULT_ROCK_PROPERTIES);
|
||||
|
||||
this.type = type;
|
||||
this.setDefaultState(getStateContainer().getBaseState().with(ENERGY_TYPE, EnergyType.OFF));
|
||||
this.registerDefaultState(getStateDefinition().any().setValue(ENERGY_TYPE, EnergyType.OFF));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
|
||||
builder.add(ENERGY_TYPE);
|
||||
}
|
||||
@@ -96,12 +96,12 @@ public class ControllerBlock extends BaseBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, @Nullable LivingEntity entity, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, pos, state, entity, stack);
|
||||
public void setPlacedBy(World world, BlockPos pos, BlockState state, @Nullable LivingEntity entity, ItemStack stack) {
|
||||
super.setPlacedBy(world, pos, state, entity, stack);
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
stack.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyFromStack -> {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
TileEntity tile = world.getBlockEntity(pos);
|
||||
|
||||
if (tile != null) {
|
||||
tile.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyFromTile -> energyFromTile.receiveEnergy(energyFromStack.getEnergyStored(), false));
|
||||
@@ -115,32 +115,32 @@ public class ControllerBlock extends BaseBlock {
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
|
||||
super.neighborChanged(state, world, pos, blockIn, fromPos, isMoving);
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
INetwork network = API.instance().getNetworkManager((ServerWorld) world).getNetwork(pos);
|
||||
if (network instanceof Network) {
|
||||
((Network) network).setRedstonePowered(world.isBlockPowered(pos));
|
||||
((Network) network).setRedstonePowered(world.hasNeighborSignal(pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ActionResultType result = super.onBlockActivated(state, world, pos, player, hand, hit);
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ActionResultType result = super.use(state, world, pos, player, hand, hit);
|
||||
if (result != ActionResultType.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
ColorMap<ControllerBlock> colorMap = type == NetworkType.CREATIVE ? RSBlocks.CREATIVE_CONTROLLER : RSBlocks.CONTROLLER;
|
||||
DyeColor color = DyeColor.getColor(player.getHeldItem(hand));
|
||||
DyeColor color = DyeColor.getColor(player.getItemInHand(hand));
|
||||
|
||||
if (color != null && !state.getBlock().equals(colorMap.get(color).get())) {
|
||||
BlockState newState = colorMap.get(color).get().getDefaultState().with(ENERGY_TYPE, state.get(ENERGY_TYPE));
|
||||
BlockState newState = colorMap.get(color).get().defaultBlockState().setValue(ENERGY_TYPE, state.getValue(ENERGY_TYPE));
|
||||
|
||||
return RSBlocks.CONTROLLER.setBlockState(newState, player.getHeldItem(hand), world, pos, player);
|
||||
return RSBlocks.CONTROLLER.setBlockState(newState, player.getItemInHand(hand), world, pos, player);
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
new INamedContainerProvider() {
|
||||
@@ -151,7 +151,7 @@ public class ControllerBlock extends BaseBlock {
|
||||
|
||||
@Override
|
||||
public Container createMenu(int i, PlayerInventory playerInventory, PlayerEntity player) {
|
||||
return new ControllerContainer((ControllerTile) world.getTileEntity(pos), player, i);
|
||||
return new ControllerContainer((ControllerTile) world.getBlockEntity(pos), player, i);
|
||||
}
|
||||
},
|
||||
pos
|
||||
@@ -162,10 +162,10 @@ public class ControllerBlock extends BaseBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (newState.getBlock() instanceof ControllerBlock) {
|
||||
return;
|
||||
}
|
||||
super.onReplaced(state, world, pos, newState, isMoving);
|
||||
super.onRemove(state, world, pos, newState, isMoving);
|
||||
}
|
||||
}
|
||||
|
@@ -40,14 +40,14 @@ public class CrafterBlock extends ColoredNetworkBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, pos, state, placer, stack);
|
||||
public void setPlacedBy(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||
super.setPlacedBy(world, pos, state, placer, stack);
|
||||
|
||||
if (!world.isRemote) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (!world.isClientSide) {
|
||||
TileEntity tile = world.getBlockEntity(pos);
|
||||
|
||||
if (tile instanceof CrafterTile && stack.hasDisplayName()) {
|
||||
((CrafterTile) tile).getNode().setDisplayName(stack.getDisplayName());
|
||||
if (tile instanceof CrafterTile && stack.hasCustomHoverName()) {
|
||||
((CrafterTile) tile).getNode().setDisplayName(stack.getHoverName());
|
||||
((CrafterTile) tile).getNode().markDirty();
|
||||
}
|
||||
}
|
||||
@@ -55,17 +55,17 @@ public class CrafterBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ActionResultType result = RSBlocks.CRAFTER.changeBlockColor(state, player.getHeldItem(hand), world, pos, player);
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ActionResultType result = RSBlocks.CRAFTER.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
if (result != ActionResultType.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attempt(world, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
new PositionalTileContainerProvider<CrafterTile>(
|
||||
((CrafterTile) world.getTileEntity(pos)).getNode().getName(),
|
||||
((CrafterTile) world.getBlockEntity(pos)).getNode().getName(),
|
||||
(tile, windowId, inventory, p) -> new CrafterContainer(tile, player, windowId),
|
||||
pos
|
||||
),
|
||||
|
@@ -38,16 +38,16 @@ public class CrafterManagerBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ActionResultType result = RSBlocks.CRAFTER_MANAGER.changeBlockColor(state, player.getHeldItem(hand), world, pos, player);
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ActionResultType result = RSBlocks.CRAFTER_MANAGER.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
if (result != ActionResultType.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attempt(world, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
new CrafterManagerContainerProvider((CrafterManagerTile) world.getTileEntity(pos)),
|
||||
new CrafterManagerContainerProvider((CrafterManagerTile) world.getBlockEntity(pos)),
|
||||
buf -> CrafterManagerContainerProvider.writeToBuffer(buf, world, pos)
|
||||
), Permission.MODIFY, Permission.AUTOCRAFTING);
|
||||
}
|
||||
|
@@ -39,14 +39,14 @@ public class CraftingMonitorBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ActionResultType result = RSBlocks.CRAFTING_MONITOR.changeBlockColor(state, player.getHeldItem(hand), world, pos, player);
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ActionResultType result = RSBlocks.CRAFTING_MONITOR.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
if (result != ActionResultType.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
CraftingMonitorTile tile = (CraftingMonitorTile) world.getTileEntity(pos);
|
||||
if (!world.isClientSide) {
|
||||
CraftingMonitorTile tile = (CraftingMonitorTile) world.getBlockEntity(pos);
|
||||
|
||||
return NetworkUtils.attempt(world, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
|
@@ -28,12 +28,12 @@ import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class DestructorBlock extends CableBlock {
|
||||
private static final VoxelShape HEAD_NORTH = VoxelShapes.or(makeCuboidShape(2, 2, 0, 14, 14, 2), HOLDER_NORTH);
|
||||
private static final VoxelShape HEAD_EAST = VoxelShapes.or(makeCuboidShape(14, 2, 2, 16, 14, 14), HOLDER_EAST);
|
||||
private static final VoxelShape HEAD_SOUTH = VoxelShapes.or(makeCuboidShape(2, 2, 14, 14, 14, 16), HOLDER_SOUTH);
|
||||
private static final VoxelShape HEAD_WEST = VoxelShapes.or(makeCuboidShape(0, 2, 2, 2, 14, 14), HOLDER_WEST);
|
||||
private static final VoxelShape HEAD_DOWN = VoxelShapes.or(makeCuboidShape(2, 0, 2, 14, 2, 14), HOLDER_DOWN);
|
||||
private static final VoxelShape HEAD_UP = VoxelShapes.or(makeCuboidShape(2, 14, 2, 14, 16, 14), HOLDER_UP);
|
||||
private static final VoxelShape HEAD_NORTH = VoxelShapes.or(box(2, 2, 0, 14, 14, 2), HOLDER_NORTH);
|
||||
private static final VoxelShape HEAD_EAST = VoxelShapes.or(box(14, 2, 2, 16, 14, 14), HOLDER_EAST);
|
||||
private static final VoxelShape HEAD_SOUTH = VoxelShapes.or(box(2, 2, 14, 14, 14, 16), HOLDER_SOUTH);
|
||||
private static final VoxelShape HEAD_WEST = VoxelShapes.or(box(0, 2, 2, 2, 14, 14), HOLDER_WEST);
|
||||
private static final VoxelShape HEAD_DOWN = VoxelShapes.or(box(2, 0, 2, 14, 2, 14), HOLDER_DOWN);
|
||||
private static final VoxelShape HEAD_UP = VoxelShapes.or(box(2, 14, 2, 14, 16, 14), HOLDER_UP);
|
||||
|
||||
public DestructorBlock() {
|
||||
super(BlockUtils.DEFAULT_GLASS_PROPERTIES);
|
||||
@@ -62,7 +62,7 @@ public class DestructorBlock extends CableBlock {
|
||||
}
|
||||
|
||||
private VoxelShape getHeadShape(BlockState state) {
|
||||
Direction direction = state.get(getDirection().getProperty());
|
||||
Direction direction = state.getValue(getDirection().getProperty());
|
||||
|
||||
if (direction == Direction.NORTH) {
|
||||
return HEAD_NORTH;
|
||||
@@ -93,8 +93,8 @@ public class DestructorBlock extends CableBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||
if (!world.isRemote && CollisionUtils.isInBounds(getHeadShape(state), pos, hit.getHitVec())) {
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||
if (!world.isClientSide && CollisionUtils.isInBounds(getHeadShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
new PositionalTileContainerProvider<DestructorTile>(
|
||||
|
@@ -32,17 +32,17 @@ import javax.annotation.Nullable;
|
||||
public class DetectorBlock extends ColoredNetworkBlock {
|
||||
public static final BooleanProperty POWERED = BooleanProperty.create("powered");
|
||||
|
||||
private static final VoxelShape SHAPE = makeCuboidShape(0, 0, 0, 16, 5, 16);
|
||||
private static final VoxelShape SHAPE = box(0, 0, 0, 16, 5, 16);
|
||||
|
||||
public DetectorBlock() {
|
||||
super(BlockUtils.DEFAULT_ROCK_PROPERTIES);
|
||||
|
||||
this.setDefaultState(this.getStateContainer().getBaseState().with(POWERED, false));
|
||||
this.registerDefaultState(this.getStateDefinition().any().setValue(POWERED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
|
||||
builder.add(POWERED);
|
||||
}
|
||||
@@ -55,31 +55,31 @@ public class DetectorBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean canProvidePower(BlockState state) {
|
||||
public boolean isSignalSource(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getWeakPower(BlockState state, IBlockReader world, BlockPos pos, Direction side) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
public int getSignal(BlockState state, IBlockReader world, BlockPos pos, Direction side) {
|
||||
TileEntity tile = world.getBlockEntity(pos);
|
||||
|
||||
return (tile instanceof DetectorTile && ((DetectorTile) tile).getNode().isPowered()) ? 15 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ColorMap<DetectorBlock> colorMap = RSBlocks.DETECTOR;
|
||||
DyeColor color = DyeColor.getColor(player.getHeldItem(hand));
|
||||
DyeColor color = DyeColor.getColor(player.getItemInHand(hand));
|
||||
|
||||
if (color != null && !state.getBlock().equals(colorMap.get(color).get())) {
|
||||
BlockState newState = colorMap.get(color).get().getDefaultState().with(POWERED, state.get(POWERED));
|
||||
BlockState newState = colorMap.get(color).get().defaultBlockState().setValue(POWERED, state.getValue(POWERED));
|
||||
|
||||
return RSBlocks.DETECTOR.setBlockState(newState, player.getHeldItem(hand), world, pos, player);
|
||||
return RSBlocks.DETECTOR.setBlockState(newState, player.getItemInHand(hand), world, pos, player);
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
new PositionalTileContainerProvider<DetectorTile>(
|
||||
|
@@ -38,8 +38,8 @@ public class DiskDriveBlock extends NetworkNodeBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) {
|
||||
if (!world.isRemote) {
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
new PositionalTileContainerProvider<DiskDriveTile>(
|
||||
|
@@ -34,13 +34,13 @@ public class DiskManipulatorBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) {
|
||||
ActionResultType result = RSBlocks.DISK_MANIPULATOR.changeBlockColor(state, player.getHeldItem(hand), world, pos, player);
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTraceResult) {
|
||||
ActionResultType result = RSBlocks.DISK_MANIPULATOR.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
if (result != ActionResultType.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
new PositionalTileContainerProvider<DiskManipulatorTile>(
|
||||
|
@@ -28,34 +28,34 @@ import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ExporterBlock extends CableBlock {
|
||||
private static final VoxelShape LINE_NORTH_1 = makeCuboidShape(6, 6, 0, 10, 10, 2);
|
||||
private static final VoxelShape LINE_NORTH_2 = makeCuboidShape(5, 5, 2, 11, 11, 4);
|
||||
private static final VoxelShape LINE_NORTH_3 = makeCuboidShape(3, 3, 4, 13, 13, 6);
|
||||
private static final VoxelShape LINE_NORTH_1 = box(6, 6, 0, 10, 10, 2);
|
||||
private static final VoxelShape LINE_NORTH_2 = box(5, 5, 2, 11, 11, 4);
|
||||
private static final VoxelShape LINE_NORTH_3 = box(3, 3, 4, 13, 13, 6);
|
||||
private static final VoxelShape LINE_NORTH = VoxelShapes.or(LINE_NORTH_1, LINE_NORTH_2, LINE_NORTH_3);
|
||||
|
||||
private static final VoxelShape LINE_EAST_1 = makeCuboidShape(14, 6, 6, 16, 10, 10);
|
||||
private static final VoxelShape LINE_EAST_2 = makeCuboidShape(12, 5, 5, 14, 11, 11);
|
||||
private static final VoxelShape LINE_EAST_3 = makeCuboidShape(10, 3, 3, 12, 13, 13);
|
||||
private static final VoxelShape LINE_EAST_1 = box(14, 6, 6, 16, 10, 10);
|
||||
private static final VoxelShape LINE_EAST_2 = box(12, 5, 5, 14, 11, 11);
|
||||
private static final VoxelShape LINE_EAST_3 = box(10, 3, 3, 12, 13, 13);
|
||||
private static final VoxelShape LINE_EAST = VoxelShapes.or(LINE_EAST_1, LINE_EAST_2, LINE_EAST_3);
|
||||
|
||||
private static final VoxelShape LINE_SOUTH_1 = makeCuboidShape(6, 6, 14, 10, 10, 16);
|
||||
private static final VoxelShape LINE_SOUTH_2 = makeCuboidShape(5, 5, 12, 11, 11, 14);
|
||||
private static final VoxelShape LINE_SOUTH_3 = makeCuboidShape(3, 3, 10, 13, 13, 12);
|
||||
private static final VoxelShape LINE_SOUTH_1 = box(6, 6, 14, 10, 10, 16);
|
||||
private static final VoxelShape LINE_SOUTH_2 = box(5, 5, 12, 11, 11, 14);
|
||||
private static final VoxelShape LINE_SOUTH_3 = box(3, 3, 10, 13, 13, 12);
|
||||
private static final VoxelShape LINE_SOUTH = VoxelShapes.or(LINE_SOUTH_1, LINE_SOUTH_2, LINE_SOUTH_3);
|
||||
|
||||
private static final VoxelShape LINE_WEST_1 = makeCuboidShape(0, 6, 6, 2, 10, 10);
|
||||
private static final VoxelShape LINE_WEST_2 = makeCuboidShape(2, 5, 5, 4, 11, 11);
|
||||
private static final VoxelShape LINE_WEST_3 = makeCuboidShape(4, 3, 3, 6, 13, 13);
|
||||
private static final VoxelShape LINE_WEST_1 = box(0, 6, 6, 2, 10, 10);
|
||||
private static final VoxelShape LINE_WEST_2 = box(2, 5, 5, 4, 11, 11);
|
||||
private static final VoxelShape LINE_WEST_3 = box(4, 3, 3, 6, 13, 13);
|
||||
private static final VoxelShape LINE_WEST = VoxelShapes.or(LINE_WEST_1, LINE_WEST_2, LINE_WEST_3);
|
||||
|
||||
private static final VoxelShape LINE_UP_1 = makeCuboidShape(6, 14, 6, 10, 16, 10);
|
||||
private static final VoxelShape LINE_UP_2 = makeCuboidShape(5, 12, 5, 11, 14, 11);
|
||||
private static final VoxelShape LINE_UP_3 = makeCuboidShape(3, 10, 3, 13, 12, 13);
|
||||
private static final VoxelShape LINE_UP_1 = box(6, 14, 6, 10, 16, 10);
|
||||
private static final VoxelShape LINE_UP_2 = box(5, 12, 5, 11, 14, 11);
|
||||
private static final VoxelShape LINE_UP_3 = box(3, 10, 3, 13, 12, 13);
|
||||
private static final VoxelShape LINE_UP = VoxelShapes.or(LINE_UP_1, LINE_UP_2, LINE_UP_3);
|
||||
|
||||
private static final VoxelShape LINE_DOWN_1 = makeCuboidShape(6, 0, 6, 10, 2, 10);
|
||||
private static final VoxelShape LINE_DOWN_2 = makeCuboidShape(5, 2, 5, 11, 4, 11);
|
||||
private static final VoxelShape LINE_DOWN_3 = makeCuboidShape(3, 4, 3, 13, 6, 13);
|
||||
private static final VoxelShape LINE_DOWN_1 = box(6, 0, 6, 10, 2, 10);
|
||||
private static final VoxelShape LINE_DOWN_2 = box(5, 2, 5, 11, 4, 11);
|
||||
private static final VoxelShape LINE_DOWN_3 = box(3, 4, 3, 13, 6, 13);
|
||||
private static final VoxelShape LINE_DOWN = VoxelShapes.or(LINE_DOWN_1, LINE_DOWN_2, LINE_DOWN_3);
|
||||
|
||||
public ExporterBlock() {
|
||||
@@ -80,7 +80,7 @@ public class ExporterBlock extends CableBlock {
|
||||
|
||||
|
||||
private VoxelShape getLineShape(BlockState state) {
|
||||
Direction direction = state.get(getDirection().getProperty());
|
||||
Direction direction = state.getValue(getDirection().getProperty());
|
||||
|
||||
if (direction == Direction.NORTH) {
|
||||
return LINE_NORTH;
|
||||
@@ -117,8 +117,8 @@ public class ExporterBlock extends CableBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
if (!world.isRemote && CollisionUtils.isInBounds(getLineShape(state), pos, hit.getHitVec())) {
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
if (!world.isClientSide && CollisionUtils.isInBounds(getLineShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
new PositionalTileContainerProvider<ExporterTile>(
|
||||
|
@@ -32,12 +32,12 @@ import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ExternalStorageBlock extends CableBlock {
|
||||
private static final VoxelShape HEAD_NORTH = VoxelShapes.or(makeCuboidShape(3, 3, 0, 13, 13, 2), HOLDER_NORTH);
|
||||
private static final VoxelShape HEAD_EAST = VoxelShapes.or(makeCuboidShape(14, 3, 3, 16, 13, 13), HOLDER_EAST);
|
||||
private static final VoxelShape HEAD_SOUTH = VoxelShapes.or(makeCuboidShape(3, 3, 14, 13, 13, 16), HOLDER_SOUTH);
|
||||
private static final VoxelShape HEAD_WEST = VoxelShapes.or(makeCuboidShape(0, 3, 3, 2, 13, 13), HOLDER_WEST);
|
||||
private static final VoxelShape HEAD_UP = VoxelShapes.or(makeCuboidShape(3, 14, 3, 13, 16, 13), HOLDER_UP);
|
||||
private static final VoxelShape HEAD_DOWN = VoxelShapes.or(makeCuboidShape(3, 0, 3, 13, 2, 13), HOLDER_DOWN);
|
||||
private static final VoxelShape HEAD_NORTH = VoxelShapes.or(box(3, 3, 0, 13, 13, 2), HOLDER_NORTH);
|
||||
private static final VoxelShape HEAD_EAST = VoxelShapes.or(box(14, 3, 3, 16, 13, 13), HOLDER_EAST);
|
||||
private static final VoxelShape HEAD_SOUTH = VoxelShapes.or(box(3, 3, 14, 13, 13, 16), HOLDER_SOUTH);
|
||||
private static final VoxelShape HEAD_WEST = VoxelShapes.or(box(0, 3, 3, 2, 13, 13), HOLDER_WEST);
|
||||
private static final VoxelShape HEAD_UP = VoxelShapes.or(box(3, 14, 3, 13, 16, 13), HOLDER_UP);
|
||||
private static final VoxelShape HEAD_DOWN = VoxelShapes.or(box(3, 0, 3, 13, 2, 13), HOLDER_DOWN);
|
||||
|
||||
public ExternalStorageBlock() {
|
||||
super(BlockUtils.DEFAULT_GLASS_PROPERTIES);
|
||||
@@ -60,7 +60,7 @@ public class ExternalStorageBlock extends CableBlock {
|
||||
}
|
||||
|
||||
private VoxelShape getHeadShape(BlockState state) {
|
||||
Direction direction = state.get(getDirection().getProperty());
|
||||
Direction direction = state.getValue(getDirection().getProperty());
|
||||
|
||||
if (direction == Direction.NORTH) {
|
||||
return HEAD_NORTH;
|
||||
@@ -97,8 +97,8 @@ public class ExternalStorageBlock extends CableBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
if (!world.isRemote && CollisionUtils.isInBounds(getHeadShape(state), pos, hit.getHitVec())) {
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
if (!world.isClientSide && CollisionUtils.isInBounds(getHeadShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
new PositionalTileContainerProvider<ExternalStorageTile>(
|
||||
@@ -118,12 +118,12 @@ public class ExternalStorageBlock extends CableBlock {
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) {
|
||||
super.neighborChanged(state, world, pos, block, fromPos, isMoving);
|
||||
|
||||
if (!world.isRemote) {
|
||||
INetworkNode node = NetworkUtils.getNodeFromTile(world.getTileEntity(pos));
|
||||
if (!world.isClientSide) {
|
||||
INetworkNode node = NetworkUtils.getNodeFromTile(world.getBlockEntity(pos));
|
||||
|
||||
if (node instanceof ExternalStorageNetworkNode &&
|
||||
node.getNetwork() != null &&
|
||||
fromPos.equals(pos.offset(((ExternalStorageNetworkNode) node).getDirection()))) {
|
||||
fromPos.equals(pos.relative(((ExternalStorageNetworkNode) node).getDirection()))) {
|
||||
((ExternalStorageNetworkNode) node).updateStorage(node.getNetwork(), InvalidateCause.NEIGHBOR_CHANGED);
|
||||
}
|
||||
}
|
||||
|
@@ -34,8 +34,8 @@ public class FluidInterfaceBlock extends NetworkNodeBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||
if (!world.isRemote) {
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attempt(world, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
new PositionalTileContainerProvider<FluidInterfaceTile>(
|
||||
|
@@ -37,19 +37,19 @@ public class FluidStorageBlock extends NetworkNodeBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, LivingEntity player, ItemStack stack) {
|
||||
if (!world.isRemote) {
|
||||
FluidStorageNetworkNode storage = ((FluidStorageTile) world.getTileEntity(pos)).getNode();
|
||||
public void setPlacedBy(World world, BlockPos pos, BlockState state, LivingEntity player, ItemStack stack) {
|
||||
if (!world.isClientSide) {
|
||||
FluidStorageNetworkNode storage = ((FluidStorageTile) world.getBlockEntity(pos)).getNode();
|
||||
|
||||
if (stack.hasTag() && stack.getTag().hasUniqueId(FluidStorageNetworkNode.NBT_ID)) {
|
||||
storage.setStorageId(stack.getTag().getUniqueId(FluidStorageNetworkNode.NBT_ID));
|
||||
if (stack.hasTag() && stack.getTag().hasUUID(FluidStorageNetworkNode.NBT_ID)) {
|
||||
storage.setStorageId(stack.getTag().getUUID(FluidStorageNetworkNode.NBT_ID));
|
||||
}
|
||||
|
||||
storage.loadStorage(player instanceof PlayerEntity ? (PlayerEntity) player : null);
|
||||
}
|
||||
|
||||
// Call this after loading the storage, so the network discovery can use the loaded storage.
|
||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||
super.setPlacedBy(world, pos, state, player, stack);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -60,10 +60,10 @@ public class FluidStorageBlock extends NetworkNodeBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||
if (!world.isRemote) {
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui((ServerPlayerEntity) player, new PositionalTileContainerProvider<FluidStorageTile>(
|
||||
((FluidStorageTile) world.getTileEntity(pos)).getNode().getTitle(),
|
||||
((FluidStorageTile) world.getBlockEntity(pos)).getNode().getTitle(),
|
||||
(tile, windowId, inventory, p) -> new FluidStorageContainer(tile, player, windowId),
|
||||
pos
|
||||
), pos));
|
||||
|
@@ -48,7 +48,7 @@ public class GridBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ColorMap<GridBlock> map;
|
||||
switch (type) {
|
||||
case FLUID:
|
||||
@@ -67,12 +67,12 @@ public class GridBlock extends ColoredNetworkBlock {
|
||||
throw new IllegalStateException("Unexpected value: " + type);
|
||||
}
|
||||
|
||||
ActionResultType result = map.changeBlockColor(state, player.getHeldItem(hand), world, pos, player);
|
||||
ActionResultType result = map.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
if (result != ActionResultType.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> API.instance().getGridManager().openGrid(GridBlockGridFactory.ID, (ServerPlayerEntity) player, pos));
|
||||
}
|
||||
|
||||
|
@@ -28,34 +28,34 @@ import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ImporterBlock extends CableBlock {
|
||||
private static final VoxelShape LINE_NORTH_1 = makeCuboidShape(6, 6, 4, 10, 10, 6);
|
||||
private static final VoxelShape LINE_NORTH_2 = makeCuboidShape(5, 5, 2, 11, 11, 4);
|
||||
private static final VoxelShape LINE_NORTH_3 = makeCuboidShape(3, 3, 0, 13, 13, 2);
|
||||
private static final VoxelShape LINE_NORTH_1 = box(6, 6, 4, 10, 10, 6);
|
||||
private static final VoxelShape LINE_NORTH_2 = box(5, 5, 2, 11, 11, 4);
|
||||
private static final VoxelShape LINE_NORTH_3 = box(3, 3, 0, 13, 13, 2);
|
||||
private static final VoxelShape LINE_NORTH = VoxelShapes.or(LINE_NORTH_1, LINE_NORTH_2, LINE_NORTH_3);
|
||||
|
||||
private static final VoxelShape LINE_EAST_1 = makeCuboidShape(10, 6, 6, 12, 10, 10);
|
||||
private static final VoxelShape LINE_EAST_2 = makeCuboidShape(12, 5, 5, 14, 11, 11);
|
||||
private static final VoxelShape LINE_EAST_3 = makeCuboidShape(14, 3, 3, 16, 13, 13);
|
||||
private static final VoxelShape LINE_EAST_1 = box(10, 6, 6, 12, 10, 10);
|
||||
private static final VoxelShape LINE_EAST_2 = box(12, 5, 5, 14, 11, 11);
|
||||
private static final VoxelShape LINE_EAST_3 = box(14, 3, 3, 16, 13, 13);
|
||||
private static final VoxelShape LINE_EAST = VoxelShapes.or(LINE_EAST_1, LINE_EAST_2, LINE_EAST_3);
|
||||
|
||||
private static final VoxelShape LINE_SOUTH_1 = makeCuboidShape(6, 6, 10, 10, 10, 12);
|
||||
private static final VoxelShape LINE_SOUTH_2 = makeCuboidShape(5, 5, 12, 11, 11, 14);
|
||||
private static final VoxelShape LINE_SOUTH_3 = makeCuboidShape(3, 3, 14, 13, 13, 16);
|
||||
private static final VoxelShape LINE_SOUTH_1 = box(6, 6, 10, 10, 10, 12);
|
||||
private static final VoxelShape LINE_SOUTH_2 = box(5, 5, 12, 11, 11, 14);
|
||||
private static final VoxelShape LINE_SOUTH_3 = box(3, 3, 14, 13, 13, 16);
|
||||
private static final VoxelShape LINE_SOUTH = VoxelShapes.or(LINE_SOUTH_1, LINE_SOUTH_2, LINE_SOUTH_3);
|
||||
|
||||
private static final VoxelShape LINE_WEST_1 = makeCuboidShape(4, 6, 6, 6, 10, 10);
|
||||
private static final VoxelShape LINE_WEST_2 = makeCuboidShape(2, 5, 5, 4, 11, 11);
|
||||
private static final VoxelShape LINE_WEST_3 = makeCuboidShape(0, 3, 3, 2, 13, 13);
|
||||
private static final VoxelShape LINE_WEST_1 = box(4, 6, 6, 6, 10, 10);
|
||||
private static final VoxelShape LINE_WEST_2 = box(2, 5, 5, 4, 11, 11);
|
||||
private static final VoxelShape LINE_WEST_3 = box(0, 3, 3, 2, 13, 13);
|
||||
private static final VoxelShape LINE_WEST = VoxelShapes.or(LINE_WEST_1, LINE_WEST_2, LINE_WEST_3);
|
||||
|
||||
private static final VoxelShape LINE_UP_1 = makeCuboidShape(6, 10, 6, 10, 12, 10);
|
||||
private static final VoxelShape LINE_UP_2 = makeCuboidShape(5, 12, 5, 11, 14, 11);
|
||||
private static final VoxelShape LINE_UP_3 = makeCuboidShape(3, 14, 3, 13, 16, 13);
|
||||
private static final VoxelShape LINE_UP_1 = box(6, 10, 6, 10, 12, 10);
|
||||
private static final VoxelShape LINE_UP_2 = box(5, 12, 5, 11, 14, 11);
|
||||
private static final VoxelShape LINE_UP_3 = box(3, 14, 3, 13, 16, 13);
|
||||
private static final VoxelShape LINE_UP = VoxelShapes.or(LINE_UP_1, LINE_UP_2, LINE_UP_3);
|
||||
|
||||
private static final VoxelShape LINE_DOWN_1 = makeCuboidShape(6, 4, 6, 10, 6, 10);
|
||||
private static final VoxelShape LINE_DOWN_2 = makeCuboidShape(5, 2, 5, 11, 4, 11);
|
||||
private static final VoxelShape LINE_DOWN_3 = makeCuboidShape(3, 0, 3, 13, 2, 13);
|
||||
private static final VoxelShape LINE_DOWN_1 = box(6, 4, 6, 10, 6, 10);
|
||||
private static final VoxelShape LINE_DOWN_2 = box(5, 2, 5, 11, 4, 11);
|
||||
private static final VoxelShape LINE_DOWN_3 = box(3, 0, 3, 13, 2, 13);
|
||||
private static final VoxelShape LINE_DOWN = VoxelShapes.or(LINE_DOWN_1, LINE_DOWN_2, LINE_DOWN_3);
|
||||
|
||||
public ImporterBlock() {
|
||||
@@ -79,7 +79,7 @@ public class ImporterBlock extends CableBlock {
|
||||
}
|
||||
|
||||
private VoxelShape getLineShape(BlockState state) {
|
||||
Direction direction = state.get(getDirection().getProperty());
|
||||
Direction direction = state.getValue(getDirection().getProperty());
|
||||
|
||||
if (direction == Direction.NORTH) {
|
||||
return LINE_NORTH;
|
||||
@@ -116,8 +116,8 @@ public class ImporterBlock extends CableBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
if (!world.isRemote && CollisionUtils.isInBounds(getLineShape(state), pos, hit.getHitVec())) {
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
if (!world.isClientSide && CollisionUtils.isInBounds(getLineShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
new PositionalTileContainerProvider<ImporterTile>(
|
||||
|
@@ -34,8 +34,8 @@ public class InterfaceBlock extends NetworkNodeBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||
if (!world.isRemote) {
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attempt(world, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
new PositionalTileContainerProvider<InterfaceTile>(
|
||||
|
@@ -27,7 +27,7 @@ public abstract class NetworkNodeBlock extends BaseBlock {
|
||||
super(props);
|
||||
|
||||
if (hasConnectedState()) {
|
||||
this.setDefaultState(this.getStateContainer().getBaseState().with(CONNECTED, false));
|
||||
this.registerDefaultState(this.getStateDefinition().any().setValue(CONNECTED, false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,19 +36,19 @@ public abstract class NetworkNodeBlock extends BaseBlock {
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
|
||||
super.neighborChanged(state, world, pos, blockIn, fromPos, isMoving);
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
INetworkNode node = API.instance().getNetworkNodeManager((ServerWorld) world).getNode(pos);
|
||||
if (node instanceof NetworkNode) {
|
||||
((NetworkNode) node).setRedstonePowered(world.isBlockPowered(pos));
|
||||
((NetworkNode) node).setRedstonePowered(world.hasNeighborSignal(pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
public void onRemove(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
TileEntity tile = world.getBlockEntity(pos);
|
||||
|
||||
if (tile instanceof NetworkNodeTile) {
|
||||
IItemHandler handler = ((NetworkNodeTile) tile).getNode().getDrops();
|
||||
@@ -60,20 +60,20 @@ public abstract class NetworkNodeBlock extends BaseBlock {
|
||||
drops.add(handler.getStackInSlot(i));
|
||||
}
|
||||
|
||||
InventoryHelper.dropItems(world, pos, drops);
|
||||
InventoryHelper.dropContents(world, pos, drops);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Call onReplaced after the drops check so the tile still exists
|
||||
super.onReplaced(state, world, pos, newState, isMoving);
|
||||
super.onRemove(state, world, pos, newState, isMoving);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDirectionChanged(World world, BlockPos pos, Direction newDirection) {
|
||||
super.onDirectionChanged(world, pos, newDirection);
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
TileEntity tile = world.getBlockEntity(pos);
|
||||
if (tile instanceof INetworkNodeProxy) {
|
||||
INetworkNode node = ((INetworkNodeProxy) tile).getNode();
|
||||
|
||||
@@ -84,8 +84,8 @@ public abstract class NetworkNodeBlock extends BaseBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
|
||||
if (hasConnectedState()) {
|
||||
builder.add(CONNECTED);
|
||||
|
@@ -32,7 +32,7 @@ public class NetworkReceiverBlock extends ColoredNetworkBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
return RSBlocks.NETWORK_RECEIVER.changeBlockColor(state, player.getHeldItem(hand), world, pos, player);
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
return RSBlocks.NETWORK_RECEIVER.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
}
|
||||
}
|
||||
|
@@ -34,13 +34,13 @@ public class NetworkTransmitterBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ActionResultType result = RSBlocks.NETWORK_TRANSMITTER.changeBlockColor(state, player.getHeldItem(hand), world, pos, player);
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ActionResultType result = RSBlocks.NETWORK_TRANSMITTER.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
if (result != ActionResultType.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
new PositionalTileContainerProvider<NetworkTransmitterTile>(
|
||||
|
@@ -31,7 +31,7 @@ public class PortableGridBlock extends BaseBlock {
|
||||
public static final EnumProperty<PortableGridDiskState> DISK_STATE = EnumProperty.create("disk_state", PortableGridDiskState.class);
|
||||
public static final BooleanProperty ACTIVE = BooleanProperty.create("active");
|
||||
|
||||
private static final VoxelShape SHAPE = makeCuboidShape(0, 0, 0, 16, 13.2, 16);
|
||||
private static final VoxelShape SHAPE = box(0, 0, 0, 16, 13.2, 16);
|
||||
|
||||
private final PortableGridBlockItem.Type type;
|
||||
|
||||
@@ -39,12 +39,12 @@ public class PortableGridBlock extends BaseBlock {
|
||||
super(BlockUtils.DEFAULT_ROCK_PROPERTIES);
|
||||
|
||||
this.type = type;
|
||||
this.setDefaultState(getDefaultState().with(DISK_STATE, PortableGridDiskState.NONE).with(ACTIVE, false));
|
||||
this.registerDefaultState(defaultBlockState().setValue(DISK_STATE, PortableGridDiskState.NONE).setValue(ACTIVE, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
|
||||
builder.add(DISK_STATE);
|
||||
builder.add(ACTIVE);
|
||||
@@ -74,23 +74,23 @@ public class PortableGridBlock extends BaseBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
if (!world.isRemote) {
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
if (!world.isClientSide) {
|
||||
API.instance().getGridManager().openGrid(PortableGridBlockGridFactory.ID, (ServerPlayerEntity) player, pos);
|
||||
|
||||
((PortableGridTile) world.getTileEntity(pos)).onOpened();
|
||||
((PortableGridTile) world.getBlockEntity(pos)).onOpened();
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, pos, state, placer, stack);
|
||||
public void setPlacedBy(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||
super.setPlacedBy(world, pos, state, placer, stack);
|
||||
|
||||
if (!world.isRemote) {
|
||||
((PortableGridTile) world.getTileEntity(pos)).applyDataFromItemToTile(stack);
|
||||
((PortableGridTile) world.getTileEntity(pos)).updateState();
|
||||
if (!world.isClientSide) {
|
||||
((PortableGridTile) world.getBlockEntity(pos)).applyDataFromItemToTile(stack);
|
||||
((PortableGridTile) world.getBlockEntity(pos)).updateState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -34,13 +34,13 @@ public class RelayBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ActionResultType result = RSBlocks.RELAY.changeBlockColor(state, player.getHeldItem(hand), world, pos, player);
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ActionResultType result = RSBlocks.RELAY.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
if (result != ActionResultType.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
new PositionalTileContainerProvider<RelayTile>(
|
||||
|
@@ -34,13 +34,13 @@ public class SecurityManagerBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ActionResultType result = RSBlocks.SECURITY_MANAGER.changeBlockColor(state, player.getHeldItem(hand), world, pos, player);
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ActionResultType result = RSBlocks.SECURITY_MANAGER.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
if (result != ActionResultType.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (!world.isClientSide) {
|
||||
Runnable action = () -> NetworkHooks.openGui(
|
||||
(ServerPlayerEntity) player,
|
||||
new PositionalTileContainerProvider<SecurityManagerTile>(
|
||||
@@ -51,7 +51,7 @@ public class SecurityManagerBlock extends ColoredNetworkBlock {
|
||||
pos
|
||||
);
|
||||
|
||||
if (player.getGameProfile().getId().equals(((SecurityManagerTile) world.getTileEntity(pos)).getNode().getOwner())) {
|
||||
if (player.getGameProfile().getId().equals(((SecurityManagerTile) world.getBlockEntity(pos)).getNode().getOwner())) {
|
||||
action.run();
|
||||
} else {
|
||||
return NetworkUtils.attempt(world, pos, player, action, Permission.MODIFY, Permission.SECURITY);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user