Compare commits

..

3 commits

Author SHA1 Message Date
Ell
1880bf785d some more workkkk 2021-12-04 19:17:21 +01:00
Ell
cd328cab6a some more work?? 2021-12-04 15:40:09 +01:00
Ell
8ee01dafe4 the start of a terrible journey 2021-12-04 14:51:31 +01:00
215 changed files with 3855 additions and 3807 deletions

View file

@ -1,7 +1,7 @@
# NaturesAura
Nature's Aura is a mod about collecting, using and replenishing the Aura
naturally present in the world to create useful devices and unique mechanics.
naturally present in the level to create useful devices and unique mechanics.
## Maven

View file

@ -1,11 +1,11 @@
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
}
}
apply plugin: 'net.minecraftforge.gradle'
@ -20,10 +20,11 @@ archivesBaseName = 'NaturesAura'
if (System.getenv('BUILD_NUMBER') != null) {
version += "." + System.getenv('BUILD_NUMBER')
}
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
minecraft {
mappings channel: 'snapshot', version: '20200723-1.16.1'
mappings channel: 'official', version: '1.18'
runs {
client {
@ -101,18 +102,22 @@ repositories {
}
dependencies {
minecraft 'net.minecraftforge:forge:1.16.5-36.1.3'
minecraft 'net.minecraftforge:forge:1.18-38.0.14'
compileOnly fg.deobf("mezz.jei:jei-1.16.5:7.6.1.75:api")
runtimeOnly fg.deobf("mezz.jei:jei-1.16.5:7.6.1.75")
// TODO JEI
/* compileOnly fg.deobf("mezz.jei:jei-1.16.5:7.6.1.75:api")
runtimeOnly fg.deobf("mezz.jei:jei-1.16.5:7.6.1.75")*/
compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.16.4-50:api")
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.16.4-50")
// TDOO Patchouli
/* compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.16.4-50:api")
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.16.4-50")*/
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.16.5-4.0.5.0")
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.16.5-4.0.5.0:api")
// TODO Curios
/* runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.16.5-4.0.5.0")
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.16.5-4.0.5.0:api")*/
compile fg.deobf("quarris.enchantability:Enchantability:11.0.48")
// TODO Enchantability
/* compile fg.deobf("quarris.enchantability:Enchantability:11.0.48")*/
}
// Example for how to get properties into the manifest for reading by the runtime..

Binary file not shown.

View file

@ -1,6 +1,5 @@
#Sun Oct 20 21:47:13 CEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip

286
gradlew vendored
View file

@ -1,78 +1,129 @@
#!/usr/bin/env sh
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
MAX_FD=maximum
warn () {
echo "$*"
}
} >&2
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@ -81,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
@ -89,84 +140,95 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

43
gradlew.bat vendored
View file

@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -35,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -45,28 +64,14 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell

View file

@ -1,74 +1,64 @@
package de.ellpeck.naturesaura;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl;
import de.ellpeck.naturesaura.api.misc.ILevelData;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl;
import de.ellpeck.naturesaura.chunk.AuraChunk;
import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.misc.WorldData;
import net.minecraft.advancements.Advancement;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.item.ItemFrameEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.nbt.INBT;
import net.minecraft.state.Property;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.chunk.AbstractChunkProvider;
import net.minecraft.world.chunk.Chunk;
import de.ellpeck.naturesaura.misc.LevelData;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry;
import org.apache.commons.lang3.tuple.ImmutableTriple;
import org.lwjgl.opengl.GL11;
import top.theillusivec4.curios.api.CuriosApi;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
public final class Helper {
public static boolean getTileEntitiesInArea(IWorld world, BlockPos pos, int radius, Function<TileEntity, Boolean> consumer) {
for (int x = pos.getX() - radius >> 4; x <= pos.getX() + radius >> 4; x++) {
for (int z = pos.getZ() - radius >> 4; z <= pos.getZ() + radius >> 4; z++) {
Chunk chunk = getLoadedChunk(world, x, z);
public static boolean getBlockEntitiesInArea(Level level, BlockPos pos, int radius, Function<BlockEntity, Boolean> consumer) {
for (var x = pos.getX() - radius >> 4; x <= pos.getX() + radius >> 4; x++) {
for (var z = pos.getZ() - radius >> 4; z <= pos.getZ() + radius >> 4; z++) {
var chunk = getLoadedChunk(level, x, z);
if (chunk != null) {
for (BlockPos tilePos : chunk.getTileEntitiesPos()) {
if (tilePos.distanceSq(pos) <= radius * radius)
if (consumer.apply(chunk.getTileEntity(tilePos)))
for (var tilePos : chunk.getBlockEntitiesPos()) {
if (tilePos.distSqr(pos) <= radius * radius)
if (consumer.apply(chunk.getBlockEntity(tilePos)))
return true;
}
}
@ -77,99 +67,86 @@ public final class Helper {
return false;
}
public static void getAuraChunksWithSpotsInArea(World world, BlockPos pos, int radius, Consumer<AuraChunk> consumer) {
WorldData data = (WorldData) IWorldData.getWorldData(world);
for (int x = pos.getX() - radius >> 4; x <= pos.getX() + radius >> 4; x++) {
for (int z = pos.getZ() - radius >> 4; z <= pos.getZ() + radius >> 4; z++) {
AuraChunk chunk = data.auraChunksWithSpots.get(ChunkPos.asLong(x, z));
public static void getAuraChunksWithSpotsInArea(Level level, BlockPos pos, int radius, Consumer<AuraChunk> consumer) {
var data = (LevelData) ILevelData.getLevelData(level);
for (var x = pos.getX() - radius >> 4; x <= pos.getX() + radius >> 4; x++) {
for (var z = pos.getZ() - radius >> 4; z <= pos.getZ() + radius >> 4; z++) {
var chunk = data.auraChunksWithSpots.get(ChunkPos.asLong(x, z));
if (chunk != null)
consumer.accept(chunk);
}
}
}
public static List<ItemFrameEntity> getAttachedItemFrames(World world, BlockPos pos) {
List<ItemFrameEntity> frames = world.getEntitiesWithinAABB(ItemFrameEntity.class, new AxisAlignedBB(pos).grow(0.25));
for (int i = frames.size() - 1; i >= 0; i--) {
ItemFrameEntity frame = frames.get(i);
BlockPos framePos = frame.getHangingPosition().offset(frame.getHorizontalFacing().getOpposite());
public static List<ItemFrame> getAttachedItemFrames(Level level, BlockPos pos) {
var frames = level.getEntitiesOfClass(ItemFrame.class, new AABB(pos).inflate(0.25));
for (var i = frames.size() - 1; i >= 0; i--) {
var frame = frames.get(i);
var framePos = frame.getPos().relative(frame.getDirection().getOpposite());
if (!pos.equals(framePos))
frames.remove(i);
}
return frames;
}
public static Chunk getLoadedChunk(IWorld world, int x, int z) {
public static LevelChunk getLoadedChunk(Level level, int x, int z) {
// DO NOT EDIT PLEASE FOR THE LOVE OF GOD
// This is very finicky and easily causes the game to hang for some reason
AbstractChunkProvider provider = world.getChunkProvider();
if (provider.isChunkLoaded(new ChunkPos(x, z)))
var provider = level.getChunkSource();
if (provider.hasChunk(x, z))
return provider.getChunk(x, z, false);
return null;
}
public static int blendColors(int c1, int c2, float ratio) {
int a = (int) ((c1 >> 24 & 0xFF) * ratio + (c2 >> 24 & 0xFF) * (1 - ratio));
int r = (int) ((c1 >> 16 & 0xFF) * ratio + (c2 >> 16 & 0xFF) * (1 - ratio));
int g = (int) ((c1 >> 8 & 0xFF) * ratio + (c2 >> 8 & 0xFF) * (1 - ratio));
int b = (int) ((c1 & 0xFF) * ratio + (c2 & 0xFF) * (1 - ratio));
var a = (int) ((c1 >> 24 & 0xFF) * ratio + (c2 >> 24 & 0xFF) * (1 - ratio));
var r = (int) ((c1 >> 16 & 0xFF) * ratio + (c2 >> 16 & 0xFF) * (1 - ratio));
var g = (int) ((c1 >> 8 & 0xFF) * ratio + (c2 >> 8 & 0xFF) * (1 - ratio));
var b = (int) ((c1 & 0xFF) * ratio + (c2 & 0xFF) * (1 - ratio));
return (a & 255) << 24 | (r & 255) << 16 | (g & 255) << 8 | b & 255;
}
public static boolean areItemsEqual(ItemStack first, ItemStack second, boolean nbt) {
if (!ItemStack.areItemsEqual(first, second))
if (!ItemStack.isSame(first, second))
return false;
return !nbt || ItemStack.areItemStackTagsEqual(first, second);
return !nbt || ItemStack.tagMatches(first, second);
}
@OnlyIn(Dist.CLIENT)
public static void renderItemInGui(ItemStack stack, int x, int y, float scale) {
RenderSystem.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.enableDepthTest();
RenderSystem.enableRescaleNormal();
RenderSystem.translatef(x, y, 0);
RenderSystem.scalef(scale, scale, scale);
Minecraft.getInstance().getItemRenderer().renderItemAndEffectIntoGUI(stack, 0, 0);
Minecraft.getInstance().getItemRenderer().renderItemOverlayIntoGUI(Minecraft.getInstance().fontRenderer, stack, 0, 0, null);
RenderSystem.popMatrix();
}
public static ActionResultType putStackOnTile(PlayerEntity player, Hand hand, BlockPos pos, int slot, boolean sound) {
TileEntity tile = player.world.getTileEntity(pos);
if (tile instanceof TileEntityImpl) {
IItemHandlerModifiable handler = ((TileEntityImpl) tile).getItemHandler();
public static InteractionResult putStackOnTile(Player player, InteractionHand hand, BlockPos pos, int slot, boolean sound) {
var tile = player.level.getBlockEntity(pos);
if (tile instanceof BlockEntityImpl) {
var handler = ((BlockEntityImpl) tile).getItemHandler();
if (handler != null) {
ItemStack handStack = player.getHeldItem(hand);
var handStack = player.getItemInHand(hand);
if (!handStack.isEmpty()) {
ItemStack remain = handler.insertItem(slot, handStack, player.world.isRemote);
if (!ItemStack.areItemStacksEqual(remain, handStack)) {
var remain = handler.insertItem(slot, handStack, player.level.isClientSide);
if (!ItemStack.isSame(remain, handStack)) {
if (sound)
player.world.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
SoundEvents.ENTITY_ITEM_FRAME_ADD_ITEM, SoundCategory.PLAYERS, 0.75F, 1F);
if (!player.world.isRemote)
player.setHeldItem(hand, remain);
return ActionResultType.SUCCESS;
player.level.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
SoundEvents.ITEM_FRAME_ADD_ITEM, SoundSource.PLAYERS, 0.75F, 1F);
if (!player.level.isClientSide)
player.setItemInHand(hand, remain);
return InteractionResult.SUCCESS;
}
}
if (!handler.getStackInSlot(slot).isEmpty()) {
if (sound)
player.world.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
SoundEvents.ENTITY_ITEM_FRAME_REMOVE_ITEM, SoundCategory.PLAYERS, 0.75F, 1F);
if (!player.world.isRemote) {
ItemStack stack = handler.getStackInSlot(slot);
if (!player.addItemStackToInventory(stack)) {
ItemEntity item = new ItemEntity(player.world, player.getPosX(), player.getPosY(), player.getPosZ(), stack);
player.world.addEntity(item);
player.level.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
SoundEvents.ITEM_FRAME_REMOVE_ITEM, SoundSource.PLAYERS, 0.75F, 1F);
if (!player.level.isClientSide) {
var stack = handler.getStackInSlot(slot);
if (!player.addItem(stack)) {
var item = new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), stack);
player.level.addFreshEntity(item);
}
handler.setStackInSlot(slot, ItemStack.EMPTY);
}
return ActionResultType.SUCCESS;
return InteractionResult.SUCCESS;
}
}
}
return ActionResultType.CONSUME;
return InteractionResult.CONSUME;
}
public static ICapabilityProvider makeRechargeProvider(ItemStack stack, boolean needsSelected) {
@ -191,8 +168,8 @@ public final class Helper {
}
public static boolean rechargeAuraItem(ItemStack stack, IAuraContainer container, int toDrain) {
if (stack.getDamage() > 0 && container.drainAura(toDrain, true) >= toDrain) {
stack.setDamage(stack.getDamage() - 1);
if (stack.getDamageValue() > 0 && container.drainAura(toDrain, true) >= toDrain) {
stack.setDamageValue(stack.getDamageValue() - 1);
container.drainAura(toDrain, false);
return true;
}
@ -200,15 +177,15 @@ public final class Helper {
}
public static BlockState getStateFromString(String raw) {
String[] split = raw.split("\\[");
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(split[0]));
var split = raw.split("\\[");
var block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(split[0]));
if (block != null) {
BlockState state = block.getDefaultState();
var state = block.defaultBlockState();
if (split.length > 1) {
for (String part : split[1].replace("]", "").split(",")) {
String[] keyValue = part.split("=");
for (Property<?> prop : state.getProperties()) {
BlockState changed = findProperty(state, prop, keyValue[0], keyValue[1]);
for (var part : split[1].replace("]", "").split(",")) {
var keyValue = part.split("=");
for (var prop : state.getProperties()) {
var changed = findProperty(state, prop, keyValue[0], keyValue[1]);
if (changed != null) {
state = changed;
break;
@ -223,39 +200,23 @@ public final class Helper {
private static <T extends Comparable<T>> BlockState findProperty(BlockState state, Property<T> prop, String key, String newValue) {
if (key.equals(prop.getName()))
for (T value : prop.getAllowedValues())
for (var value : prop.getPossibleValues())
if (prop.getName(value).equals(newValue))
return state.with(prop, value);
return state.setValue(prop, value);
return null;
}
public static <T> void registerCap(Class<T> type) {
CapabilityManager.INSTANCE.register(type, new Capability.IStorage<T>() {
@Override
public void readNBT(Capability<T> capability, T instance, Direction side, INBT nbt) {
}
@Nullable
@Override
public INBT writeNBT(Capability capability, Object instance, Direction side) {
return null;
}
}, () -> null);
}
public static void addAdvancement(PlayerEntity player, ResourceLocation advancement, String criterion) {
if (!(player instanceof ServerPlayerEntity))
public static void addAdvancement(Player player, ResourceLocation advancement, String criterion) {
if (!(player instanceof ServerPlayer playerMp))
return;
ServerPlayerEntity playerMp = (ServerPlayerEntity) player;
Advancement adv = playerMp.getServerWorld().getServer().getAdvancementManager().getAdvancement(advancement);
var adv = playerMp.getLevel().getServer().getAdvancements().getAdvancement(advancement);
if (adv != null)
playerMp.getAdvancements().grantCriterion(adv, criterion);
playerMp.getAdvancements().award(adv, criterion);
}
public static int getIngredientAmount(Ingredient ingredient) {
int highestAmount = 0;
for (ItemStack stack : ingredient.getMatchingStacks())
var highestAmount = 0;
for (var stack : ingredient.getItems())
if (stack.getCount() > highestAmount)
highestAmount = stack.getCount();
return highestAmount;
@ -289,9 +250,9 @@ public final class Helper {
GL11.glVertex3d(x, y, z);
}
public static boolean isHoldingItem(PlayerEntity player, Item item) {
for (Hand hand : Hand.values()) {
ItemStack stack = player.getHeldItem(hand);
public static boolean isHoldingItem(Player player, Item item) {
for (var hand : InteractionHand.values()) {
var stack = player.getItemInHand(hand);
if (!stack.isEmpty() && stack.getItem() == item)
return true;
}
@ -299,22 +260,22 @@ public final class Helper {
}
public static boolean isEmpty(IItemHandler handler) {
for (int i = 0; i < handler.getSlots(); i++)
for (var i = 0; i < handler.getSlots(); i++)
if (!handler.getStackInSlot(i).isEmpty())
return false;
return true;
}
public static AxisAlignedBB aabb(Vector3d pos) {
return new AxisAlignedBB(pos.x, pos.y, pos.z, pos.x, pos.y, pos.z);
public static AABB aabb(Vec3 pos) {
return new AABB(pos.x, pos.y, pos.z, pos.x, pos.y, pos.z);
}
// This is how @ObjectHolder _SHOULD_ work...
public static <T extends IForgeRegistryEntry<T>> void populateObjectHolders(Class clazz, IForgeRegistry<T> registry) {
for (Field entry : clazz.getFields()) {
// This is how @ObjectHolder SHOULD work...
public static <T extends IForgeRegistryEntry<T>> void populateObjectHolders(Class<?> clazz, IForgeRegistry<T> registry) {
for (var entry : clazz.getFields()) {
if (!Modifier.isStatic(entry.getModifiers()))
continue;
ResourceLocation location = new ResourceLocation(NaturesAura.MOD_ID, entry.getName().toLowerCase(Locale.ROOT));
var location = new ResourceLocation(NaturesAura.MOD_ID, entry.getName().toLowerCase(Locale.ROOT));
if (!registry.containsKey(location)) {
NaturesAura.LOGGER.fatal("Couldn't find entry named " + location + " in registry " + registry.getRegistryName());
continue;
@ -327,14 +288,15 @@ public final class Helper {
}
}
public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, PlayerEntity player) {
if (Compat.hasCompat("curios")) {
public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, Player player) {
// TODO Curios
/* if (Compat.hasCompat("curios")) {
Optional<ItemStack> stack = CuriosApi.getCuriosHelper().findEquippedCurio(predicate, player).map(ImmutableTriple::getRight);
if (stack.isPresent())
return stack.get();
}
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack slot = player.inventory.getStackInSlot(i);
}*/
for (var i = 0; i < player.getInventory().getContainerSize(); i++) {
var slot = player.getInventory().getItem(i);
if (!slot.isEmpty() && predicate.test(slot))
return slot;
}

View file

@ -3,18 +3,18 @@ package de.ellpeck.naturesaura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.api.misc.ILevelData;
import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
import de.ellpeck.naturesaura.blocks.multi.Multiblock;
import de.ellpeck.naturesaura.misc.WorldData;
import net.minecraft.entity.player.PlayerEntity;
import de.ellpeck.naturesaura.misc.LevelData;
import net.minecraft.entity.player.Player;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Tuple;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import net.minecraft.level.Level;
import org.apache.commons.lang3.mutable.MutableFloat;
import org.apache.commons.lang3.mutable.MutableInt;
import org.apache.commons.lang3.mutable.MutableObject;
@ -27,16 +27,16 @@ import java.util.function.BiConsumer;
public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
@Override
public boolean extractAuraFromPlayer(PlayerEntity player, int amount, boolean simulate) {
public boolean extractAuraFromPlayer(Player player, int amount, boolean simulate) {
return this.auraPlayerInteraction(player, amount, true, simulate);
}
@Override
public boolean insertAuraIntoPlayer(PlayerEntity player, int amount, boolean simulate) {
public boolean insertAuraIntoPlayer(Player player, int amount, boolean simulate) {
return this.auraPlayerInteraction(player, amount, false, simulate);
}
private boolean auraPlayerInteraction(PlayerEntity player, int amount, boolean extract, boolean simulate) {
private boolean auraPlayerInteraction(Player player, int amount, boolean extract, boolean simulate) {
if (extract && player.isCreative())
return true;
ItemStack stack = Helper.getEquippedItem(s -> s.getCapability(NaturesAuraAPI.capAuraContainer).isPresent(), player);
@ -90,18 +90,18 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
}
@Override
public List<Tuple<Vector3d, Integer>> getActiveEffectPowders(World world, AxisAlignedBB area, ResourceLocation name) {
public List<Tuple<Vector3d, Integer>> getActiveEffectPowders(Level level, AxisAlignedBB area, ResourceLocation name) {
List<Tuple<Vector3d, Integer>> found = new ArrayList<>();
for (Tuple<Vector3d, Integer> powder : ((WorldData) IWorldData.getWorldData(world)).effectPowders.get(name))
for (Tuple<Vector3d, Integer> powder : ((LevelData) ILevelData.getLevelData(level)).effectPowders.get(name))
if (area.contains(powder.getA()))
found.add(powder);
return found;
}
@Override
public boolean isEffectPowderActive(World world, BlockPos pos, ResourceLocation name) {
public boolean isEffectPowderActive(Level level, BlockPos pos, ResourceLocation name) {
Vector3d posVec = new Vector3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
List<Tuple<Vector3d, Integer>> powders = this.getActiveEffectPowders(world, new AxisAlignedBB(pos).grow(64), name);
List<Tuple<Vector3d, Integer>> powders = this.getActiveEffectPowders(level, new AxisAlignedBB(pos).grow(64), name);
for (Tuple<Vector3d, Integer> powder : powders) {
AxisAlignedBB bounds = Helper.aabb(powder.getA()).grow(powder.getB());
if (bounds.contains(posVec))
@ -111,29 +111,29 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
}
@Override
public void getAuraSpotsInArea(World world, BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer) {
Helper.getAuraChunksWithSpotsInArea(world, pos, radius, chunk -> chunk.getSpotsInArea(pos, radius, consumer));
public void getAuraSpotsInArea(Level level, BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer) {
Helper.getAuraChunksWithSpotsInArea(level, pos, radius, chunk -> chunk.getSpotsInArea(pos, radius, consumer));
}
@Override
public int getSpotAmountInArea(World world, BlockPos pos, int radius) {
public int getSpotAmountInArea(Level level, BlockPos pos, int radius) {
MutableInt result = new MutableInt();
this.getAuraSpotsInArea(world, pos, radius, (blockpos, drainSpot) -> result.increment());
this.getAuraSpotsInArea(level, pos, radius, (blockpos, drainSpot) -> result.increment());
return result.intValue();
}
@Override
public int getAuraInArea(World world, BlockPos pos, int radius) {
public int getAuraInArea(Level level, BlockPos pos, int radius) {
MutableInt result = new MutableInt(IAuraChunk.DEFAULT_AURA);
this.getAuraSpotsInArea(world, pos, radius, (blockPos, drainSpot) -> result.add(drainSpot));
this.getAuraSpotsInArea(level, pos, radius, (blockPos, drainSpot) -> result.add(drainSpot));
return result.intValue();
}
@Override
public Pair<Integer, Integer> getAuraAndSpotAmountInArea(World world, BlockPos pos, int radius) {
public Pair<Integer, Integer> getAuraAndSpotAmountInArea(Level level, BlockPos pos, int radius) {
MutableInt spots = new MutableInt();
MutableInt aura = new MutableInt(IAuraChunk.DEFAULT_AURA);
this.getAuraSpotsInArea(world, pos, radius, (blockPos, drainSpot) -> {
this.getAuraSpotsInArea(level, pos, radius, (blockPos, drainSpot) -> {
aura.add(drainSpot);
spots.increment();
});
@ -141,9 +141,9 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
}
@Override
public int triangulateAuraInArea(World world, BlockPos pos, int radius) {
public int triangulateAuraInArea(Level level, BlockPos pos, int radius) {
MutableFloat result = new MutableFloat(IAuraChunk.DEFAULT_AURA);
IAuraChunk.getSpotsInArea(world, pos, radius, (blockPos, spot) -> {
IAuraChunk.getSpotsInArea(level, pos, radius, (blockPos, spot) -> {
float percentage = 1F - (float) Math.sqrt(pos.distanceSq(blockPos)) / radius;
result.add(spot * percentage);
});
@ -151,10 +151,10 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
}
@Override
public BlockPos getLowestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) {
public BlockPos getLowestAuraDrainSpot(Level level, BlockPos pos, int radius, BlockPos defaultSpot) {
MutableInt lowestAmount = new MutableInt(Integer.MAX_VALUE);
MutableObject<BlockPos> lowestSpot = new MutableObject<>();
this.getAuraSpotsInArea(world, pos, radius, (blockPos, drainSpot) -> {
this.getAuraSpotsInArea(level, pos, radius, (blockPos, drainSpot) -> {
if (drainSpot < lowestAmount.intValue()) {
lowestAmount.setValue(drainSpot);
lowestSpot.setValue(blockPos);
@ -167,10 +167,10 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
}
@Override
public BlockPos getHighestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) {
public BlockPos getHighestAuraDrainSpot(Level level, BlockPos pos, int radius, BlockPos defaultSpot) {
MutableInt highestAmount = new MutableInt(Integer.MIN_VALUE);
MutableObject<BlockPos> highestSpot = new MutableObject<>();
this.getAuraSpotsInArea(world, pos, radius, (blockPos, drainSpot) -> {
this.getAuraSpotsInArea(level, pos, radius, (blockPos, drainSpot) -> {
if (drainSpot > highestAmount.intValue()) {
highestAmount.setValue(drainSpot);
highestSpot.setValue(blockPos);

View file

@ -46,7 +46,7 @@ public final class ModConfig {
public ConfigValue<Integer> auraBarLocation;
public ConfigValue<Integer> cacheBarLocation;
public ConfigValue<Boolean> debugText;
public ConfigValue<Boolean> debugWorld;
public ConfigValue<Boolean> debugLevel;
public ConfigValue<Boolean> renderItemsOnPlayer;
public ModConfig(ForgeConfigSpec.Builder builder) {
@ -131,7 +131,7 @@ public final class ModConfig {
.translation("config." + NaturesAura.MOD_ID + ".oreEffect")
.define("oreEffect", true);
this.auraBlooms = builder
.comment("If Aura Blooms and Aura Cacti should generate in the world")
.comment("If Aura Blooms and Aura Cacti should generate in the level")
.translation("config." + NaturesAura.MOD_ID + ".auraBlooms")
.define("auraBlooms", true);
this.netherGrassEffect = builder
@ -165,10 +165,10 @@ public final class ModConfig {
.comment("If debug information about Aura around the player should be displayed in the F3 debug menu if the player is in creative mode")
.translation("config." + NaturesAura.MOD_ID + ".debugText")
.define("debugText", true);
this.debugWorld = builder
.comment("If, when the F3 debug menu is open and the player is in creative mode, every Aura spot should be highlighted in the world for debug purposes")
.translation("config." + NaturesAura.MOD_ID + ".debugWorld")
.define("debugWorld", false);
this.debugLevel = builder
.comment("If, when the F3 debug menu is open and the player is in creative mode, every Aura spot should be highlighted in the level for debug purposes")
.translation("config." + NaturesAura.MOD_ID + ".debugLevel")
.define("debugLevel", false);
this.renderItemsOnPlayer = builder
.comment("If certain equippable items, like the Environmental Eye, should be rendered on the player")
.translation("config." + NaturesAura.MOD_ID + ".renderItemsOnPlayer")

View file

@ -5,7 +5,7 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.api.misc.ILevelData;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.chunk.effect.DrainSpotEffects;
import de.ellpeck.naturesaura.compat.Compat;
@ -17,11 +17,10 @@ import de.ellpeck.naturesaura.proxy.IProxy;
import de.ellpeck.naturesaura.proxy.ServerProxy;
import de.ellpeck.naturesaura.recipes.ModRecipes;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.DeferredWorkQueue;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
@ -37,9 +36,9 @@ public final class NaturesAura {
public static final String MOD_NAME = "Nature's Aura";
public static final Logger LOGGER = LogManager.getLogger(MOD_NAME);
public static final ItemGroup CREATIVE_TAB = new ItemGroup(MOD_ID) {
public static final CreativeModeTab CREATIVE_TAB = new CreativeModeTab(MOD_ID) {
@Override
public ItemStack createIcon() {
public ItemStack makeIcon() {
return new ItemStack(ModItems.GOLD_LEAF);
}
};
@ -65,7 +64,7 @@ public final class NaturesAura {
Helper.registerCap(IAuraContainer.class);
Helper.registerCap(IAuraRecharge.class);
Helper.registerCap(IAuraChunk.class);
Helper.registerCap(IWorldData.class);
Helper.registerCap(ILevelData.class);
Compat.setup(event);
PacketHandler.init();

View file

@ -8,24 +8,24 @@ import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
import de.ellpeck.naturesaura.api.aura.type.BasicAuraType;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.api.misc.ILevelData;
import de.ellpeck.naturesaura.api.misc.WeatherType;
import de.ellpeck.naturesaura.api.misc.WeightedOre;
import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
import de.ellpeck.naturesaura.api.multiblock.Matcher;
import net.minecraft.block.BlockState;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Tuple;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.CapabilityToken;
import org.apache.commons.lang3.tuple.Pair;
import java.util.ArrayList;
@ -46,34 +46,34 @@ public final class NaturesAuraAPI {
public static final String API_ID = MOD_ID + "api";
public static final String VERSION = "9";
/**
* A map of all of the block states that the Botanist's Pickaxe can convert
* A map of all the block states that the Botanist's Pickaxe can convert
* into their mossy variations. Contains mossy brick and mossy cobblestone
* by default, along with all blocks specified in the config file
*/
public static final BiMap<BlockState, BlockState> BOTANIST_PICKAXE_CONVERSIONS = HashBiMap.create();
/**
* A map of all {@link IAuraType} instances which are types of Aura present
* in different types of worlds. {@link BasicAuraType} instances can be
* in different types of levels. {@link BasicAuraType} instances can be
* easily registered using {@link BasicAuraType#register()}.
*/
public static final Map<ResourceLocation, IAuraType> AURA_TYPES = new HashMap<>();
public static final BasicAuraType TYPE_OVERWORLD = new BasicAuraType(new ResourceLocation(MOD_ID, "overworld"), World.field_234918_g_, 0x89cc37, 0).register();
public static final BasicAuraType TYPE_NETHER = new BasicAuraType(new ResourceLocation(MOD_ID, "nether"), World.field_234919_h_, 0x871c0c, 0).register();
public static final BasicAuraType TYPE_END = new BasicAuraType(new ResourceLocation(MOD_ID, "end"), World.field_234920_i_, 0x302624, 0).register();
public static final BasicAuraType TYPE_OVERWORLD = new BasicAuraType(new ResourceLocation(MOD_ID, "overworld"), Level.OVERWORLD, 0x89cc37, 0).register();
public static final BasicAuraType TYPE_NETHER = new BasicAuraType(new ResourceLocation(MOD_ID, "nether"), Level.NETHER, 0x871c0c, 0).register();
public static final BasicAuraType TYPE_END = new BasicAuraType(new ResourceLocation(MOD_ID, "end"), Level.END, 0x302624, 0).register();
public static final BasicAuraType TYPE_OTHER = new BasicAuraType(new ResourceLocation(MOD_ID, "other"), null, 0x2fa8a0, Integer.MIN_VALUE).register();
/**
* A map of all {@link IDrainSpotEffect} suppliers which are effects that
* happen passively at every spot that Aura has been drained from in the
* world. These effects include things like vegetational increase and
* level. These effects include things like vegetational increase and
* natural decay. To register your own drain spot effects, just add a
* supplier for them to this map and they will automatically be executed
* supplier for them to this map, and they will automatically be executed
* once a second for every drain spot currently loaded.
*/
public static final Map<ResourceLocation, Supplier<IDrainSpotEffect>> DRAIN_SPOT_EFFECTS = new HashMap<>();
/**
* A map of all effect powder type. The integer the effect is registered to
* is the color that the powder and its effect should have. To check if a
* powder is active in any given area, use {@link IInternalHooks#isEffectPowderActive(World,
* powder is active in any given area, use {@link IInternalHooks#isEffectPowderActive(Level,
* BlockPos, ResourceLocation)}
*/
public static final Map<ResourceLocation, Integer> EFFECT_POWDERS = new HashMap<>();
@ -90,48 +90,50 @@ public final class NaturesAuraAPI {
public static final List<WeightedOre> OVERWORLD_ORES = new ArrayList<>();
/**
* A list of all {@link WeightedOre} objects that represent ores that can
* spawn inside of netherrack blocks in the nether
* spawn inside netherrack blocks in the nether
*/
public static final List<WeightedOre> NETHER_ORES = new ArrayList<>();
/**
* A map of all of the entities' registry names to the amounts of aura they
* A map of all the entities' registry names to the amounts of aura they
* each generate in the projectile generator
*/
public static final Map<EntityType, Integer> PROJECTILE_GENERATIONS = new HashMap<>();
public static final Map<EntityType<?>, Integer> PROJECTILE_GENERATIONS = new HashMap<>();
/**
* A map of all of the items that cause the {@link WeatherType} to be
* changed using the weather changer
* A map of all the items that cause the {@link WeatherType} to be changed
* using the weather changer
*/
public static final Map<ItemStack, WeatherType> WEATHER_CHANGER_CONVERSIONS = new HashMap<>();
/**
* The capability for any item or block that stores Aura in the form of an
* {@link IAuraContainer}
*/
@CapabilityInject(IAuraContainer.class)
public static Capability<IAuraContainer> capAuraContainer;
public static Capability<IAuraContainer> capAuraContainer = CapabilityManager.get(new CapabilityToken<>() {
});
/**
* The capability for any item that can be recharged from an Aura storage
* container like the Aura Cache in the form of {@link IAuraRecharge} by a
* player holding it in their hand
*/
@CapabilityInject(IAuraRecharge.class)
public static Capability<IAuraRecharge> capAuraRecharge;
public static Capability<IAuraRecharge> capAuraRecharge = CapabilityManager.get(new CapabilityToken<>() {
});
/**
* The capability that any chunk in a world has to store Aura in it. As this
* is only applicable to chunks and all chunks in the world automatically
* The capability that any chunk in a level has to store Aura in it. As this
* is only applicable to chunks and all chunks in the level automatically
* get assigned this capability, using it directly is not necessary for
* addon developers. To retrieve this capability from any chunk, use the
* helper method {@link IAuraChunk#getAuraChunk(IWorld, BlockPos)}.
* helper method {@link IAuraChunk#getAuraChunk(net.minecraft.world.level.Level,
* BlockPos)}.
*/
@CapabilityInject(IAuraChunk.class)
public static Capability<IAuraChunk> capAuraChunk;
public static Capability<IAuraChunk> capAuraChunk = CapabilityManager.get(new CapabilityToken<>() {
});
/**
* The capability that any world has to store Nature's Aura specific data in
* it. To retrieve this capability from any world, use the helper methods
* {@link IWorldData#getWorldData(World)} or {@link IWorldData#getOverworldData(World)}.
* The capability that any level has to store Nature's Aura specific data in
* it. To retrieve this capability from any level, use the helper methods
* {@link ILevelData#getLevelData(net.minecraft.world.level.Level)} or
* {@link ILevelData#getOverworldData(net.minecraft.world.level.Level)}.
*/
@CapabilityInject(IWorldData.class)
public static Capability<IWorldData> capWorldData;
public static Capability<ILevelData> capLevelData = CapabilityManager.get(new CapabilityToken<>() {
});
private static final IInternalHooks INSTANCE;
static {
@ -169,7 +171,7 @@ public final class NaturesAuraAPI {
* @param simulate If the extraction should be simulated
* @return If the extraction was successful
*/
boolean extractAuraFromPlayer(PlayerEntity player, int amount, boolean simulate);
boolean extractAuraFromPlayer(Player player, int amount, boolean simulate);
/**
* Helper method to insert aura into an {@link IAuraContainer} in the
@ -181,7 +183,7 @@ public final class NaturesAuraAPI {
* @param simulate If the insertion should be simulated
* @return If the insertion was successful
*/
boolean insertAuraIntoPlayer(PlayerEntity player, int amount, boolean simulate);
boolean insertAuraIntoPlayer(Player player, int amount, boolean simulate);
/**
* This method can be used to spawn the magic particle effect used by
@ -262,65 +264,65 @@ public final class NaturesAuraAPI {
IMultiblock createMultiblock(ResourceLocation name, String[][] pattern, Object... rawMatchers);
/**
* Get all of the active effect powders in the given area and consume
* the position and the range that they have. To register a powder with
* the supplied name, use {@link #EFFECT_POWDERS}
* Get all the active effect powders in the given area and consume the
* position and the range that they have. To register a powder with the
* supplied name, use {@link #EFFECT_POWDERS}
*
* @param world The world
* @param level The level
* @param area The area to find powders in
* @param name The registry name of the powder
* @return A list of powders' positions and ranges
*/
List<Tuple<Vector3d, Integer>> getActiveEffectPowders(World world, AxisAlignedBB area, ResourceLocation name);
List<Tuple<Vec3, Integer>> getActiveEffectPowders(Level level, AABB area, ResourceLocation name);
/**
* Returns true if there is an effect powder entity active anywhere
* around the given position based on the radius it has. This is a
* shorthand function of {@link #getActiveEffectPowders(World,
* AxisAlignedBB, ResourceLocation)} that returns true if the list is
* non-empty
* shorthand function of {@link #getActiveEffectPowders(Level,
* net.minecraft.world.phys.AABB, ResourceLocation)} that returns true
* if the list is non-empty
*
* @param world The world
* @param level The level
* @param pos The center position
* @param name The registry name of the powder
* @return If the effect is currently inhibited by any inhibitors
*/
boolean isEffectPowderActive(World world, BlockPos pos, ResourceLocation name);
boolean isEffectPowderActive(Level level, BlockPos pos, ResourceLocation name);
/**
* @see IAuraChunk#getSpotsInArea(IWorld, BlockPos, int, BiConsumer)
* @see IAuraChunk#getSpotsInArea(Level, BlockPos, int, BiConsumer)
*/
void getAuraSpotsInArea(World world, BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer);
void getAuraSpotsInArea(Level level, BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer);
/**
* @see IAuraChunk#getSpotAmountInArea(IWorld, BlockPos, int)
* @see IAuraChunk#getSpotAmountInArea(Level, BlockPos, int)
*/
int getSpotAmountInArea(World world, BlockPos pos, int radius);
int getSpotAmountInArea(Level level, BlockPos pos, int radius);
/**
* @see IAuraChunk#getAuraInArea(IWorld, BlockPos, int)
* @see IAuraChunk#getAuraInArea(Level, BlockPos, int)
*/
int getAuraInArea(World world, BlockPos pos, int radius);
int getAuraInArea(Level level, BlockPos pos, int radius);
/**
* @see IAuraChunk#getAuraAndSpotAmountInArea(World, BlockPos, int)
* @see IAuraChunk#getAuraAndSpotAmountInArea(Level, BlockPos, int)
*/
Pair<Integer, Integer> getAuraAndSpotAmountInArea(World world, BlockPos pos, int radius);
Pair<Integer, Integer> getAuraAndSpotAmountInArea(Level level, BlockPos pos, int radius);
/**
* @see IAuraChunk#triangulateAuraInArea(IWorld, BlockPos, int)
* @see IAuraChunk#triangulateAuraInArea(Level, BlockPos, int)
*/
int triangulateAuraInArea(World world, BlockPos pos, int radius);
int triangulateAuraInArea(Level level, BlockPos pos, int radius);
/**
* @see IAuraChunk#getLowestSpot(IWorld, BlockPos, int, BlockPos)
* @see IAuraChunk#getLowestSpot(Level, BlockPos, int, BlockPos)
*/
BlockPos getLowestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot);
BlockPos getLowestAuraDrainSpot(Level level, BlockPos pos, int radius, BlockPos defaultSpot);
/**
* @see IAuraChunk#getHighestSpot(IWorld, BlockPos, int, BlockPos)
* @see IAuraChunk#getHighestSpot(Level, BlockPos, int, BlockPos)
*/
BlockPos getHighestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot);
BlockPos getHighestAuraDrainSpot(Level level, BlockPos pos, int radius, BlockPos defaultSpot);
}
}

View file

@ -2,11 +2,10 @@ package de.ellpeck.naturesaura.api.aura.chunk;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraftforge.common.util.INBTSerializable;
import org.apache.commons.lang3.tuple.Pair;
@ -14,13 +13,13 @@ import java.util.function.BiConsumer;
/**
* A class whose instances hold information about the aura present in any given
* {@link Chunk}. To get an instance for a chunk, use {@link
* #getAuraChunk(IWorld, BlockPos)}.
* {@link net.minecraft.world.level.chunk.LevelChunk}. To get an instance for a
* chunk, use {@link #getAuraChunk(Level, BlockPos)}.
* <p>
* It is not intended for API users to create custom implementation of this
* class.
*/
public interface IAuraChunk extends INBTSerializable<CompoundNBT> {
public interface IAuraChunk extends INBTSerializable<CompoundTag> {
/**
* The default amount of Aura that a chunk has stored
@ -31,12 +30,12 @@ public interface IAuraChunk extends INBTSerializable<CompoundNBT> {
* This method is used to get information about the Aura in any given chunk.
* This is a convenience method.
*
* @param world The world
* @param level The level
* @param pos A position that the chunk contains
* @return The {@link IAuraChunk} instance belonging to the chunk
*/
static IAuraChunk getAuraChunk(IWorld world, BlockPos pos) {
Chunk chunk = (Chunk) world.getChunk(pos);
static IAuraChunk getAuraChunk(Level level, BlockPos pos) {
LevelChunk chunk = (LevelChunk) level.getChunk(pos);
return chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
}
@ -45,78 +44,78 @@ public interface IAuraChunk extends INBTSerializable<CompoundNBT> {
* spots, represented as a position and the number of Aura in them, in any
* given area.
*
* @param world The world
* @param level The level
* @param pos The center position
* @param radius The radius around the center to search for spots in
* @param consumer A consumer that gets given the position and amount of
* aura in each drain spot found
*/
static void getSpotsInArea(IWorld world, BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer) {
NaturesAuraAPI.instance().getAuraSpotsInArea((World) world, pos, radius, consumer);
static void getSpotsInArea(Level level, BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer) {
NaturesAuraAPI.instance().getAuraSpotsInArea(level, pos, radius, consumer);
}
/**
* Convenience method that adds up the amount of aura spots from {@link
* #getSpotsInArea(IWorld, BlockPos, int, BiConsumer)} and returns it.
* #getSpotsInArea(Level, BlockPos, int, BiConsumer)} and returns it.
*
* @param world The world
* @param level The level
* @param pos The center position
* @param radius The radius around the center to search for spots in
* @return The amount of spots found in the area
*/
static int getSpotAmountInArea(IWorld world, BlockPos pos, int radius) {
return NaturesAuraAPI.instance().getSpotAmountInArea((World) world, pos, radius);
static int getSpotAmountInArea(Level level, BlockPos pos, int radius) {
return NaturesAuraAPI.instance().getSpotAmountInArea(level, pos, radius);
}
/**
* Convenience method that adds up all of the aura from each drain spot from
* {@link #getSpotsInArea(IWorld, BlockPos, int, BiConsumer)} and
* {@link #getSpotsInArea(Level, BlockPos, int, BiConsumer)} and
* conveniently returns it. For a better visual display with a more gradual
* increase, use {@link #triangulateAuraInArea(IWorld, BlockPos, int)}.
* increase, use {@link #triangulateAuraInArea(Level, BlockPos, int)}.
*
* @param world The world
* @param level The level
* @param pos The center position
* @param radius The radius around the center to search for spots in
* @return The amount of Aura present in that area, based on the drain spots
* that are found
*/
static int getAuraInArea(IWorld world, BlockPos pos, int radius) {
return NaturesAuraAPI.instance().getAuraInArea((World) world, pos, radius);
static int getAuraInArea(Level level, BlockPos pos, int radius) {
return NaturesAuraAPI.instance().getAuraInArea(level, pos, radius);
}
/**
* Convenience method that combines {@link #getAuraInArea(IWorld, BlockPos,
* int)} and {@link #getSpotAmountInArea(IWorld, BlockPos, int)} to increase
* Convenience method that combines {@link #getAuraInArea(Level, BlockPos,
* int)} and {@link #getSpotAmountInArea(Level, BlockPos, int)} to increase
* performance.
*
* @param world The world
* @param level The level
* @param pos The center position
* @param radius The radius around the center to search for spots in
* @return A pair of the amount of aura in the area as the {@link
* Pair#getLeft()} entry, and the amount of aura spots in the area as the
* {@link Pair#getRight()} entry
*/
static Pair<Integer, Integer> getAuraAndSpotAmountInArea(World world, BlockPos pos, int radius) {
return NaturesAuraAPI.instance().getAuraAndSpotAmountInArea(world, pos, radius);
static Pair<Integer, Integer> getAuraAndSpotAmountInArea(Level level, BlockPos pos, int radius) {
return NaturesAuraAPI.instance().getAuraAndSpotAmountInArea(level, pos, radius);
}
/**
* Convenience method that adds up all of the aura from each drain spot from
* {@link #getSpotsInArea(IWorld, BlockPos, int, BiConsumer)}, but
* multiplies their amount by the percentual distance to the supplied
* position. This will cause for a lot more gradual of an increase and
* decrease of Aura when moving closer to actual spots. This should be used
* for visual purposes as it is more performance intensive than {@link
* #getAuraInArea(IWorld, BlockPos, int)}.
* {@link #getSpotsInArea(Level, BlockPos, int, BiConsumer)}, but multiplies
* their amount by the percentual distance to the supplied position. This
* will cause for a lot more gradual of an increase and decrease of Aura
* when moving closer to actual spots. This should be used for visual
* purposes as it is more performance intensive than {@link
* #getAuraInArea(Level, BlockPos, int)}.
*
* @param world The world
* @param level The level
* @param pos The center position
* @param radius The radius around the center to search for spots in
* @return The amount of Aura presetn in that area, based on the drain spots
* that are found and their distance to the center
*/
static int triangulateAuraInArea(IWorld world, BlockPos pos, int radius) {
return NaturesAuraAPI.instance().triangulateAuraInArea((World) world, pos, radius);
static int triangulateAuraInArea(Level level, BlockPos pos, int radius) {
return NaturesAuraAPI.instance().triangulateAuraInArea(level, pos, radius);
}
/**
@ -126,15 +125,15 @@ public interface IAuraChunk extends INBTSerializable<CompoundNBT> {
* drained spots get selected first. Note that, when there is no drain spot
* with an amount lower than 0, the default will always be returned.
*
* @param world The world
* @param level The level
* @param pos The center position
* @param radius The radius around the center to search for spots in
* @param defaultSpot A position that will be used to create a new drain
* spot when none are found
* @return The position of the lowest drain spot
*/
static BlockPos getLowestSpot(IWorld world, BlockPos pos, int radius, BlockPos defaultSpot) {
return NaturesAuraAPI.instance().getLowestAuraDrainSpot((World) world, pos, radius, defaultSpot);
static BlockPos getLowestSpot(Level level, BlockPos pos, int radius, BlockPos defaultSpot) {
return NaturesAuraAPI.instance().getLowestAuraDrainSpot(level, pos, radius, defaultSpot);
}
/**
@ -144,15 +143,15 @@ public interface IAuraChunk extends INBTSerializable<CompoundNBT> {
* amount are drained first. Note that, when there is no drain spot with an
* amount greater than 0, the defautl will always be returned.
*
* @param world The world
* @param level The level
* @param pos The center position
* @param radius The radius around the center to search for spots in
* @param defaultSpot A position that will be used to create a new drain
* spot when none are found
* @return The position of the highest drain spot
*/
static BlockPos getHighestSpot(IWorld world, BlockPos pos, int radius, BlockPos defaultSpot) {
return NaturesAuraAPI.instance().getHighestAuraDrainSpot((World) world, pos, radius, defaultSpot);
static BlockPos getHighestSpot(Level level, BlockPos pos, int radius, BlockPos defaultSpot) {
return NaturesAuraAPI.instance().getHighestAuraDrainSpot(level, pos, radius, defaultSpot);
}
/**

View file

@ -1,22 +1,22 @@
package de.ellpeck.naturesaura.api.aura.chunk;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.LevelChunk;
public interface IDrainSpotEffect {
void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot);
void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot);
boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type);
boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type);
ResourceLocation getName();
default ActiveType isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
default ActiveType isActiveHere(Player player, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
return ActiveType.INACTIVE;
}

View file

@ -1,7 +1,7 @@
package de.ellpeck.naturesaura.api.aura.container;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
public class BasicAuraContainer implements IAuraContainer {
@ -52,11 +52,11 @@ public class BasicAuraContainer implements IAuraContainer {
return this.type == null || type.isSimilar(this.type);
}
public void writeNBT(CompoundNBT compound) {
public void writeNBT(CompoundTag compound) {
compound.putInt("aura", this.aura);
}
public void readNBT(CompoundNBT compound) {
public void readNBT(CompoundTag compound) {
this.aura = compound.getInt("aura");
}
}

View file

@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.api.aura.container;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
public class ItemAuraContainer implements IAuraContainer {
@ -38,7 +38,7 @@ public class ItemAuraContainer implements IAuraContainer {
private void setAura(int amount) {
if (!this.stack.hasTag()) {
this.stack.setTag(new CompoundNBT());
this.stack.setTag(new CompoundTag());
}
this.stack.getTag().putInt("aura", amount);
}

View file

@ -1,10 +1,9 @@
package de.ellpeck.naturesaura.api.aura.type;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
import java.util.HashSet;
import java.util.Set;
@ -16,12 +15,12 @@ public class BasicAuraType implements IAuraType {
private final int priority;
private final Set<ResourceLocation> dimensions = new HashSet<>();
public BasicAuraType(ResourceLocation name, RegistryKey<World> dimension, int color, int priority) {
public BasicAuraType(ResourceLocation name, ResourceKey<Level> dimension, int color, int priority) {
this.name = name;
this.color = color;
this.priority = priority;
if (dimension != null)
this.dimensions.add(dimension.func_240901_a_());
this.dimensions.add(dimension.location());
}
public BasicAuraType register() {
@ -35,8 +34,8 @@ public class BasicAuraType implements IAuraType {
}
@Override
public boolean isPresentInWorld(IWorld world) {
return this.dimensions.isEmpty() || this.dimensions.contains(((World) world).func_234923_W_().func_240901_a_());
public boolean isPresentInLevel(Level level) {
return this.dimensions.isEmpty() || this.dimensions.contains(level.dimension().location());
}
@Override

View file

@ -1,22 +1,22 @@
package de.ellpeck.naturesaura.api.aura.type;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IWorld;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
public interface IAuraType {
static IAuraType forWorld(IWorld world) {
static IAuraType forLevel(Level level) {
IAuraType highestType = NaturesAuraAPI.TYPE_OTHER;
for (IAuraType type : NaturesAuraAPI.AURA_TYPES.values())
if (type.isPresentInWorld(world) && type.getPriority() > highestType.getPriority())
if (type.isPresentInLevel(level) && type.getPriority() > highestType.getPriority())
highestType = type;
return highestType;
}
ResourceLocation getName();
boolean isPresentInWorld(IWorld world);
boolean isPresentInLevel(Level level);
int getColor();

View file

@ -0,0 +1,25 @@
package de.ellpeck.naturesaura.api.misc;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.INBTSerializable;
import net.minecraftforge.items.IItemHandlerModifiable;
public interface ILevelData extends ICapabilityProvider, INBTSerializable<CompoundTag> {
static ILevelData getLevelData(Level level) {
return level.getCapability(NaturesAuraAPI.capLevelData, null).orElse(null);
}
static ILevelData getOverworldData(Level level) {
if (!level.isClientSide)
return getLevelData(level.getServer().getLevel(Level.OVERWORLD));
return getLevelData(level);
}
IItemHandlerModifiable getEnderStorage(String name);
boolean isEnderStorageLocked(String name);
}

View file

@ -1,25 +0,0 @@
package de.ellpeck.naturesaura.api.misc;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.INBTSerializable;
import net.minecraftforge.items.IItemHandlerModifiable;
public interface IWorldData extends ICapabilityProvider, INBTSerializable<CompoundNBT> {
static IWorldData getWorldData(World world) {
return world.getCapability(NaturesAuraAPI.capWorldData, null).orElse(null);
}
static IWorldData getOverworldData(World world) {
if (!world.isRemote)
return getWorldData(world.getServer().getWorld(World.field_234918_g_));
return getWorldData(world);
}
IItemHandlerModifiable getEnderStorage(String name);
boolean isEnderStorageLocked(String name);
}

View file

@ -1,9 +1,9 @@
package de.ellpeck.naturesaura.api.misc;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.WeightedRandom;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.random.WeightedEntry;
public class WeightedOre extends WeightedRandom.Item {
public class WeightedOre extends WeightedEntry.IntrusiveBase {
public final ResourceLocation tag;

View file

@ -1,15 +1,15 @@
package de.ellpeck.naturesaura.api.multiblock;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
import java.util.Map;
import java.util.function.BiFunction;
public interface IMultiblock {
boolean isComplete(World world, BlockPos center);
boolean isComplete(Level level, BlockPos center);
boolean forEach(BlockPos center, char c, BiFunction<BlockPos, Matcher, Boolean> function);

View file

@ -1,11 +1,11 @@
package de.ellpeck.naturesaura.api.multiblock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.tags.ITag;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.core.BlockPos;
import net.minecraft.tags.Tag;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
public class Matcher {
@ -18,11 +18,11 @@ public class Matcher {
}
public static Matcher wildcard() {
return new Matcher(Blocks.AIR.getDefaultState(), null);
return new Matcher(Blocks.AIR.defaultBlockState(), null);
}
public static Matcher tag(Block defaultBlock, ITag.INamedTag tag) {
return new Matcher(defaultBlock.getDefaultState(), (world, start, offset, pos, state, c) -> state.getBlock().getTags().contains(tag.getName()));
public static Matcher tag(Block defaultBlock, Tag.Named<?> tag) {
return new Matcher(defaultBlock.defaultBlockState(), (level, start, offset, pos, state, c) -> state.getBlock().getTags().contains(tag.getName()));
}
public BlockState getDefaultState() {
@ -34,6 +34,7 @@ public class Matcher {
}
public interface ICheck {
boolean matches(World world, BlockPos start, BlockPos offset, BlockPos pos, BlockState state, char c);
boolean matches(Level level, BlockPos start, BlockPos offset, BlockPos pos, BlockState state, char c);
}
}

View file

@ -2,14 +2,14 @@ package de.ellpeck.naturesaura.api.render;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.Player;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public interface ITrinketItem {
@OnlyIn(Dist.CLIENT)
void render(ItemStack stack, PlayerEntity player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding);
void render(ItemStack stack, Player player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding);
enum RenderType {
HEAD, BODY

View file

@ -2,15 +2,15 @@ package de.ellpeck.naturesaura.api.render;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public interface IVisualizable {
@OnlyIn(Dist.CLIENT)
AxisAlignedBB getVisualizationBounds(World world, BlockPos pos);
AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos);
@OnlyIn(Dist.CLIENT)
int getVisualizationColor(World world, BlockPos pos);
int getVisualizationColor(Level level, BlockPos pos);
}

View file

@ -1,7 +1,7 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAncientLeaves;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAncientLeaves;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.*;
import net.minecraft.block.BlockState;
@ -11,11 +11,11 @@ import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialColor;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.Level;
import net.minecraft.level.server.ServerLevel;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -27,7 +27,7 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP
public BlockAncientLeaves() {
super(Properties.create(Material.LEAVES, MaterialColor.PINK).hardnessAndResistance(0.2F).tickRandomly().notSolid().sound(SoundType.PLANT));
ModRegistry.add(this);
ModRegistry.add(new ModTileType<>(TileEntityAncientLeaves::new, this));
ModRegistry.add(new ModTileType<>(BlockEntityAncientLeaves::new, this));
}
@Override
@ -37,19 +37,19 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new TileEntityAncientLeaves();
public BlockEntity createBlockEntity(BlockState state, IBlockReader level) {
return new BlockEntityAncientLeaves();
}
@Override
public boolean hasTileEntity(BlockState state) {
public boolean hasBlockEntity(BlockState state) {
return true;
}
@Override
@OnlyIn(Dist.CLIENT)
public IBlockColor getBlockColor() {
return (state, worldIn, pos, tintIndex) -> 0xE55B97;
return (state, levelIn, pos, tintIndex) -> 0xE55B97;
}
@Override
@ -60,12 +60,12 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP
@Override
@OnlyIn(Dist.CLIENT)
public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) {
super.animateTick(stateIn, worldIn, pos, rand);
if (rand.nextFloat() >= 0.95F && !worldIn.getBlockState(pos.down()).isOpaqueCube(worldIn, pos)) {
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityAncientLeaves) {
if (((TileEntityAncientLeaves) tile).getAuraContainer().getStoredAura() > 0) {
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) {
super.animateTick(stateIn, levelIn, pos, rand);
if (rand.nextFloat() >= 0.95F && !levelIn.getBlockState(pos.down()).isOpaqueCube(levelIn, pos)) {
BlockEntity tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntityAncientLeaves) {
if (((BlockEntityAncientLeaves) tile).getAuraContainer().getStoredAura() > 0) {
NaturesAuraAPI.instance().spawnMagicParticle(
pos.getX() + rand.nextDouble(), pos.getY(), pos.getZ() + rand.nextDouble(),
0F, 0F, 0F, 0xCC4780,
@ -79,13 +79,13 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP
}
@Override
public void randomTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) {
super.randomTick(state, worldIn, pos, random);
if (!worldIn.isRemote) {
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityAncientLeaves) {
if (((TileEntityAncientLeaves) tile).getAuraContainer().getStoredAura() <= 0) {
worldIn.setBlockState(pos, ModBlocks.DECAYED_LEAVES.getDefaultState());
public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) {
super.randomTick(state, levelIn, pos, random);
if (!levelIn.isClientSide) {
BlockEntity tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntityAncientLeaves) {
if (((BlockEntityAncientLeaves) tile).getAuraContainer().getStoredAura() <= 0) {
levelIn.setBlockState(pos, ModBlocks.DECAYED_LEAVES.getDefaultState());
}
}
}

View file

@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.data.ItemModelGenerator;
import de.ellpeck.naturesaura.gen.ModFeatures;
import de.ellpeck.naturesaura.gen.WorldGenAncientTree;
import de.ellpeck.naturesaura.gen.LevelGenAncientTree;
import de.ellpeck.naturesaura.reg.*;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
@ -12,9 +12,9 @@ import net.minecraft.state.StateContainer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.Level;
import net.minecraft.level.server.ServerLevel;
import net.minecraftforge.event.ForgeEventFactory;
import java.util.Random;
@ -29,17 +29,17 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
}
@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
if (!world.isRemote) {
super.randomTick(state, world, pos, random);
public void randomTick(BlockState state, ServerLevel level, BlockPos pos, Random random) {
if (!level.isClientSide) {
super.randomTick(state, level, pos, random);
if (world.getLight(pos.up()) >= 9 && random.nextInt(7) == 0) {
this.grow(world, random, pos, state);
if (level.getLight(pos.up()) >= 9 && random.nextInt(7) == 0) {
this.grow(level, random, pos, state);
}
}
}
@ -55,21 +55,21 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte
}
@Override
public boolean canGrow(IBlockReader worldIn, BlockPos pos, BlockState state, boolean isClient) {
public boolean canGrow(IBlockReader levelIn, BlockPos pos, BlockState state, boolean isClient) {
return true;
}
@Override
public boolean canUseBonemeal(World world, Random rand, BlockPos pos, BlockState state) {
return world.rand.nextFloat() < 0.45F;
public boolean canUseBonemeal(Level level, Random rand, BlockPos pos, BlockState state) {
return level.rand.nextFloat() < 0.45F;
}
@Override
public void grow(ServerWorld world, Random rand, BlockPos pos, BlockState state) {
public void grow(ServerLevel level, Random rand, BlockPos pos, BlockState state) {
if (state.get(SaplingBlock.STAGE) == 0) {
world.setBlockState(pos, state.func_235896_a_(SaplingBlock.STAGE), 4);
} else if (ForgeEventFactory.saplingGrowTree(world, rand, pos)) {
ModFeatures.ANCIENT_TREE.func_241855_a(world, world.getChunkProvider().getChunkGenerator(), rand, pos, WorldGenAncientTree.CONFIG);
level.setBlockState(pos, state.func_235896_a_(SaplingBlock.STAGE), 4);
} else if (ForgeEventFactory.saplingGrowTree(level, rand, pos)) {
ModFeatures.ANCIENT_TREE.func_241855_a(level, level.getChunkProvider().getChunkGenerator(), rand, pos, LevelGenAncientTree.CONFIG);
}
}

View file

@ -1,18 +1,18 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAnimalContainer;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAnimalContainer;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -21,7 +21,7 @@ public class BlockAnimalContainer extends BlockContainerImpl implements IVisuali
private static final VoxelShape SHAPE = makeCuboidShape(5, 0, 5, 11, 13, 11);
public BlockAnimalContainer() {
super("animal_container", TileEntityAnimalContainer::new, Properties.from(Blocks.STONE));
super("animal_container", BlockEntityAnimalContainer::new, Properties.from(Blocks.STONE));
}
@Override
@ -30,16 +30,16 @@ public class BlockAnimalContainer extends BlockContainerImpl implements IVisuali
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
}
@Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityAnimalContainer) {
int radius = ((TileEntityAnimalContainer) tile).getRadius();
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
BlockEntity tile = level.getBlockEntity(pos);
if (tile instanceof BlockEntityAnimalContainer) {
int radius = ((BlockEntityAnimalContainer) tile).getRadius();
if (radius > 0)
return new AxisAlignedBB(pos).grow(radius);
}
@ -48,7 +48,7 @@ public class BlockAnimalContainer extends BlockContainerImpl implements IVisuali
@Override
@OnlyIn(Dist.CLIENT)
public int getVisualizationColor(World world, BlockPos pos) {
public int getVisualizationColor(Level level, BlockPos pos) {
return 0x42ddf5;
}

View file

@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAnimalGenerator;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAnimalGenerator;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
@ -14,11 +14,11 @@ import net.minecraft.entity.INPC;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraft.util.math.Mth;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
@ -30,7 +30,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
public class BlockAnimalGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockAnimalGenerator() {
super("animal_generator", TileEntityAnimalGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE));
super("animal_generator", BlockEntityAnimalGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE));
MinecraftForge.EVENT_BUS.register(this);
}
@ -38,9 +38,9 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali
@SubscribeEvent
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
LivingEntity entity = event.getEntityLiving();
if (entity.world.isRemote || entity.world.getGameTime() % 40 != 0 || !(entity instanceof AnimalEntity) || entity instanceof IMob || entity instanceof INPC)
if (entity.level.isClientSide || entity.level.getGameTime() % 40 != 0 || !(entity instanceof AnimalEntity) || entity instanceof IMob || entity instanceof INPC)
return;
CompoundNBT data = entity.getPersistentData();
CompoundTag data = entity.getPersistentData();
int timeAlive = data.getInt(NaturesAura.MOD_ID + ":time_alive");
data.putInt(NaturesAura.MOD_ID + ":time_alive", timeAlive + 40);
}
@ -48,15 +48,15 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali
@SubscribeEvent
public void onEntityDeath(LivingDeathEvent event) {
LivingEntity entity = event.getEntityLiving();
if (entity.world.isRemote || !(entity instanceof AnimalEntity) || entity instanceof IMob || entity instanceof INPC)
if (entity.level.isClientSide || !(entity instanceof AnimalEntity) || entity instanceof IMob || entity instanceof INPC)
return;
BlockPos pos = entity.getPosition();
Helper.getTileEntitiesInArea(entity.world, pos, 5, tile -> {
if (!(tile instanceof TileEntityAnimalGenerator))
Helper.getBlockEntitiesInArea(entity.level, pos, 5, tile -> {
if (!(tile instanceof BlockEntityAnimalGenerator))
return false;
TileEntityAnimalGenerator gen = (TileEntityAnimalGenerator) tile;
BlockEntityAnimalGenerator gen = (BlockEntityAnimalGenerator) tile;
CompoundNBT data = entity.getPersistentData();
CompoundTag data = entity.getPersistentData();
data.putBoolean(NaturesAura.MOD_ID + ":no_drops", true);
if (gen.isBusy())
@ -67,14 +67,14 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali
float amountMod = child ? 0.667F : 1;
int timeAlive = data.getInt(NaturesAura.MOD_ID + ":time_alive");
int time = Math.min(MathHelper.floor((timeAlive - 15000) / 500F * timeMod), 200);
int amount = Math.min(MathHelper.floor((timeAlive - 8000) / 2F * amountMod), 25000);
int time = Math.min(Mth.floor((timeAlive - 15000) / 500F * timeMod), 200);
int amount = Math.min(Mth.floor((timeAlive - 8000) / 2F * amountMod), 25000);
if (time <= 0 || amount <= 0)
return false;
gen.setGenerationValues(time, amount);
BlockPos genPos = gen.getPos();
PacketHandler.sendToAllAround(entity.world, pos, 32, new PacketParticles(
PacketHandler.sendToAllAround(entity.level, pos, 32, new PacketParticles(
(float) entity.getPosX(), (float) entity.getPosY(), (float) entity.getPosZ(), PacketParticles.Type.ANIMAL_GEN_CONSUME,
child ? 1 : 0,
(int) (entity.getEyeHeight() * 10F),
@ -100,13 +100,13 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali
@Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) {
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
return new AxisAlignedBB(pos).grow(5);
}
@Override
@OnlyIn(Dist.CLIENT)
public int getVisualizationColor(World world, BlockPos pos) {
public int getVisualizationColor(Level level, BlockPos pos) {
return 0x11377a;
}

View file

@ -1,11 +1,11 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAnimalSpawner;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAnimalSpawner;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
public class BlockAnimalSpawner extends BlockContainerImpl {
public BlockAnimalSpawner() {
super("animal_spawner", TileEntityAnimalSpawner::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
super("animal_spawner", BlockEntityAnimalSpawner::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
}
}

View file

@ -1,6 +1,6 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraBloom;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraBloom;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.data.ItemModelGenerator;
import de.ellpeck.naturesaura.reg.*;
@ -11,15 +11,15 @@ import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.ILevelReader;
import net.minecraft.level.Level;
import javax.annotation.Nullable;
import java.util.Arrays;
@ -39,25 +39,25 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS
}
@Override
public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) {
public boolean isValidPosition(BlockState state, ILevelReader levelIn, BlockPos pos) {
BlockPos down = pos.down();
return this.isValidGround(worldIn.getBlockState(down), worldIn, down);
return this.isValidGround(levelIn.getBlockState(down), levelIn, down);
}
@Override
protected boolean isValidGround(BlockState state, IBlockReader worldIn, BlockPos pos) {
protected boolean isValidGround(BlockState state, IBlockReader levelIn, BlockPos pos) {
return Arrays.stream(this.allowedGround).anyMatch(state::isIn);
}
@Override
public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) {
public void onEntityCollision(BlockState state, Level levelIn, BlockPos pos, Entity entityIn) {
if (this == ModBlocks.AURA_CACTUS)
entityIn.attackEntityFrom(DamageSource.CACTUS, 1);
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Vector3d vec3d = state.getOffset(worldIn, pos);
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
Vector3d vec3d = state.getOffset(levelIn, pos);
return SHAPE.withOffset(vec3d.x, vec3d.y, vec3d.z);
}
@ -83,12 +83,12 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new TileEntityAuraBloom();
public BlockEntity createBlockEntity(BlockState state, IBlockReader level) {
return new BlockEntityAuraBloom();
}
@Override
public boolean hasTileEntity(BlockState state) {
public boolean hasBlockEntity(BlockState state) {
return true;
}
}

View file

@ -1,17 +1,17 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraDetector;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraDetector;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.level.Level;
public class BlockAuraDetector extends BlockContainerImpl {
public BlockAuraDetector() {
super("aura_detector", TileEntityAuraDetector::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
super("aura_detector", BlockEntityAuraDetector::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
}
@Override
@ -20,10 +20,10 @@ public class BlockAuraDetector extends BlockContainerImpl {
}
@Override
public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) {
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityAuraDetector)
return ((TileEntityAuraDetector) tile).redstonePower;
public int getComparatorInputOverride(BlockState blockState, Level levelIn, BlockPos pos) {
BlockEntity tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntityAuraDetector)
return ((BlockEntityAuraDetector) tile).redstonePower;
else
return 0;
}

View file

@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraTimer;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraTimer;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderAuraTimer;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
@ -12,13 +12,13 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
import net.minecraft.entity.player.Player;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ActionResultType;
import net.minecraft.tileentity.BlockEntityType;
import net.minecraft.util.InteractionResult;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.Tuple;
@ -26,9 +26,9 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.Level;
import net.minecraft.level.server.ServerLevel;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -36,12 +36,12 @@ import java.util.Random;
import java.util.function.Function;
import java.util.function.Supplier;
public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockState, ITESRProvider<TileEntityAuraTimer>, ICustomRenderType {
public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockState, ITESRProvider<BlockEntityAuraTimer>, ICustomRenderType {
private static final VoxelShape SHAPE = makeCuboidShape(1, 0, 1, 15, 15, 15);
public BlockAuraTimer() {
super("aura_timer", TileEntityAuraTimer::new, Properties.from(Blocks.SMOOTH_STONE));
super("aura_timer", BlockEntityAuraTimer::new, Properties.from(Blocks.SMOOTH_STONE));
this.setDefaultState(this.getDefaultState().with(BlockStateProperties.POWERED, false));
}
@ -51,13 +51,13 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
}
@Override
@OnlyIn(Dist.CLIENT)
public Tuple<TileEntityType<TileEntityAuraTimer>, Supplier<Function<? super TileEntityRendererDispatcher, ? extends TileEntityRenderer<? super TileEntityAuraTimer>>>> getTESR() {
public Tuple<BlockEntityType<BlockEntityAuraTimer>, Supplier<Function<? super BlockEntityRendererDispatcher, ? extends BlockEntityRenderer<? super BlockEntityAuraTimer>>>> getTESR() {
return new Tuple<>(ModTileEntities.AURA_TIMER, () -> RenderAuraTimer::new);
}
@ -72,7 +72,7 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt
}
@Override
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult p_225533_6_) {
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult p_225533_6_) {
return Helper.putStackOnTile(player, handIn, pos, 0, true);
}
@ -82,15 +82,15 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt
}
@Override
public int getWeakPower(BlockState state, IBlockReader world, BlockPos pos, Direction side) {
public int getWeakPower(BlockState state, IBlockReader level, BlockPos pos, Direction side) {
return state.get(BlockStateProperties.POWERED) ? 15 : 0;
}
@Override
public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) {
super.tick(state, worldIn, pos, random);
public void tick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) {
super.tick(state, levelIn, pos, random);
if (state.get(BlockStateProperties.POWERED))
worldIn.setBlockState(pos, state.with(BlockStateProperties.POWERED, false));
levelIn.setBlockState(pos, state.with(BlockStateProperties.POWERED, false));
}
}

View file

@ -1,6 +1,6 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAutoCrafter;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAutoCrafter;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.Block;
@ -16,7 +16,7 @@ public class BlockAutoCrafter extends BlockContainerImpl implements ICustomBlock
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
public BlockAutoCrafter() {
super("auto_crafter", TileEntityAutoCrafter::new, Properties.create(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD));
super("auto_crafter", BlockEntityAutoCrafter::new, Properties.create(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD));
}
@Override

View file

@ -1,6 +1,6 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityBlastFurnaceBooster;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityBlastFurnaceBooster;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.Block;
@ -13,15 +13,15 @@ import net.minecraft.state.StateContainer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.util.math.shapes.Shapes;
import net.minecraft.level.IBlockReader;
public class BlockBlastFurnaceBooster extends BlockContainerImpl implements ICustomBlockState {
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
private static final VoxelShape SHAPE = VoxelShapes.create(1 / 16F, 0, 1 / 16F, 15 / 16F, 1, 15 / 16F);
private static final VoxelShape SHAPE = Shapes.create(1 / 16F, 0, 1 / 16F, 15 / 16F, 1, 15 / 16F);
public BlockBlastFurnaceBooster() {
super("blast_furnace_booster", TileEntityBlastFurnaceBooster::new, Block.Properties.from(Blocks.BLAST_FURNACE).setLightLevel(s -> 0));
super("blast_furnace_booster", BlockEntityBlastFurnaceBooster::new, Block.Properties.from(Blocks.BLAST_FURNACE).setLightLevel(s -> 0));
}
@Override
@ -30,7 +30,7 @@ public class BlockBlastFurnaceBooster extends BlockContainerImpl implements ICus
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
}

View file

@ -7,8 +7,8 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
public class BlockCatalyst extends BlockImpl implements ICustomBlockState {
public static final BooleanProperty NETHER = BlockNatureAltar.NETHER;
@ -20,7 +20,7 @@ public class BlockCatalyst extends BlockImpl implements ICustomBlockState {
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
boolean nether = IAuraType.forWorld(context.getWorld()).isSimilar(NaturesAuraAPI.TYPE_NETHER);
boolean nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER);
return super.getStateForPlacement(context).with(NETHER, nether);
}

View file

@ -1,13 +1,13 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityChorusGenerator;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityChorusGenerator;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.Blocks;
public class BlockChorusGenerator extends BlockContainerImpl implements ICustomBlockState {
public BlockChorusGenerator() {
super("chorus_generator", TileEntityChorusGenerator::new, Properties.from(Blocks.END_STONE));
super("chorus_generator", BlockEntityChorusGenerator::new, Properties.from(Blocks.END_STONE));
}
@Override

View file

@ -4,7 +4,7 @@ import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityChunkLoader;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityChunkLoader;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.BlockState;
@ -12,15 +12,15 @@ import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Mth;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -33,7 +33,7 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
private static final VoxelShape SHAPE = makeCuboidShape(4, 4, 4, 12, 12, 12);
public BlockChunkLoader() {
super("chunk_loader", TileEntityChunkLoader::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE));
super("chunk_loader", BlockEntityChunkLoader::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE));
}
@Override
@ -43,17 +43,17 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
@Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityChunkLoader) {
int range = ((TileEntityChunkLoader) tile).range();
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
BlockEntity tile = level.getBlockEntity(pos);
if (tile instanceof BlockEntityChunkLoader) {
int range = ((BlockEntityChunkLoader) tile).range();
if (range > 0) {
return new AxisAlignedBB(
(pos.getX() - range) >> 4 << 4,
0,
(pos.getZ() - range) >> 4 << 4,
((pos.getX() + range) >> 4 << 4) + 16,
world.getHeight(),
level.getHeight(),
((pos.getZ() + range) >> 4 << 4) + 16);
}
}
@ -62,28 +62,28 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
@Override
@OnlyIn(Dist.CLIENT)
public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) {
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) {
if (!ModConfig.instance.chunkLoader.get())
return;
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityChunkLoader) {
int range = ((TileEntityChunkLoader) tile).range();
for (int i = MathHelper.ceil(range / 8F); i > 0; i--) {
BlockEntity tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntityChunkLoader) {
int range = ((BlockEntityChunkLoader) tile).range();
for (int i = Mth.ceil(range / 8F); i > 0; i--) {
NaturesAuraAPI.instance().spawnMagicParticle(
pos.getX() + worldIn.rand.nextFloat(), pos.getY() + worldIn.rand.nextFloat(), pos.getZ() + worldIn.rand.nextFloat(),
0, 0, 0, 0xa12dff, 1F + worldIn.rand.nextFloat(), 100, 0, false, true);
pos.getX() + levelIn.rand.nextFloat(), pos.getY() + levelIn.rand.nextFloat(), pos.getZ() + levelIn.rand.nextFloat(),
0, 0, 0, 0xa12dff, 1F + levelIn.rand.nextFloat(), 100, 0, false, true);
}
}
}
@Override
@OnlyIn(Dist.CLIENT)
public int getVisualizationColor(World world, BlockPos pos) {
public int getVisualizationColor(Level level, BlockPos pos) {
return 0xc159f9;
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
}
@ -93,8 +93,8 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
}
@Override
public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
super.addInformation(stack, worldIn, tooltip, flagIn);
public void addInformation(ItemStack stack, @Nullable IBlockReader levelIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
super.addInformation(stack, levelIn, tooltip, flagIn);
}
@Override

View file

@ -1,40 +1,42 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl;
import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.ModRegistry;
import de.ellpeck.naturesaura.reg.ModTileType;
import net.minecraft.block.*;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.Player;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.ILevel;
import net.minecraft.level.Level;
import net.minecraft.level.server.ServerLevel;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootParameters;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tags.FluidTags;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Random;
import java.util.function.Supplier;
public class BlockContainerImpl extends ContainerBlock implements IModItem {
public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
private final String baseName;
private final ModTileType<? extends TileEntity> tileType;
private final ModTileType<? extends BlockEntity> tileType;
public BlockContainerImpl(String baseName, Supplier<TileEntity> tileSupplier, Block.Properties properties) {
public BlockContainerImpl(String baseName, Supplier<BlockEntity> tileSupplier, Block.Properties properties) {
super(properties);
this.baseName = baseName;
@ -63,17 +65,17 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem {
}
@Override
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) {
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, ILevel levelIn, BlockPos currentPos, BlockPos facingPos) {
if (this.hasWaterlogging() && stateIn.get(BlockStateProperties.WATERLOGGED))
worldIn.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn));
return super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos);
levelIn.getPendingFluidTicks().scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickRate(levelIn));
return super.updatePostPlacement(stateIn, facing, facingState, levelIn, currentPos, facingPos);
}
@Override
@Nullable
public BlockState getStateForPlacement(BlockItemUseContext context) {
if (this.hasWaterlogging()) {
FluidState state = context.getWorld().getFluidState(context.getPos());
FluidState state = context.getLevel().getFluidState(context.getPos());
return this.getDefaultState().with(BlockStateProperties.WATERLOGGED, state.isTagged(FluidTags.WATER) && state.getLevel() == 8);
}
return super.getStateForPlacement(context);
@ -81,7 +83,7 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem {
@Nullable
@Override
public TileEntity createNewTileEntity(IBlockReader worldIn) {
public BlockEntity createNewBlockEntity(IBlockReader levelIn) {
return this.tileType.type.create();
}
@ -96,20 +98,20 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem {
}
@Override
public void onPlayerDestroy(IWorld worldIn, BlockPos pos, BlockState state) {
super.onPlayerDestroy(worldIn, pos, state);
public void onPlayerDestroy(ILevel levelIn, BlockPos pos, BlockState state) {
super.onPlayerDestroy(levelIn, pos, state);
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
List<ItemStack> drops = super.getDrops(state, builder);
TileEntity tile = builder.get(LootParameters.BLOCK_ENTITY);
if (tile instanceof TileEntityImpl) {
BlockEntity tile = builder.get(LootParameters.BLOCK_ENTITY);
if (tile instanceof BlockEntityImpl) {
for (ItemStack stack : drops) {
if (stack.getItem() != this.asItem())
continue;
((TileEntityImpl) tile).modifyDrop(stack);
((BlockEntityImpl) tile).modifyDrop(stack);
break;
}
}
@ -117,57 +119,57 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem {
}
@Override
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
public void onReplaced(BlockState state, Level levelIn, BlockPos pos, BlockState newState, boolean isMoving) {
if (state.getBlock() != newState.getBlock()) {
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityImpl)
((TileEntityImpl) tile).dropInventory();
BlockEntity tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntityImpl)
((BlockEntityImpl) tile).dropInventory();
}
super.onReplaced(state, worldIn, pos, newState, isMoving);
super.onReplaced(state, levelIn, pos, newState, isMoving);
}
@Override
public void harvestBlock(World worldIn, PlayerEntity player, BlockPos pos, BlockState state, @Nullable TileEntity te, ItemStack stack) {
super.harvestBlock(worldIn, player, pos, state, te, stack);
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
public void harvestBlock(Level levelIn, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity te, ItemStack stack) {
super.harvestBlock(levelIn, player, pos, state, te, stack);
levelIn.setBlockState(pos, Blocks.AIR.getDefaultState());
}
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityImpl)
((TileEntityImpl) tile).loadDataOnPlace(stack);
public void onBlockPlacedBy(Level levelIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
BlockEntity tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntityImpl)
((BlockEntityImpl) tile).loadDataOnPlace(stack);
}
@Override
public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) {
this.updateRedstoneState(worldIn, pos);
public void onBlockAdded(BlockState state, Level levelIn, BlockPos pos, BlockState oldState, boolean isMoving) {
this.updateRedstoneState(levelIn, pos);
}
@Override
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
this.updateRedstoneState(worldIn, pos);
public void neighborChanged(BlockState state, Level levelIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
this.updateRedstoneState(levelIn, pos);
}
private void updateRedstoneState(World world, BlockPos pos) {
if (!world.isRemote) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityImpl) {
TileEntityImpl impl = (TileEntityImpl) tile;
int newPower = world.getRedstonePowerFromNeighbors(pos);
private void updateRedstoneState(Level level, BlockPos pos) {
if (!level.isClientSide) {
BlockEntity tile = level.getBlockEntity(pos);
if (tile instanceof BlockEntityImpl) {
BlockEntityImpl impl = (BlockEntityImpl) tile;
int newPower = level.getRedstonePowerFromNeighbors(pos);
if (impl.redstonePower != newPower)
world.getPendingBlockTicks().scheduleTick(pos, this, 4);
level.getPendingBlockTicks().scheduleTick(pos, this, 4);
}
}
}
@Override
public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) {
if (!worldIn.isRemote) {
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityImpl) {
TileEntityImpl impl = (TileEntityImpl) tile;
int newPower = worldIn.getRedstonePowerFromNeighbors(pos);
public void tick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) {
if (!levelIn.isClientSide) {
BlockEntity tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntityImpl) {
BlockEntityImpl impl = (BlockEntityImpl) tile;
int newPower = levelIn.getRedstonePowerFromNeighbors(pos);
if (impl.redstonePower != newPower)
impl.onRedstonePowerChange(newPower);
}

View file

@ -9,8 +9,8 @@ import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.server.ServerLevel;
import java.util.Random;
import java.util.function.Supplier;
@ -22,9 +22,9 @@ public class BlockDecayedLeaves extends BlockImpl implements ICustomBlockState,
}
@Override
public void tick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
if (!world.isRemote) {
world.setBlockState(pos, Blocks.AIR.getDefaultState());
public void tick(BlockState state, ServerLevel level, BlockPos pos, Random random) {
if (!level.isClientSide) {
level.setBlockState(pos, Blocks.AIR.getDefaultState());
}
}
@ -34,7 +34,7 @@ public class BlockDecayedLeaves extends BlockImpl implements ICustomBlockState,
}
@Override
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
public int getOpacity(BlockState state, IBlockReader levelIn, BlockPos pos) {
return 1;
}

View file

@ -15,9 +15,9 @@ import net.minecraft.block.Blocks;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.Player;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.MinecraftServer;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.Property;
@ -28,10 +28,10 @@ import net.minecraft.util.*;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.world.gen.Heightmap;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.Level;
import net.minecraft.level.gen.Heightmap;
import net.minecraft.level.server.ServerLevel;
import net.minecraftforge.common.util.ITeleporter;
import java.util.function.Function;
@ -42,10 +42,10 @@ public class BlockDimensionRail extends AbstractRailBlock implements IModItem, I
public static final EnumProperty<RailShape> SHAPE = BlockStateProperties.RAIL_SHAPE;
private final String name;
private final RegistryKey<World> goalDim;
private final RegistryKey<World>[] canUseDims;
private final RegistryKey<Level> goalDim;
private final RegistryKey<Level>[] canUseDims;
public BlockDimensionRail(String name, RegistryKey<World> goalDim, RegistryKey<World>... canUseDims) {
public BlockDimensionRail(String name, RegistryKey<Level> goalDim, RegistryKey<Level>... canUseDims) {
super(false, Properties.from(Blocks.RAIL));
this.name = name;
this.goalDim = goalDim;
@ -54,77 +54,77 @@ public class BlockDimensionRail extends AbstractRailBlock implements IModItem, I
ModRegistry.add(this);
}
private boolean canUseHere(RegistryKey<World> dimension) {
for (RegistryKey<World> dim : this.canUseDims)
private boolean canUseHere(RegistryKey<Level> dimension) {
for (RegistryKey<Level> dim : this.canUseDims)
if (dim == dimension)
return true;
return false;
}
@Override
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand hand, BlockRayTraceResult hit) {
ItemStack stack = player.getHeldItem(hand);
if (stack.getItem() == ModItems.RANGE_VISUALIZER) {
if (!worldIn.isRemote) {
BlockPos goalPos = this.getGoalCoords(worldIn, pos);
CompoundNBT data = new CompoundNBT();
if (!levelIn.isClientSide) {
BlockPos goalPos = this.getGoalCoords(levelIn, pos);
CompoundTag data = new CompoundTag();
data.putString("dim", this.goalDim.func_240901_a_().toString());
data.putLong("pos", goalPos.toLong());
PacketHandler.sendTo(player, new PacketClient(0, data));
}
return ActionResultType.SUCCESS;
return InteractionResult.SUCCESS;
}
return ActionResultType.FAIL;
return InteractionResult.FAIL;
}
@Override
public void onMinecartPass(BlockState state, World world, BlockPos pos, AbstractMinecartEntity cart) {
if (world.isRemote)
public void onMinecartPass(BlockState state, Level level, BlockPos pos, AbstractMinecartEntity cart) {
if (level.isClientSide)
return;
if (cart.isBeingRidden())
return;
if (!this.canUseHere(world.func_234923_W_()))
if (!this.canUseHere(level.func_234923_W_()))
return;
AxisAlignedBB box = cart.getBoundingBox();
PacketHandler.sendToAllAround(world, pos, 32, new PacketParticles((float) box.minX, (float) box.minY, (float) box.minZ, PacketParticles.Type.DIMENSION_RAIL, (int) ((box.maxX - box.minX) * 100F), (int) ((box.maxY - box.minY) * 100F), (int) ((box.maxZ - box.minZ) * 100F)));
world.playSound(null, pos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 1F, 1F);
PacketHandler.sendToAllAround(level, pos, 32, new PacketParticles((float) box.minX, (float) box.minY, (float) box.minZ, PacketParticles.Type.DIMENSION_RAIL, (int) ((box.maxX - box.minX) * 100F), (int) ((box.maxY - box.minY) * 100F), (int) ((box.maxZ - box.minZ) * 100F)));
level.playSound(null, pos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 1F, 1F);
BlockPos goalCoords = this.getGoalCoords(world, pos);
cart.changeDimension(world.getServer().getWorld(this.goalDim), new ITeleporter() {
BlockPos goalCoords = this.getGoalCoords(level, pos);
cart.changeDimension(level.getServer().getLevel(this.goalDim), new ITeleporter() {
@Override
public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destWorld, float yaw, Function<Boolean, Entity> repositionEntity) {
public Entity placeEntity(Entity entity, ServerLevel currentLevel, ServerLevel destLevel, float yaw, Function<Boolean, Entity> repositionEntity) {
// repositionEntity always causes a NPE because why wouldn't it, so this is a fixed copy
entity.world.getProfiler().endStartSection("reloading");
Entity result = entity.getType().create(destWorld);
entity.level.getProfiler().endStartSection("reloading");
Entity result = entity.getType().create(destLevel);
if (result != null) {
result.copyDataFromOld(entity);
destWorld.addFromAnotherDimension(result);
destLevel.addFromAnotherDimension(result);
result.moveToBlockPosAndAngles(goalCoords, yaw, result.rotationPitch);
}
return result;
}
});
BlockPos spot = IAuraChunk.getHighestSpot(world, pos, 35, pos);
IAuraChunk.getAuraChunk(world, spot).drainAura(spot, 50000);
BlockPos spot = IAuraChunk.getHighestSpot(level, pos, 35, pos);
IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 50000);
}
private BlockPos getGoalCoords(World world, BlockPos pos) {
MinecraftServer server = world.getServer();
private BlockPos getGoalCoords(Level level, BlockPos pos) {
MinecraftServer server = level.getServer();
if (this == ModBlocks.DIMENSION_RAIL_NETHER) {
// travel to the nether from the overworld
return new BlockPos(pos.getX() / 8, pos.getY() / 2, pos.getZ() / 8);
} else if (this == ModBlocks.DIMENSION_RAIL_END) {
// travel to the end from the overworld
return ServerWorld.field_241108_a_.up(8);
return ServerLevel.field_241108_a_.up(8);
} else {
if (world.func_234923_W_() == World.field_234919_h_) {
if (level.func_234923_W_() == Level.field_234919_h_) {
// travel to the overworld from the nether
return new BlockPos(pos.getX() * 8, pos.getY() * 2, pos.getZ() * 8);
} else {
// travel to the overworld from the end
ServerWorld overworld = server.getWorld(this.goalDim);
ServerLevel overworld = server.getLevel(this.goalDim);
BlockPos spawn = overworld.func_241135_u_();
BlockPos ret = new BlockPos(spawn.getX(), 0, spawn.getZ());
return ret.up(overworld.getHeight(Heightmap.Type.WORLD_SURFACE, spawn.getX(), spawn.getZ()));
@ -138,12 +138,12 @@ public class BlockDimensionRail extends AbstractRailBlock implements IModItem, I
}
@Override
public boolean isFlexibleRail(BlockState state, IBlockReader world, BlockPos pos) {
public boolean isFlexibleRail(BlockState state, IBlockReader level, BlockPos pos) {
return false;
}
@Override
public boolean canMakeSlopes(BlockState state, IBlockReader world, BlockPos pos) {
public boolean canMakeSlopes(BlockState state, IBlockReader level, BlockPos pos) {
return false;
}

View file

@ -1,6 +1,6 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEndFlower;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEndFlower;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.data.ItemModelGenerator;
import de.ellpeck.naturesaura.reg.*;
@ -9,21 +9,21 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.Player;
import net.minecraft.fluid.FluidState;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootParameters;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraft.world.gen.Heightmap;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.ILevelReader;
import net.minecraft.level.Level;
import net.minecraft.level.gen.Heightmap;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -40,44 +40,44 @@ public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockS
super(Properties.create(Material.PLANTS).doesNotBlockMovement().hardnessAndResistance(0.5F).sound(SoundType.PLANT));
MinecraftForge.EVENT_BUS.register(this);
ModRegistry.add(this);
ModRegistry.add(new ModTileType<>(TileEntityEndFlower::new, this));
ModRegistry.add(new ModTileType<>(BlockEntityEndFlower::new, this));
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Vector3d vec3d = state.getOffset(worldIn, pos);
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
Vector3d vec3d = state.getOffset(levelIn, pos);
return SHAPE.withOffset(vec3d.x, vec3d.y, vec3d.z);
}
@SubscribeEvent
public void onDragonTick(LivingUpdateEvent event) {
LivingEntity living = event.getEntityLiving();
if (living.world.isRemote || !(living instanceof EnderDragonEntity))
if (living.level.isClientSide || !(living instanceof EnderDragonEntity))
return;
EnderDragonEntity dragon = (EnderDragonEntity) living;
if (dragon.deathTicks < 150 || dragon.deathTicks % 10 != 0)
return;
for (int i = 0; i < 6; i++) {
int x = dragon.world.rand.nextInt(256) - 128;
int z = dragon.world.rand.nextInt(256) - 128;
BlockPos pos = new BlockPos(x, dragon.world.getHeight(Heightmap.Type.WORLD_SURFACE, x, z), z);
if (!dragon.world.isBlockLoaded(pos))
int x = dragon.level.rand.nextInt(256) - 128;
int z = dragon.level.rand.nextInt(256) - 128;
BlockPos pos = new BlockPos(x, dragon.level.getHeight(Heightmap.Type.WORLD_SURFACE, x, z), z);
if (!dragon.level.isBlockLoaded(pos))
continue;
if (dragon.world.getBlockState(pos.down()).getBlock() != Blocks.END_STONE)
if (dragon.level.getBlockState(pos.down()).getBlock() != Blocks.END_STONE)
continue;
dragon.world.setBlockState(pos, this.getDefaultState());
dragon.level.setBlockState(pos, this.getDefaultState());
}
}
@Override
protected boolean isValidGround(BlockState state, IBlockReader worldIn, BlockPos pos) {
protected boolean isValidGround(BlockState state, IBlockReader levelIn, BlockPos pos) {
return state.getBlock() == Blocks.END_STONE;
}
@Override
public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) {
return worldIn.getBlockState(pos.down()).getBlock() == Blocks.END_STONE;
public boolean isValidPosition(BlockState state, ILevelReader levelIn, BlockPos pos) {
return levelIn.getBlockState(pos.down()).getBlock() == Blocks.END_STONE;
}
@Override
@ -87,30 +87,30 @@ public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockS
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new TileEntityEndFlower();
public BlockEntity createBlockEntity(BlockState state, IBlockReader level) {
return new BlockEntityEndFlower();
}
@Override
public boolean hasTileEntity(BlockState state) {
public boolean hasBlockEntity(BlockState state) {
return true;
}
@Override
public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, FluidState fluid) {
return willHarvest || super.removedByPlayer(state, world, pos, player, willHarvest, fluid);
public boolean removedByPlayer(BlockState state, Level level, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) {
return willHarvest || super.removedByPlayer(state, level, pos, player, willHarvest, fluid);
}
@Override
public void harvestBlock(World worldIn, PlayerEntity player, BlockPos pos, BlockState state, @Nullable TileEntity te, ItemStack stack) {
super.harvestBlock(worldIn, player, pos, state, te, stack);
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
public void harvestBlock(Level levelIn, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity te, ItemStack stack) {
super.harvestBlock(levelIn, player, pos, state, te, stack);
levelIn.setBlockState(pos, Blocks.AIR.getDefaultState());
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
TileEntity tile = builder.get(LootParameters.BLOCK_ENTITY);
if (tile instanceof TileEntityEndFlower && ((TileEntityEndFlower) tile).isDrainMode)
BlockEntity tile = builder.get(LootParameters.BLOCK_ENTITY);
if (tile instanceof BlockEntityEndFlower && ((BlockEntityEndFlower) tile).isDrainMode)
return NonNullList.create();
return super.getDrops(state, builder);
}

View file

@ -1,9 +1,9 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.api.misc.ILevelData;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEnderCrate;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderEnderCrate;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.items.ModItems;
@ -13,19 +13,19 @@ import net.minecraft.block.AnvilBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.player.Player;
import net.minecraft.entity.player.ServerPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ActionResultType;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.tileentity.BlockEntityType;
import net.minecraft.util.InteractionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Tuple;
import net.minecraft.util.math.BlockPos;
@ -33,8 +33,8 @@ import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
@ -50,13 +50,13 @@ import java.util.Random;
import java.util.function.Function;
import java.util.function.Supplier;
public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider<TileEntityEnderCrate>, ICustomBlockState {
public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider<BlockEntityEnderCrate>, ICustomBlockState {
// This is terrible but I can't see a better solution right now so oh well
private static final ThreadLocal<WeakReference<World>> CACHED_WORLD = new ThreadLocal<>();
private static final ThreadLocal<WeakReference<Level>> CACHED_WORLD = new ThreadLocal<>();
public BlockEnderCrate() {
super("ender_crate", TileEntityEnderCrate::new, Properties.create(Material.ROCK).hardnessAndResistance(5F).setLightLevel(s -> 7).sound(SoundType.STONE));
super("ender_crate", BlockEntityEnderCrate::new, Properties.create(Material.ROCK).hardnessAndResistance(5F).setLightLevel(s -> 7).sound(SoundType.STONE));
MinecraftForge.EVENT_BUS.register(this);
}
@ -79,18 +79,18 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
@SubscribeEvent
public void onRightClick(PlayerInteractEvent.RightClickBlock event) {
World world = event.getWorld();
Level level = event.getLevel();
BlockPos pos = event.getPos();
BlockState state = world.getBlockState(pos);
BlockState state = level.getBlockState(pos);
if (state.getBlock() instanceof AnvilBlock) {
CACHED_WORLD.set(new WeakReference<>(world));
CACHED_WORLD.set(new WeakReference<>(level));
}
}
@SubscribeEvent
public void onAnvilUpdate(AnvilUpdateEvent event) {
WeakReference<World> world = CACHED_WORLD.get();
if (world == null || world.get() == null)
WeakReference<Level> level = CACHED_WORLD.get();
if (level == null || level.get() == null)
return;
ItemStack stack = event.getLeft();
if (stack.getItem() != Item.getItemFromBlock(this) && stack.getItem() != ModItems.ENDER_ACCESS)
@ -101,7 +101,7 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
String name = event.getName();
if (name == null || name.isEmpty())
return;
if (IWorldData.getOverworldData(world.get()).isEnderStorageLocked(name))
if (ILevelData.getOverworldData(level.get()).isEnderStorageLocked(name))
return;
ItemStack output = stack.copy();
output.getOrCreateTag().putString(NaturesAura.MOD_ID + ":ender_name", name);
@ -111,29 +111,29 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
}
@Override
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!worldIn.isRemote) {
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityEnderCrate) {
TileEntityEnderCrate crate = (TileEntityEnderCrate) tile;
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) {
if (!levelIn.isClientSide) {
BlockEntity tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntityEnderCrate) {
BlockEntityEnderCrate crate = (BlockEntityEnderCrate) tile;
if (crate.canOpen()) {
crate.drainAura(2500);
NetworkHooks.openGui((ServerPlayerEntity) player, crate, pos);
NetworkHooks.openGui((ServerPlayer) player, crate, pos);
}
}
}
return ActionResultType.SUCCESS;
return InteractionResult.SUCCESS;
}
@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
public void addInformation(ItemStack stack, @Nullable IBlockReader levelIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
addEnderNameInfo(stack, tooltip);
}
@Override
@OnlyIn(Dist.CLIENT)
public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) {
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) {
for (int i = 0; i < 3; ++i) {
int j = rand.nextInt(2) * 2 - 1;
int k = rand.nextInt(2) * 2 - 1;
@ -143,12 +143,12 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
double d3 = rand.nextFloat() * (float) j;
double d4 = ((double) rand.nextFloat() - 0.5D) * 0.125D;
double d5 = rand.nextFloat() * (float) k;
worldIn.addParticle(ParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5);
levelIn.addParticle(ParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5);
}
}
@Override
public Tuple<TileEntityType<TileEntityEnderCrate>, Supplier<Function<? super TileEntityRendererDispatcher, ? extends TileEntityRenderer<? super TileEntityEnderCrate>>>> getTESR() {
public Tuple<BlockEntityType<BlockEntityEnderCrate>, Supplier<Function<? super BlockEntityRendererDispatcher, ? extends BlockEntityRenderer<? super BlockEntityEnderCrate>>>> getTESR() {
return new Tuple<>(ModTileEntities.ENDER_CRATE, () -> RenderEnderCrate::new);
}

View file

@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityFieldCreator;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityFieldCreator;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ICustomRenderType;
@ -10,15 +10,15 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.entity.player.Player;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.InteractionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -27,28 +27,28 @@ import java.util.function.Supplier;
public class BlockFieldCreator extends BlockContainerImpl implements ICustomBlockState, ICustomRenderType {
public BlockFieldCreator() {
super("field_creator", TileEntityFieldCreator::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).notSolid().sound(SoundType.STONE));
super("field_creator", BlockEntityFieldCreator::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).notSolid().sound(SoundType.STONE));
}
@Override
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult p_225533_6_) {
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityFieldCreator) {
if (!worldIn.isRemote) {
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult p_225533_6_) {
BlockEntity tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntityFieldCreator) {
if (!levelIn.isClientSide) {
String key = NaturesAura.MOD_ID + ":field_creator_pos";
CompoundNBT compound = player.getPersistentData();
CompoundTag compound = player.getPersistentData();
if (!player.isSneaking() && compound.contains(key)) {
BlockPos stored = BlockPos.fromLong(compound.getLong(key));
TileEntityFieldCreator creator = (TileEntityFieldCreator) tile;
BlockEntityFieldCreator creator = (BlockEntityFieldCreator) tile;
if (!pos.equals(stored)) {
if (creator.isCloseEnough(stored)) {
TileEntity otherTile = worldIn.getTileEntity(stored);
if (otherTile instanceof TileEntityFieldCreator) {
BlockEntity otherTile = levelIn.getBlockEntity(stored);
if (otherTile instanceof BlockEntityFieldCreator) {
creator.connectionOffset = stored.subtract(pos);
creator.isMain = true;
creator.sendToClients();
TileEntityFieldCreator otherCreator = (TileEntityFieldCreator) otherTile;
BlockEntityFieldCreator otherCreator = (BlockEntityFieldCreator) otherTile;
otherCreator.connectionOffset = pos.subtract(stored);
otherCreator.isMain = false;
otherCreator.sendToClients();
@ -66,17 +66,17 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc
player.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".stored_pos"), true);
}
}
return ActionResultType.SUCCESS;
return InteractionResult.SUCCESS;
} else
return ActionResultType.FAIL;
return InteractionResult.FAIL;
}
@Override
@OnlyIn(Dist.CLIENT)
public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) {
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityFieldCreator) {
TileEntityFieldCreator creator = (TileEntityFieldCreator) tile;
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) {
BlockEntity tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntityFieldCreator) {
BlockEntityFieldCreator creator = (BlockEntityFieldCreator) tile;
if (creator.isCharged) {
BlockPos connected = creator.getConnectedPos();
if (connected != null)

View file

@ -1,31 +1,31 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityFireworkGenerator;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityFireworkGenerator;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockFireworkGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockFireworkGenerator() {
super("firework_generator", TileEntityFireworkGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE));
super("firework_generator", BlockEntityFireworkGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE));
}
@Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) {
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
return new AxisAlignedBB(pos).grow(4);
}
@Override
@OnlyIn(Dist.CLIENT)
public int getVisualizationColor(World world, BlockPos pos) {
public int getVisualizationColor(Level level, BlockPos pos) {
return 0xa442f4;
}

View file

@ -1,32 +1,32 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityFlowerGenerator;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityFlowerGenerator;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockFlowerGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockFlowerGenerator() {
super("flower_generator", TileEntityFlowerGenerator::new, Properties.create(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(2F));
super("flower_generator", BlockEntityFlowerGenerator::new, Properties.create(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(2F));
}
@Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) {
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
return new AxisAlignedBB(pos).grow(3, 1, 3);
}
@Override
@OnlyIn(Dist.CLIENT)
public int getVisualizationColor(World world, BlockPos pos) {
public int getVisualizationColor(Level level, BlockPos pos) {
return 0xffed2b;
}

View file

@ -1,7 +1,7 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityFurnaceHeater;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityFurnaceHeater;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.Block;
@ -11,13 +11,13 @@ import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ToolType;
@ -38,7 +38,7 @@ public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlo
};
public BlockFurnaceHeater() {
super("furnace_heater", TileEntityFurnaceHeater::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).harvestLevel(1).harvestTool(ToolType.PICKAXE));
super("furnace_heater", BlockEntityFurnaceHeater::new, Properties.create(Material.ROCK).hardnessAndResistance(3F).harvestLevel(1).harvestTool(ToolType.PICKAXE));
}
@Override
@ -48,9 +48,9 @@ public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlo
@Override
@OnlyIn(Dist.CLIENT)
public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) {
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityFurnaceHeater && ((TileEntityFurnaceHeater) tile).isActive) {
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) {
BlockEntity tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntityFurnaceHeater && ((BlockEntityFurnaceHeater) tile).isActive) {
Direction facing = stateIn.get(FACING);
float x;
@ -80,7 +80,7 @@ public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlo
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
return SHAPES[state.get(FACING).getIndex()];
}

View file

@ -1,29 +1,29 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityGeneratorLimitRemover;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityGeneratorLimitRemover;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderGeneratorLimitRemover;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
import net.minecraft.tileentity.BlockEntityType;
import net.minecraft.util.Tuple;
import java.util.function.Function;
import java.util.function.Supplier;
public class BlockGeneratorLimitRemover extends BlockContainerImpl implements ITESRProvider<TileEntityGeneratorLimitRemover>, ICustomBlockState {
public class BlockGeneratorLimitRemover extends BlockContainerImpl implements ITESRProvider<BlockEntityGeneratorLimitRemover>, ICustomBlockState {
public BlockGeneratorLimitRemover() {
super("generator_limit_remover", TileEntityGeneratorLimitRemover::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
super("generator_limit_remover", BlockEntityGeneratorLimitRemover::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
}
@Override
public Tuple<TileEntityType<TileEntityGeneratorLimitRemover>, Supplier<Function<? super TileEntityRendererDispatcher, ? extends TileEntityRenderer<? super TileEntityGeneratorLimitRemover>>>> getTESR() {
public Tuple<BlockEntityType<BlockEntityGeneratorLimitRemover>, Supplier<Function<? super BlockEntityRendererDispatcher, ? extends BlockEntityRenderer<? super BlockEntityGeneratorLimitRemover>>>> getTESR() {
return new Tuple<>(ModTileEntities.GENERATOR_LIMIT_REMOVER, () -> RenderGeneratorLimitRemover::new);
}

View file

@ -21,11 +21,11 @@ import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraft.util.math.shapes.Shapes;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.ILevel;
import net.minecraft.level.ILevelReader;
import net.minecraft.level.Level;
import java.util.function.Supplier;
@ -71,39 +71,39 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
@Override
public IBlockColor getBlockColor() {
return (state, worldIn, pos, tintIndex) -> 0xf4cb42;
return (state, levelIn, pos, tintIndex) -> 0xf4cb42;
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
return SHAPES[getShapeIndex(state)];
}
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
IBlockReader iblockreader = context.getWorld();
IBlockReader iblockreader = context.getLevel();
BlockPos blockpos = context.getPos();
return this.getDefaultState().with(WEST, this.getSide(iblockreader, blockpos, Direction.WEST)).with(EAST, this.getSide(iblockreader, blockpos, Direction.EAST)).with(NORTH, this.getSide(iblockreader, blockpos, Direction.NORTH)).with(SOUTH, this.getSide(iblockreader, blockpos, Direction.SOUTH));
}
@Override
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) {
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, ILevel levelIn, BlockPos currentPos, BlockPos facingPos) {
if (facing == Direction.DOWN) {
return stateIn;
} else {
return facing == Direction.UP ? stateIn.with(WEST, this.getSide(worldIn, currentPos, Direction.WEST)).with(EAST, this.getSide(worldIn, currentPos, Direction.EAST)).with(NORTH, this.getSide(worldIn, currentPos, Direction.NORTH)).with(SOUTH, this.getSide(worldIn, currentPos, Direction.SOUTH)) : stateIn.with(RedstoneWireBlock.FACING_PROPERTY_MAP.get(facing), this.getSide(worldIn, currentPos, facing));
return facing == Direction.UP ? stateIn.with(WEST, this.getSide(levelIn, currentPos, Direction.WEST)).with(EAST, this.getSide(levelIn, currentPos, Direction.EAST)).with(NORTH, this.getSide(levelIn, currentPos, Direction.NORTH)).with(SOUTH, this.getSide(levelIn, currentPos, Direction.SOUTH)) : stateIn.with(RedstoneWireBlock.FACING_PROPERTY_MAP.get(facing), this.getSide(levelIn, currentPos, facing));
}
}
private RedstoneSide getSide(IBlockReader worldIn, BlockPos pos, Direction face) {
private RedstoneSide getSide(IBlockReader levelIn, BlockPos pos, Direction face) {
BlockPos blockpos = pos.offset(face);
BlockState blockstate = worldIn.getBlockState(blockpos);
BlockState blockstate = levelIn.getBlockState(blockpos);
BlockPos blockpos1 = pos.up();
BlockState blockstate1 = worldIn.getBlockState(blockpos1);
if (!blockstate1.isNormalCube(worldIn, blockpos1)) {
boolean flag = blockstate.isSolidSide(worldIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER;
if (flag && this.canConnectTo(worldIn.getBlockState(blockpos.up()))) {
if (blockstate.hasOpaqueCollisionShape(worldIn, blockpos)) {
BlockState blockstate1 = levelIn.getBlockState(blockpos1);
if (!blockstate1.isNormalCube(levelIn, blockpos1)) {
boolean flag = blockstate.isSolidSide(levelIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER;
if (flag && this.canConnectTo(levelIn.getBlockState(blockpos.up()))) {
if (blockstate.hasOpaqueCollisionShape(levelIn, blockpos)) {
return RedstoneSide.UP;
}
@ -111,7 +111,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
}
}
return !this.canConnectTo(blockstate) && (blockstate.isNormalCube(worldIn, blockpos) || !this.canConnectTo(worldIn.getBlockState(blockpos.down()))) ? RedstoneSide.NONE : RedstoneSide.SIDE;
return !this.canConnectTo(blockstate) && (blockstate.isNormalCube(levelIn, blockpos) || !this.canConnectTo(levelIn.getBlockState(blockpos.down()))) ? RedstoneSide.NONE : RedstoneSide.SIDE;
}
protected boolean canConnectTo(BlockState blockState) {
@ -120,32 +120,32 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
}
@Override
public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) {
public boolean isValidPosition(BlockState state, ILevelReader levelIn, BlockPos pos) {
BlockPos blockpos = pos.down();
BlockState blockstate = worldIn.getBlockState(blockpos);
return blockstate.isSolidSide(worldIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER;
BlockState blockstate = levelIn.getBlockState(blockpos);
return blockstate.isSolidSide(levelIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER;
}
@Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return VoxelShapes.empty();
public VoxelShape getCollisionShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
return Shapes.empty();
}
@Override
public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) {
if (oldState.getBlock() != state.getBlock() && !worldIn.isRemote) {
public void onBlockAdded(BlockState state, Level levelIn, BlockPos pos, BlockState oldState, boolean isMoving) {
if (oldState.getBlock() != state.getBlock() && !levelIn.isClientSide) {
for (Direction direction : Direction.Plane.VERTICAL) {
worldIn.notifyNeighborsOfStateChange(pos.offset(direction), this);
levelIn.notifyNeighborsOfStateChange(pos.offset(direction), this);
}
for (Direction direction1 : Direction.Plane.HORIZONTAL) {
this.notifyWireNeighborsOfStateChange(worldIn, pos.offset(direction1));
this.notifyWireNeighborsOfStateChange(levelIn, pos.offset(direction1));
}
for (Direction direction2 : Direction.Plane.HORIZONTAL) {
BlockPos blockpos = pos.offset(direction2);
if (worldIn.getBlockState(blockpos).isNormalCube(worldIn, blockpos)) {
this.notifyWireNeighborsOfStateChange(worldIn, blockpos.up());
if (levelIn.getBlockState(blockpos).isNormalCube(levelIn, blockpos)) {
this.notifyWireNeighborsOfStateChange(levelIn, blockpos.up());
} else {
this.notifyWireNeighborsOfStateChange(worldIn, blockpos.down());
this.notifyWireNeighborsOfStateChange(levelIn, blockpos.down());
}
}
@ -153,22 +153,22 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
}
@Override
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
public void onReplaced(BlockState state, Level levelIn, BlockPos pos, BlockState newState, boolean isMoving) {
if (!isMoving && state.getBlock() != newState.getBlock()) {
super.onReplaced(state, worldIn, pos, newState, isMoving);
if (!worldIn.isRemote) {
super.onReplaced(state, levelIn, pos, newState, isMoving);
if (!levelIn.isClientSide) {
for (Direction direction : Direction.values()) {
worldIn.notifyNeighborsOfStateChange(pos.offset(direction), this);
levelIn.notifyNeighborsOfStateChange(pos.offset(direction), this);
}
for (Direction direction1 : Direction.Plane.HORIZONTAL) {
this.notifyWireNeighborsOfStateChange(worldIn, pos.offset(direction1));
this.notifyWireNeighborsOfStateChange(levelIn, pos.offset(direction1));
}
for (Direction direction2 : Direction.Plane.HORIZONTAL) {
BlockPos blockpos = pos.offset(direction2);
if (worldIn.getBlockState(blockpos).isNormalCube(worldIn, blockpos)) {
this.notifyWireNeighborsOfStateChange(worldIn, blockpos.up());
if (levelIn.getBlockState(blockpos).isNormalCube(levelIn, blockpos)) {
this.notifyWireNeighborsOfStateChange(levelIn, blockpos.up());
} else {
this.notifyWireNeighborsOfStateChange(worldIn, blockpos.down());
this.notifyWireNeighborsOfStateChange(levelIn, blockpos.down());
}
}
@ -177,47 +177,47 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
}
@Override
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
if (!worldIn.isRemote) {
if (!state.isValidPosition(worldIn, pos)) {
spawnDrops(state, worldIn, pos);
worldIn.removeBlock(pos, false);
public void neighborChanged(BlockState state, Level levelIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
if (!levelIn.isClientSide) {
if (!state.isValidPosition(levelIn, pos)) {
spawnDrops(state, levelIn, pos);
levelIn.removeBlock(pos, false);
}
}
}
@Override
public void updateDiagonalNeighbors(BlockState state, IWorld worldIn, BlockPos pos, int flags, int recursionLeft) {
public void updateDiagonalNeighbors(BlockState state, ILevel levelIn, BlockPos pos, int flags, int recursionLeft) {
BlockPos.Mutable pool = new BlockPos.Mutable();
for (Direction direction : Direction.Plane.HORIZONTAL) {
RedstoneSide redstoneside = state.get(RedstoneWireBlock.FACING_PROPERTY_MAP.get(direction));
if (redstoneside != RedstoneSide.NONE && worldIn.getBlockState(pool.setPos(pos).move(direction)).getBlock() != this) {
if (redstoneside != RedstoneSide.NONE && levelIn.getBlockState(pool.setPos(pos).move(direction)).getBlock() != this) {
pool.move(Direction.DOWN);
BlockState blockstate = worldIn.getBlockState(pool);
BlockState blockstate = levelIn.getBlockState(pool);
if (blockstate.getBlock() != Blocks.OBSERVER) {
BlockPos blockpos = pool.offset(direction.getOpposite());
BlockState blockstate1 = blockstate.updatePostPlacement(direction.getOpposite(), worldIn.getBlockState(blockpos), worldIn, pool, blockpos);
replaceBlock(blockstate, blockstate1, worldIn, pool, flags);
BlockState blockstate1 = blockstate.updatePostPlacement(direction.getOpposite(), levelIn.getBlockState(blockpos), levelIn, pool, blockpos);
replaceBlock(blockstate, blockstate1, levelIn, pool, flags);
}
pool.setPos(pos).move(direction).move(Direction.UP);
BlockState blockstate3 = worldIn.getBlockState(pool);
BlockState blockstate3 = levelIn.getBlockState(pool);
if (blockstate3.getBlock() != Blocks.OBSERVER) {
BlockPos blockpos1 = pool.offset(direction.getOpposite());
BlockState blockstate2 = blockstate3.updatePostPlacement(direction.getOpposite(), worldIn.getBlockState(blockpos1), worldIn, pool, blockpos1);
replaceBlock(blockstate3, blockstate2, worldIn, pool, flags);
BlockState blockstate2 = blockstate3.updatePostPlacement(direction.getOpposite(), levelIn.getBlockState(blockpos1), levelIn, pool, blockpos1);
replaceBlock(blockstate3, blockstate2, levelIn, pool, flags);
}
}
}
}
private void notifyWireNeighborsOfStateChange(World worldIn, BlockPos pos) {
if (worldIn.getBlockState(pos).getBlock() == this) {
worldIn.notifyNeighborsOfStateChange(pos, this);
private void notifyWireNeighborsOfStateChange(Level levelIn, BlockPos pos) {
if (levelIn.getBlockState(pos).getBlock() == this) {
levelIn.notifyNeighborsOfStateChange(pos, this);
for (Direction direction : Direction.values()) {
worldIn.notifyNeighborsOfStateChange(pos.offset(direction), this);
levelIn.notifyNeighborsOfStateChange(pos.offset(direction), this);
}
}
}

View file

@ -16,9 +16,9 @@ import net.minecraft.state.IntegerProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeColors;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.level.Level;
import net.minecraft.level.biome.BiomeColors;
import net.minecraft.level.server.ServerLevel;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -34,11 +34,11 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
ModRegistry.add(this);
}
public static boolean convert(World world, BlockPos pos) {
BlockState state = world.getBlockState(pos);
public static boolean convert(Level level, BlockPos pos) {
BlockState state = level.getBlockState(pos);
if (state.getBlock() instanceof LeavesBlock && !(state.getBlock() instanceof BlockAncientLeaves || state.getBlock() instanceof BlockGoldenLeaves)) {
if (!world.isRemote) {
world.setBlockState(pos, ModBlocks.GOLDEN_LEAVES.getDefaultState()
if (!level.isClientSide) {
level.setBlockState(pos, ModBlocks.GOLDEN_LEAVES.getDefaultState()
.with(DISTANCE, state.hasProperty(DISTANCE) ? state.get(DISTANCE) : 1)
.with(PERSISTENT, state.hasProperty(PERSISTENT) ? state.get(PERSISTENT) : false));
}
@ -54,7 +54,7 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
@Override
@OnlyIn(Dist.CLIENT)
public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) {
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) {
if (stateIn.get(STAGE) == HIGHEST_STAGE && rand.nextFloat() >= 0.75F)
NaturesAuraAPI.instance().spawnMagicParticle(
pos.getX() + rand.nextFloat(),
@ -73,10 +73,10 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
@Override
@OnlyIn(Dist.CLIENT)
public IBlockColor getBlockColor() {
return (state, worldIn, pos, tintIndex) -> {
return (state, levelIn, pos, tintIndex) -> {
int color = 0xF2FF00;
if (state != null && worldIn != null && pos != null) {
int foliage = BiomeColors.getFoliageColor(worldIn, pos);
if (state != null && levelIn != null && pos != null) {
int foliage = BiomeColors.getFoliageColor(levelIn, pos);
return Helper.blendColors(color, foliage, state.get(STAGE) / (float) HIGHEST_STAGE);
} else {
return color;
@ -91,18 +91,18 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr
}
@Override
public void randomTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) {
super.randomTick(state, worldIn, pos, random);
if (!worldIn.isRemote) {
public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) {
super.randomTick(state, levelIn, pos, random);
if (!levelIn.isClientSide) {
int stage = state.get(STAGE);
if (stage < HIGHEST_STAGE) {
worldIn.setBlockState(pos, state.with(STAGE, stage + 1));
levelIn.setBlockState(pos, state.with(STAGE, stage + 1));
}
if (stage > 1) {
BlockPos offset = pos.offset(Direction.func_239631_a_(random));
if (worldIn.isBlockLoaded(offset))
convert(worldIn, offset);
if (levelIn.isBlockLoaded(offset))
convert(levelIn, offset);
}
}
}

View file

@ -1,31 +1,31 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityGratedChute;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityGratedChute;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.data.ItemModelGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ICustomItemModel;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.Player;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.IHopper;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.InteractionResult;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Mth;
import net.minecraft.util.math.shapes.IBooleanFunction;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.util.math.shapes.Shapes;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.Level;
import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nullable;
@ -35,21 +35,21 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
public static final DirectionProperty FACING = HopperBlock.FACING;
private static final VoxelShape INPUT_SHAPE = Block.makeCuboidShape(0.0D, 10.0D, 0.0D, 16.0D, 16.0D, 16.0D);
private static final VoxelShape MIDDLE_SHAPE = Block.makeCuboidShape(4.0D, 4.0D, 4.0D, 12.0D, 10.0D, 12.0D);
private static final VoxelShape INPUT_MIDDLE_SHAPE = VoxelShapes.or(MIDDLE_SHAPE, INPUT_SHAPE);
private static final VoxelShape COMBINED_SHAPE = VoxelShapes.combineAndSimplify(INPUT_MIDDLE_SHAPE, IHopper.INSIDE_BOWL_SHAPE, IBooleanFunction.ONLY_FIRST);
private static final VoxelShape DOWN_SHAPE = VoxelShapes.or(COMBINED_SHAPE, Block.makeCuboidShape(6.0D, 0.0D, 6.0D, 10.0D, 4.0D, 10.0D));
private static final VoxelShape EAST_SHAPE = VoxelShapes.or(COMBINED_SHAPE, Block.makeCuboidShape(12.0D, 4.0D, 6.0D, 16.0D, 8.0D, 10.0D));
private static final VoxelShape NORTH_SHAPE = VoxelShapes.or(COMBINED_SHAPE, Block.makeCuboidShape(6.0D, 4.0D, 0.0D, 10.0D, 8.0D, 4.0D));
private static final VoxelShape SOUTH_SHAPE = VoxelShapes.or(COMBINED_SHAPE, Block.makeCuboidShape(6.0D, 4.0D, 12.0D, 10.0D, 8.0D, 16.0D));
private static final VoxelShape WEST_SHAPE = VoxelShapes.or(COMBINED_SHAPE, Block.makeCuboidShape(0.0D, 4.0D, 6.0D, 4.0D, 8.0D, 10.0D));
private static final VoxelShape INPUT_MIDDLE_SHAPE = Shapes.or(MIDDLE_SHAPE, INPUT_SHAPE);
private static final VoxelShape COMBINED_SHAPE = Shapes.combineAndSimplify(INPUT_MIDDLE_SHAPE, IHopper.INSIDE_BOWL_SHAPE, IBooleanFunction.ONLY_FIRST);
private static final VoxelShape DOWN_SHAPE = Shapes.or(COMBINED_SHAPE, Block.makeCuboidShape(6.0D, 0.0D, 6.0D, 10.0D, 4.0D, 10.0D));
private static final VoxelShape EAST_SHAPE = Shapes.or(COMBINED_SHAPE, Block.makeCuboidShape(12.0D, 4.0D, 6.0D, 16.0D, 8.0D, 10.0D));
private static final VoxelShape NORTH_SHAPE = Shapes.or(COMBINED_SHAPE, Block.makeCuboidShape(6.0D, 4.0D, 0.0D, 10.0D, 8.0D, 4.0D));
private static final VoxelShape SOUTH_SHAPE = Shapes.or(COMBINED_SHAPE, Block.makeCuboidShape(6.0D, 4.0D, 12.0D, 10.0D, 8.0D, 16.0D));
private static final VoxelShape WEST_SHAPE = Shapes.or(COMBINED_SHAPE, Block.makeCuboidShape(0.0D, 4.0D, 6.0D, 4.0D, 8.0D, 10.0D));
private static final VoxelShape DOWN_RAYTRACE_SHAPE = IHopper.INSIDE_BOWL_SHAPE;
private static final VoxelShape EAST_RAYTRACE_SHAPE = VoxelShapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(12.0D, 8.0D, 6.0D, 16.0D, 10.0D, 10.0D));
private static final VoxelShape NORTH_RAYTRACE_SHAPE = VoxelShapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(6.0D, 8.0D, 0.0D, 10.0D, 10.0D, 4.0D));
private static final VoxelShape SOUTH_RAYTRACE_SHAPE = VoxelShapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(6.0D, 8.0D, 12.0D, 10.0D, 10.0D, 16.0D));
private static final VoxelShape WEST_RAYTRACE_SHAPE = VoxelShapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(0.0D, 8.0D, 6.0D, 4.0D, 10.0D, 10.0D));
private static final VoxelShape EAST_RAYTRACE_SHAPE = Shapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(12.0D, 8.0D, 6.0D, 16.0D, 10.0D, 10.0D));
private static final VoxelShape NORTH_RAYTRACE_SHAPE = Shapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(6.0D, 8.0D, 0.0D, 10.0D, 10.0D, 4.0D));
private static final VoxelShape SOUTH_RAYTRACE_SHAPE = Shapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(6.0D, 8.0D, 12.0D, 10.0D, 10.0D, 16.0D));
private static final VoxelShape WEST_RAYTRACE_SHAPE = Shapes.or(IHopper.INSIDE_BOWL_SHAPE, Block.makeCuboidShape(0.0D, 8.0D, 6.0D, 4.0D, 10.0D, 10.0D));
public BlockGratedChute() {
super("grated_chute", TileEntityGratedChute::new, Properties.create(Material.IRON).hardnessAndResistance(3.0F, 8.0F).sound(SoundType.METAL));
super("grated_chute", BlockEntityGratedChute::new, Properties.create(Material.IRON).hardnessAndResistance(3.0F, 8.0F).sound(SoundType.METAL));
}
@Override
@ -58,7 +58,7 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
switch (state.get(FACING)) {
case DOWN:
return DOWN_SHAPE;
@ -76,7 +76,7 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
}
@Override
public VoxelShape getRaytraceShape(BlockState state, IBlockReader worldIn, BlockPos pos) {
public VoxelShape getRaytraceShape(BlockState state, IBlockReader levelIn, BlockPos pos) {
switch (state.get(FACING)) {
case DOWN:
return DOWN_RAYTRACE_SHAPE;
@ -94,18 +94,18 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
}
@Override
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) {
if (!player.isSneaking())
return ActionResultType.FAIL;
TileEntity tile = worldIn.getTileEntity(pos);
if (!(tile instanceof TileEntityGratedChute))
return ActionResultType.FAIL;
if (!worldIn.isRemote) {
TileEntityGratedChute chute = (TileEntityGratedChute) tile;
return InteractionResult.FAIL;
BlockEntity tile = levelIn.getBlockEntity(pos);
if (!(tile instanceof BlockEntityGratedChute))
return InteractionResult.FAIL;
if (!levelIn.isClientSide) {
BlockEntityGratedChute chute = (BlockEntityGratedChute) tile;
chute.isBlacklist = !chute.isBlacklist;
chute.sendToClients();
}
return ActionResultType.SUCCESS;
return InteractionResult.SUCCESS;
}
@Nullable
@ -128,14 +128,14 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
}
@Override
public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) {
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityGratedChute) {
IItemHandler handler = ((TileEntityGratedChute) tile).getItemHandler();
public int getComparatorInputOverride(BlockState blockState, Level levelIn, BlockPos pos) {
BlockEntity tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntityGratedChute) {
IItemHandler handler = ((BlockEntityGratedChute) tile).getItemHandler();
ItemStack stack = handler.getStackInSlot(0);
if (stack.isEmpty())
return 0;
return MathHelper.ceil(stack.getCount() / (float) stack.getMaxStackSize() * 15);
return Mth.ceil(stack.getCount() / (float) stack.getMaxStackSize() * 15);
} else
return 0;
}

View file

@ -1,29 +1,29 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityHopperUpgrade;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityHopperUpgrade;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockHopperUpgrade extends BlockContainerImpl implements IVisualizable {
public BlockHopperUpgrade() {
super("hopper_upgrade", TileEntityHopperUpgrade::new, Properties.create(Material.IRON).hardnessAndResistance(2.5F).sound(SoundType.METAL));
super("hopper_upgrade", BlockEntityHopperUpgrade::new, Properties.create(Material.IRON).hardnessAndResistance(2.5F).sound(SoundType.METAL));
}
@Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) {
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
return new AxisAlignedBB(pos).grow(7);
}
@Override
@OnlyIn(Dist.CLIENT)
public int getVisualizationColor(World world, BlockPos pos) {
public int getVisualizationColor(Level level, BlockPos pos) {
return 0x434f3f;
}
}

View file

@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.block.Block;
import net.minecraft.world.level.block.Block;
public class BlockImpl extends Block implements IModItem {

View file

@ -1,37 +1,37 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityItemDistributor;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityItemDistributor;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.entity.player.Player;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.InteractionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World;
import net.minecraft.level.Level;
public class BlockItemDistributor extends BlockContainerImpl implements ICustomBlockState {
public BlockItemDistributor() {
super("item_distributor", TileEntityItemDistributor::new, Properties.from(Blocks.STONE_BRICKS));
super("item_distributor", BlockEntityItemDistributor::new, Properties.from(Blocks.STONE_BRICKS));
}
@Override
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) {
if (!player.isSneaking())
return ActionResultType.FAIL;
TileEntity tile = worldIn.getTileEntity(pos);
if (!(tile instanceof TileEntityItemDistributor))
return ActionResultType.FAIL;
if (!worldIn.isRemote) {
TileEntityItemDistributor distributor = (TileEntityItemDistributor) tile;
return InteractionResult.FAIL;
BlockEntity tile = levelIn.getBlockEntity(pos);
if (!(tile instanceof BlockEntityItemDistributor))
return InteractionResult.FAIL;
if (!levelIn.isClientSide) {
BlockEntityItemDistributor distributor = (BlockEntityItemDistributor) tile;
distributor.isRandomMode = !distributor.isRandomMode;
distributor.sendToClients();
}
return ActionResultType.SUCCESS;
return InteractionResult.SUCCESS;
}
@Override

View file

@ -12,8 +12,8 @@ import net.minecraft.item.BlockItemUseContext;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -30,7 +30,7 @@ public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemB
@Override
@OnlyIn(Dist.CLIENT)
public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) {
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, Random rand) {
for (int i = 0; i < 2; i++)
NaturesAuraAPI.instance().spawnMagicParticle(
pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F,
@ -39,7 +39,7 @@ public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemB
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
}

View file

@ -1,29 +1,29 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityMossGenerator;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityMossGenerator;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockMossGenerator extends BlockContainerImpl implements IVisualizable {
public BlockMossGenerator() {
super("moss_generator", TileEntityMossGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
super("moss_generator", BlockEntityMossGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
}
@Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) {
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
return new AxisAlignedBB(pos).grow(2);
}
@Override
@OnlyIn(Dist.CLIENT)
public int getVisualizationColor(World world, BlockPos pos) {
public int getVisualizationColor(Level level, BlockPos pos) {
return 0x15702d;
}
}

View file

@ -3,45 +3,46 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityNatureAltar;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderNatureAltar;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
import net.minecraft.core.BlockPos;
import net.minecraft.entity.player.Player;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ActionResultType;
import net.minecraft.tileentity.BlockEntityType;
import net.minecraft.util.Hand;
import net.minecraft.util.Tuple;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.common.ToolType;
import javax.annotation.Nullable;
import java.util.function.Function;
import java.util.function.Supplier;
public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvider<TileEntityNatureAltar>, ICustomBlockState {
public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvider<BlockEntityNatureAltar>, ICustomBlockState {
private static final VoxelShape SHAPE = VoxelShapes.create(0, 0, 0, 1, 12 / 16F, 1);
private static final VoxelShape SHAPE = Shapes.create(0, 0, 0, 1, 12 / 16F, 1);
public static final BooleanProperty NETHER = BooleanProperty.create("nether");
public BlockNatureAltar() {
super("nature_altar", TileEntityNatureAltar::new, Properties.create(Material.ROCK).hardnessAndResistance(4F).harvestLevel(1).harvestTool(ToolType.PICKAXE));
super("nature_altar", BlockEntityNatureAltar::new, Block.Properties.create(Material.ROCK).hardnessAndResistance(4F).harvestLevel(1).harvestTool(ToolType.PICKAXE));
this.setDefaultState(this.getDefaultState().with(NETHER, false));
}
@ -51,17 +52,18 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
return SHAPE;
}
@Override
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) {
return Helper.putStackOnTile(player, handIn, pos, 0, true);
}
@Override
public Tuple<TileEntityType<TileEntityNatureAltar>, Supplier<Function<? super TileEntityRendererDispatcher, ? extends TileEntityRenderer<? super TileEntityNatureAltar>>>> getTESR() {
public Tuple<BlockEntityType<BlockEntityNatureAltar>, Supplier<Function<? super BlockEntityRenderDispatcher, ? extends BlockEntityRenderer<? super BlockEntityNatureAltar>>>> getTESR() {
return new Tuple<>(ModTileEntities.NATURE_ALTAR, () -> RenderNatureAltar::new);
}
@ -79,7 +81,7 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
boolean nether = IAuraType.forWorld(context.getWorld()).isSimilar(NaturesAuraAPI.TYPE_NETHER);
boolean nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER);
return super.getStateForPlacement(context).with(NETHER, nether);
}
}

View file

@ -7,9 +7,9 @@ import net.minecraft.block.Blocks;
import net.minecraft.block.IGrowable;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.Level;
import net.minecraft.level.server.ServerLevel;
import java.util.Random;
@ -20,11 +20,11 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, IG
}
@Override
public void randomTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) {
public void randomTick(BlockState state, ServerLevel levelIn, BlockPos pos, Random random) {
BlockPos up = pos.up();
BlockState upState = worldIn.getBlockState(up);
if (upState.isSolidSide(worldIn, up, Direction.DOWN))
worldIn.setBlockState(pos, Blocks.NETHERRACK.getDefaultState());
BlockState upState = levelIn.getBlockState(up);
if (upState.isSolidSide(levelIn, up, Direction.DOWN))
levelIn.setBlockState(pos, Blocks.NETHERRACK.getDefaultState());
}
@Override
@ -36,17 +36,17 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, IG
}
@Override
public boolean canGrow(IBlockReader worldIn, BlockPos pos, BlockState state, boolean isClient) {
return worldIn.getBlockState(pos.up()).isAir(worldIn, pos.up());
public boolean canGrow(IBlockReader levelIn, BlockPos pos, BlockState state, boolean isClient) {
return levelIn.getBlockState(pos.up()).isAir(levelIn, pos.up());
}
@Override
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, BlockState state) {
public boolean canUseBonemeal(Level levelIn, Random rand, BlockPos pos, BlockState state) {
return true;
}
@Override
public void grow(ServerWorld world, Random rand, BlockPos pos, BlockState state) {
public void grow(ServerLevel level, Random rand, BlockPos pos, BlockState state) {
BlockPos blockpos = pos.up();
BlockState blockstate = Blocks.GRASS.getDefaultState();
@ -56,23 +56,23 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, IG
while (true) {
if (j >= i / 16) {
BlockState blockstate2 = world.getBlockState(blockpos1);
BlockState blockstate2 = level.getBlockState(blockpos1);
if (blockstate2.getBlock() == blockstate.getBlock() && rand.nextInt(10) == 0) {
((IGrowable) blockstate.getBlock()).grow(world, rand, blockpos1, blockstate2);
((IGrowable) blockstate.getBlock()).grow(level, rand, blockpos1, blockstate2);
}
if (!blockstate2.isAir()) {
break;
}
if (blockstate.isValidPosition(world, blockpos1)) {
world.setBlockState(blockpos1, blockstate, 3);
if (blockstate.isValidPosition(level, blockpos1)) {
level.setBlockState(blockpos1, blockstate, 3);
}
break;
}
blockpos1 = blockpos1.add(rand.nextInt(3) - 1, (rand.nextInt(3) - 1) * rand.nextInt(3) / 2, rand.nextInt(3) - 1);
if (world.getBlockState(blockpos1.down()).getBlock() != this || world.getBlockState(blockpos1).hasOpaqueCollisionShape(world, blockpos1)) {
if (level.getBlockState(blockpos1.down()).getBlock() != this || level.getBlockState(blockpos1).hasOpaqueCollisionShape(level, blockpos1)) {
break;
}

View file

@ -4,7 +4,7 @@ import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityOakGenerator;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityOakGenerator;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.SaplingBlock;
@ -12,12 +12,12 @@ import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.level.ILevel;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.SaplingGrowTreeEvent;
import net.minecraftforge.event.level.SaplingGrowTreeEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import java.util.Random;
@ -25,24 +25,24 @@ import java.util.Random;
public class BlockOakGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockOakGenerator() {
super("oak_generator", TileEntityOakGenerator::new, Properties.create(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD));
super("oak_generator", BlockEntityOakGenerator::new, Properties.create(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD));
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void onTreeGrow(SaplingGrowTreeEvent event) {
IWorld world = event.getWorld();
ILevel level = event.getLevel();
BlockPos pos = event.getPos();
if (world instanceof World && !world.isRemote() && IAuraType.forWorld(world).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD)
&& world.getBlockState(pos).getBlock() instanceof SaplingBlock) {
Helper.getTileEntitiesInArea(world, pos, 10, tile -> {
if (!(tile instanceof TileEntityOakGenerator))
if (level instanceof Level && !level.isClientSide() && IAuraType.forLevel(level).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD)
&& level.getBlockState(pos).getBlock() instanceof SaplingBlock) {
Helper.getBlockEntitiesInArea(level, pos, 10, tile -> {
if (!(tile instanceof BlockEntityOakGenerator))
return false;
Random rand = event.getRand();
if (rand.nextInt(10) == 0)
((TileEntityOakGenerator) tile).scheduledBigTrees.add(pos);
((BlockEntityOakGenerator) tile).scheduledBigTrees.add(pos);
long seed;
do {
@ -59,13 +59,13 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab
@Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) {
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
return new AxisAlignedBB(pos).grow(10);
}
@Override
@OnlyIn(Dist.CLIENT)
public int getVisualizationColor(World world, BlockPos pos) {
public int getVisualizationColor(Level level, BlockPos pos) {
return 0x2e7a11;
}

View file

@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityOfferingTable;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityOfferingTable;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderOfferingTable;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
@ -10,30 +10,30 @@ import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ActionResultType;
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
import net.minecraft.entity.player.Player;
import net.minecraft.tileentity.BlockEntityType;
import net.minecraft.util.InteractionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Tuple;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.util.math.shapes.Shapes;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.Level;
import java.util.function.Function;
import java.util.function.Supplier;
public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvider<TileEntityOfferingTable>, ICustomBlockState {
public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvider<BlockEntityOfferingTable>, ICustomBlockState {
private static final VoxelShape SHAPE = VoxelShapes.create(2 / 16F, 0F, 2 / 16F, 14 / 16F, 1F, 14 / 16F);
private static final VoxelShape SHAPE = Shapes.create(2 / 16F, 0F, 2 / 16F, 14 / 16F, 1F, 14 / 16F);
public BlockOfferingTable() {
super("offering_table", TileEntityOfferingTable::new, Properties.create(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD));
super("offering_table", BlockEntityOfferingTable::new, Properties.create(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD));
}
@Override
@ -42,17 +42,17 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi
}
@Override
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) {
return Helper.putStackOnTile(player, handIn, pos, 0, true);
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
}
@Override
public Tuple<TileEntityType<TileEntityOfferingTable>, Supplier<Function<? super TileEntityRendererDispatcher, ? extends TileEntityRenderer<? super TileEntityOfferingTable>>>> getTESR() {
public Tuple<BlockEntityType<BlockEntityOfferingTable>, Supplier<Function<? super BlockEntityRendererDispatcher, ? extends BlockEntityRenderer<? super BlockEntityOfferingTable>>>> getTESR() {
return new Tuple<>(ModTileEntities.OFFERING_TABLE, () -> RenderOfferingTable::new);
}

View file

@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPickupStopper;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPickupStopper;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
@ -10,11 +10,11 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.entity.player.Player;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
@ -23,21 +23,21 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockPickupStopper() {
super("pickup_stopper", TileEntityPickupStopper::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
super("pickup_stopper", BlockEntityPickupStopper::new, Properties.create(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void onPickup(EntityItemPickupEvent event) {
PlayerEntity player = event.getPlayer();
Player player = event.getPlayer();
if (player != null && !player.isSneaking()) {
ItemEntity item = event.getItem();
BlockPos pos = item.getPosition();
Helper.getTileEntitiesInArea(item.world, pos, 8, tile -> {
if (!(tile instanceof TileEntityPickupStopper))
Helper.getBlockEntitiesInArea(item.level, pos, 8, tile -> {
if (!(tile instanceof BlockEntityPickupStopper))
return false;
TileEntityPickupStopper stopper = (TileEntityPickupStopper) tile;
BlockEntityPickupStopper stopper = (BlockEntityPickupStopper) tile;
float radius = stopper.getRadius();
if (radius <= 0F)
return false;
@ -47,8 +47,8 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
event.setCanceled(true);
if (item.world.getGameTime() % 3 == 0)
PacketHandler.sendToAllAround(item.world, pos, 32,
if (item.level.getGameTime() % 3 == 0)
PacketHandler.sendToAllAround(item.level, pos, 32,
new PacketParticles((float) item.getPosX(), (float) item.getPosY(), (float) item.getPosZ(), PacketParticles.Type.PICKUP_STOPPER));
return true;
});
@ -57,10 +57,10 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
@Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityPickupStopper) {
double radius = ((TileEntityPickupStopper) tile).getRadius();
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
BlockEntity tile = level.getBlockEntity(pos);
if (tile instanceof BlockEntityPickupStopper) {
double radius = ((BlockEntityPickupStopper) tile).getRadius();
if (radius > 0)
return new AxisAlignedBB(pos).grow(radius);
}
@ -69,7 +69,7 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
@Override
@OnlyIn(Dist.CLIENT)
public int getVisualizationColor(World world, BlockPos pos) {
public int getVisualizationColor(Level level, BlockPos pos) {
return 0xf4aa42;
}

View file

@ -1,32 +1,32 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPlacer;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPlacer;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockPlacer extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockPlacer() {
super("placer", TileEntityPlacer::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
super("placer", BlockEntityPlacer::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
}
@Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) {
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
return new AxisAlignedBB(pos).grow(5);
}
@Override
@OnlyIn(Dist.CLIENT)
public int getVisualizationColor(World world, BlockPos pos) {
public int getVisualizationColor(Level level, BlockPos pos) {
return 0x078a93;
}

View file

@ -1,6 +1,6 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPotionGenerator;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPotionGenerator;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.material.Material;
@ -8,7 +8,7 @@ import net.minecraftforge.common.ToolType;
public class BlockPotionGenerator extends BlockContainerImpl implements ICustomBlockState {
public BlockPotionGenerator() {
super("potion_generator", TileEntityPotionGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(5F).harvestTool(ToolType.PICKAXE).harvestLevel(1));
super("potion_generator", BlockEntityPotionGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(5F).harvestTool(ToolType.PICKAXE).harvestLevel(1));
}
@Override

View file

@ -1,6 +1,6 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPowderPlacer;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPowderPlacer;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.BlockState;
@ -9,15 +9,15 @@ import net.minecraft.block.material.Material;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.util.math.shapes.Shapes;
import net.minecraft.level.IBlockReader;
public class BlockPowderPlacer extends BlockContainerImpl implements ICustomBlockState {
private static final VoxelShape SHAPE = VoxelShapes.create(0F, 0F, 0F, 1F, 4 / 16F, 1F);
private static final VoxelShape SHAPE = Shapes.create(0F, 0F, 0F, 1F, 4 / 16F, 1F);
public BlockPowderPlacer() {
super("powder_placer", TileEntityPowderPlacer::new, Properties.create(Material.ROCK).hardnessAndResistance(2, 5F).sound(SoundType.STONE));
super("powder_placer", BlockEntityPowderPlacer::new, Properties.create(Material.ROCK).hardnessAndResistance(2, 5F).sound(SoundType.STONE));
}
@Override
@ -26,7 +26,7 @@ public class BlockPowderPlacer extends BlockContainerImpl implements ICustomBloc
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
}

View file

@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityProjectileGenerator;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityProjectileGenerator;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderProjectileGenerator;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.packet.PacketHandler;
@ -13,8 +13,8 @@ import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.block.DispenserBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
import net.minecraft.dispenser.IPosition;
import net.minecraft.dispenser.ProjectileDispenseBehavior;
import net.minecraft.entity.Entity;
@ -25,15 +25,15 @@ import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.entity.projectile.TridentEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.tileentity.BlockEntityType;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.Tuple;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraft.level.Level;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.ProjectileImpactEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -42,24 +42,24 @@ import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import java.util.function.Function;
import java.util.function.Supplier;
public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider<TileEntityProjectileGenerator>, ICustomBlockState {
public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider<BlockEntityProjectileGenerator>, ICustomBlockState {
public BlockProjectileGenerator() {
super("projectile_generator", TileEntityProjectileGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
super("projectile_generator", BlockEntityProjectileGenerator::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
MinecraftForge.EVENT_BUS.register(this);
DispenserBlock.registerDispenseBehavior(Items.ENDER_PEARL, new ProjectileDispenseBehavior() {
@Override
protected ProjectileEntity getProjectileEntity(World worldIn, IPosition position, ItemStack stackIn) {
EnderPearlEntity ret = new EnderPearlEntity(EntityType.ENDER_PEARL, worldIn);
protected ProjectileEntity getProjectileEntity(Level levelIn, IPosition position, ItemStack stackIn) {
EnderPearlEntity ret = new EnderPearlEntity(EntityType.ENDER_PEARL, levelIn);
ret.setPosition(position.getX(), position.getY(), position.getZ());
return ret;
}
});
DispenserBlock.registerDispenseBehavior(Items.TRIDENT, new ProjectileDispenseBehavior() {
@Override
protected ProjectileEntity getProjectileEntity(World worldIn, IPosition position, ItemStack stackIn) {
TridentEntity ret = new TridentEntity(EntityType.TRIDENT, worldIn);
protected ProjectileEntity getProjectileEntity(Level levelIn, IPosition position, ItemStack stackIn) {
TridentEntity ret = new TridentEntity(EntityType.TRIDENT, levelIn);
ret.setPosition(position.getX(), position.getY(), position.getZ());
// set thrownStack
ObfuscationReflectionHelper.setPrivateValue(TridentEntity.class, ret, stackIn.copy(), "field_203054_h");
@ -72,7 +72,7 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
@SubscribeEvent
public void onProjectileImpact(ProjectileImpactEvent event) {
Entity entity = event.getEntity();
if (entity.world.isRemote)
if (entity.level.isClientSide)
return;
RayTraceResult ray = event.getRayTraceResult();
if (!(ray instanceof BlockRayTraceResult))
@ -81,10 +81,10 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
BlockPos pos = blockRay.getPos();
if (pos == null)
return;
TileEntity tile = entity.world.getTileEntity(pos);
if (!(tile instanceof TileEntityProjectileGenerator))
BlockEntity tile = entity.level.getBlockEntity(pos);
if (!(tile instanceof BlockEntityProjectileGenerator))
return;
TileEntityProjectileGenerator generator = (TileEntityProjectileGenerator) tile;
BlockEntityProjectileGenerator generator = (BlockEntityProjectileGenerator) tile;
if (generator.nextSide != blockRay.getFace())
return;
Integer amount = NaturesAuraAPI.PROJECTILE_GENERATIONS.get(entity.getType());
@ -94,9 +94,9 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
return;
generator.generateAura(amount);
PacketHandler.sendToAllAround(entity.world, pos, 32,
PacketHandler.sendToAllAround(entity.level, pos, 32,
new PacketParticles((float) entity.getPosX(), (float) entity.getPosY(), (float) entity.getPosZ(), PacketParticles.Type.PROJECTILE_GEN, pos.getX(), pos.getY(), pos.getZ()));
entity.world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_ENDER_EYE_LAUNCH, SoundCategory.BLOCKS, 0.8F, 1F);
entity.level.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_ENDER_EYE_LAUNCH, SoundCategory.BLOCKS, 0.8F, 1F);
generator.nextSide = generator.nextSide.rotateY();
generator.sendToClients();
@ -106,7 +106,7 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
}
@Override
public Tuple<TileEntityType<TileEntityProjectileGenerator>, Supplier<Function<? super TileEntityRendererDispatcher, ? extends TileEntityRenderer<? super TileEntityProjectileGenerator>>>> getTESR() {
public Tuple<BlockEntityType<BlockEntityProjectileGenerator>, Supplier<Function<? super BlockEntityRendererDispatcher, ? extends BlockEntityRenderer<? super BlockEntityProjectileGenerator>>>> getTESR() {
return new Tuple<>(ModTileEntities.PROJECTILE_GENERATOR, () -> RenderProjectileGenerator::new);
}

View file

@ -2,14 +2,14 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityRFConverter;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityRFConverter;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
public class BlockRFConverter extends BlockContainerImpl {
public BlockRFConverter() {
super("rf_converter", TileEntityRFConverter::new, Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(3));
super("rf_converter", BlockEntityRFConverter::new, Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(3));
}
@Override

View file

@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntitySlimeSplitGenerator;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySlimeSplitGenerator;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.Blocks;
@ -10,7 +10,7 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.monster.SlimeEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
@ -19,7 +19,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockSlimeSplitGenerator() {
super("slime_split_generator", TileEntitySlimeSplitGenerator::new, Properties.from(Blocks.SLIME_BLOCK).hardnessAndResistance(2));
super("slime_split_generator", BlockEntitySlimeSplitGenerator::new, Properties.from(Blocks.SLIME_BLOCK).hardnessAndResistance(2));
MinecraftForge.EVENT_BUS.register(new Events());
}
@ -33,13 +33,13 @@ public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVis
@Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) {
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
return new AxisAlignedBB(pos).grow(8);
}
@Override
@OnlyIn(Dist.CLIENT)
public int getVisualizationColor(World world, BlockPos pos) {
public int getVisualizationColor(Level level, BlockPos pos) {
return 0x4da84f;
}
@ -48,16 +48,16 @@ public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVis
@SubscribeEvent
public void onLivingDeath(LivingDeathEvent event) {
LivingEntity entity = event.getEntityLiving();
if (!(entity instanceof SlimeEntity) || entity.world.isRemote)
if (!(entity instanceof SlimeEntity) || entity.level.isClientSide)
return;
SlimeEntity slime = (SlimeEntity) entity;
int size = slime.getSlimeSize();
if (size <= 1)
return;
Helper.getTileEntitiesInArea(entity.world, entity.getPosition(), 8, tile -> {
if (!(tile instanceof TileEntitySlimeSplitGenerator))
Helper.getBlockEntitiesInArea(entity.level, entity.getPosition(), 8, tile -> {
if (!(tile instanceof BlockEntitySlimeSplitGenerator))
return false;
TileEntitySlimeSplitGenerator gen = (TileEntitySlimeSplitGenerator) tile;
BlockEntitySlimeSplitGenerator gen = (BlockEntitySlimeSplitGenerator) tile;
if (gen.isBusy())
return false;
gen.startGenerating(slime);

View file

@ -1,28 +1,28 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntitySnowCreator;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySnowCreator;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockSnowCreator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
public BlockSnowCreator() {
super("snow_creator", TileEntitySnowCreator::new, Properties.from(Blocks.STONE_BRICKS));
super("snow_creator", BlockEntitySnowCreator::new, Properties.from(Blocks.STONE_BRICKS));
}
@Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntitySnowCreator) {
int radius = ((TileEntitySnowCreator) tile).getRange();
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
BlockEntity tile = level.getBlockEntity(pos);
if (tile instanceof BlockEntitySnowCreator) {
int radius = ((BlockEntitySnowCreator) tile).getRange();
if (radius > 0)
return new AxisAlignedBB(pos).grow(radius);
}
@ -30,7 +30,7 @@ public class BlockSnowCreator extends BlockContainerImpl implements IVisualizabl
}
@Override
public int getVisualizationColor(World world, BlockPos pos) {
public int getVisualizationColor(Level level, BlockPos pos) {
return 0xdbe9ff;
}

View file

@ -1,11 +1,11 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.api.misc.ILevelData;
import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpawnLamp;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySpawnLamp;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.misc.WorldData;
import de.ellpeck.naturesaura.misc.LevelData;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
@ -15,17 +15,17 @@ import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.entity.MobEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.util.math.shapes.Shapes;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.ILevel;
import net.minecraft.level.Level;
import net.minecraft.level.server.ServerLevel;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
@ -37,10 +37,10 @@ import java.util.function.Supplier;
public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable, ICustomBlockState, ICustomRenderType {
private static final VoxelShape SHAPE = VoxelShapes.create(4 / 16F, 0F, 4 / 16F, 12 / 16F, 13 / 16F, 12 / 16F);
private static final VoxelShape SHAPE = Shapes.create(4 / 16F, 0F, 4 / 16F, 12 / 16F, 13 / 16F, 12 / 16F);
public BlockSpawnLamp() {
super("spawn_lamp", TileEntitySpawnLamp::new, Properties.create(Material.IRON).hardnessAndResistance(3F).setLightLevel(s -> 15).sound(SoundType.METAL));
super("spawn_lamp", BlockEntitySpawnLamp::new, Properties.create(Material.IRON).hardnessAndResistance(3F).setLightLevel(s -> 15).sound(SoundType.METAL));
MinecraftForge.EVENT_BUS.register(this);
}
@ -53,12 +53,12 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
public void onSpawn(LivingSpawnEvent.CheckSpawn event) {
if (event.getSpawner() != null)
return;
IWorld world = event.getWorld();
ILevel level = event.getLevel();
BlockPos pos = new BlockPos(event.getX(), event.getY(), event.getZ());
if (!(world instanceof World))
if (!(level instanceof Level))
return;
WorldData data = (WorldData) IWorldData.getWorldData((World) world);
for (TileEntitySpawnLamp lamp : data.spawnLamps) {
LevelData data = (LevelData) ILevelData.getLevelData((Level) level);
for (BlockEntitySpawnLamp lamp : data.spawnLamps) {
if (lamp.isRemoved())
continue;
@ -71,11 +71,11 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
continue;
MobEntity entity = (MobEntity) event.getEntityLiving();
if (entity.canSpawn(world, event.getSpawnReason()) && entity.isNotColliding(world)) {
BlockPos spot = IAuraChunk.getHighestSpot(world, lampPos, 32, lampPos);
IAuraChunk.getAuraChunk(world, spot).drainAura(spot, 200);
if (entity.canSpawn(level, event.getSpawnReason()) && entity.isNotColliding(level)) {
BlockPos spot = IAuraChunk.getHighestSpot(level, lampPos, 32, lampPos);
IAuraChunk.getAuraChunk(level, spot).drainAura(spot, 200);
PacketHandler.sendToAllAround((ServerWorld) world, lampPos, 32,
PacketHandler.sendToAllAround((ServerLevel) level, lampPos, 32,
new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), PacketParticles.Type.SPAWN_LAMP));
}
@ -85,16 +85,16 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
}
@Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntitySpawnLamp) {
int radius = ((TileEntitySpawnLamp) tile).getRadius();
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
BlockEntity tile = level.getBlockEntity(pos);
if (tile instanceof BlockEntitySpawnLamp) {
int radius = ((BlockEntitySpawnLamp) tile).getRadius();
if (radius > 0)
return new AxisAlignedBB(pos).grow(radius);
}
@ -103,7 +103,7 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable,
@Override
@OnlyIn(Dist.CLIENT)
public int getVisualizationColor(World world, BlockPos pos) {
public int getVisualizationColor(Level level, BlockPos pos) {
return 0x825ee5;
}

View file

@ -1,6 +1,6 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpring;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySpring;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.IColorProvidingBlock;
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
@ -13,14 +13,14 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.Player;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.biome.BiomeColors;
import net.minecraft.level.ILevel;
import net.minecraft.level.biome.BiomeColors;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -28,13 +28,13 @@ import java.util.function.Supplier;
public class BlockSpring extends BlockContainerImpl implements ICustomBlockState, IColorProvidingBlock, IColorProvidingItem, IBucketPickupHandler, ICustomRenderType {
public BlockSpring() {
super("spring", TileEntitySpring::new, Properties.from(Blocks.STONE_BRICKS));
super("spring", BlockEntitySpring::new, Properties.from(Blocks.STONE_BRICKS));
}
@Override
@OnlyIn(Dist.CLIENT)
public IBlockColor getBlockColor() {
return (state, world, pos, i) -> BiomeColors.getWaterColor(world, pos);
return (state, level, pos, i) -> BiomeColors.getWaterColor(level, pos);
}
@Override
@ -44,8 +44,8 @@ public class BlockSpring extends BlockContainerImpl implements ICustomBlockState
return new IItemColor() {
@Override
public int getColor(ItemStack stack, int i) {
PlayerEntity player = Minecraft.getInstance().player;
return BiomeColors.getWaterColor(player.world, player.getPosition());
Player player = Minecraft.getInstance().player;
return BiomeColors.getWaterColor(player.level, player.getPosition());
}
};
}
@ -56,10 +56,10 @@ public class BlockSpring extends BlockContainerImpl implements ICustomBlockState
}
@Override
public Fluid pickupFluid(IWorld worldIn, BlockPos pos, BlockState state) {
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntitySpring)
((TileEntitySpring) tile).consumeAura(2500);
public Fluid pickupFluid(ILevel levelIn, BlockPos pos, BlockState state) {
BlockEntity tile = levelIn.getBlockEntity(pos);
if (tile instanceof BlockEntitySpring)
((BlockEntitySpring) tile).consumeAura(2500);
return Fluids.WATER;
}

View file

@ -1,6 +1,6 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityTimeChanger;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityTimeChanger;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.SoundType;
@ -8,7 +8,7 @@ import net.minecraft.block.material.Material;
public class BlockTimeChanger extends BlockContainerImpl implements ICustomBlockState {
public BlockTimeChanger() {
super("time_changer", TileEntityTimeChanger::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
super("time_changer", BlockEntityTimeChanger::new, Properties.create(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
}
@Override

View file

@ -1,13 +1,13 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityWeatherChanger;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityWeatherChanger;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.Blocks;
public class BlockWeatherChanger extends BlockContainerImpl implements ICustomBlockState {
public BlockWeatherChanger() {
super("weather_changer", TileEntityWeatherChanger::new, Properties.from(Blocks.STONE_BRICKS));
super("weather_changer", BlockEntityWeatherChanger::new, Properties.from(Blocks.STONE_BRICKS));
}
@Override

View file

@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityWoodStand;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderWoodStand;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.recipes.ModRecipes;
@ -13,27 +13,27 @@ import de.ellpeck.naturesaura.reg.ITESRProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.client.renderer.tileentity.BlockEntityRenderer;
import net.minecraft.client.renderer.tileentity.BlockEntityRendererDispatcher;
import net.minecraft.entity.player.Player;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ActionResultType;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.tileentity.BlockEntityType;
import net.minecraft.util.InteractionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Tuple;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.util.math.shapes.Shapes;
import net.minecraft.level.IBlockReader;
import net.minecraft.level.ILevel;
import net.minecraft.level.Level;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.event.world.SaplingGrowTreeEvent;
import net.minecraftforge.event.level.SaplingGrowTreeEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.commons.lang3.mutable.MutableObject;
@ -43,12 +43,12 @@ import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;
public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<TileEntityWoodStand>, ICustomBlockState {
public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<BlockEntityWoodStand>, ICustomBlockState {
private static final VoxelShape SHAPE = VoxelShapes.create(3 / 16F, 0F, 3 / 16F, 13 / 16F, 13 / 16F, 13 / 16F);
private static final VoxelShape SHAPE = Shapes.create(3 / 16F, 0F, 3 / 16F, 13 / 16F, 13 / 16F, 13 / 16F);
public BlockWoodStand() {
super("wood_stand", TileEntityWoodStand::new, Properties.create(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD).harvestLevel(0).harvestTool(ToolType.AXE));
super("wood_stand", BlockEntityWoodStand::new, Properties.create(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD).harvestLevel(0).harvestTool(ToolType.AXE));
MinecraftForge.EVENT_BUS.register(this);
}
@ -58,28 +58,28 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
}
@SubscribeEvent
public void onTreeGrow(SaplingGrowTreeEvent event) {
IWorld world = event.getWorld();
ILevel level = event.getLevel();
BlockPos pos = event.getPos();
if (!world.isRemote() && world instanceof World) {
if (Multiblocks.TREE_RITUAL.isComplete((World) world, pos)) {
BlockState sapling = world.getBlockState(pos);
ItemStack saplingStack = sapling.getBlock().getItem(world, pos, sapling);
if (!level.isClientSide() && level instanceof Level) {
if (Multiblocks.TREE_RITUAL.isComplete((Level) level, pos)) {
BlockState sapling = level.getBlockState(pos);
ItemStack saplingStack = sapling.getBlock().getItem(level, pos, sapling);
if (!saplingStack.isEmpty()) {
for (TreeRitualRecipe recipe : ((World) world).getRecipeManager().getRecipes(ModRecipes.TREE_RITUAL_TYPE, null, null)) {
for (TreeRitualRecipe recipe : ((Level) level).getRecipeManager().getRecipes(ModRecipes.TREE_RITUAL_TYPE, null, null)) {
if (recipe.saplingType.test(saplingStack)) {
List<Ingredient> required = new ArrayList<>(Arrays.asList(recipe.ingredients));
MutableObject<TileEntityWoodStand> toPick = new MutableObject<>();
MutableObject<BlockEntityWoodStand> toPick = new MutableObject<>();
boolean fine = Multiblocks.TREE_RITUAL.forEach(pos, 'W', (tilePos, matcher) -> {
TileEntity tile = world.getTileEntity(tilePos);
if (tile instanceof TileEntityWoodStand) {
TileEntityWoodStand stand = (TileEntityWoodStand) tile;
BlockEntity tile = level.getBlockEntity(tilePos);
if (tile instanceof BlockEntityWoodStand) {
BlockEntityWoodStand stand = (BlockEntityWoodStand) tile;
ItemStack stack = stand.items.getStackInSlot(0);
if (!stack.isEmpty()) {
for (int i = required.size() - 1; i >= 0; i--) {
@ -111,12 +111,12 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
}
@Override
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
public InteractionResult onBlockActivated(BlockState state, Level levelIn, BlockPos pos, Player player, Hand handIn, BlockRayTraceResult hit) {
return Helper.putStackOnTile(player, handIn, pos, 0, true);
}
@Override
public Tuple<TileEntityType<TileEntityWoodStand>, Supplier<Function<? super TileEntityRendererDispatcher, ? extends TileEntityRenderer<? super TileEntityWoodStand>>>> getTESR() {
public Tuple<BlockEntityType<BlockEntityWoodStand>, Supplier<Function<? super BlockEntityRendererDispatcher, ? extends BlockEntityRenderer<? super BlockEntityWoodStand>>>> getTESR() {
return new Tuple<>(ModTileEntities.WOOD_STAND, () -> RenderWoodStand::new);
}

View file

@ -1,6 +1,6 @@
package de.ellpeck.naturesaura.blocks;
import net.minecraft.block.Block;
import net.minecraft.world.level.block.Block;
@SuppressWarnings("FieldNamingConvention")
public final class ModBlocks {

View file

@ -8,7 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.level.Level;
import java.util.HashMap;
import java.util.Map;
@ -83,11 +83,11 @@ public class Multiblock implements IMultiblock {
if (value instanceof BlockState) {
BlockState state = (BlockState) value;
matchers.put(c, new Matcher(state,
(world, start, offset, pos, other, otherC) -> other == state));
(level, start, offset, pos, other, otherC) -> other == state));
} else if (value instanceof Block) {
Block block = (Block) value;
matchers.put(c, new Matcher(block.getDefaultState(),
(world, start, offset, pos, state, otherC) -> state.getBlock() == block));
(level, start, offset, pos, state, otherC) -> state.getBlock() == block));
} else
matchers.put(c, (Matcher) value);
}
@ -107,11 +107,11 @@ public class Multiblock implements IMultiblock {
}
@Override
public boolean isComplete(World world, BlockPos center) {
public boolean isComplete(Level level, BlockPos center) {
BlockPos start = this.getStart(center);
return this.forEach(center, (char) 0, (pos, matcher) -> {
BlockPos offset = pos.subtract(start);
return matcher.getCheck().matches(world, start, offset, pos, world.getBlockState(pos), this.getChar(offset));
return matcher.getCheck().matches(level, start, offset, pos, level.getBlockState(pos), this.getChar(offset));
});
}

View file

@ -8,12 +8,12 @@ import de.ellpeck.naturesaura.blocks.BlockNatureAltar;
import de.ellpeck.naturesaura.blocks.ModBlocks;
import de.ellpeck.naturesaura.data.BlockTagProvider;
import de.ellpeck.naturesaura.recipes.ModRecipes;
import net.minecraft.block.Blocks;
import net.minecraft.block.SaplingBlock;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SaplingBlock;
import net.minecraft.world.level.material.Material;
public final class Multiblocks {
@ -38,23 +38,23 @@ public final class Multiblocks {
'B', Blocks.NETHER_BRICKS,
'W', Matcher.tag(Blocks.CRIMSON_PLANKS, BlockTagProvider.NETHER_ALTAR_WOOD),
'M', ModBlocks.GOLD_NETHER_BRICK,
'0', ModBlocks.NATURE_ALTAR.getDefaultState().with(BlockNatureAltar.NETHER, true),
'0', ModBlocks.NATURE_ALTAR.defaultBlockState().setValue(BlockNatureAltar.NETHER, true),
' ', Matcher.wildcard());
public static final IMultiblock TREE_RITUAL = NaturesAuraAPI.instance().createMultiblock(
new ResourceLocation(NaturesAura.MOD_ID, "tree_ritual"),
new String[][]{
{" W ", " W W ", " GGG ", " GG GG ", "W G 0 G W", " GG GG ", " GGG ", " W W ", " W "}},
'W', new Matcher(ModBlocks.WOOD_STAND.getDefaultState(),
(world, start, offset, pos, state, c) -> world != null || state.getBlock() == ModBlocks.WOOD_STAND),
'W', new Matcher(ModBlocks.WOOD_STAND.defaultBlockState(),
(level, start, offset, pos, state, c) -> level != null || state.getBlock() == ModBlocks.WOOD_STAND),
'G', ModBlocks.GOLD_POWDER,
'0', new Matcher(Blocks.OAK_SAPLING.getDefaultState(),
(world, start, offset, pos, state, c) -> {
'0', new Matcher(Blocks.OAK_SAPLING.defaultBlockState(),
(level, start, offset, pos, state, c) -> {
if (state.getBlock() instanceof SaplingBlock || state.getMaterial() == Material.WOOD)
return true;
// try-catch to prevent blocks that need to have been placed crashing here
try {
ItemStack stack = state.getBlock().getItem(world, pos, state);
return !stack.isEmpty() && world.getRecipeManager().getRecipes(ModRecipes.TREE_RITUAL_TYPE, null, null).stream().anyMatch(r -> r.saplingType.test(stack));
ItemStack stack = state.getBlock().getCloneItemStack(level, pos, state);
return !stack.isEmpty() && level.getRecipeManager().getRecipesFor(ModRecipes.TREE_RITUAL_TYPE, null, null).stream().anyMatch(r -> r.saplingType.test(stack));
} catch (Exception e) {
return false;
}
@ -76,8 +76,8 @@ public final class Multiblocks {
new ResourceLocation(NaturesAura.MOD_ID, "offering_table"),
new String[][]{
{" RRRRR ", " R R ", "R RRR R", "R R R R", "R R 0 R R", "R R R R", "R RRR R", " R R ", " RRRRR "}},
'R', new Matcher(Blocks.POPPY.getDefaultState(),
(world, start, offset, pos, state, c) -> BlockTags.SMALL_FLOWERS.contains(state.getBlock())),
'R', new Matcher(Blocks.POPPY.defaultBlockState(),
(level, start, offset, pos, state, c) -> BlockTags.SMALL_FLOWERS.contains(state.getBlock())),
'0', ModBlocks.OFFERING_TABLE,
' ', Matcher.wildcard());
public static final IMultiblock ANIMAL_SPAWNER = NaturesAuraAPI.instance().createMultiblock(

View file

@ -3,9 +3,11 @@ package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.container.NaturalAuraContainer;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.block.state.BlockState;
public class TileEntityAncientLeaves extends TileEntityImpl {
public class BlockEntityAncientLeaves extends BlockEntityImpl {
private final NaturalAuraContainer container = new NaturalAuraContainer(NaturesAuraAPI.TYPE_OVERWORLD, 2000, 500) {
@Override
@ -17,14 +19,14 @@ public class TileEntityAncientLeaves extends TileEntityImpl {
public int drainAura(int amountToDrain, boolean simulate) {
int amount = super.drainAura(amountToDrain, simulate);
if (amount > 0 && !simulate) {
TileEntityAncientLeaves.this.sendToClients();
BlockEntityAncientLeaves.this.sendToClients();
}
return amount;
}
};
public TileEntityAncientLeaves() {
super(ModTileEntities.ANCIENT_LEAVES);
public BlockEntityAncientLeaves(BlockPos pos, BlockState state) {
super(ModTileEntities.ANCIENT_LEAVES, pos, state);
}
@Override
@ -33,14 +35,14 @@ public class TileEntityAncientLeaves extends TileEntityImpl {
}
@Override
public void writeNBT(CompoundNBT compound, SaveType type) {
public void writeNBT(CompoundTag compound, SaveType type) {
super.writeNBT(compound, type);
if (type != SaveType.BLOCK)
this.container.writeNBT(compound);
}
@Override
public void readNBT(CompoundNBT compound, SaveType type) {
public void readNBT(CompoundTag compound, SaveType type) {
super.readNBT(compound, type);
if (type != SaveType.BLOCK)
this.container.readNBT(compound);

View file

@ -0,0 +1,51 @@
package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import java.util.HashSet;
import java.util.Set;
public class BlockEntityAnimalContainer extends BlockEntityImpl implements ITickableBlockEntity {
public BlockEntityAnimalContainer(BlockPos pos, BlockState state) {
super(ModTileEntities.ANIMAL_CONTAINER, pos, state);
}
public int getRadius() {
return this.redstonePower / 2;
}
@Override
public void onRedstonePowerChange(int newPower) {
super.onRedstonePowerChange(newPower);
this.sendToClients();
}
@Override
public void tick() {
if (this.level.isClientSide)
return;
var radius = this.getRadius();
Set<Animal> animalsInRange = new HashSet<>(this.level.getEntitiesOfClass(Animal.class, new AABB(this.worldPosition).inflate(radius - 1)));
var animalsOutRange = this.level.getEntitiesOfClass(Animal.class, new AABB(this.worldPosition).inflate(radius + 1));
for (var animal : animalsOutRange) {
if (animalsInRange.contains(animal))
continue;
var pos = animal.position();
var distance = pos.subtract(this.worldPosition.getX(), pos.y, this.worldPosition.getZ());
distance = distance.normalize().scale(-0.15F);
animal.setDeltaMovement(distance);
if (this.level.random.nextBoolean()) {
var eye = animal.getEyePosition(1).add(animal.getLookAngle());
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
new PacketParticles((float) eye.x, (float) eye.y, (float) eye.z, PacketParticles.Type.ANIMAL_CONTAINER));
}
}
}
}

View file

@ -1,24 +1,23 @@
package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
public class TileEntityAnimalGenerator extends TileEntityImpl implements ITickableTileEntity {
public class BlockEntityAnimalGenerator extends BlockEntityImpl implements ITickableBlockEntity {
private int timeRemaining;
private int amountToRelease;
public TileEntityAnimalGenerator() {
super(ModTileEntities.ANIMAL_GENERATOR);
public BlockEntityAnimalGenerator(BlockPos pos, BlockState state) {
super(ModTileEntities.ANIMAL_GENERATOR, pos, state);
}
@Override
public void tick() {
if (!this.world.isRemote) {
if (this.world.getGameTime() % 10 != 0)
if (!this.level.isClientSide) {
if (this.level.getGameTime() % 10 != 0)
return;
if (this.timeRemaining <= 0)
return;
@ -26,8 +25,8 @@ public class TileEntityAnimalGenerator extends TileEntityImpl implements ITickab
int remain = this.amountToRelease;
if (this.canGenerateRightNow(remain)) {
this.generateAura(remain);
PacketHandler.sendToAllAround(this.world, this.pos, 32,
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.ANIMAL_GEN_CREATE));
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.ANIMAL_GEN_CREATE));
}
this.timeRemaining -= 10;

View file

@ -9,22 +9,22 @@ import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe;
import de.ellpeck.naturesaura.recipes.ModRecipes;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickableTileEntity {
public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickableBlockEntity {
private AnimalSpawnerRecipe currentRecipe;
private double spawnX;
@ -32,16 +32,16 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
private int time;
private Entity entityClient;
public TileEntityAnimalSpawner() {
super(ModTileEntities.ANIMAL_SPAWNER);
public BlockEntityAnimalSpawner(BlockPos pos, BlockState state) {
super(ModTileEntities.ANIMAL_SPAWNER, pos, state);
}
@Override
public void tick() {
if (!this.world.isRemote) {
if (this.world.getGameTime() % 10 != 0)
if (!this.level.isClientSide) {
if (this.level.getGameTime() % 10 != 0)
return;
if (!Multiblocks.ANIMAL_SPAWNER.isComplete(this.world, this.pos)) {
if (!Multiblocks.ANIMAL_SPAWNER.isComplete(this.level, this.worldPosition)) {
if (this.currentRecipe != null) {
this.currentRecipe = null;
this.time = 0;
@ -51,29 +51,29 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
}
if (this.currentRecipe != null) {
int drain = MathHelper.ceil(this.currentRecipe.aura / (float) this.currentRecipe.time * 10F);
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 35, this.pos);
IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, drain);
int drain = Mth.ceil(this.currentRecipe.aura / (float) this.currentRecipe.time * 10F);
BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, drain);
this.time += 10;
if (this.time >= this.currentRecipe.time) {
Entity entity = this.currentRecipe.makeEntity(this.world, new BlockPos(this.spawnX, this.pos.getY() + 1, this.spawnZ));
this.world.addEntity(entity);
Entity entity = this.currentRecipe.makeEntity(this.level, new BlockPos(this.spawnX, this.worldPosition.getY() + 1, this.spawnZ));
this.level.addFreshEntity(entity);
this.currentRecipe = null;
this.time = 0;
this.sendToClients();
}
} else {
List<ItemEntity> items = this.world.getEntitiesWithinAABB(ItemEntity.class,
new AxisAlignedBB(this.pos).grow(2));
List<ItemEntity> items = this.level.getEntitiesOfClass(ItemEntity.class,
new AABB(this.worldPosition).inflate(2));
for (AnimalSpawnerRecipe recipe : this.world.getRecipeManager().getRecipes(ModRecipes.ANIMAL_SPAWNER_TYPE, null, null)) {
for (AnimalSpawnerRecipe recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE, null, null)) {
if (recipe.ingredients.length != items.size())
continue;
List<Ingredient> required = new ArrayList<>(Arrays.asList(recipe.ingredients));
for (ItemEntity item : items) {
if (!item.isAlive() || item.cannotPickup())
if (!item.isAlive() || item.hasPickUpDelay())
break;
ItemStack stack = item.getItem();
if (stack.isEmpty())
@ -89,20 +89,20 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
continue;
for (ItemEntity item : items) {
item.remove();
PacketHandler.sendToAllAround(this.world, this.pos, 32,
new PacketParticles((float) item.getPosX(), (float) item.getPosY(), (float) item.getPosZ(), PacketParticles.Type.ANIMAL_SPAWNER));
item.remove(Entity.RemovalReason.KILLED);
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.ANIMAL_SPAWNER));
}
this.currentRecipe = recipe;
this.spawnX = this.pos.getX() + 0.5 + this.world.rand.nextFloat() * 4 - 2;
this.spawnZ = this.pos.getZ() + 0.5 + this.world.rand.nextFloat() * 4 - 2;
this.spawnX = this.worldPosition.getX() + 0.5 + this.level.random.nextFloat() * 4 - 2;
this.spawnZ = this.worldPosition.getZ() + 0.5 + this.level.random.nextFloat() * 4 - 2;
this.sendToClients();
break;
}
}
} else {
if (this.world.getGameTime() % 5 != 0)
if (this.level.getGameTime() % 5 != 0)
return;
if (this.currentRecipe == null) {
this.entityClient = null;
@ -110,32 +110,32 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
}
NaturesAuraAPI.instance().spawnParticleStream(
this.pos.getX() + (float) this.world.rand.nextGaussian() * 5F,
this.pos.getY() + 1 + this.world.rand.nextFloat() * 5F,
this.pos.getZ() + (float) this.world.rand.nextGaussian() * 5F,
this.pos.getX() + this.world.rand.nextFloat(),
this.pos.getY() + this.world.rand.nextFloat(),
this.pos.getZ() + this.world.rand.nextFloat(),
this.world.rand.nextFloat() * 0.07F + 0.07F,
IAuraType.forWorld(this.world).getColor(),
this.world.rand.nextFloat() + 0.5F);
this.worldPosition.getX() + (float) this.level.random.nextGaussian() * 5F,
this.worldPosition.getY() + 1 + this.level.random.nextFloat() * 5F,
this.worldPosition.getZ() + (float) this.level.random.nextGaussian() * 5F,
this.worldPosition.getX() + this.level.random.nextFloat(),
this.worldPosition.getY() + this.level.random.nextFloat(),
this.worldPosition.getZ() + this.level.random.nextFloat(),
this.level.random.nextFloat() * 0.07F + 0.07F,
IAuraType.forLevel(this.level).getColor(),
this.level.random.nextFloat() + 0.5F);
if (this.entityClient == null) {
this.entityClient = this.currentRecipe.makeEntity(this.world, BlockPos.ZERO);
this.entityClient.setPosition(this.spawnX, this.pos.getY() + 1, this.spawnZ);
this.entityClient = this.currentRecipe.makeEntity(this.level, BlockPos.ZERO);
this.entityClient.setPos(this.spawnX, this.worldPosition.getY() + 1, this.spawnZ);
}
AxisAlignedBB bounds = this.entityClient.getBoundingBox();
for (int i = this.world.rand.nextInt(5) + 5; i >= 0; i--)
AABB bounds = this.entityClient.getBoundingBox();
for (int i = this.level.random.nextInt(5) + 5; i >= 0; i--)
NaturesAuraAPI.instance().spawnMagicParticle(
bounds.minX + this.world.rand.nextFloat() * (bounds.maxX - bounds.minX),
bounds.minY + this.world.rand.nextFloat() * (bounds.maxY - bounds.minY),
bounds.minZ + this.world.rand.nextFloat() * (bounds.maxZ - bounds.minZ),
bounds.minX + this.level.random.nextFloat() * (bounds.maxX - bounds.minX),
bounds.minY + this.level.random.nextFloat() * (bounds.maxY - bounds.minY),
bounds.minZ + this.level.random.nextFloat() * (bounds.maxZ - bounds.minZ),
0F, 0F, 0F, 0x2fd8d3, 2F, 60, 0F, false, true);
}
}
@Override
public void writeNBT(CompoundNBT compound, SaveType type) {
public void writeNBT(CompoundTag compound, SaveType type) {
super.writeNBT(compound, type);
if (type != SaveType.BLOCK) {
if (this.currentRecipe != null) {
@ -148,13 +148,13 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
}
@Override
public void readNBT(CompoundNBT compound, SaveType type) {
public void readNBT(CompoundTag compound, SaveType type) {
super.readNBT(compound, type);
if (type != SaveType.BLOCK) {
if (compound.contains("recipe")) {
if (this.hasWorld()) {
if (this.hasLevel()) {
ResourceLocation name = new ResourceLocation(compound.getString("recipe"));
this.currentRecipe = (AnimalSpawnerRecipe) this.world.getRecipeManager().getRecipe(name).orElse(null);
this.currentRecipe = (AnimalSpawnerRecipe) this.level.getRecipeManager().byKey(name).orElse(null);
}
this.spawnX = compound.getDouble("spawn_x");
this.spawnZ = compound.getDouble("spawn_z");

View file

@ -4,19 +4,18 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.blocks.ModBlocks;
import net.minecraft.block.BlockState;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.Connection;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
@ -24,40 +23,37 @@ import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import javax.annotation.Nullable;
import java.util.stream.Stream;
public class TileEntityImpl extends TileEntity {
public class BlockEntityImpl extends BlockEntity {
public int redstonePower;
private LazyOptional<IItemHandler> itemHandler;
private LazyOptional<IAuraContainer> auraContainer;
public TileEntityImpl(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
public BlockEntityImpl(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
}
@Override
public CompoundNBT write(CompoundNBT compound) {
public void saveAdditional(CompoundTag compound) {
this.writeNBT(compound, SaveType.TILE);
return compound;
}
@Override
public void read(BlockState state, CompoundNBT compound) {
public void load(CompoundTag compound) {
this.readNBT(compound, SaveType.TILE);
}
public void writeNBT(CompoundNBT compound, SaveType type) {
public void writeNBT(CompoundTag compound, SaveType type) {
if (type != SaveType.BLOCK) {
super.write(compound);
super.saveAdditional(compound);
compound.putInt("redstone", this.redstonePower);
}
}
public void readNBT(CompoundNBT compound, SaveType type) {
public void readNBT(CompoundTag compound, SaveType type) {
if (type != SaveType.BLOCK) {
// looks like the block state isn't used in the super
super.read(null, compound);
super.load(compound);
this.redstonePower = compound.getInt("redstone");
}
}
@ -67,36 +63,38 @@ public class TileEntityImpl extends TileEntity {
}
@Override
public final SUpdateTileEntityPacket getUpdatePacket() {
CompoundNBT compound = new CompoundNBT();
public final ClientboundBlockEntityDataPacket getUpdatePacket() {
return ClientboundBlockEntityDataPacket.create(this, e -> {
CompoundTag compound = new CompoundTag();
this.writeNBT(compound, SaveType.SYNC);
return new SUpdateTileEntityPacket(this.pos, 0, compound);
return compound;
});
}
@Override
public final CompoundNBT getUpdateTag() {
CompoundNBT compound = new CompoundNBT();
public final CompoundTag getUpdateTag() {
CompoundTag compound = new CompoundTag();
this.writeNBT(compound, SaveType.SYNC);
return compound;
}
@Override
public void handleUpdateTag(BlockState state, CompoundNBT tag) {
public void handleUpdateTag(CompoundTag tag) {
this.readNBT(tag, SaveType.SYNC);
}
@Override
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket packet) {
super.onDataPacket(net, packet);
this.readNBT(packet.getNbtCompound(), SaveType.SYNC);
public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) {
super.onDataPacket(net, pkt);
this.readNBT(pkt.getTag(), SaveType.SYNC);
}
public void sendToClients() {
ServerWorld world = (ServerWorld) this.getWorld();
Stream<ServerPlayerEntity> entities = world.getChunkProvider().chunkManager.getTrackingPlayers(new ChunkPos(this.getPos()), false);
SUpdateTileEntityPacket packet = this.getUpdatePacket();
entities.forEach(e -> e.connection.sendPacket(packet));
var world = (ServerLevel) this.getLevel();
var entities = world.getChunkSource().chunkMap.getPlayers(new ChunkPos(this.getBlockPos()), false);
ClientboundBlockEntityDataPacket packet = this.getUpdatePacket();
for (var e : entities)
e.connection.send(packet);
}
public IItemHandlerModifiable getItemHandler() {
@ -128,8 +126,8 @@ public class TileEntityImpl extends TileEntity {
}
@Override
public void remove() {
super.remove();
public void setRemoved() {
super.setRemoved();
if (this.itemHandler != null)
this.itemHandler.invalidate();
if (this.auraContainer != null)
@ -142,40 +140,36 @@ public class TileEntityImpl extends TileEntity {
for (int i = 0; i < handler.getSlots(); i++) {
ItemStack stack = handler.getStackInSlot(i);
if (!stack.isEmpty()) {
ItemEntity item = new ItemEntity(this.world,
this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5,
stack);
this.world.addEntity(item);
ItemEntity item = new ItemEntity(this.level, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 0.5, this.worldPosition.getZ() + 0.5, stack);
this.level.addFreshEntity(item);
}
}
}
}
public void modifyDrop(ItemStack regularItem) {
CompoundNBT compound = new CompoundNBT();
CompoundTag compound = new CompoundTag();
this.writeNBT(compound, SaveType.BLOCK);
if (!compound.isEmpty()) {
if (!regularItem.hasTag())
regularItem.setTag(new CompoundNBT());
if (!regularItem.hasTag()) regularItem.setTag(new CompoundTag());
regularItem.getTag().put("data", compound);
}
}
public void loadDataOnPlace(ItemStack stack) {
if (stack.hasTag()) {
CompoundNBT compound = stack.getTag().getCompound("data");
if (compound != null)
this.readNBT(compound, SaveType.BLOCK);
CompoundTag compound = stack.getTag().getCompound("data");
if (compound != null) this.readNBT(compound, SaveType.BLOCK);
}
}
public boolean canGenerateRightNow(int toAdd) {
if (this.wantsLimitRemover()) {
BlockState below = this.world.getBlockState(this.pos.down());
BlockState below = this.level.getBlockState(this.worldPosition.below());
if (below.getBlock() == ModBlocks.GENERATOR_LIMIT_REMOVER)
return true;
}
int aura = IAuraChunk.getAuraInArea(this.world, this.pos, 35);
int aura = IAuraChunk.getAuraInArea(this.level, this.worldPosition, 35);
return aura + toAdd <= IAuraChunk.DEFAULT_AURA * 2;
}
@ -185,14 +179,12 @@ public class TileEntityImpl extends TileEntity {
public void generateAura(int amount) {
while (amount > 0) {
BlockPos spot = IAuraChunk.getLowestSpot(this.world, this.pos, 35, this.pos);
amount -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, amount);
BlockPos spot = IAuraChunk.getLowestSpot(this.level, this.worldPosition, 35, this.worldPosition);
amount -= IAuraChunk.getAuraChunk(this.level, spot).storeAura(spot, amount);
}
}
public enum SaveType {
TILE,
SYNC,
BLOCK
TILE, SYNC, BLOCK
}
}

View file

@ -5,21 +5,20 @@ import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticleStream;
import de.ellpeck.naturesaura.packet.PacketParticles;
import de.ellpeck.naturesaura.recipes.TreeRitualRecipe;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.LeavesBlock;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.BlockTags;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemStackHandler;
@ -27,7 +26,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class TileEntityWoodStand extends TileEntityImpl implements ITickableTileEntity {
public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBlockEntity {
public final ItemStackHandler items = new ItemStackHandlerNA(1, this, true) {
@Override
@ -40,8 +39,8 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
private BlockPos ritualPos;
private int timer;
public TileEntityWoodStand() {
super(ModTileEntities.WOOD_STAND);
public BlockEntityWoodStand(BlockPos pos, BlockState state) {
super(ModTileEntities.WOOD_STAND, pos, state);
}
public void setRitual(BlockPos pos, TreeRitualRecipe recipe) {
@ -51,9 +50,9 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
@Override
public void tick() {
if (!this.world.isRemote) {
if (!this.level.isClientSide) {
if (this.ritualPos != null && this.recipe != null) {
if (this.world.getGameTime() % 5 == 0) {
if (this.level.getGameTime() % 5 == 0) {
if (this.isRitualOkay()) {
boolean wasOverHalf = this.timer >= this.recipe.time / 2;
this.timer += 5;
@ -61,57 +60,54 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
if (!isOverHalf)
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> {
TileEntity tile = this.world.getTileEntity(pos);
if (tile instanceof TileEntityWoodStand && !((TileEntityWoodStand) tile).items.getStackInSlot(0).isEmpty()) {
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
(float) pos.getX() + 0.2F + this.world.rand.nextFloat() * 0.6F,
BlockEntity tile = this.level.getBlockEntity(pos);
if (tile instanceof BlockEntityWoodStand && !((BlockEntityWoodStand) tile).items.getStackInSlot(0).isEmpty()) {
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream(
(float) pos.getX() + 0.2F + this.level.random.nextFloat() * 0.6F,
(float) pos.getY() + 0.85F,
(float) pos.getZ() + 0.2F + this.world.rand.nextFloat() * 0.6F,
this.ritualPos.getX() + 0.5F, this.ritualPos.getY() + this.world.rand.nextFloat() * 3F + 2F, this.ritualPos.getZ() + 0.5F,
this.world.rand.nextFloat() * 0.04F + 0.04F, 0x89cc37, this.world.rand.nextFloat() * 1F + 1F
(float) pos.getZ() + 0.2F + this.level.random.nextFloat() * 0.6F,
this.ritualPos.getX() + 0.5F, this.ritualPos.getY() + this.level.random.nextFloat() * 3F + 2F, this.ritualPos.getZ() + 0.5F,
this.level.random.nextFloat() * 0.04F + 0.04F, 0x89cc37, this.level.random.nextFloat() + 1F
));
}
return true;
});
PacketHandler.sendToAllAround(this.world, this.ritualPos, 32,
PacketHandler.sendToAllAround(this.level, this.ritualPos, 32,
new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), PacketParticles.Type.TR_GOLD_POWDER));
if (this.timer >= this.recipe.time) {
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'G', (pos, matcher) -> {
this.world.setBlockState(pos, Blocks.AIR.getDefaultState());
this.level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
return true;
});
recurseTreeDestruction(this.world, this.ritualPos, this.ritualPos, true, false);
recurseTreeDestruction(this.level, this.ritualPos, this.ritualPos, true, false);
ItemEntity item = new ItemEntity(this.world,
ItemEntity item = new ItemEntity(this.level,
this.ritualPos.getX() + 0.5, this.ritualPos.getY() + 4.5, this.ritualPos.getZ() + 0.5,
this.recipe.result.copy());
this.world.addEntity(item);
this.level.addFreshEntity(item);
PacketHandler.sendToAllAround(this.world, this.pos, 32,
new PacketParticles((float) item.getPosX(), (float) item.getPosY(), (float) item.getPosZ(), PacketParticles.Type.TR_SPAWN_RESULT));
this.world.playSound(null, this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5,
SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 0.65F, 1F);
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.TR_SPAWN_RESULT));
this.level.playSound(null, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 0.5, this.worldPosition.getZ() + 0.5,
SoundEvents.ENDERMAN_TELEPORT, SoundSource.BLOCKS, 0.65F, 1F);
this.ritualPos = null;
this.recipe = null;
this.timer = 0;
} else if (isOverHalf && !wasOverHalf) {
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> {
TileEntity tile = this.world.getTileEntity(pos);
if (tile instanceof TileEntityWoodStand) {
TileEntityWoodStand stand = (TileEntityWoodStand) tile;
if (!stand.items.getStackInSlot(0).isEmpty()) {
PacketHandler.sendToAllAround(this.world, this.pos, 32,
new PacketParticles(stand.pos.getX(), stand.pos.getY(), stand.pos.getZ(), PacketParticles.Type.TR_CONSUME_ITEM));
this.world.playSound(null, stand.pos.getX() + 0.5, stand.pos.getY() + 0.5, stand.pos.getZ() + 0.5,
SoundEvents.BLOCK_WOOD_STEP, SoundCategory.BLOCKS, 0.5F, 1F);
BlockEntity tile = this.level.getBlockEntity(pos);
if (tile instanceof BlockEntityWoodStand stand && !stand.items.getStackInSlot(0).isEmpty()) {
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
new PacketParticles(stand.worldPosition.getX(), stand.worldPosition.getY(), stand.worldPosition.getZ(), PacketParticles.Type.TR_CONSUME_ITEM));
this.level.playSound(null, stand.worldPosition.getX() + 0.5, stand.worldPosition.getY() + 0.5, stand.worldPosition.getZ() + 0.5,
SoundEvents.WOOD_STEP, SoundSource.BLOCKS, 0.5F, 1F);
stand.items.setStackInSlot(0, ItemStack.EMPTY);
stand.sendToClients();
}
}
return true;
});
}
@ -126,7 +122,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
}
public static void recurseTreeDestruction(World world, BlockPos pos, BlockPos start, boolean includeLeaves, boolean drop) {
public static void recurseTreeDestruction(Level level, BlockPos pos, BlockPos start, boolean includeLeaves, boolean drop) {
if (Math.abs(pos.getX() - start.getX()) >= 6
|| Math.abs(pos.getZ() - start.getZ()) >= 6
|| Math.abs(pos.getY() - start.getY()) >= 32) {
@ -136,17 +132,17 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
for (int z = -1; z <= 1; z++) {
BlockPos offset = pos.add(x, y, z);
BlockState state = world.getBlockState(offset);
BlockPos offset = pos.offset(x, y, z);
BlockState state = level.getBlockState(offset);
if (state.getBlock().getTags().contains(BlockTags.LOGS.getName()) || includeLeaves && state.getBlock() instanceof LeavesBlock) {
if (drop) {
world.destroyBlock(offset, true);
level.destroyBlock(offset, true);
} else {
// in this case we don't want the particles, so we can't use destroyBlock
world.setBlockState(offset, Blocks.AIR.getDefaultState());
PacketHandler.sendToAllAround(world, pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), PacketParticles.Type.TR_DISAPPEAR));
level.setBlockAndUpdate(offset, Blocks.AIR.defaultBlockState());
PacketHandler.sendToAllAround(level, pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), PacketParticles.Type.TR_DISAPPEAR));
}
recurseTreeDestruction(world, offset, start, includeLeaves, drop);
recurseTreeDestruction(level, offset, start, includeLeaves, drop);
}
}
}
@ -154,20 +150,20 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
}
private boolean isRitualOkay() {
if (!Multiblocks.TREE_RITUAL.isComplete(this.world, this.ritualPos)) {
if (!Multiblocks.TREE_RITUAL.isComplete(this.level, this.ritualPos)) {
return false;
}
for (int i = 0; i < 2; i++) {
BlockState state = this.world.getBlockState(this.ritualPos.up(i));
BlockState state = this.level.getBlockState(this.ritualPos.above(i));
if (!(state.getBlock().getTags().contains(BlockTags.LOGS.getName())))
return false;
}
if (this.timer < this.recipe.time / 2) {
List<Ingredient> required = new ArrayList<>(Arrays.asList(this.recipe.ingredients));
boolean fine = Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> {
TileEntity tile = this.world.getTileEntity(pos);
if (tile instanceof TileEntityWoodStand) {
ItemStack stack = ((TileEntityWoodStand) tile).items.getStackInSlot(0);
BlockEntity tile = this.level.getBlockEntity(pos);
if (tile instanceof BlockEntityWoodStand) {
ItemStack stack = ((BlockEntityWoodStand) tile).items.getStackInSlot(0);
if (!stack.isEmpty()) {
for (int i = required.size() - 1; i >= 0; i--) {
Ingredient req = required.get(i);
@ -187,14 +183,14 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
}
@Override
public void writeNBT(CompoundNBT compound, SaveType type) {
public void writeNBT(CompoundTag compound, SaveType type) {
super.writeNBT(compound, type);
if (type != SaveType.BLOCK)
compound.put("items", this.items.serializeNBT());
if (type == SaveType.TILE) {
if (this.ritualPos != null && this.recipe != null) {
compound.putLong("ritual_pos", this.ritualPos.toLong());
compound.putLong("ritual_pos", this.ritualPos.asLong());
compound.putInt("timer", this.timer);
compound.putString("recipe", this.recipe.name.toString());
}
@ -202,17 +198,17 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
}
@Override
public void readNBT(CompoundNBT compound, SaveType type) {
public void readNBT(CompoundTag compound, SaveType type) {
super.readNBT(compound, type);
if (type != SaveType.BLOCK)
this.items.deserializeNBT(compound.getCompound("items"));
if (type == SaveType.TILE) {
if (compound.contains("recipe")) {
this.ritualPos = BlockPos.fromLong(compound.getLong("ritual_pos"));
this.ritualPos = BlockPos.of(compound.getLong("ritual_pos"));
this.timer = compound.getInt("timer");
if (this.hasWorld())
this.recipe = (TreeRitualRecipe) this.world.getRecipeManager().getRecipe(new ResourceLocation(compound.getString("recipe"))).orElse(null);
if (this.hasLevel())
this.recipe = (TreeRitualRecipe) this.level.getRecipeManager().byKey(new ResourceLocation(compound.getString("recipe"))).orElse(null);
}
}
}

View file

@ -0,0 +1,7 @@
package de.ellpeck.naturesaura.blocks.tiles;
public interface ITickableBlockEntity {
void tick();
}

View file

@ -7,14 +7,14 @@ import javax.annotation.Nonnull;
public class ItemStackHandlerNA extends ItemStackHandler {
private final TileEntityImpl tile;
private final BlockEntityImpl tile;
private final boolean sendToClients;
public ItemStackHandlerNA(int size) {
this(size, null, false);
}
public ItemStackHandlerNA(int size, TileEntityImpl tile, boolean sendToClients) {
public ItemStackHandlerNA(int size, BlockEntityImpl tile, boolean sendToClients) {
super(size);
this.tile = tile;
this.sendToClients = sendToClients;
@ -24,7 +24,7 @@ public class ItemStackHandlerNA extends ItemStackHandler {
protected void onContentsChanged(int slot) {
if (this.tile != null) {
this.tile.markDirty();
if (this.sendToClients && !this.tile.getWorld().isRemote)
if (this.sendToClients && !this.tile.getLevel().isClientSide)
this.tile.sendToClients();
}
}

View file

@ -1,45 +1,46 @@
package de.ellpeck.naturesaura.blocks.tiles;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.world.level.block.entity.BlockEntityType;
@SuppressWarnings("FieldNamingConvention")
public final class ModTileEntities {
public static TileEntityType<TileEntityAncientLeaves> ANCIENT_LEAVES;
public static TileEntityType<TileEntityAnimalGenerator> ANIMAL_GENERATOR;
public static TileEntityType<TileEntityAnimalSpawner> ANIMAL_SPAWNER;
public static TileEntityType<TileEntityAuraDetector> AURA_DETECTOR;
public static TileEntityType<TileEntityAutoCrafter> AUTO_CRAFTER;
public static TileEntityType<TileEntityChunkLoader> CHUNK_LOADER;
public static TileEntityType<TileEntityEnderCrate> ENDER_CRATE;
public static TileEntityType<TileEntityEndFlower> END_FLOWER;
public static TileEntityType<TileEntityFieldCreator> FIELD_CREATOR;
public static TileEntityType<TileEntityFireworkGenerator> FIREWORK_GENERATOR;
public static TileEntityType<TileEntityFlowerGenerator> FLOWER_GENERATOR;
public static TileEntityType<TileEntityFurnaceHeater> FURNACE_HEATER;
public static TileEntityType<TileEntityGeneratorLimitRemover> GENERATOR_LIMIT_REMOVER;
public static TileEntityType<TileEntityGratedChute> GRATED_CHUTE;
public static TileEntityType<TileEntityHopperUpgrade> HOPPER_UPGRADE;
public static TileEntityType<TileEntityMossGenerator> MOSS_GENERATOR;
public static TileEntityType<TileEntityNatureAltar> NATURE_ALTAR;
public static TileEntityType<TileEntityOakGenerator> OAK_GENERATOR;
public static TileEntityType<TileEntityOfferingTable> OFFERING_TABLE;
public static TileEntityType<TileEntityPickupStopper> PICKUP_STOPPER;
public static TileEntityType<TileEntityPlacer> PLACER;
public static TileEntityType<TileEntityPotionGenerator> POTION_GENERATOR;
public static TileEntityType<TileEntityPowderPlacer> POWDER_PLACER;
public static TileEntityType<TileEntityProjectileGenerator> PROJECTILE_GENERATOR;
public static TileEntityType<TileEntityRFConverter> RF_CONVERTER;
public static TileEntityType<TileEntitySpawnLamp> SPAWN_LAMP;
public static TileEntityType<TileEntityTimeChanger> TIME_CHANGER;
public static TileEntityType<TileEntityWoodStand> WOOD_STAND;
public static TileEntityType<TileEntityBlastFurnaceBooster> BLAST_FURNACE_BOOSTER;
public static TileEntityType<TileEntityAnimalContainer> ANIMAL_CONTAINER;
public static TileEntityType<TileEntitySnowCreator> SNOW_CREATOR;
public static TileEntityType<TileEntityItemDistributor> ITEM_DISTRIBUTOR;
public static TileEntityType<TileEntityAuraBloom> AURA_BLOOM;
public static TileEntityType<TileEntityChorusGenerator> CHORUS_GENERATOR;
public static TileEntityType<TileEntityAuraTimer> AURA_TIMER;
public static TileEntityType<TileEntitySlimeSplitGenerator> SLIME_SPLIT_GENERATOR;
public static TileEntityType<TileEntitySpring> SPRING;
public static TileEntityType<TileEntityWeatherChanger> WEATHER_CHANGER;
public static BlockEntityType<BlockEntityAncientLeaves> ANCIENT_LEAVES;
public static BlockEntityType<BlockEntityAnimalGenerator> ANIMAL_GENERATOR;
public static BlockEntityType<BlockEntityAnimalSpawner> ANIMAL_SPAWNER;
public static BlockEntityType<BlockEntityAuraDetector> AURA_DETECTOR;
public static BlockEntityType<BlockEntityAutoCrafter> AUTO_CRAFTER;
public static BlockEntityType<BlockEntityChunkLoader> CHUNK_LOADER;
public static BlockEntityType<BlockEntityEnderCrate> ENDER_CRATE;
public static BlockEntityType<BlockEntityEndFlower> END_FLOWER;
public static BlockEntityType<BlockEntityFieldCreator> FIELD_CREATOR;
public static BlockEntityType<BlockEntityFireworkGenerator> FIREWORK_GENERATOR;
public static BlockEntityType<BlockEntityFlowerGenerator> FLOWER_GENERATOR;
public static BlockEntityType<BlockEntityFurnaceHeater> FURNACE_HEATER;
public static BlockEntityType<BlockEntityGeneratorLimitRemover> GENERATOR_LIMIT_REMOVER;
public static BlockEntityType<BlockEntityGratedChute> GRATED_CHUTE;
public static BlockEntityType<BlockEntityHopperUpgrade> HOPPER_UPGRADE;
public static BlockEntityType<BlockEntityMossGenerator> MOSS_GENERATOR;
public static BlockEntityType<BlockEntityNatureAltar> NATURE_ALTAR;
public static BlockEntityType<BlockEntityOakGenerator> OAK_GENERATOR;
public static BlockEntityType<BlockEntityOfferingTable> OFFERING_TABLE;
public static BlockEntityType<BlockEntityPickupStopper> PICKUP_STOPPER;
public static BlockEntityType<BlockEntityPlacer> PLACER;
public static BlockEntityType<BlockEntityPotionGenerator> POTION_GENERATOR;
public static BlockEntityType<BlockEntityPowderPlacer> POWDER_PLACER;
public static BlockEntityType<BlockEntityProjectileGenerator> PROJECTILE_GENERATOR;
public static BlockEntityType<BlockEntityRFConverter> RF_CONVERTER;
public static BlockEntityType<BlockEntitySpawnLamp> SPAWN_LAMP;
public static BlockEntityType<BlockEntityTimeChanger> TIME_CHANGER;
public static BlockEntityType<BlockEntityWoodStand> WOOD_STAND;
public static BlockEntityType<BlockEntityBlastFurnaceBooster> BLAST_FURNACE_BOOSTER;
public static BlockEntityType<BlockEntityAnimalContainer> ANIMAL_CONTAINER;
public static BlockEntityType<BlockEntitySnowCreator> SNOW_CREATOR;
public static BlockEntityType<BlockEntityItemDistributor> ITEM_DISTRIBUTOR;
public static BlockEntityType<BlockEntityAuraBloom> AURA_BLOOM;
public static BlockEntityType<BlockEntityChorusGenerator> CHORUS_GENERATOR;
public static BlockEntityType<BlockEntityAuraTimer> AURA_TIMER;
public static BlockEntityType<BlockEntitySlimeSplitGenerator> SLIME_SPLIT_GENERATOR;
public static BlockEntityType<BlockEntitySpring> SPRING;
public static BlockEntityType<BlockEntityWeatherChanger> WEATHER_CHANGER;
}

View file

@ -1,52 +0,0 @@
package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.vector.Vector3d;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class TileEntityAnimalContainer extends TileEntityImpl implements ITickableTileEntity {
public TileEntityAnimalContainer() {
super(ModTileEntities.ANIMAL_CONTAINER);
}
public int getRadius() {
return this.redstonePower / 2;
}
@Override
public void onRedstonePowerChange(int newPower) {
super.onRedstonePowerChange(newPower);
this.sendToClients();
}
@Override
public void tick() {
if (this.world.isRemote)
return;
int radius = this.getRadius();
Set<AnimalEntity> animalsInRange = new HashSet<>(this.world.getEntitiesWithinAABB(AnimalEntity.class, new AxisAlignedBB(this.pos).grow(radius - 1)));
List<AnimalEntity> animalsOutRange = this.world.getEntitiesWithinAABB(AnimalEntity.class, new AxisAlignedBB(this.pos).grow(radius + 1));
for (AnimalEntity animal : animalsOutRange) {
if (animalsInRange.contains(animal))
continue;
Vector3d pos = animal.getPositionVec();
Vector3d distance = pos.subtract(this.pos.getX(), pos.getY(), this.pos.getZ());
distance = distance.normalize().scale(-0.15F);
animal.setMotion(distance);
if (this.world.rand.nextBoolean()) {
Vector3d eye = animal.getEyePosition(1).add(animal.getLookVec());
PacketHandler.sendToAllAround(this.world, this.pos, 32,
new PacketParticles((float) eye.getX(), (float) eye.getY(), (float) eye.getZ(), PacketParticles.Type.ANIMAL_CONTAINER));
}
}
}
}

View file

@ -1,40 +1,40 @@
package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.tileentity.ITickableBlockEntity;
import net.minecraft.tileentity.BlockEntityType;
public class TileEntityAuraBloom extends TileEntityImpl implements ITickableTileEntity {
public class BlockEntityAuraBloom extends BlockEntityImpl implements ITickableBlockEntity {
public boolean justGenerated;
public TileEntityAuraBloom() {
public BlockEntityAuraBloom() {
this(ModTileEntities.AURA_BLOOM);
}
protected TileEntityAuraBloom(TileEntityType<TileEntityAuraBloom> type) {
protected BlockEntityAuraBloom(BlockEntityType<BlockEntityAuraBloom> type) {
super(type);
}
// Doing this in validate() creates a loading deadlock for some reason...
@Override
public void tick() {
if (this.world.isRemote || !this.justGenerated)
if (this.level.isClientSide || !this.justGenerated)
return;
this.generateAura(150000);
this.justGenerated = false;
}
@Override
public void writeNBT(CompoundNBT compound, SaveType type) {
public void writeNBT(CompoundTag compound, SaveType type) {
super.writeNBT(compound, type);
if (type == SaveType.TILE)
compound.putBoolean("just_generated", this.justGenerated);
}
@Override
public void readNBT(CompoundNBT compound, SaveType type) {
public void readNBT(CompoundTag compound, SaveType type) {
super.readNBT(compound, type);
if (type == SaveType.TILE)
this.justGenerated = compound.getBoolean("just_generated");

View file

@ -1,25 +1,25 @@
package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.util.math.MathHelper;
import net.minecraft.tileentity.ITickableBlockEntity;
import net.minecraft.util.math.Mth;
public class TileEntityAuraDetector extends TileEntityImpl implements ITickableTileEntity {
public class BlockEntityAuraDetector extends BlockEntityImpl implements ITickableBlockEntity {
public int redstonePower;
public TileEntityAuraDetector() {
public BlockEntityAuraDetector() {
super(ModTileEntities.AURA_DETECTOR);
}
@Override
public void tick() {
if (!this.world.isRemote && this.world.getGameTime() % 20 == 0) {
int totalAmount = IAuraChunk.triangulateAuraInArea(this.world, this.pos, 25);
int power = MathHelper.clamp(MathHelper.ceil(totalAmount / (IAuraChunk.DEFAULT_AURA * 2F) * 15F), 0, 15);
if (!this.level.isClientSide && this.level.getGameTime() % 20 == 0) {
int totalAmount = IAuraChunk.triangulateAuraInArea(this.level, this.worldPosition, 25);
int power = Mth.clamp(Mth.ceil(totalAmount / (IAuraChunk.DEFAULT_AURA * 2F) * 15F), 0, 15);
if (this.redstonePower != power) {
this.redstonePower = power;
this.world.updateComparatorOutputLevel(this.pos, this.getBlockState().getBlock());
this.level.updateComparatorOutputLevel(this.worldPosition, this.getBlockState().getBlock());
}
}
}

View file

@ -9,14 +9,14 @@ import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.ITickableBlockEntity;
import net.minecraftforge.items.IItemHandlerModifiable;
import java.util.Map;
public class TileEntityAuraTimer extends TileEntityImpl implements ITickableTileEntity {
public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBlockEntity {
private static final Map<IAuraType, Integer> TIMES = ImmutableMap.<IAuraType, Integer>builder()
.put(NaturesAuraAPI.TYPE_OVERWORLD, 20)
@ -30,7 +30,7 @@ public class TileEntityAuraTimer extends TileEntityImpl implements ITickableTile
};
private int timer;
public TileEntityAuraTimer() {
public BlockEntityAuraTimer() {
super(ModTileEntities.AURA_TIMER);
}
@ -39,7 +39,7 @@ public class TileEntityAuraTimer extends TileEntityImpl implements ITickableTile
if (this.redstonePower <= 0 && newPower > 0) {
this.timer = 0;
int color = ItemAuraBottle.getType(this.itemHandler.getStackInSlot(0)).getColor();
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.TIMER_RESET, color));
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.TIMER_RESET, color));
this.sendToClients();
}
super.onRedstonePowerChange(newPower);
@ -53,14 +53,14 @@ public class TileEntityAuraTimer extends TileEntityImpl implements ITickableTile
return;
}
if (this.world.isRemote) {
if (this.world.getGameTime() % 8 == 0) {
if (this.level.isClientSide) {
if (this.level.getGameTime() % 8 == 0) {
int color = ItemAuraBottle.getType(this.itemHandler.getStackInSlot(0)).getColor();
NaturesAuraAPI.instance().spawnMagicParticle(
this.pos.getX() + 1 / 16F + this.world.rand.nextFloat() * 14 / 16F,
this.pos.getY() + 1 / 16F + this.world.rand.nextFloat() * 14 / 16F,
this.pos.getZ() + 1 / 16F + this.world.rand.nextFloat() * 14 / 16F,
0, 0, 0, color, 1, 80 + this.world.rand.nextInt(50), 0, false, true);
this.worldPosition.getX() + 1 / 16F + this.level.rand.nextFloat() * 14 / 16F,
this.worldPosition.getY() + 1 / 16F + this.level.rand.nextFloat() * 14 / 16F,
this.worldPosition.getZ() + 1 / 16F + this.level.rand.nextFloat() * 14 / 16F,
0, 0, 0, color, 1, 80 + this.level.rand.nextInt(50), 0, false, true);
}
return;
}
@ -70,11 +70,11 @@ public class TileEntityAuraTimer extends TileEntityImpl implements ITickableTile
this.timer = 0;
BlockState state = this.getBlockState();
this.world.setBlockState(this.pos, state.with(BlockStateProperties.POWERED, true), 1);
this.world.getPendingBlockTicks().scheduleTick(this.pos, state.getBlock(), 4);
this.level.setBlockState(this.worldPosition, state.with(BlockStateProperties.POWERED, true), 1);
this.level.getPendingBlockTicks().scheduleTick(this.worldPosition, state.getBlock(), 4);
int color = ItemAuraBottle.getType(this.itemHandler.getStackInSlot(0)).getColor();
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.TIMER_RESET, color));
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.TIMER_RESET, color));
}
if (this.timer % 2 == 0)
this.sendToClients();
@ -104,7 +104,7 @@ public class TileEntityAuraTimer extends TileEntityImpl implements ITickableTile
}
@Override
public void writeNBT(CompoundNBT compound, SaveType type) {
public void writeNBT(CompoundTag compound, SaveType type) {
super.writeNBT(compound, type);
if (type != SaveType.BLOCK) {
compound.put("items", this.itemHandler.serializeNBT());
@ -113,7 +113,7 @@ public class TileEntityAuraTimer extends TileEntityImpl implements ITickableTile
}
@Override
public void readNBT(CompoundNBT compound, SaveType type) {
public void readNBT(CompoundTag compound, SaveType type) {
super.readNBT(compound, type);
if (type != SaveType.BLOCK) {
this.itemHandler.deserializeNBT(compound.getCompound("items"));

View file

@ -6,13 +6,13 @@ import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.BlockState;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.Player;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.ITickableBlockEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.EntityPredicates;
import net.minecraft.util.NonNullList;
@ -21,30 +21,30 @@ import net.minecraft.util.math.BlockPos;
import java.util.List;
public class TileEntityAutoCrafter extends TileEntityImpl implements ITickableTileEntity {
public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickableBlockEntity {
public final CraftingInventory crafting = new CraftingInventory(new Container(null, 0) {
@Override
public boolean canInteractWith(PlayerEntity playerIn) {
public boolean canInteractWith(Player playerIn) {
return false;
}
}, 3, 3);
public TileEntityAutoCrafter() {
public BlockEntityAutoCrafter() {
super(ModTileEntities.AUTO_CRAFTER);
}
@Override
public void tick() {
if (!this.world.isRemote) {
if (this.world.getGameTime() % 60 != 0)
if (!this.level.isClientSide) {
if (this.level.getGameTime() % 60 != 0)
return;
if (!Multiblocks.AUTO_CRAFTER.isComplete(this.world, this.pos))
if (!Multiblocks.AUTO_CRAFTER.isComplete(this.level, this.worldPosition))
return;
this.crafting.clear();
BlockState state = this.world.getBlockState(this.pos);
BlockState state = this.level.getBlockState(this.worldPosition);
Direction facing = state.get(BlockAutoCrafter.FACING);
BlockPos middlePos = this.pos.up();
BlockPos middlePos = this.worldPosition.up();
BlockPos topPos = middlePos.offset(facing, 2);
BlockPos bottomPos = middlePos.offset(facing.getOpposite(), 2);
BlockPos[] poses = new BlockPos[]{
@ -61,7 +61,7 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickableTi
ItemEntity[] items = new ItemEntity[9];
for (int i = 0; i < poses.length; i++) {
List<ItemEntity> entities = this.world.getEntitiesWithinAABB(
List<ItemEntity> entities = this.level.getEntitiesWithinAABB(
ItemEntity.class, new AxisAlignedBB(poses[i]).grow(0.25), EntityPredicates.IS_ALIVE);
if (entities.size() > 1)
return;
@ -77,17 +77,17 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickableTi
this.crafting.setInventorySlotContents(i, stack.copy());
}
IRecipe recipe = this.world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, this.crafting, this.world).orElse(null);
IRecipe recipe = this.level.getRecipeManager().getRecipe(IRecipeType.CRAFTING, this.crafting, this.level).orElse(null);
if (recipe == null)
return;
ItemStack result = recipe.getCraftingResult(this.crafting);
if (result.isEmpty())
return;
ItemEntity resultItem = new ItemEntity(this.world,
this.pos.getX() + 0.5F, this.pos.getY() - 0.35F, this.pos.getZ() + 0.5F, result.copy());
ItemEntity resultItem = new ItemEntity(this.level,
this.worldPosition.getX() + 0.5F, this.worldPosition.getY() - 0.35F, this.worldPosition.getZ() + 0.5F, result.copy());
resultItem.setMotion(0, 0, 0);
this.world.addEntity(resultItem);
this.level.addEntity(resultItem);
NonNullList<ItemStack> remainingItems = recipe.getRemainingItems(this.crafting);
for (int i = 0; i < items.length; i++) {
@ -104,12 +104,12 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickableTi
ItemStack remain = remainingItems.get(i);
if (!remain.isEmpty()) {
ItemEntity remItem = new ItemEntity(this.world, item.getPosX(), item.getPosY(), item.getPosZ(), remain.copy());
ItemEntity remItem = new ItemEntity(this.level, item.getPosX(), item.getPosY(), item.getPosZ(), remain.copy());
remItem.setMotion(0, 0, 0);
this.world.addEntity(remItem);
this.level.addEntity(remItem);
}
PacketHandler.sendToAllAround(this.world, this.pos, 32,
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
new PacketParticles((float) item.getPosX(), (float) item.getPosY(), (float) item.getPosZ(), PacketParticles.Type.ANIMAL_SPAWNER));
}
}

View file

@ -6,9 +6,9 @@ import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.tileentity.BlastFurnaceTileEntity;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.BlastFurnaceBlockEntity;
import net.minecraft.tileentity.ITickableBlockEntity;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.IIntArray;
import net.minecraft.util.math.BlockPos;
@ -19,35 +19,35 @@ import net.minecraftforge.items.IItemHandlerModifiable;
import javax.annotation.Nonnull;
import java.util.List;
public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITickableTileEntity {
public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements ITickableBlockEntity {
public TileEntityBlastFurnaceBooster() {
public BlockEntityBlastFurnaceBooster() {
super(ModTileEntities.BLAST_FURNACE_BOOSTER);
}
@Override
public void tick() {
if (this.world.isRemote)
if (this.level.isClientSide)
return;
TileEntity below = this.world.getTileEntity(this.pos.down());
if (!(below instanceof BlastFurnaceTileEntity))
BlockEntity below = this.level.getBlockEntity(this.worldPosition.down());
if (!(below instanceof BlastFurnaceBlockEntity))
return;
BlastFurnaceTileEntity tile = (BlastFurnaceTileEntity) below;
IRecipe<?> recipe = this.world.getRecipeManager().getRecipe(TileEntityFurnaceHeater.getRecipeType(tile), tile, this.world).orElse(null);
BlastFurnaceBlockEntity tile = (BlastFurnaceBlockEntity) below;
IRecipe<?> recipe = this.level.getRecipeManager().getRecipe(BlockEntityFurnaceHeater.getRecipeType(tile), tile, this.level).orElse(null);
if (recipe == null)
return;
if (!this.isApplicable(recipe.getIngredients()))
return;
IIntArray data = TileEntityFurnaceHeater.getFurnaceData(tile);
IIntArray data = BlockEntityFurnaceHeater.getFurnaceData(tile);
int doneDiff = data.get(3) - data.get(2);
if (doneDiff > 1)
return;
if (this.world.rand.nextFloat() > 0.45F) {
PacketHandler.sendToAllAround(this.world, this.pos, 32,
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 0));
if (this.level.rand.nextFloat() > 0.45F) {
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 0));
return;
}
@ -62,11 +62,11 @@ public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITi
output.grow(1);
}
BlockPos pos = IAuraChunk.getHighestSpot(this.world, this.pos, 30, this.pos);
IAuraChunk.getAuraChunk(this.world, pos).drainAura(pos, 6500);
BlockPos pos = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 30, this.worldPosition);
IAuraChunk.getAuraChunk(this.level, pos).drainAura(pos, 6500);
PacketHandler.sendToAllAround(this.world, this.pos, 32,
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 1));
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 1));
}
private boolean isApplicable(List<Ingredient> ingredients) {
@ -81,8 +81,8 @@ public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITi
@Override
public IItemHandlerModifiable getItemHandler() {
TileEntity below = this.world.getTileEntity(this.pos.down());
if (!(below instanceof BlastFurnaceTileEntity))
BlockEntity below = this.level.getBlockEntity(this.worldPosition.down());
if (!(below instanceof BlastFurnaceBlockEntity))
return null;
IItemHandler handler = below.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).orElse(null);
if (handler == null)

View file

@ -5,10 +5,10 @@ import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.ITickableBlockEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
@ -19,32 +19,32 @@ import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
public class TileEntityChorusGenerator extends TileEntityImpl implements ITickableTileEntity {
public class BlockEntityChorusGenerator extends BlockEntityImpl implements ITickableBlockEntity {
private final Deque<BlockPos> currentlyBreaking = new ArrayDeque<>();
private int auraPerBlock;
public TileEntityChorusGenerator() {
public BlockEntityChorusGenerator() {
super(ModTileEntities.CHORUS_GENERATOR);
}
@Override
public void tick() {
if (this.world.isRemote)
if (this.level.isClientSide)
return;
if (this.world.getGameTime() % 5 != 0)
if (this.level.getGameTime() % 5 != 0)
return;
if (this.currentlyBreaking.isEmpty())
return;
BlockPos pos = this.currentlyBreaking.removeLast();
BlockState state = this.world.getBlockState(pos);
BlockState state = this.level.getBlockState(pos);
if (state.getBlock() != Blocks.CHORUS_PLANT && state.getBlock() != Blocks.CHORUS_FLOWER) {
this.currentlyBreaking.clear();
return;
}
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.CHORUS_GENERATOR, pos.getX(), pos.getY(), pos.getZ()));
this.world.removeBlock(pos, false);
this.world.playSound(null, this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5,
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.CHORUS_GENERATOR, pos.getX(), pos.getY(), pos.getZ()));
this.level.removeBlock(pos, false);
this.level.playSound(null, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 0.5, this.worldPosition.getZ() + 0.5,
SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.BLOCKS, 0.5F, 1F);
this.generateAura(this.auraPerBlock);
}
@ -57,11 +57,11 @@ public class TileEntityChorusGenerator extends TileEntityImpl implements ITickab
for (int x = -range; x <= range; x++) {
for (int y = -range; y <= range; y++) {
for (int z = -range; z <= range; z++) {
BlockPos offset = this.pos.add(x, y, z);
BlockState below = this.world.getBlockState(offset.down());
BlockPos offset = this.worldPosition.add(x, y, z);
BlockState below = this.level.getBlockState(offset.down());
if (below.getBlock() != Blocks.END_STONE)
continue;
BlockState state = this.world.getBlockState(offset);
BlockState state = this.level.getBlockState(offset);
if (state.getBlock() != Blocks.CHORUS_PLANT)
continue;
@ -90,7 +90,7 @@ public class TileEntityChorusGenerator extends TileEntityImpl implements ITickab
BlockPos offset = pos.offset(dir);
if (blocks.contains(offset))
continue;
BlockState state = this.world.getBlockState(offset);
BlockState state = this.level.getBlockState(offset);
if (state.getBlock() != Blocks.CHORUS_PLANT && state.getBlock() != Blocks.CHORUS_FLOWER)
continue;
blocks.add(offset);
@ -99,7 +99,7 @@ public class TileEntityChorusGenerator extends TileEntityImpl implements ITickab
}
@Override
public void writeNBT(CompoundNBT compound, SaveType type) {
public void writeNBT(CompoundTag compound, SaveType type) {
super.writeNBT(compound, type);
if (type == SaveType.TILE) {
ListNBT list = new ListNBT();
@ -111,7 +111,7 @@ public class TileEntityChorusGenerator extends TileEntityImpl implements ITickab
}
@Override
public void readNBT(CompoundNBT compound, SaveType type) {
public void readNBT(CompoundTag compound, SaveType type) {
super.readNBT(compound, type);
if (type == SaveType.TILE) {
this.currentlyBreaking.clear();

View file

@ -2,24 +2,24 @@ package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.tileentity.ITickableBlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.util.math.Mth;
import net.minecraft.level.server.ServerLevel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class TileEntityChunkLoader extends TileEntityImpl implements ITickableTileEntity {
public class BlockEntityChunkLoader extends BlockEntityImpl implements ITickableBlockEntity {
private final List<ChunkPos> forcedChunks = new ArrayList<>();
private boolean firstTick = true;
public TileEntityChunkLoader() {
public BlockEntityChunkLoader() {
super(ModTileEntities.CHUNK_LOADER);
}
@ -32,7 +32,7 @@ public class TileEntityChunkLoader extends TileEntityImpl implements ITickableTi
@Override
public void onRedstonePowerChange(int newPower) {
super.onRedstonePowerChange(newPower);
if (!this.world.isRemote) {
if (!this.level.isClientSide) {
this.loadChunks(false);
this.sendToClients();
}
@ -43,19 +43,19 @@ public class TileEntityChunkLoader extends TileEntityImpl implements ITickableTi
}
private void loadChunks(boolean unload) {
if (this.world.isRemote || !ModConfig.instance.chunkLoader.get())
if (this.level.isClientSide || !ModConfig.instance.chunkLoader.get())
return;
ServerWorld world = (ServerWorld) this.world;
ServerLevel level = (ServerLevel) this.level;
List<ChunkPos> shouldBeForced = new ArrayList<>();
if (!unload) {
int range = this.range();
if (range > 0) {
for (int x = (this.pos.getX() - range) >> 4; x <= (this.pos.getX() + range) >> 4; x++) {
for (int z = (this.pos.getZ() - range) >> 4; z <= (this.pos.getZ() + range) >> 4; z++) {
for (int x = (this.worldPosition.getX() - range) >> 4; x <= (this.worldPosition.getX() + range) >> 4; x++) {
for (int z = (this.worldPosition.getZ() - range) >> 4; z <= (this.worldPosition.getZ() + range) >> 4; z++) {
ChunkPos pos = new ChunkPos(x, z);
// Only force chunks that we're already forcing or that nobody else is forcing
if (this.forcedChunks.contains(pos) || !world.getForcedChunks().contains(pos.asLong()))
if (this.forcedChunks.contains(pos) || !level.getForcedChunks().contains(pos.asLong()))
shouldBeForced.add(pos);
}
}
@ -65,20 +65,20 @@ public class TileEntityChunkLoader extends TileEntityImpl implements ITickableTi
// Unforce all of the chunks that shouldn't be forced anymore
for (ChunkPos pos : this.forcedChunks) {
if (!shouldBeForced.contains(pos))
world.forceChunk(pos.x, pos.z, false);
level.forceChunk(pos.x, pos.z, false);
}
this.forcedChunks.clear();
// Force all chunks that should be forced
for (ChunkPos pos : shouldBeForced) {
world.forceChunk(pos.x, pos.z, true);
level.forceChunk(pos.x, pos.z, true);
this.forcedChunks.add(pos);
}
}
@Override
public void tick() {
if (!this.world.isRemote && ModConfig.instance.chunkLoader.get()) {
if (!this.level.isClientSide && ModConfig.instance.chunkLoader.get()) {
// defer loading chunks on load to here since, otherwise, deadlocks happen oof
// since forced chunks are saved to disk by the game, this is only necessary for when the chunk loader config changes
if (this.firstTick) {
@ -86,25 +86,25 @@ public class TileEntityChunkLoader extends TileEntityImpl implements ITickableTi
this.firstTick = false;
}
if (this.world.getGameTime() % 20 != 0)
if (this.level.getGameTime() % 20 != 0)
return;
int toUse = MathHelper.ceil(this.range() / 2F);
int toUse = Mth.ceil(this.range() / 2F);
if (toUse > 0) {
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 35, this.pos);
IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, toUse);
BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, toUse);
}
}
}
@Override
public void writeNBT(CompoundNBT compound, SaveType type) {
public void writeNBT(CompoundTag compound, SaveType type) {
super.writeNBT(compound, type);
if (type == SaveType.TILE)
compound.putLongArray("forced_chunks", this.forcedChunks.stream().map(ChunkPos::asLong).collect(Collectors.toList()));
}
@Override
public void readNBT(CompoundNBT compound, SaveType type) {
public void readNBT(CompoundTag compound, SaveType type) {
super.readNBT(compound, type);
if (type == SaveType.TILE) {

View file

@ -10,15 +10,15 @@ import net.minecraft.block.Blocks;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.tileentity.ITickableBlockEntity;
import net.minecraft.util.EntityPredicates;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import java.util.List;
public class TileEntityEndFlower extends TileEntityImpl implements ITickableTileEntity {
public class BlockEntityEndFlower extends BlockEntityImpl implements ITickableBlockEntity {
private final BasicAuraContainer container = new BasicAuraContainer(null, 500000) {
{
@ -34,7 +34,7 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickableTile
public int drainAura(int amountToDrain, boolean simulate) {
int amount = super.drainAura(amountToDrain, simulate);
if (amount > 0 && !simulate)
TileEntityEndFlower.this.sendToClients();
BlockEntityEndFlower.this.sendToClients();
return amount;
}
@ -46,19 +46,19 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickableTile
public boolean isDrainMode;
public TileEntityEndFlower() {
public BlockEntityEndFlower() {
super(ModTileEntities.END_FLOWER);
}
@Override
public void tick() {
if (!this.world.isRemote) {
if (this.world.getGameTime() % 10 != 0)
if (!this.level.isClientSide) {
if (this.level.getGameTime() % 10 != 0)
return;
if (!this.isDrainMode) {
List<ItemEntity> items = this.world.getEntitiesWithinAABB(ItemEntity.class,
new AxisAlignedBB(this.pos).grow(1), EntityPredicates.IS_ALIVE);
List<ItemEntity> items = this.level.getEntitiesWithinAABB(ItemEntity.class,
new AxisAlignedBB(this.worldPosition).grow(1), EntityPredicates.IS_ALIVE);
for (ItemEntity item : items) {
if (item.cannotPickup())
continue;
@ -71,7 +71,7 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickableTile
this.isDrainMode = true;
item.remove();
PacketHandler.sendToAllAround(this.world, this.pos, 32,
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
new PacketParticles((float) item.getPosX(), (float) item.getPosY(), (float) item.getPosZ(), PacketParticles.Type.END_FLOWER_CONSUME, this.container.getAuraColor()));
break;
}
@ -81,21 +81,21 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickableTile
this.generateAura(toDrain);
if (this.container.getStoredAura() <= 0) {
this.world.setBlockState(this.pos, Blocks.DEAD_BUSH.getDefaultState());
PacketHandler.sendToAllAround(this.world, this.pos, 32,
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.END_FLOWER_DECAY, this.container.getAuraColor()));
this.level.setBlockState(this.worldPosition, Blocks.DEAD_BUSH.getDefaultState());
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.END_FLOWER_DECAY, this.container.getAuraColor()));
}
}
} else {
if (this.isDrainMode && this.world.getGameTime() % 5 == 0)
if (this.isDrainMode && this.level.getGameTime() % 5 == 0)
NaturesAuraAPI.instance().spawnMagicParticle(
this.pos.getX() + 0.25F + this.world.rand.nextFloat() * 0.5F,
this.pos.getY() + 0.25F + this.world.rand.nextFloat() * 0.5F,
this.pos.getZ() + 0.25F + this.world.rand.nextFloat() * 0.5F,
this.world.rand.nextGaussian() * 0.05F,
this.world.rand.nextFloat() * 0.1F,
this.world.rand.nextGaussian() * 0.05F,
this.container.getAuraColor(), this.world.rand.nextFloat() * 2F + 1F, 50, 0F, false, true);
this.worldPosition.getX() + 0.25F + this.level.rand.nextFloat() * 0.5F,
this.worldPosition.getY() + 0.25F + this.level.rand.nextFloat() * 0.5F,
this.worldPosition.getZ() + 0.25F + this.level.rand.nextFloat() * 0.5F,
this.level.rand.nextGaussian() * 0.05F,
this.level.rand.nextFloat() * 0.1F,
this.level.rand.nextGaussian() * 0.05F,
this.container.getAuraColor(), this.level.rand.nextFloat() * 2F + 1F, 50, 0F, false, true);
}
}
@ -105,7 +105,7 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickableTile
}
@Override
public void writeNBT(CompoundNBT compound, SaveType type) {
public void writeNBT(CompoundTag compound, SaveType type) {
super.writeNBT(compound, type);
if (type != SaveType.BLOCK) {
this.container.writeNBT(compound);
@ -114,7 +114,7 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickableTile
}
@Override
public void readNBT(CompoundNBT compound, SaveType type) {
public void readNBT(CompoundTag compound, SaveType type) {
super.readNBT(compound, type);
if (type != SaveType.BLOCK) {
this.container.readNBT(compound);

View file

@ -2,16 +2,16 @@ package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.api.misc.ILevelData;
import de.ellpeck.naturesaura.blocks.BlockEnderCrate;
import de.ellpeck.naturesaura.gui.ContainerEnderCrate;
import de.ellpeck.naturesaura.gui.ModContainers;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.Player;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
@ -21,7 +21,7 @@ import net.minecraftforge.items.IItemHandlerModifiable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class TileEntityEnderCrate extends TileEntityImpl implements INamedContainerProvider {
public class BlockEntityEnderCrate extends BlockEntityImpl implements INamedContainerProvider {
public String name;
private final IItemHandlerModifiable wrappedEnderStorage = new IItemHandlerModifiable() {
@ -46,7 +46,7 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
ItemStack remain = this.getStorage().insertItem(slot, stack, simulate);
if (!simulate)
TileEntityEnderCrate.this.drainAura((stack.getCount() - remain.getCount()) * 20);
BlockEntityEnderCrate.this.drainAura((stack.getCount() - remain.getCount()) * 20);
return remain;
}
@ -55,7 +55,7 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai
public ItemStack extractItem(int slot, int amount, boolean simulate) {
ItemStack extracted = this.getStorage().extractItem(slot, amount, simulate);
if (!simulate)
TileEntityEnderCrate.this.drainAura(extracted.getCount() * 20);
BlockEntityEnderCrate.this.drainAura(extracted.getCount() * 20);
return extracted;
}
@ -70,11 +70,11 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai
}
private IItemHandlerModifiable getStorage() {
return IWorldData.getOverworldData(TileEntityEnderCrate.this.world).getEnderStorage(TileEntityEnderCrate.this.name);
return ILevelData.getOverworldData(BlockEntityEnderCrate.this.level).getEnderStorage(BlockEntityEnderCrate.this.name);
}
};
public TileEntityEnderCrate() {
public BlockEntityEnderCrate() {
super(ModTileEntities.ENDER_CRATE);
}
@ -97,7 +97,7 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai
public void modifyDrop(ItemStack regularItem) {
if (this.name != null) {
if (!regularItem.hasTag())
regularItem.setTag(new CompoundNBT());
regularItem.setTag(new CompoundTag());
regularItem.getTag().putString(NaturesAura.MOD_ID + ":ender_name", this.name);
}
}
@ -105,7 +105,7 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai
@Override
public void loadDataOnPlace(ItemStack stack) {
super.loadDataOnPlace(stack);
if (!this.world.isRemote) {
if (!this.level.isClientSide) {
String name = BlockEnderCrate.getEnderName(stack);
if (name != null && !name.isEmpty())
this.name = name;
@ -113,7 +113,7 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai
}
@Override
public void writeNBT(CompoundNBT compound, SaveType type) {
public void writeNBT(CompoundTag compound, SaveType type) {
super.writeNBT(compound, type);
if (type != SaveType.BLOCK) {
if (this.name != null)
@ -122,7 +122,7 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai
}
@Override
public void readNBT(CompoundNBT compound, SaveType type) {
public void readNBT(CompoundTag compound, SaveType type) {
super.readNBT(compound, type);
if (type != SaveType.BLOCK) {
if (compound.contains("name"))
@ -132,8 +132,8 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai
public void drainAura(int amount) {
if (amount > 0) {
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 35, this.pos);
IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, amount);
BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 35, this.worldPosition);
IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, amount);
}
}
@ -144,7 +144,7 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai
@Nullable
@Override
public Container createMenu(int window, PlayerInventory inv, PlayerEntity player) {
public Container createMenu(int window, PlayerInventory inv, Player player) {
return new ContainerEnderCrate(ModContainers.ENDER_CRATE, window, player, this.getItemHandler());
}
}

View file

@ -13,44 +13,44 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootParameters;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.tileentity.ITickableBlockEntity;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Mth;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.level.server.ServerLevel;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.level.BlockEvent;
import java.util.List;
public class TileEntityFieldCreator extends TileEntityImpl implements ITickableTileEntity {
public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickableBlockEntity {
public BlockPos connectionOffset;
public boolean isMain;
public boolean isCharged;
private int chargeTimer;
public TileEntityFieldCreator() {
public BlockEntityFieldCreator() {
super(ModTileEntities.FIELD_CREATOR);
}
@Override
public void tick() {
if (this.world.isRemote || this.world.getGameTime() % 10 != 0)
if (this.level.isClientSide || this.level.getGameTime() % 10 != 0)
return;
BlockPos connectedPos = this.getConnectedPos();
if (connectedPos == null || !this.world.isBlockLoaded(connectedPos))
if (connectedPos == null || !this.level.isBlockLoaded(connectedPos))
return;
TileEntity other = this.world.getTileEntity(connectedPos);
BlockEntity other = this.level.getBlockEntity(connectedPos);
if (!this.isCloseEnough(connectedPos)
|| !(other instanceof TileEntityFieldCreator)
|| !this.pos.equals(((TileEntityFieldCreator) other).getConnectedPos())) {
|| !(other instanceof BlockEntityFieldCreator)
|| !this.worldPosition.equals(((BlockEntityFieldCreator) other).getConnectedPos())) {
this.connectionOffset = null;
this.chargeTimer = 0;
this.isCharged = false;
@ -62,7 +62,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT
if (!this.isMain)
return;
TileEntityFieldCreator creator = (TileEntityFieldCreator) other;
BlockEntityFieldCreator creator = (BlockEntityFieldCreator) other;
if (this.redstonePower <= 0 && creator.redstonePower <= 0) {
this.chargeTimer = 0;
if (this.isCharged) {
@ -74,8 +74,8 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT
return;
}
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 32, this.pos);
IAuraChunk chunk = IAuraChunk.getAuraChunk(this.world, spot);
BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 32, this.worldPosition);
IAuraChunk chunk = IAuraChunk.getAuraChunk(this.level, spot);
if (!this.isCharged) {
this.chargeTimer += 10;
@ -91,41 +91,41 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT
chunk.drainAura(spot, 300);
this.sendParticles();
} else {
if (this.world.getGameTime() % 40 == 0)
if (this.level.getGameTime() % 40 == 0)
chunk.drainAura(spot, 20);
ItemStack tool = this.getToolUsed(creator);
Vector3d dist = new Vector3d(
this.pos.getX() - connectedPos.getX(),
this.pos.getY() - connectedPos.getY(),
this.pos.getZ() - connectedPos.getZ()
this.worldPosition.getX() - connectedPos.getX(),
this.worldPosition.getY() - connectedPos.getY(),
this.worldPosition.getZ() - connectedPos.getZ()
);
double length = dist.length();
Vector3d normal = new Vector3d(dist.x / length, dist.y / length, dist.z / length);
for (float i = MathHelper.floor(length); i > 0; i -= 0.5F) {
for (float i = Mth.floor(length); i > 0; i -= 0.5F) {
Vector3d scaled = normal.scale(i);
BlockPos pos = connectedPos.add(
MathHelper.floor(scaled.x + 0.5F),
MathHelper.floor(scaled.y + 0.5F),
MathHelper.floor(scaled.z + 0.5F));
Mth.floor(scaled.x + 0.5F),
Mth.floor(scaled.y + 0.5F),
Mth.floor(scaled.z + 0.5F));
if (pos.equals(this.pos) || pos.equals(connectedPos))
if (pos.equals(this.worldPosition) || pos.equals(connectedPos))
continue;
BlockState state = this.world.getBlockState(pos);
BlockState state = this.level.getBlockState(pos);
Block block = state.getBlock();
if (!block.isAir(state, this.world, pos) && state.getBlockHardness(this.world, pos) >= 0F) {
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerWorld) this.world);
if (!MinecraftForge.EVENT_BUS.post(new BlockEvent.BreakEvent(this.world, pos, state, fake))) {
List<ItemStack> drops = state.getDrops(new LootContext.Builder((ServerWorld) this.world)
if (!block.isAir(state, this.level, pos) && state.getBlockHardness(this.level, pos) >= 0F) {
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerLevel) this.level);
if (!MinecraftForge.EVENT_BUS.post(new BlockEvent.BreakEvent(this.level, pos, state, fake))) {
List<ItemStack> drops = state.getDrops(new LootContext.Builder((ServerLevel) this.level)
.withParameter(LootParameters.THIS_ENTITY, fake)
.withParameter(LootParameters.field_237457_g_, Vector3d.copyCentered(pos))
.withParameter(LootParameters.BLOCK_STATE, state)
.withParameter(LootParameters.TOOL, tool.isEmpty() ? new ItemStack(Items.DIAMOND_PICKAXE) : tool)
.withNullableParameter(LootParameters.BLOCK_ENTITY, this.world.getTileEntity(pos)));
this.world.destroyBlock(pos, false);
.withNullableParameter(LootParameters.BLOCK_ENTITY, this.level.getBlockEntity(pos)));
this.level.destroyBlock(pos, false);
for (ItemStack stack : drops)
Block.spawnAsEntity(this.world, pos, stack);
Block.spawnAsEntity(this.level, pos, stack);
chunk.drainAura(spot, !tool.isEmpty() ? 300 : 100);
this.sendParticles();
}
@ -134,20 +134,20 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT
}
}
private ItemStack getToolUsed(TileEntityFieldCreator other) {
private ItemStack getToolUsed(BlockEntityFieldCreator other) {
ItemStack myTool = this.getMyTool();
ItemStack otherTool = other.getMyTool();
if (!myTool.isEmpty()) {
// if both have tools, choose randomly
if (!otherTool.isEmpty())
return this.world.rand.nextBoolean() ? myTool : otherTool;
return this.level.rand.nextBoolean() ? myTool : otherTool;
return myTool;
}
return otherTool;
}
private ItemStack getMyTool() {
List<ItemFrameEntity> frames = Helper.getAttachedItemFrames(this.world, this.pos);
List<ItemFrameEntity> frames = Helper.getAttachedItemFrames(this.level, this.worldPosition);
for (ItemFrameEntity frame : frames) {
ItemStack stack = frame.getDisplayedItem();
if (!stack.isEmpty())
@ -158,32 +158,32 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT
private void sendParticles() {
for (int j = 0; j < 2; j++) {
BlockPos p = j == 0 ? this.pos : this.getConnectedPos();
PacketHandler.sendToAllAround(this.world, p, 32, new PacketParticleStream(
p.getX() + (float) this.world.rand.nextGaussian() * 3F,
p.getY() + 1 + this.world.rand.nextFloat() * 3F,
p.getZ() + (float) this.world.rand.nextGaussian() * 3F,
BlockPos p = j == 0 ? this.worldPosition : this.getConnectedPos();
PacketHandler.sendToAllAround(this.level, p, 32, new PacketParticleStream(
p.getX() + (float) this.level.rand.nextGaussian() * 3F,
p.getY() + 1 + this.level.rand.nextFloat() * 3F,
p.getZ() + (float) this.level.rand.nextGaussian() * 3F,
p.getX() + 0.5F,
p.getY() + 0.5F,
p.getZ() + 0.5F,
this.world.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forWorld(this.world).getColor(), this.world.rand.nextFloat() + 0.5F
this.level.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forLevel(this.level).getColor(), this.level.rand.nextFloat() + 0.5F
));
}
}
public boolean isCloseEnough(BlockPos pos) {
int range = ModConfig.instance.fieldCreatorRange.get() + 1;
return this.pos.distanceSq(pos) <= range * range;
return this.worldPosition.distanceSq(pos) <= range * range;
}
public BlockPos getConnectedPos() {
if (this.connectionOffset == null)
return null;
return this.pos.add(this.connectionOffset);
return this.worldPosition.add(this.connectionOffset);
}
@Override
public void writeNBT(CompoundNBT compound, SaveType type) {
public void writeNBT(CompoundTag compound, SaveType type) {
super.writeNBT(compound, type);
if (type != SaveType.BLOCK) {
if (this.connectionOffset != null)
@ -197,7 +197,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT
}
@Override
public void readNBT(CompoundNBT compound, SaveType type) {
public void readNBT(CompoundTag compound, SaveType type) {
super.readNBT(compound, type);
if (type != SaveType.BLOCK) {
if (compound.contains("connection"))

View file

@ -8,37 +8,37 @@ import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.projectile.FireworkRocketEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.ITickableBlockEntity;
import net.minecraft.util.EntityPredicates;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Mth;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class TileEntityFireworkGenerator extends TileEntityImpl implements ITickableTileEntity {
public class BlockEntityFireworkGenerator extends BlockEntityImpl implements ITickableBlockEntity {
private FireworkRocketEntity trackedEntity;
private ItemStack trackedItem;
private int toRelease;
private int releaseTimer;
public TileEntityFireworkGenerator() {
public BlockEntityFireworkGenerator() {
super(ModTileEntities.FIREWORK_GENERATOR);
}
@Override
public void tick() {
if (!this.world.isRemote) {
if (this.world.getGameTime() % 10 == 0) {
List<ItemEntity> items = this.world.getEntitiesWithinAABB(ItemEntity.class,
new AxisAlignedBB(this.pos).grow(4), EntityPredicates.IS_ALIVE);
if (!this.level.isClientSide) {
if (this.level.getGameTime() % 10 == 0) {
List<ItemEntity> items = this.level.getEntitiesWithinAABB(ItemEntity.class,
new AxisAlignedBB(this.worldPosition).grow(4), EntityPredicates.IS_ALIVE);
for (ItemEntity item : items) {
if (item.cannotPickup())
continue;
@ -46,10 +46,10 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick
if (stack.isEmpty() || stack.getItem() != Items.FIREWORK_ROCKET)
continue;
if (this.trackedEntity == null && this.releaseTimer <= 0) {
FireworkRocketEntity entity = new FireworkRocketEntity(this.world, item.getPosX(), item.getPosY(), item.getPosZ(), stack);
FireworkRocketEntity entity = new FireworkRocketEntity(this.level, item.getPosX(), item.getPosY(), item.getPosZ(), stack);
this.trackedEntity = entity;
this.trackedItem = stack.copy();
this.world.addEntity(entity);
this.level.addEntity(entity);
}
stack.shrink(1);
if (stack.isEmpty())
@ -64,8 +64,8 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick
float generateFactor = 0;
Set<Integer> usedColors = new HashSet<>();
CompoundNBT compound = this.trackedItem.getTag();
CompoundNBT fireworks = compound.getCompound("Fireworks");
CompoundTag compound = this.trackedItem.getTag();
CompoundTag fireworks = compound.getCompound("Fireworks");
int flightTime = fireworks.getInt("Flight");
ListNBT explosions = fireworks.getList("Explosions", 10);
@ -73,7 +73,7 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick
generateFactor += flightTime;
for (INBT base : explosions) {
CompoundNBT explosion = (CompoundNBT) base;
CompoundTag explosion = (CompoundTag) base;
generateFactor += 1.5F;
boolean flicker = explosion.getBoolean("Flicker");
@ -97,18 +97,18 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick
}
if (generateFactor > 0) {
int toAdd = MathHelper.ceil(generateFactor * 10000F);
int toAdd = Mth.ceil(generateFactor * 10000F);
if (this.canGenerateRightNow(toAdd)) {
this.toRelease = toAdd;
this.releaseTimer = 15 * flightTime + 40;
}
List<Integer> data = new ArrayList<>();
data.add(this.pos.getX());
data.add(this.pos.getY());
data.add(this.pos.getZ());
data.add(this.worldPosition.getX());
data.add(this.worldPosition.getY());
data.add(this.worldPosition.getZ());
data.addAll(usedColors);
PacketHandler.sendToAllLoaded(this.world, this.pos, new PacketParticles(
PacketHandler.sendToAllLoaded(this.level, this.worldPosition, new PacketParticles(
(float) this.trackedEntity.getPosX(), (float) this.trackedEntity.getPosY(), (float) this.trackedEntity.getPosZ(),
PacketParticles.Type.FIREWORK_GEN, Ints.toArray(data)));
}
@ -124,8 +124,8 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick
this.generateAura(this.toRelease);
this.toRelease = 0;
PacketHandler.sendToAllLoaded(this.world, this.pos,
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.FLOWER_GEN_AURA_CREATION));
PacketHandler.sendToAllLoaded(this.level, this.worldPosition,
new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.FLOWER_GEN_AURA_CREATION));
}
}
}

View file

@ -9,11 +9,11 @@ import de.ellpeck.naturesaura.packet.PacketParticleStream;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.tags.BlockTags;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.ITickableBlockEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.registries.ForgeRegistries;
@ -24,24 +24,24 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickableTileEntity {
public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITickableBlockEntity {
private final Map<BlockState, MutableInt> consumedRecently = new HashMap<>();
public TileEntityFlowerGenerator() {
public BlockEntityFlowerGenerator() {
super(ModTileEntities.FLOWER_GENERATOR);
}
@Override
public void tick() {
if (!this.world.isRemote && this.world.getGameTime() % 10 == 0) {
if (!this.level.isClientSide && this.level.getGameTime() % 10 == 0) {
List<BlockPos> possible = new ArrayList<>();
int range = 3;
for (int x = -range; x <= range; x++) {
for (int y = -1; y <= 1; y++) {
for (int z = -range; z <= range; z++) {
BlockPos offset = this.pos.add(x, y, z);
BlockState state = this.world.getBlockState(offset);
BlockPos offset = this.worldPosition.add(x, y, z);
BlockState state = this.level.getBlockState(offset);
if (BlockTags.SMALL_FLOWERS.contains(state.getBlock()))
possible.add(offset);
}
@ -51,14 +51,14 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab
if (possible.isEmpty())
return;
BlockPos pos = possible.get(this.world.rand.nextInt(possible.size()));
BlockState state = this.world.getBlockState(pos);
BlockPos pos = possible.get(this.level.rand.nextInt(possible.size()));
BlockState state = this.level.getBlockState(pos);
MutableInt curr = this.consumedRecently.computeIfAbsent(state, s -> new MutableInt());
int addAmount = 25000;
int toAdd = Math.max(0, addAmount - curr.getValue() * 100);
if (toAdd > 0) {
if (IAuraType.forWorld(this.world).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) && this.canGenerateRightNow(toAdd)) {
if (IAuraType.forLevel(this.level).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) && this.canGenerateRightNow(toAdd)) {
this.generateAura(toAdd);
} else {
toAdd = 0;
@ -74,23 +74,23 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab
}
curr.add(5);
this.world.removeBlock(pos, false);
this.level.removeBlock(pos, false);
int color = Helper.blendColors(0x5ccc30, 0xe53c16, toAdd / (float) addAmount);
if (toAdd > 0) {
for (int i = this.world.rand.nextInt(5) + 5; i >= 0; i--)
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
pos.getX() + 0.25F + this.world.rand.nextFloat() * 0.5F,
pos.getY() + 0.25F + this.world.rand.nextFloat() * 0.5F,
pos.getZ() + 0.25F + this.world.rand.nextFloat() * 0.5F,
this.pos.getX() + 0.25F + this.world.rand.nextFloat() * 0.5F,
this.pos.getY() + 0.25F + this.world.rand.nextFloat() * 0.5F,
this.pos.getZ() + 0.25F + this.world.rand.nextFloat() * 0.5F,
this.world.rand.nextFloat() * 0.02F + 0.1F, color, 1F
for (int i = this.level.rand.nextInt(5) + 5; i >= 0; i--)
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream(
pos.getX() + 0.25F + this.level.rand.nextFloat() * 0.5F,
pos.getY() + 0.25F + this.level.rand.nextFloat() * 0.5F,
pos.getZ() + 0.25F + this.level.rand.nextFloat() * 0.5F,
this.worldPosition.getX() + 0.25F + this.level.rand.nextFloat() * 0.5F,
this.worldPosition.getY() + 0.25F + this.level.rand.nextFloat() * 0.5F,
this.worldPosition.getZ() + 0.25F + this.level.rand.nextFloat() * 0.5F,
this.level.rand.nextFloat() * 0.02F + 0.1F, color, 1F
));
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.FLOWER_GEN_AURA_CREATION));
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.FLOWER_GEN_AURA_CREATION));
}
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), PacketParticles.Type.FLOWER_GEN_CONSUME, color));
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), PacketParticles.Type.FLOWER_GEN_CONSUME, color));
}
}
@ -100,7 +100,7 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab
}
@Override
public void writeNBT(CompoundNBT compound, SaveType type) {
public void writeNBT(CompoundTag compound, SaveType type) {
super.writeNBT(compound, type);
if (type != SaveType.SYNC && !this.consumedRecently.isEmpty()) {
@ -109,7 +109,7 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab
BlockState state = entry.getKey();
Block block = state.getBlock();
CompoundNBT tag = new CompoundNBT();
CompoundTag tag = new CompoundTag();
tag.putString("block", block.getRegistryName().toString());
tag.putInt("amount", entry.getValue().intValue());
list.add(tag);
@ -119,13 +119,13 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab
}
@Override
public void readNBT(CompoundNBT compound, SaveType type) {
public void readNBT(CompoundTag compound, SaveType type) {
super.readNBT(compound, type);
if (type != SaveType.SYNC) {
this.consumedRecently.clear();
ListNBT list = compound.getList("consumed_recently", 10);
for (INBT base : list) {
CompoundNBT tag = (CompoundNBT) base;
CompoundTag tag = (CompoundTag) base;
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(tag.getString("block")));
if (block != null)
this.consumedRecently.put(block.getDefaultState(), new MutableInt(tag.getInt("amount")));

View file

@ -11,26 +11,26 @@ import net.minecraft.block.AbstractFurnaceBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.AbstractCookingRecipe;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.tileentity.*;
import net.minecraft.util.Direction;
import net.minecraft.util.IIntArray;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Mth;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import java.lang.reflect.Field;
public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickableTileEntity {
public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickableBlockEntity {
private static final Field FURNACE_DATA_FIELD = ObfuscationReflectionHelper.findField(AbstractFurnaceTileEntity.class, "field_214013_b");
private static final Field FURNACE_DATA_FIELD = ObfuscationReflectionHelper.findField(AbstractFurnaceBlockEntity.class, "field_214013_b");
public boolean isActive;
public TileEntityFurnaceHeater() {
public BlockEntityFurnaceHeater() {
super(ModTileEntities.FURNACE_HEATER);
}
public static IIntArray getFurnaceData(AbstractFurnaceTileEntity tile) {
public static IIntArray getFurnaceData(AbstractFurnaceBlockEntity tile) {
try {
return (IIntArray) FURNACE_DATA_FIELD.get(tile);
} catch (IllegalAccessException e) {
@ -39,10 +39,10 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable
}
}
public static IRecipeType<? extends AbstractCookingRecipe> getRecipeType(AbstractFurnaceTileEntity furnace) {
if (furnace instanceof BlastFurnaceTileEntity) {
public static IRecipeType<? extends AbstractCookingRecipe> getRecipeType(AbstractFurnaceBlockEntity furnace) {
if (furnace instanceof BlastFurnaceBlockEntity) {
return IRecipeType.BLASTING;
} else if (furnace instanceof SmokerTileEntity) {
} else if (furnace instanceof SmokerBlockEntity) {
return IRecipeType.SMOKING;
} else {
return IRecipeType.SMELTING;
@ -51,38 +51,38 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable
@Override
public void tick() {
if (!this.world.isRemote && this.world.getGameTime() % 5 == 0) {
if (!this.level.isClientSide && this.level.getGameTime() % 5 == 0) {
boolean did = false;
Direction facing = this.world.getBlockState(this.pos).get(BlockFurnaceHeater.FACING);
BlockPos tilePos = this.pos.offset(facing.getOpposite());
TileEntity tile = this.world.getTileEntity(tilePos);
if (tile instanceof AbstractFurnaceTileEntity) {
AbstractFurnaceTileEntity furnace = (AbstractFurnaceTileEntity) tile;
Direction facing = this.level.getBlockState(this.worldPosition).get(BlockFurnaceHeater.FACING);
BlockPos tilePos = this.worldPosition.offset(facing.getOpposite());
BlockEntity tile = this.level.getBlockEntity(tilePos);
if (tile instanceof AbstractFurnaceBlockEntity) {
AbstractFurnaceBlockEntity furnace = (AbstractFurnaceBlockEntity) tile;
if (this.isReady(furnace)) {
IIntArray data = getFurnaceData(furnace);
int burnTime = data.get(0);
if (burnTime <= 0)
this.world.setBlockState(tilePos, this.world.getBlockState(tilePos).with(AbstractFurnaceBlock.LIT, true));
this.level.setBlockState(tilePos, this.level.getBlockState(tilePos).with(AbstractFurnaceBlock.LIT, true));
data.set(0, 200);
//if set higher than 199, it'll never finish because the furnace does ++ and then ==
data.set(2, Math.min(data.get(3) - 1, data.get(2) + 5));
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 20, this.pos);
IAuraChunk chunk = IAuraChunk.getAuraChunk(this.world, spot);
chunk.drainAura(spot, MathHelper.ceil((200 - burnTime) * 16.6F));
BlockPos spot = IAuraChunk.getHighestSpot(this.level, this.worldPosition, 20, this.worldPosition);
IAuraChunk chunk = IAuraChunk.getAuraChunk(this.level, spot);
chunk.drainAura(spot, Mth.ceil((200 - burnTime) * 16.6F));
did = true;
if (this.world.getGameTime() % 15 == 0) {
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
this.pos.getX() + (float) this.world.rand.nextGaussian() * 5F,
this.pos.getY() + 1 + this.world.rand.nextFloat() * 5F,
this.pos.getZ() + (float) this.world.rand.nextGaussian() * 5F,
tilePos.getX() + this.world.rand.nextFloat(),
tilePos.getY() + this.world.rand.nextFloat(),
tilePos.getZ() + this.world.rand.nextFloat(),
this.world.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forWorld(this.world).getColor(), this.world.rand.nextFloat() + 0.5F
if (this.level.getGameTime() % 15 == 0) {
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream(
this.worldPosition.getX() + (float) this.level.rand.nextGaussian() * 5F,
this.worldPosition.getY() + 1 + this.level.rand.nextFloat() * 5F,
this.worldPosition.getZ() + (float) this.level.rand.nextGaussian() * 5F,
tilePos.getX() + this.level.rand.nextFloat(),
tilePos.getY() + this.level.rand.nextFloat(),
tilePos.getZ() + this.level.rand.nextFloat(),
this.level.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forLevel(this.level).getColor(), this.level.rand.nextFloat() + 0.5F
));
}
}
@ -95,13 +95,13 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable
}
}
private boolean isReady(AbstractFurnaceTileEntity furnace) {
private boolean isReady(AbstractFurnaceBlockEntity furnace) {
if (!furnace.getStackInSlot(1).isEmpty())
return false;
ItemStack input = furnace.getStackInSlot(0);
if (!input.isEmpty()) {
AbstractCookingRecipe recipe = this.world.getRecipeManager().getRecipe(getRecipeType(furnace), furnace, this.world).orElse(null);
AbstractCookingRecipe recipe = this.level.getRecipeManager().getRecipe(getRecipeType(furnace), furnace, this.level).orElse(null);
if (recipe == null)
return false;
ItemStack output = recipe.getRecipeOutput();
@ -112,7 +112,7 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable
}
@Override
public void writeNBT(CompoundNBT compound, SaveType type) {
public void writeNBT(CompoundTag compound, SaveType type) {
super.writeNBT(compound, type);
if (type == SaveType.SYNC)
@ -120,7 +120,7 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable
}
@Override
public void readNBT(CompoundNBT compound, SaveType type) {
public void readNBT(CompoundTag compound, SaveType type) {
super.readNBT(compound, type);
if (type == SaveType.SYNC)

View file

@ -4,15 +4,15 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class TileEntityGeneratorLimitRemover extends TileEntityImpl {
public class BlockEntityGeneratorLimitRemover extends BlockEntityImpl {
public TileEntityGeneratorLimitRemover() {
public BlockEntityGeneratorLimitRemover() {
super(ModTileEntities.GENERATOR_LIMIT_REMOVER);
}
@Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getRenderBoundingBox() {
return new AxisAlignedBB(this.pos, this.pos.add(1, 2, 1));
return new AxisAlignedBB(this.worldPosition, this.worldPosition.add(1, 2, 1));
}
}

View file

@ -6,9 +6,9 @@ import net.minecraft.block.BlockState;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.item.ItemFrameEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.tileentity.ITickableBlockEntity;
import net.minecraft.tileentity.BlockEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraftforge.items.CapabilityItemHandler;
@ -17,29 +17,29 @@ import net.minecraftforge.items.IItemHandlerModifiable;
import java.util.List;
public class TileEntityGratedChute extends TileEntityImpl implements ITickableTileEntity {
public class BlockEntityGratedChute extends BlockEntityImpl implements ITickableBlockEntity {
public boolean isBlacklist;
private final ItemStackHandlerNA items = new ItemStackHandlerNA(1, this, true) {
@Override
protected boolean canExtract(ItemStack stack, int slot, int amount) {
return TileEntityGratedChute.this.redstonePower <= 0;
return BlockEntityGratedChute.this.redstonePower <= 0;
}
@Override
protected boolean canInsert(ItemStack stack, int slot) {
return TileEntityGratedChute.this.isBlacklist != TileEntityGratedChute.this.isItemInFrame(stack);
return BlockEntityGratedChute.this.isBlacklist != BlockEntityGratedChute.this.isItemInFrame(stack);
}
};
private int cooldown;
public TileEntityGratedChute() {
public BlockEntityGratedChute() {
super(ModTileEntities.GRATED_CHUTE);
}
@Override
public void tick() {
if (!this.world.isRemote) {
if (!this.level.isClientSide) {
if (this.cooldown <= 0) {
this.cooldown = 6;
if (this.redstonePower > 0)
@ -48,9 +48,9 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickableTi
ItemStack curr = this.items.getStackInSlot(0);
push:
if (!curr.isEmpty()) {
BlockState state = this.world.getBlockState(this.pos);
BlockState state = this.level.getBlockState(this.worldPosition);
Direction facing = state.get(BlockGratedChute.FACING);
TileEntity tile = this.world.getTileEntity(this.pos.offset(facing));
BlockEntity tile = this.level.getBlockEntity(this.worldPosition.offset(facing));
if (tile == null)
break push;
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,
@ -70,9 +70,9 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickableTi
}
pull:
if (curr.isEmpty() || curr.getCount() < curr.getMaxStackSize()) {
List<ItemEntity> items = this.world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(
this.pos.getX(), this.pos.getY() + 0.5, this.pos.getZ(),
this.pos.getX() + 1, this.pos.getY() + 2, this.pos.getZ() + 1));
List<ItemEntity> items = this.level.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(
this.worldPosition.getX(), this.worldPosition.getY() + 0.5, this.worldPosition.getZ(),
this.worldPosition.getX() + 1, this.worldPosition.getY() + 2, this.worldPosition.getZ() + 1));
for (ItemEntity item : items) {
if (!item.isAlive())
continue;
@ -89,7 +89,7 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickableTi
}
}
TileEntity tileUp = this.world.getTileEntity(this.pos.up());
BlockEntity tileUp = this.level.getBlockEntity(this.worldPosition.up());
if (tileUp == null)
break pull;
IItemHandler handlerUp = tileUp.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN).orElse(null);
@ -112,7 +112,7 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickableTi
}
private boolean isItemInFrame(ItemStack stack) {
List<ItemFrameEntity> frames = Helper.getAttachedItemFrames(this.world, this.pos);
List<ItemFrameEntity> frames = Helper.getAttachedItemFrames(this.level, this.worldPosition);
if (frames.isEmpty())
return false;
for (ItemFrameEntity frame : frames) {
@ -125,7 +125,7 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickableTi
}
@Override
public void writeNBT(CompoundNBT compound, SaveType type) {
public void writeNBT(CompoundTag compound, SaveType type) {
super.writeNBT(compound, type);
if (type != SaveType.BLOCK) {
compound.putInt("cooldown", this.cooldown);
@ -135,7 +135,7 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickableTi
}
@Override
public void readNBT(CompoundNBT compound, SaveType type) {
public void readNBT(CompoundTag compound, SaveType type) {
super.readNBT(compound, type);
if (type != SaveType.BLOCK) {
this.cooldown = compound.getInt("cooldown");

Some files were not shown because too many files have changed in this diff Show more