diff --git a/banner.png b/banner.png index 2dc28917..97d3d543 100644 Binary files a/banner.png and b/banner.png differ diff --git a/banner.psd b/banner.psd index cc47d5b1..b76db453 100644 Binary files a/banner.psd and b/banner.psd differ diff --git a/build.gradle b/build.gradle index f1476867..eb6a7ca7 100644 --- a/build.gradle +++ b/build.gradle @@ -2,18 +2,19 @@ buildscript { repositories { maven { url = 'https://files.minecraftforge.net/maven' } maven { url = 'https://repo.spongepowered.org/repository/maven-public/' } - //maven { url = 'https://maven.parchmentmc.org' } + maven { url = 'https://maven.parchmentmc.org' } + jcenter() mavenCentral() } dependencies { classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.7-SNAPSHOT' - //classpath 'org.parchmentmc:librarian:1.+' + classpath 'org.parchmentmc:librarian:1.+' } } apply plugin: 'net.minecraftforge.gradle' // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. -//apply plugin: 'org.parchmentmc.librarian.forgegradle' +apply plugin: 'org.parchmentmc.librarian.forgegradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'eclipse' apply plugin: 'maven-publish' @@ -22,7 +23,7 @@ version = "${mod_version}-mc${mc_version}" group = 'insane96mcp.progressivebosses' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'ProgressiveBosses' -java.toolchain.languageVersion = JavaLanguageVersion.of(17) // Need this here so eclipse task generates correctly. +sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. minecraft { // The mappings can be changed at any time, and must be in the following format. @@ -30,7 +31,7 @@ minecraft { // stable_# Stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'official', version: '1.18.1' + mappings channel: 'parchment', version: '2021.10.17-1.16.5' // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') @@ -106,19 +107,22 @@ dependencies { // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. - minecraft 'net.minecraftforge:forge:1.18.1-39.0.0' + minecraft 'net.minecraftforge:forge:1.16.5-36.2.9' // Mixin annotation processor - generates the refmap //annotationProcessor 'org.spongepowered:mixin:0.8.3:processor' // Prevent Mixin annotation processor from getting into IntelliJ's annotation processor settings // This allows 'Settings > Build, Execution, and Deployment > Build Tools > Gradle > Build and run using' set to IntelliJ to work correctly - annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor" + if (System.getProperty('idea.sync.active') != 'true') { + // Mixin annotation processor - generates the refmap + annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor" + } // You may put jars on which you depend on in ./libs or you may define them like so.. implementation fg.deobf("blank:InsaneLib:${lib_version}-mc${mc_version}") // compile "some.group:artifact:version" - //implementation fg.deobf("curse.maven:endergetic-291509:3154938") - //implementation fg.deobf("curse.maven:abnormals_core-382216:3147409") + implementation fg.deobf("curse.maven:endergetic-291509:3154938") + implementation fg.deobf("curse.maven:abnormals_core-382216:3147409") // Real examples // compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env diff --git a/gradle.properties b/gradle.properties index 6a81c8b6..e232cf8c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -mc_version=1.18.1 +mc_version=1.16.5 mod_version=3.4.1 -lib_version=1.4.1 +lib_version=1.4.0 mixin_version=0.8.4 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f..7a3265ee 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102e..54165851 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ 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-7.1.1-bin.zip diff --git a/gradlew b/gradlew index c53aefaa..cccdd3d5 100755 --- a/gradlew +++ b/gradlew @@ -1,129 +1,78 @@ -#!/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. -# +#!/usr/bin/env sh ############################################################################## -# -# 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/. -# +## +## Gradle start up script for UN*X +## ############################################################################## # Attempt to set APP_HOME - # Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} +APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +DEFAULT_JVM_OPTS="" # 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 ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + 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 @@ -132,7 +81,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 @@ -140,95 +89,84 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -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 +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 -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) +# 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 - 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" ) + 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 - # 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 + i=$((i+1)) done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac fi -# 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' ' ' - )" '"$@"' +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 107acd32..f9553162 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,19 +1,3 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -29,18 +13,15 @@ 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="-Xmx64m" "-Xms64m" +set DEFAULT_JVM_OPTS= @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 execute +if "%ERRORLEVEL%" == "0" goto init echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -54,7 +35,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto execute +if exist "%JAVA_EXE%" goto init echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -64,14 +45,28 @@ 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 %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% :end @rem End local scope for the variables with windows NT shell diff --git a/icon.png b/icon.png index c58f57f2..2e731664 100644 Binary files a/icon.png and b/icon.png differ diff --git a/icon.psd b/icon.psd index 76b27aa5..69569627 100644 Binary files a/icon.psd and b/icon.psd differ diff --git a/libs/InsaneLib-1.4.0-mc1.16.5.jar b/libs/InsaneLib-1.4.0-mc1.16.5.jar new file mode 100644 index 00000000..1fd48f63 Binary files /dev/null and b/libs/InsaneLib-1.4.0-mc1.16.5.jar differ diff --git a/libs/InsaneLib-1.4.1-mc1.18.1.jar b/libs/InsaneLib-1.4.1-mc1.18.1.jar deleted file mode 100644 index 28c0f583..00000000 Binary files a/libs/InsaneLib-1.4.1-mc1.18.1.jar and /dev/null differ diff --git a/src/main/java/insane96mcp/progressivebosses/ProgressiveBosses.java b/src/main/java/insane96mcp/progressivebosses/ProgressiveBosses.java index e5e35acc..b8a1956d 100644 --- a/src/main/java/insane96mcp/progressivebosses/ProgressiveBosses.java +++ b/src/main/java/insane96mcp/progressivebosses/ProgressiveBosses.java @@ -1,11 +1,13 @@ package insane96mcp.progressivebosses; -import insane96mcp.progressivebosses.capability.DifficultyProvider; +import insane96mcp.progressivebosses.base.Strings; +import insane96mcp.progressivebosses.capability.DifficultyCapability; import insane96mcp.progressivebosses.commands.PBCommand; import insane96mcp.progressivebosses.module.dragon.phase.CrystalRespawnPhase; import insane96mcp.progressivebosses.setup.*; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.RegisterCommandsEvent; @@ -13,6 +15,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -28,6 +31,7 @@ public class ProgressiveBosses { public ProgressiveBosses() { ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.ModConfig.Type.COMMON, Config.COMMON_SPEC); MinecraftForge.EVENT_BUS.register(this); + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(ClientSetup::init); final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); PBItems.ITEMS.register(modEventBus); @@ -40,14 +44,17 @@ public ProgressiveBosses() { @SubscribeEvent public void attachCapabilitiesEntity(final AttachCapabilitiesEvent event) { - final DifficultyProvider provider = new DifficultyProvider(); - - if (event.getObject() instanceof Player) { - event.addCapability(DifficultyProvider.IDENTIFIER, provider); - event.addListener(provider::invalidate); + if(event.getObject() instanceof PlayerEntity) { + DifficultyCapability difficultyCapability = new DifficultyCapability(); + event.addCapability(new ResourceLocation(Strings.Tags.DIFFICULTY), difficultyCapability); + event.addListener(difficultyCapability::invalidate); } } + private void setup(final FMLCommonSetupEvent event) { + DifficultyCapability.register(); + } + @SubscribeEvent public void registerCommands(RegisterCommandsEvent event) { PBCommand.register(event.getDispatcher()); diff --git a/src/main/java/insane96mcp/progressivebosses/capability/Difficulty.java b/src/main/java/insane96mcp/progressivebosses/capability/Difficulty.java index cc26c5ed..075f573b 100644 --- a/src/main/java/insane96mcp/progressivebosses/capability/Difficulty.java +++ b/src/main/java/insane96mcp/progressivebosses/capability/Difficulty.java @@ -1,12 +1,54 @@ package insane96mcp.progressivebosses.capability; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.CapabilityManager; -import net.minecraftforge.common.capabilities.CapabilityToken; +import net.minecraft.util.math.MathHelper; -public class Difficulty { +public class Difficulty implements IDifficulty { + + private int spawnedWithers; + private int killedDragons; + // 0 = just spawned, 1 = first dragon, 2 = first dragon spawned + private byte firstDragon; + + @Override + public int getSpawnedWithers() { + return this.spawnedWithers; + } + + @Override + public void setSpawnedWithers(int spawnedWithers) { + this.spawnedWithers = MathHelper.clamp(spawnedWithers, 0, Integer.MAX_VALUE); + } + + @Override + public int getKilledDragons() { + return this.killedDragons; + } + + @Override + public void setKilledDragons(int killedDragons) { + this.killedDragons = MathHelper.clamp(killedDragons, 0, Integer.MAX_VALUE); + } + + @Override + public byte getFirstDragon() { + return this.firstDragon; + } + + @Override + public void setFirstDragon(byte firstDragon) { + this.firstDragon = firstDragon; + } + + + @Override + public void addSpawnedWithers(int amount) { + this.setSpawnedWithers(this.getSpawnedWithers() + amount); + } + + @Override + public void addKilledDragons(int amount) { + this.setKilledDragons(this.getKilledDragons() + amount); + } - public static final Capability INSTANCE = CapabilityManager.get(new CapabilityToken<>() {}); - public Difficulty() { } } diff --git a/src/main/java/insane96mcp/progressivebosses/capability/DifficultyCapability.java b/src/main/java/insane96mcp/progressivebosses/capability/DifficultyCapability.java new file mode 100644 index 00000000..1138ebe7 --- /dev/null +++ b/src/main/java/insane96mcp/progressivebosses/capability/DifficultyCapability.java @@ -0,0 +1,43 @@ +package insane96mcp.progressivebosses.capability; + +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.Direction; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityInject; +import net.minecraftforge.common.capabilities.CapabilityManager; +import net.minecraftforge.common.capabilities.ICapabilitySerializable; +import net.minecraftforge.common.util.LazyOptional; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class DifficultyCapability implements ICapabilitySerializable { + + @CapabilityInject(IDifficulty.class) + public static final Capability DIFFICULTY = null; + private final LazyOptional instance = LazyOptional.of(DIFFICULTY::getDefaultInstance); + + public static void register() { + CapabilityManager.INSTANCE.register(IDifficulty.class, new DifficultyStorage(), Difficulty::new); + } + + public void invalidate() { + instance.invalidate(); + } + + @Nonnull + @Override + public LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side) { + return DIFFICULTY.orEmpty(cap, instance); + } + + @Override + public CompoundNBT serializeNBT() { + return (CompoundNBT) DIFFICULTY.getStorage().writeNBT(DIFFICULTY, instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional cannot be empty!")), null); + } + + @Override + public void deserializeNBT(CompoundNBT nbt) { + DIFFICULTY.getStorage().readNBT(DIFFICULTY, instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional cannot be empty!")), null, nbt); + } +} diff --git a/src/main/java/insane96mcp/progressivebosses/capability/DifficultyImpl.java b/src/main/java/insane96mcp/progressivebosses/capability/DifficultyImpl.java deleted file mode 100644 index c05b2e9f..00000000 --- a/src/main/java/insane96mcp/progressivebosses/capability/DifficultyImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -package insane96mcp.progressivebosses.capability; - -import net.minecraft.util.Mth; - -public class DifficultyImpl implements IDifficulty { - - private int spawnedWithers; - private int killedDragons; - // 0 = just spawned, 1 = first dragon, 2 = first dragon spawned - private byte firstDragon; - - @Override - public int getSpawnedWithers() { - return this.spawnedWithers; - } - - @Override - public void setSpawnedWithers(int spawnedWithers) { - this.spawnedWithers = Mth.clamp(spawnedWithers, 0, Integer.MAX_VALUE); - } - - @Override - public int getKilledDragons() { - return this.killedDragons; - } - - @Override - public void setKilledDragons(int killedDragons) { - this.killedDragons = Mth.clamp(killedDragons, 0, Integer.MAX_VALUE); - } - - @Override - public byte getFirstDragon() { - return this.firstDragon; - } - - @Override - public void setFirstDragon(byte firstDragon) { - this.firstDragon = firstDragon; - } - - - @Override - public void addSpawnedWithers(int amount) { - this.setSpawnedWithers(this.getSpawnedWithers() + amount); - } - - @Override - public void addKilledDragons(int amount) { - this.setKilledDragons(this.getKilledDragons() + amount); - } - - -} diff --git a/src/main/java/insane96mcp/progressivebosses/capability/DifficultyProvider.java b/src/main/java/insane96mcp/progressivebosses/capability/DifficultyProvider.java deleted file mode 100644 index dc60db69..00000000 --- a/src/main/java/insane96mcp/progressivebosses/capability/DifficultyProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -package insane96mcp.progressivebosses.capability; - -import insane96mcp.progressivebosses.base.Strings; -import net.minecraft.core.Direction; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.common.capabilities.ICapabilitySerializable; -import net.minecraftforge.common.util.LazyOptional; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -//TODO Cleanup this mess -public class DifficultyProvider implements ICapabilityProvider, ICapabilitySerializable { - - public static final ResourceLocation IDENTIFIER = new ResourceLocation(Strings.Tags.DIFFICULTY); - - private final IDifficulty backend = new DifficultyImpl(); - private final LazyOptional optionalData = LazyOptional.of(() -> backend); - - @NotNull - @Override - public LazyOptional getCapability(@NotNull Capability cap, @Nullable Direction side) { - return Difficulty.INSTANCE.orEmpty(cap, this.optionalData); - } - - public void invalidate() { - this.optionalData.invalidate(); - } - - @Override - public CompoundTag serializeNBT() { - CompoundTag nbt = new CompoundTag(); - nbt.putInt(Strings.Tags.SPAWNED_WITHERS, backend.getSpawnedWithers()); - nbt.putInt(Strings.Tags.KILLED_DRAGONS, backend.getKilledDragons()); - nbt.putByte(Strings.Tags.FIRST_DRAGON, backend.getFirstDragon()); - return nbt; - } - - @Override - public void deserializeNBT(CompoundTag nbt) { - backend.setSpawnedWithers(nbt.getInt(Strings.Tags.SPAWNED_WITHERS)); - backend.setKilledDragons(nbt.getInt(Strings.Tags.KILLED_DRAGONS)); - backend.setFirstDragon(nbt.getByte(Strings.Tags.FIRST_DRAGON)); - } -} diff --git a/src/main/java/insane96mcp/progressivebosses/capability/DifficultyStorage.java b/src/main/java/insane96mcp/progressivebosses/capability/DifficultyStorage.java new file mode 100644 index 00000000..0a37395c --- /dev/null +++ b/src/main/java/insane96mcp/progressivebosses/capability/DifficultyStorage.java @@ -0,0 +1,33 @@ +package insane96mcp.progressivebosses.capability; + +import insane96mcp.progressivebosses.base.Strings; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.util.Direction; +import net.minecraftforge.common.capabilities.Capability; + +import javax.annotation.Nullable; + +public class DifficultyStorage implements Capability.IStorage { + + @Nullable + @Override + public INBT writeNBT(Capability capability, IDifficulty instance, Direction side) { + CompoundNBT nbt = new CompoundNBT(); + nbt.putInt(Strings.Tags.SPAWNED_WITHERS, instance.getSpawnedWithers()); + nbt.putInt(Strings.Tags.KILLED_DRAGONS, instance.getKilledDragons()); + nbt.putByte(Strings.Tags.FIRST_DRAGON, instance.getFirstDragon()); + return nbt; + } + + @Override + public void readNBT(Capability capability, IDifficulty instance, Direction side, INBT nbt) { + if (!(instance instanceof Difficulty)) + throw new IllegalArgumentException("Can not deserialize to an instance that isn't the default implementation"); + + CompoundNBT compoundNBT = (CompoundNBT) nbt; + instance.setSpawnedWithers(compoundNBT.getInt(Strings.Tags.SPAWNED_WITHERS)); + instance.setKilledDragons(compoundNBT.getInt(Strings.Tags.KILLED_DRAGONS)); + instance.setFirstDragon(compoundNBT.getByte(Strings.Tags.FIRST_DRAGON)); + } +} diff --git a/src/main/java/insane96mcp/progressivebosses/classutils/Drop.java b/src/main/java/insane96mcp/progressivebosses/classutils/Drop.java index 50fd7d59..93cb575b 100644 --- a/src/main/java/insane96mcp/progressivebosses/classutils/Drop.java +++ b/src/main/java/insane96mcp/progressivebosses/classutils/Drop.java @@ -3,13 +3,13 @@ import insane96mcp.insanelib.utils.LogHelper; import insane96mcp.insanelib.utils.RandomHelper; import insane96mcp.progressivebosses.setup.PBItems; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.World; import net.minecraftforge.registries.ForgeRegistries; import org.apache.commons.lang3.math.NumberUtils; @@ -118,7 +118,7 @@ public static ArrayList parseDropsList(List list) { return drops; } - public void drop(Level world, Vec3 pos, float difficulty) { + public void drop(World world, Vector3d pos, float difficulty) { if (this.amount == 0) return; if (difficulty < this.difficultyRequired) @@ -150,11 +150,11 @@ else if (this.difficultyMode == Drop.DifficultyMode.PER_DIFFICULTY) { } } - private static ItemEntity createDrop(Level world, Vec3 pos, Item item, int amount) { + private static ItemEntity createDrop(World world, Vector3d pos, Item item, int amount) { ItemEntity itemEntity = new ItemEntity(world, pos.x, pos.y, pos.z, new ItemStack(item, amount)); //If it's a nether star shard set it as "invincible" if (item.getRegistryName().equals(PBItems.NETHER_STAR_SHARD.get().getRegistryName())) { - CompoundTag compoundNBT = new CompoundTag(); + CompoundNBT compoundNBT = new CompoundNBT(); itemEntity.addAdditionalSaveData(compoundNBT); compoundNBT.putShort("Health", Short.MAX_VALUE); itemEntity.readAdditionalSaveData(compoundNBT); diff --git a/src/main/java/insane96mcp/progressivebosses/commands/PBCommand.java b/src/main/java/insane96mcp/progressivebosses/commands/PBCommand.java index 1d900a9d..f59d1345 100644 --- a/src/main/java/insane96mcp/progressivebosses/commands/PBCommand.java +++ b/src/main/java/insane96mcp/progressivebosses/commands/PBCommand.java @@ -3,15 +3,15 @@ import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.IntegerArgumentType; import insane96mcp.progressivebosses.base.Strings; -import insane96mcp.progressivebosses.capability.Difficulty; +import insane96mcp.progressivebosses.capability.DifficultyCapability; import insane96mcp.progressivebosses.module.Modules; -import net.minecraft.commands.CommandSourceStack; -import net.minecraft.commands.Commands; -import net.minecraft.commands.arguments.EntityArgument; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.server.level.ServerPlayer; +import net.minecraft.command.CommandSource; +import net.minecraft.command.Commands; +import net.minecraft.command.arguments.EntityArgument; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.text.TranslationTextComponent; import java.util.concurrent.atomic.AtomicInteger; @@ -21,7 +21,7 @@ private PBCommand() { } - public static void register(CommandDispatcher dispatcher) { + public static void register(CommandDispatcher dispatcher) { dispatcher.register(Commands.literal("progressivebosses").requires(source -> source.hasPermission(2)) .then(Commands.literal("difficulty") .then(Commands.argument("targetPlayer", EntityArgument.player()) @@ -99,105 +99,105 @@ public static void register(CommandDispatcher dispatcher) { ); } - private static int setBossDifficulty(CommandSourceStack source, ServerPlayer targetPlayer, String boss, int amount) { + private static int setBossDifficulty(CommandSource source, ServerPlayerEntity targetPlayer, String boss, int amount) { if (boss.equals("wither")) - targetPlayer.getCapability(Difficulty.INSTANCE).ifPresent(difficulty -> difficulty.setSpawnedWithers(amount)); + targetPlayer.getCapability(DifficultyCapability.DIFFICULTY).ifPresent(difficulty -> difficulty.setSpawnedWithers(amount)); if (boss.equals("dragon")) - targetPlayer.getCapability(Difficulty.INSTANCE).ifPresent(difficulty -> difficulty.setKilledDragons(amount)); - source.sendSuccess(new TranslatableComponent(Strings.Translatable.PLAYER_SET_BOSS_DIFFICULTY, targetPlayer.getName(), boss, amount), true); + targetPlayer.getCapability(DifficultyCapability.DIFFICULTY).ifPresent(difficulty -> difficulty.setKilledDragons(amount)); + source.sendSuccess(new TranslationTextComponent(Strings.Translatable.PLAYER_SET_BOSS_DIFFICULTY, targetPlayer.getName(), boss, amount), true); return amount; } - private static int addBossDifficulty(CommandSourceStack source, ServerPlayer targetPlayer, String boss, int amount) { + private static int addBossDifficulty(CommandSource source, ServerPlayerEntity targetPlayer, String boss, int amount) { AtomicInteger difficulty = new AtomicInteger(0); if (boss.equals("wither")) { - targetPlayer.getCapability(Difficulty.INSTANCE).ifPresent(difficultyCap -> { + targetPlayer.getCapability(DifficultyCapability.DIFFICULTY).ifPresent(difficultyCap -> { difficultyCap.addSpawnedWithers(amount); difficulty.set(difficultyCap.getSpawnedWithers()); }); } else if (boss.equals("dragon")) { - targetPlayer.getCapability(Difficulty.INSTANCE).ifPresent(difficultyCap -> { + targetPlayer.getCapability(DifficultyCapability.DIFFICULTY).ifPresent(difficultyCap -> { difficultyCap.addKilledDragons(amount); difficulty.set(difficultyCap.getKilledDragons()); }); } - source.sendSuccess(new TranslatableComponent(Strings.Translatable.PLAYER_ADD_BOSS_DIFFICULTY, amount, boss, targetPlayer.getName(), difficulty.get()), true); + source.sendSuccess(new TranslationTextComponent(Strings.Translatable.PLAYER_ADD_BOSS_DIFFICULTY, amount, boss, targetPlayer.getName(), difficulty.get()), true); return difficulty.get(); } - private static int getBossDifficulty(CommandSourceStack source, ServerPlayer targetPlayer, String boss) { + private static int getBossDifficulty(CommandSource source, ServerPlayerEntity targetPlayer, String boss) { AtomicInteger witherDifficulty = new AtomicInteger(0); - targetPlayer.getCapability(Difficulty.INSTANCE).ifPresent(difficultyCap -> witherDifficulty.set(difficultyCap.getSpawnedWithers())); + targetPlayer.getCapability(DifficultyCapability.DIFFICULTY).ifPresent(difficultyCap -> witherDifficulty.set(difficultyCap.getSpawnedWithers())); AtomicInteger dragonDifficulty = new AtomicInteger(0); - targetPlayer.getCapability(Difficulty.INSTANCE).ifPresent(difficultyCap -> dragonDifficulty.set(difficultyCap.getKilledDragons())); + targetPlayer.getCapability(DifficultyCapability.DIFFICULTY).ifPresent(difficultyCap -> dragonDifficulty.set(difficultyCap.getKilledDragons())); if (boss.equals("wither")) { - source.sendSuccess(new TranslatableComponent(Strings.Translatable.PLAYER_GET_WITHER_DIFFICULTY, targetPlayer.getName(), witherDifficulty), true); + source.sendSuccess(new TranslationTextComponent(Strings.Translatable.PLAYER_GET_WITHER_DIFFICULTY, targetPlayer.getName(), witherDifficulty), true); return witherDifficulty.get(); } else if (boss.equals("dragon")) { - source.sendSuccess(new TranslatableComponent(Strings.Translatable.PLAYER_GET_DRAGON_DIFFICULTY, targetPlayer.getName(), dragonDifficulty), true); + source.sendSuccess(new TranslationTextComponent(Strings.Translatable.PLAYER_GET_DRAGON_DIFFICULTY, targetPlayer.getName(), dragonDifficulty), true); return dragonDifficulty.get(); } else { - source.sendSuccess(new TranslatableComponent(Strings.Translatable.PLAYER_GET_WITHER_DIFFICULTY, targetPlayer.getName(), witherDifficulty), true); - source.sendSuccess(new TranslatableComponent(Strings.Translatable.PLAYER_GET_DRAGON_DIFFICULTY, targetPlayer.getName(), dragonDifficulty), true); + source.sendSuccess(new TranslationTextComponent(Strings.Translatable.PLAYER_GET_WITHER_DIFFICULTY, targetPlayer.getName(), witherDifficulty), true); + source.sendSuccess(new TranslationTextComponent(Strings.Translatable.PLAYER_GET_DRAGON_DIFFICULTY, targetPlayer.getName(), dragonDifficulty), true); return 1; } } - private static int getBossDifficultyLegacy(CommandSourceStack source, ServerPlayer targetPlayer, String boss) { - source.sendSuccess(new TextComponent("This difficulty is no longer used by the mod. The command is here to let you see your old difficulty and trasnfer it to the new system with /progressivebosses difficulty set ."), true); - CompoundTag targetNBT = targetPlayer.getPersistentData(); + private static int getBossDifficultyLegacy(CommandSource source, ServerPlayerEntity targetPlayer, String boss) { + source.sendSuccess(new StringTextComponent("This difficulty is no longer used by the mod. The command is here to let you see your old difficulty and trasnfer it to the new system with /progressivebosses difficulty set ."), true); + CompoundNBT targetNBT = targetPlayer.getPersistentData(); if (boss.equals("wither")) { - source.sendSuccess(new TranslatableComponent(Strings.Translatable.PLAYER_GET_WITHER_DIFFICULTY, targetPlayer.getName(), targetNBT.getInt(Strings.Tags.SPAWNED_WITHERS)), true); + source.sendSuccess(new TranslationTextComponent(Strings.Translatable.PLAYER_GET_WITHER_DIFFICULTY, targetPlayer.getName(), targetNBT.getInt(Strings.Tags.SPAWNED_WITHERS)), true); return targetNBT.getInt(Strings.Tags.SPAWNED_WITHERS); } else if (boss.equals("dragon")) { - source.sendSuccess(new TranslatableComponent(Strings.Translatable.PLAYER_GET_DRAGON_DIFFICULTY, targetPlayer.getName(), targetNBT.getInt(Strings.Tags.KILLED_DRAGONS)), true); + source.sendSuccess(new TranslationTextComponent(Strings.Translatable.PLAYER_GET_DRAGON_DIFFICULTY, targetPlayer.getName(), targetNBT.getInt(Strings.Tags.KILLED_DRAGONS)), true); return targetNBT.getInt(Strings.Tags.KILLED_DRAGONS); } else { - source.sendSuccess(new TranslatableComponent(Strings.Translatable.PLAYER_GET_WITHER_DIFFICULTY, targetPlayer.getName(), targetNBT.getInt(Strings.Tags.SPAWNED_WITHERS)), true); - source.sendSuccess(new TranslatableComponent(Strings.Translatable.PLAYER_GET_DRAGON_DIFFICULTY, targetPlayer.getName(), targetNBT.getInt(Strings.Tags.KILLED_DRAGONS)), true); + source.sendSuccess(new TranslationTextComponent(Strings.Translatable.PLAYER_GET_WITHER_DIFFICULTY, targetPlayer.getName(), targetNBT.getInt(Strings.Tags.SPAWNED_WITHERS)), true); + source.sendSuccess(new TranslationTextComponent(Strings.Translatable.PLAYER_GET_DRAGON_DIFFICULTY, targetPlayer.getName(), targetNBT.getInt(Strings.Tags.KILLED_DRAGONS)), true); return 1; } } - private static int summon(CommandSourceStack source, String entity, int difficulty) { + private static int summon(CommandSource source, String entity, int difficulty) { switch (entity) { case Strings.Tags.WITHER_MINION: Modules.wither.minion.summonMinion(source.getLevel(), source.getPosition(), difficulty, false); - source.sendSuccess(new TranslatableComponent(Strings.Translatable.SUMMONED_ENTITY, new TranslatableComponent(entity), difficulty), true); + source.sendSuccess(new TranslationTextComponent(Strings.Translatable.SUMMONED_ENTITY, new TranslationTextComponent(entity), difficulty), true); return 1; case Strings.Tags.DRAGON_MINION: Modules.dragon.minion.summonMinion(source.getLevel(), source.getPosition(), difficulty); - source.sendSuccess(new TranslatableComponent(Strings.Translatable.SUMMONED_ENTITY, new TranslatableComponent(entity), difficulty), true); + source.sendSuccess(new TranslationTextComponent(Strings.Translatable.SUMMONED_ENTITY, new TranslationTextComponent(entity), difficulty), true); return 1; case Strings.Tags.DRAGON_LARVA: Modules.dragon.larva.summonLarva(source.getLevel(), source.getPosition(), difficulty); - source.sendSuccess(new TranslatableComponent(Strings.Translatable.SUMMONED_ENTITY, new TranslatableComponent(entity), difficulty), true); + source.sendSuccess(new TranslationTextComponent(Strings.Translatable.SUMMONED_ENTITY, new TranslationTextComponent(entity), difficulty), true); return 1; case Strings.Tags.ELDER_MINION: Modules.elderGuardian.minion.summonMinion(source.getLevel(), source.getPosition()); - source.sendSuccess(new TranslatableComponent(Strings.Translatable.SUMMONED_ENTITY, new TranslatableComponent(entity), difficulty), true); + source.sendSuccess(new TranslationTextComponent(Strings.Translatable.SUMMONED_ENTITY, new TranslationTextComponent(entity), difficulty), true); return 1; default: - source.sendSuccess(new TranslatableComponent(Strings.Translatable.SUMMON_ENTITY_INVALID, entity), true); + source.sendSuccess(new TranslationTextComponent(Strings.Translatable.SUMMON_ENTITY_INVALID, entity), true); return 0; } } - private static int summon(CommandSourceStack source, ServerPlayer targetPlayer, String entity) { + private static int summon(CommandSource source, ServerPlayerEntity targetPlayer, String entity) { AtomicInteger witherDifficulty = new AtomicInteger(0); - targetPlayer.getCapability(Difficulty.INSTANCE).ifPresent(difficultyCap -> witherDifficulty.set(difficultyCap.getSpawnedWithers())); + targetPlayer.getCapability(DifficultyCapability.DIFFICULTY).ifPresent(difficultyCap -> witherDifficulty.set(difficultyCap.getSpawnedWithers())); AtomicInteger dragonDifficulty = new AtomicInteger(0); - targetPlayer.getCapability(Difficulty.INSTANCE).ifPresent(difficultyCap -> dragonDifficulty.set(difficultyCap.getKilledDragons())); + targetPlayer.getCapability(DifficultyCapability.DIFFICULTY).ifPresent(difficultyCap -> dragonDifficulty.set(difficultyCap.getKilledDragons())); if (entity.contains("wither")) return summon(source, entity, witherDifficulty.get()); else if (entity.contains("dragon")) diff --git a/src/main/java/insane96mcp/progressivebosses/events/CapabilityEvent.java b/src/main/java/insane96mcp/progressivebosses/events/CapabilityEvent.java deleted file mode 100644 index 9c7cb2a2..00000000 --- a/src/main/java/insane96mcp/progressivebosses/events/CapabilityEvent.java +++ /dev/null @@ -1,15 +0,0 @@ -package insane96mcp.progressivebosses.events; - -import insane96mcp.progressivebosses.ProgressiveBosses; -import insane96mcp.progressivebosses.capability.DifficultyImpl; -import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; - -@Mod.EventBusSubscriber(modid = ProgressiveBosses.MOD_ID) -public class CapabilityEvent { - @SubscribeEvent - public void registerCaps(RegisterCapabilitiesEvent event) { - event.register(DifficultyImpl.class); - } -} diff --git a/src/main/java/insane96mcp/progressivebosses/events/PlayerClone.java b/src/main/java/insane96mcp/progressivebosses/events/PlayerClone.java index f372b940..b0f316a6 100644 --- a/src/main/java/insane96mcp/progressivebosses/events/PlayerClone.java +++ b/src/main/java/insane96mcp/progressivebosses/events/PlayerClone.java @@ -1,8 +1,8 @@ package insane96mcp.progressivebosses.events; import insane96mcp.progressivebosses.ProgressiveBosses; -import insane96mcp.progressivebosses.capability.Difficulty; -import net.minecraft.world.entity.player.Player; +import insane96mcp.progressivebosses.capability.DifficultyCapability; +import net.minecraft.entity.player.PlayerEntity; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -12,11 +12,11 @@ public class PlayerClone { @SubscribeEvent public static void eventPlayerClone(PlayerEvent.Clone event) { - Player oldPlayer = event.getOriginal(); - Player newPlayer = event.getPlayer(); + PlayerEntity oldPlayer = event.getOriginal(); + PlayerEntity newPlayer = event.getPlayer(); - oldPlayer.getCapability(Difficulty.INSTANCE).ifPresent(oldDifficulty -> { - newPlayer.getCapability(Difficulty.INSTANCE).ifPresent(newDifficulty -> { + oldPlayer.getCapability(DifficultyCapability.DIFFICULTY).ifPresent(oldDifficulty -> { + newPlayer.getCapability(DifficultyCapability.DIFFICULTY).ifPresent(newDifficulty -> { newDifficulty.setSpawnedWithers(oldDifficulty.getSpawnedWithers()); newDifficulty.setKilledDragons(oldDifficulty.getKilledDragons()); newDifficulty.setFirstDragon(oldDifficulty.getFirstDragon()); diff --git a/src/main/java/insane96mcp/progressivebosses/mixin/ChargingPlayerPhaseMixin.java b/src/main/java/insane96mcp/progressivebosses/mixin/ChargingPlayerPhaseMixin.java index 1a24ccf8..58cb6f42 100644 --- a/src/main/java/insane96mcp/progressivebosses/mixin/ChargingPlayerPhaseMixin.java +++ b/src/main/java/insane96mcp/progressivebosses/mixin/ChargingPlayerPhaseMixin.java @@ -1,12 +1,12 @@ package insane96mcp.progressivebosses.mixin; import insane96mcp.progressivebosses.module.Modules; -import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.entity.boss.enderdragon.phases.AbstractDragonPhaseInstance; -import net.minecraft.world.entity.boss.enderdragon.phases.DragonChargePlayerPhase; -import net.minecraft.world.entity.boss.enderdragon.phases.DragonPhaseInstance; -import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase; -import net.minecraft.world.phys.Vec3; +import net.minecraft.entity.boss.dragon.EnderDragonEntity; +import net.minecraft.entity.boss.dragon.phase.ChargingPlayerPhase; +import net.minecraft.entity.boss.dragon.phase.IPhase; +import net.minecraft.entity.boss.dragon.phase.Phase; +import net.minecraft.entity.boss.dragon.phase.PhaseType; +import net.minecraft.util.math.vector.Vector3d; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.spongepowered.asm.mixin.Final; @@ -16,8 +16,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(DragonChargePlayerPhase.class) -public abstract class ChargingPlayerPhaseMixin extends AbstractDragonPhaseInstance { +@Mixin(ChargingPlayerPhase.class) +public abstract class ChargingPlayerPhaseMixin extends Phase { @Shadow @Final @@ -25,9 +25,9 @@ public abstract class ChargingPlayerPhaseMixin extends AbstractDragonPhaseInstan @Shadow private int timeSinceCharge; @Shadow - private Vec3 targetLocation; + private Vector3d targetLocation; - public ChargingPlayerPhaseMixin(EnderDragon dragonIn) { + public ChargingPlayerPhaseMixin(EnderDragonEntity dragonIn) { super(dragonIn); } @@ -35,11 +35,11 @@ public ChargingPlayerPhaseMixin(EnderDragon dragonIn) { public void doServerTick() { if (this.targetLocation == null) { LOGGER.warn("Aborting charge player as no target was set."); - this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN); + this.dragon.getPhaseManager().setPhase(PhaseType.HOLDING_PATTERN); } else if (this.timeSinceCharge > 0 && this.timeSinceCharge++ >= 10) { //If must not charge or fireball then go back to holding pattern if (!Modules.dragon.attack.onPhaseEnd(this.dragon)) - this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN); + this.dragon.getPhaseManager().setPhase(PhaseType.HOLDING_PATTERN); //Otherwise reset the phase, in case she charges again else //Can't use initPhase() otherwise the target is reset. Also making the dragon take more time to restart the charging @@ -62,5 +62,5 @@ private void getFlySpeed(CallbackInfoReturnable callback) { @Shadow public abstract void begin(); @Override - public EnderDragonPhase getPhase() { return EnderDragonPhase.CHARGING_PLAYER; } + public PhaseType getPhase() { return PhaseType.CHARGING_PLAYER; } } diff --git a/src/main/java/insane96mcp/progressivebosses/mixin/DragonFireballEntityMixin.java b/src/main/java/insane96mcp/progressivebosses/mixin/DragonFireballEntityMixin.java index 1345d1c7..4eb6e4af 100644 --- a/src/main/java/insane96mcp/progressivebosses/mixin/DragonFireballEntityMixin.java +++ b/src/main/java/insane96mcp/progressivebosses/mixin/DragonFireballEntityMixin.java @@ -1,26 +1,26 @@ package insane96mcp.progressivebosses.mixin; import insane96mcp.progressivebosses.module.Modules; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.projectile.AbstractHurtingProjectile; -import net.minecraft.world.entity.projectile.DragonFireball; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.HitResult; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.projectile.DamagingProjectileEntity; +import net.minecraft.entity.projectile.DragonFireballEntity; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(DragonFireball.class) -public class DragonFireballEntityMixin extends AbstractHurtingProjectile { +@Mixin(DragonFireballEntity.class) +public class DragonFireballEntityMixin extends DamagingProjectileEntity { - protected DragonFireballEntityMixin(EntityType p_i50173_1_, Level p_i50173_2_) { + protected DragonFireballEntityMixin(EntityType p_i50173_1_, World p_i50173_2_) { super(p_i50173_1_, p_i50173_2_); } - @Inject(at = @At("HEAD"), method = "onHit(Lnet/minecraft/world/phys/HitResult;)V", cancellable = true) - private void onHit(HitResult result, CallbackInfo callback) { - if (Modules.dragon.attack.onFireballImpact((DragonFireball) (Object) this, this.getOwner(), result)) + @Inject(at = @At("HEAD"), method = "onHit(Lnet/minecraft/util/math/RayTraceResult;)V", cancellable = true) + private void onHit(RayTraceResult result, CallbackInfo callback) { + if (Modules.dragon.attack.onFireballImpact((DragonFireballEntity) (Object) this, this.getOwner(), result)) callback.cancel(); } } diff --git a/src/main/java/insane96mcp/progressivebosses/mixin/ElderGuardianEntityMixin.java b/src/main/java/insane96mcp/progressivebosses/mixin/ElderGuardianEntityMixin.java index 7b251f58..2283f701 100644 --- a/src/main/java/insane96mcp/progressivebosses/mixin/ElderGuardianEntityMixin.java +++ b/src/main/java/insane96mcp/progressivebosses/mixin/ElderGuardianEntityMixin.java @@ -1,17 +1,17 @@ package insane96mcp.progressivebosses.mixin; import insane96mcp.progressivebosses.module.Modules; -import net.minecraft.world.entity.monster.ElderGuardian; +import net.minecraft.entity.monster.ElderGuardianEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(ElderGuardian.class) +@Mixin(ElderGuardianEntity.class) public class ElderGuardianEntityMixin { @Inject(at = @At("HEAD"), method = "getAttackDuration()I", cancellable = true) private void getAttackDuration(CallbackInfoReturnable callback) { - callback.setReturnValue(Modules.elderGuardian.attack.getAttackDuration((ElderGuardian) (Object) this)); + callback.setReturnValue(Modules.elderGuardian.attack.getAttackDuration((ElderGuardianEntity) (Object) this)); } } diff --git a/src/main/java/insane96mcp/progressivebosses/mixin/EnderCrystalEntityMixin.java b/src/main/java/insane96mcp/progressivebosses/mixin/EnderCrystalEntityMixin.java index 8b030c1e..71d5cd39 100644 --- a/src/main/java/insane96mcp/progressivebosses/mixin/EnderCrystalEntityMixin.java +++ b/src/main/java/insane96mcp/progressivebosses/mixin/EnderCrystalEntityMixin.java @@ -1,19 +1,19 @@ package insane96mcp.progressivebosses.mixin; import insane96mcp.progressivebosses.module.Modules; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.boss.enderdragon.EndCrystal; +import net.minecraft.entity.item.EnderCrystalEntity; +import net.minecraft.util.DamageSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(EndCrystal.class) +@Mixin(EnderCrystalEntity.class) public class EnderCrystalEntityMixin { - @Inject(at = @At("HEAD"), method = "hurt(Lnet/minecraft/world/damagesource/DamageSource;F)Z", cancellable = true) + @Inject(at = @At("HEAD"), method = "hurt(Lnet/minecraft/util/DamageSource;F)Z", cancellable = true) private void hurt(DamageSource source, float amount, CallbackInfoReturnable callback) { - if (Modules.dragon.crystal.onDamageFromExplosion((EndCrystal) (Object) this, source)) + if (Modules.dragon.crystal.onDamageFromExplosion((EnderCrystalEntity) (Object) this, source)) callback.setReturnValue(false); } } diff --git a/src/main/java/insane96mcp/progressivebosses/mixin/EnderDragonEntityMixin.java b/src/main/java/insane96mcp/progressivebosses/mixin/EnderDragonEntityMixin.java index f8c7b797..7c6ea9fa 100644 --- a/src/main/java/insane96mcp/progressivebosses/mixin/EnderDragonEntityMixin.java +++ b/src/main/java/insane96mcp/progressivebosses/mixin/EnderDragonEntityMixin.java @@ -1,25 +1,25 @@ package insane96mcp.progressivebosses.mixin; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.damagesource.EntityDamageSource; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.level.Level; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.MobEntity; +import net.minecraft.entity.boss.dragon.EnderDragonEntity; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EntityDamageSource; +import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(EnderDragon.class) -public class EnderDragonEntityMixin extends Mob { - protected EnderDragonEntityMixin(EntityType type, Level worldIn) { +@Mixin(EnderDragonEntity.class) +public class EnderDragonEntityMixin extends MobEntity { + protected EnderDragonEntityMixin(EntityType type, World worldIn) { super(type, worldIn); } - @Inject(at = @At("HEAD"), method = "hurt(Lnet/minecraft/world/damagesource/DamageSource;F)Z", cancellable = true) + @Inject(at = @At("HEAD"), method = "hurt(Lnet/minecraft/util/DamageSource;F)Z", cancellable = true) private void hurt(DamageSource source, float amount, CallbackInfoReturnable callback) { - EnderDragon $this = (EnderDragon) (Object) this; + EnderDragonEntity $this = (EnderDragonEntity) (Object) this; if (source instanceof EntityDamageSource && !((EntityDamageSource)source).isThorns()) { $this.hurt($this.getSubEntities()[2], source, amount); } diff --git a/src/main/java/insane96mcp/progressivebosses/mixin/HoldingPatternPhaseMixin.java b/src/main/java/insane96mcp/progressivebosses/mixin/HoldingPatternPhaseMixin.java index fde87bcd..bb8fec24 100644 --- a/src/main/java/insane96mcp/progressivebosses/mixin/HoldingPatternPhaseMixin.java +++ b/src/main/java/insane96mcp/progressivebosses/mixin/HoldingPatternPhaseMixin.java @@ -1,15 +1,15 @@ package insane96mcp.progressivebosses.mixin; import insane96mcp.progressivebosses.module.Modules; -import net.minecraft.world.entity.boss.enderdragon.phases.DragonHoldingPatternPhase; -import net.minecraft.world.level.pathfinder.Path; +import net.minecraft.entity.boss.dragon.phase.HoldingPatternPhase; +import net.minecraft.pathfinding.Path; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(DragonHoldingPatternPhase.class) +@Mixin(HoldingPatternPhase.class) public class HoldingPatternPhaseMixin { @Shadow @@ -20,7 +20,7 @@ private void findNewTarget(CallbackInfo callback) { if (this.currentPath == null || !this.currentPath.isDone()) return; - if (Modules.dragon.attack.onPhaseEnd(((DragonHoldingPatternPhase)(Object)this).dragon)) + if (Modules.dragon.attack.onPhaseEnd(((HoldingPatternPhase)(Object)this).dragon)) callback.cancel(); } } diff --git a/src/main/java/insane96mcp/progressivebosses/mixin/LandingPhaseMixin.java b/src/main/java/insane96mcp/progressivebosses/mixin/LandingPhaseMixin.java index ec21aed8..a264567c 100644 --- a/src/main/java/insane96mcp/progressivebosses/mixin/LandingPhaseMixin.java +++ b/src/main/java/insane96mcp/progressivebosses/mixin/LandingPhaseMixin.java @@ -1,13 +1,13 @@ package insane96mcp.progressivebosses.mixin; import insane96mcp.progressivebosses.module.Modules; -import net.minecraft.world.entity.boss.enderdragon.phases.DragonLandingPhase; +import net.minecraft.entity.boss.dragon.phase.LandingPhase; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(DragonLandingPhase.class) +@Mixin(LandingPhase.class) public class LandingPhaseMixin { @Inject(at = @At("HEAD"), method = "getFlySpeed()F", cancellable = true) diff --git a/src/main/java/insane96mcp/progressivebosses/mixin/ShulkerBulletEntityMixin.java b/src/main/java/insane96mcp/progressivebosses/mixin/ShulkerBulletEntityMixin.java index 16295711..0486629f 100644 --- a/src/main/java/insane96mcp/progressivebosses/mixin/ShulkerBulletEntityMixin.java +++ b/src/main/java/insane96mcp/progressivebosses/mixin/ShulkerBulletEntityMixin.java @@ -2,23 +2,23 @@ import insane96mcp.progressivebosses.base.Strings; import insane96mcp.progressivebosses.module.Modules; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.projectile.Projectile; -import net.minecraft.world.entity.projectile.ShulkerBullet; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.projectile.ProjectileEntity; +import net.minecraft.entity.projectile.ShulkerBulletEntity; +import net.minecraft.potion.EffectInstance; +import net.minecraft.potion.Effects; +import net.minecraft.util.math.EntityRayTraceResult; +import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(ShulkerBullet.class) -public abstract class ShulkerBulletEntityMixin extends Projectile { +@Mixin(ShulkerBulletEntity.class) +public abstract class ShulkerBulletEntityMixin extends ProjectileEntity { - public ShulkerBulletEntityMixin(EntityType entityType, Level world) { + public ShulkerBulletEntityMixin(EntityType entityType, World world) { super(entityType, world); this.noPhysics = true; } @@ -29,15 +29,15 @@ protected void onEntityHit(EntityRayTraceResult rayTraceResult) { Modules.dragon.minion.onBulletEntityHit((ShulkerBulletEntity) (Object) this, rayTraceResult); }*/ - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;addEffect(Lnet/minecraft/world/effect/MobEffectInstance;Lnet/minecraft/world/entity/Entity;)Z"), method = "onHitEntity(Lnet/minecraft/world/phys/EntityHitResult;)V") - protected void onEntityHit(EntityHitResult rayTraceResult, CallbackInfo callbackInfo) { - ShulkerBullet $this = (ShulkerBullet) (Object) this; + @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;addEffect(Lnet/minecraft/potion/EffectInstance;)Z"), method = "onHitEntity(Lnet/minecraft/util/math/EntityRayTraceResult;)V") + protected void onEntityHit(EntityRayTraceResult rayTraceResult, CallbackInfo callbackInfo) { + ShulkerBulletEntity $this = (ShulkerBulletEntity) (Object) this; if ($this.getPersistentData().getBoolean(Strings.Tags.BLINDNESS_BULLET)) - ((LivingEntity)rayTraceResult.getEntity()).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 150)); + ((LivingEntity)rayTraceResult.getEntity()).addEffect(new EffectInstance(Effects.BLINDNESS, 150)); } @Inject(at = @At("HEAD"), method = "tick()V", cancellable = true) public void tick(CallbackInfo callback) { - Modules.dragon.minion.onBulletTick((ShulkerBullet) (Object) this); + Modules.dragon.minion.onBulletTick((ShulkerBulletEntity) (Object) this); } } diff --git a/src/main/java/insane96mcp/progressivebosses/mixin/StrafePlayerPhaseMixin.java b/src/main/java/insane96mcp/progressivebosses/mixin/StrafePlayerPhaseMixin.java index ac59c834..93a77e5f 100644 --- a/src/main/java/insane96mcp/progressivebosses/mixin/StrafePlayerPhaseMixin.java +++ b/src/main/java/insane96mcp/progressivebosses/mixin/StrafePlayerPhaseMixin.java @@ -2,30 +2,30 @@ import insane96mcp.insanelib.utils.LogHelper; import insane96mcp.progressivebosses.module.Modules; -import net.minecraft.util.Mth; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.entity.boss.enderdragon.phases.AbstractDragonPhaseInstance; -import net.minecraft.world.entity.boss.enderdragon.phases.DragonPhaseInstance; -import net.minecraft.world.entity.boss.enderdragon.phases.DragonStrafePlayerPhase; -import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase; -import net.minecraft.world.level.pathfinder.Path; -import net.minecraft.world.phys.Vec3; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.boss.dragon.EnderDragonEntity; +import net.minecraft.entity.boss.dragon.phase.IPhase; +import net.minecraft.entity.boss.dragon.phase.Phase; +import net.minecraft.entity.boss.dragon.phase.PhaseType; +import net.minecraft.entity.boss.dragon.phase.StrafePlayerPhase; +import net.minecraft.pathfinding.Path; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.vector.Vector3d; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -@Mixin(DragonStrafePlayerPhase.class) -public abstract class StrafePlayerPhaseMixin extends AbstractDragonPhaseInstance { +@Mixin(StrafePlayerPhase.class) +public abstract class StrafePlayerPhaseMixin extends Phase { @Shadow private int fireballCharge; @Shadow private Path currentPath; @Shadow - private Vec3 targetLocation; + private Vector3d targetLocation; @Shadow private LivingEntity attackTarget; - public StrafePlayerPhaseMixin(EnderDragon dragonIn) { + public StrafePlayerPhaseMixin(EnderDragonEntity dragonIn) { super(dragonIn); } @@ -33,16 +33,16 @@ public StrafePlayerPhaseMixin(EnderDragon dragonIn) { public void doServerTick() { if (this.attackTarget == null) { LogHelper.warn("Skipping player strafe phase because no player was found"); - this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN); + this.dragon.getPhaseManager().setPhase(PhaseType.HOLDING_PATTERN); } else { if (this.currentPath != null && this.currentPath.isDone()) { double d0 = this.attackTarget.getX(); double d1 = this.attackTarget.getZ(); double d2 = d0 - this.dragon.getX(); double d3 = d1 - this.dragon.getZ(); - double d4 = Mth.sqrt((float) (d2 * d2 + d3 * d3)); + double d4 = MathHelper.sqrt(d2 * d2 + d3 * d3); double d5 = Math.min((double)0.4F + d4 / 80.0D - 1.0D, 10.0D); - this.targetLocation = new Vec3(d0, this.attackTarget.getY() + d5, d1); + this.targetLocation = new Vector3d(d0, this.attackTarget.getY() + d5, d1); } double d12 = this.targetLocation == null ? 0.0D : this.targetLocation.distanceToSqr(this.dragon.getX(), this.dragon.getY(), this.dragon.getZ()); @@ -52,10 +52,10 @@ public void doServerTick() { double d13 = 96.0d; if (this.attackTarget.distanceToSqr(this.dragon) < 9216d) { - if (this.dragon.hasLineOfSight(this.attackTarget)) { + if (this.dragon.canSee(this.attackTarget)) { ++this.fireballCharge; - Vec3 vector3d1 = (new Vec3(this.attackTarget.getX() - this.dragon.getX(), 0.0D, this.attackTarget.getZ() - this.dragon.getZ())).normalize(); - Vec3 vector3d = (new Vec3((double) Mth.sin(this.dragon.getRotationVector().y * ((float)Math.PI / 180F)), 0.0D, (double)(-Mth.cos(this.dragon.getRotationVector().y * ((float)Math.PI / 180F))))).normalize(); + Vector3d vector3d1 = (new Vector3d(this.attackTarget.getX() - this.dragon.getX(), 0.0D, this.attackTarget.getZ() - this.dragon.getZ())).normalize(); + Vector3d vector3d = (new Vector3d((double) MathHelper.sin(this.dragon.yRot * ((float)Math.PI / 180F)), 0.0D, (double)(-MathHelper.cos(this.dragon.yRot * ((float)Math.PI / 180F))))).normalize(); float f1 = (float)vector3d.dot(vector3d1); float f = (float)(Math.acos(f1) * (double)(180F / (float)Math.PI)); f = f + 0.5F; @@ -70,7 +70,7 @@ public void doServerTick() { //If must not charge or fireball then go back to holding pattern if (!Modules.dragon.attack.onPhaseEnd(this.dragon)) - this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN); + this.dragon.getPhaseManager().setPhase(PhaseType.HOLDING_PATTERN); //Otherwise reset the phase, in case she fireballs again else //Can't use initPhase() otherwise the target is reset. Also making the dragon fire slower when chaining fireballs @@ -94,5 +94,5 @@ private void findNewTarget() {} @Shadow public abstract void begin(); @Override - public EnderDragonPhase getPhase() { return EnderDragonPhase.STRAFE_PLAYER; } + public PhaseType getPhase() { return PhaseType.STRAFE_PLAYER; } } diff --git a/src/main/java/insane96mcp/progressivebosses/module/dragon/ai/DragonMinionAttackGoal.java b/src/main/java/insane96mcp/progressivebosses/module/dragon/ai/DragonMinionAttackGoal.java index d52ff99f..20ce72bc 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/dragon/ai/DragonMinionAttackGoal.java +++ b/src/main/java/insane96mcp/progressivebosses/module/dragon/ai/DragonMinionAttackGoal.java @@ -2,24 +2,24 @@ import insane96mcp.progressivebosses.base.Strings; import insane96mcp.progressivebosses.utils.DragonMinionHelper; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.sounds.SoundEvents; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.ai.goal.Goal; +import net.minecraft.entity.monster.ShulkerEntity; +import net.minecraft.entity.projectile.ShulkerBulletEntity; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.SoundEvents; import net.minecraft.world.Difficulty; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.ai.goal.Goal; -import net.minecraft.world.entity.monster.Shulker; -import net.minecraft.world.entity.projectile.ShulkerBullet; import java.util.EnumSet; public class DragonMinionAttackGoal extends Goal { private int attackTime; - private final Shulker shulker; + private final ShulkerEntity shulker; private final int baseAttackInterval; - public DragonMinionAttackGoal(Shulker shulker, int attackInterval) { + public DragonMinionAttackGoal(ShulkerEntity shulker, int attackInterval) { this.shulker = shulker; this.baseAttackInterval = attackInterval; this.setFlags(EnumSet.of(Flag.MOVE, Flag.LOOK)); @@ -56,9 +56,9 @@ public void tick() { if (d0 < 9216d) { //96 blocks if (this.attackTime <= 0) { this.attackTime = this.baseAttackInterval + shulker.getRandom().nextInt(10) * this.baseAttackInterval / 2; - ShulkerBullet bullet = new ShulkerBullet(shulker.level, shulker, livingentity, shulker.getAttachFace().getAxis()); + ShulkerBulletEntity bullet = new ShulkerBulletEntity(shulker.level, shulker, livingentity, shulker.getAttachFace().getAxis()); if (DragonMinionHelper.isBlindingMinion(this.shulker)) { - CompoundTag nbt = bullet.getPersistentData(); + CompoundNBT nbt = bullet.getPersistentData(); nbt.putBoolean(Strings.Tags.BLINDNESS_BULLET, true); } shulker.level.addFreshEntity(bullet); diff --git a/src/main/java/insane96mcp/progressivebosses/module/dragon/ai/PBNearestAttackableTargetGoal.java b/src/main/java/insane96mcp/progressivebosses/module/dragon/ai/PBNearestAttackableTargetGoal.java index 49b864dc..2f2052c3 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/dragon/ai/PBNearestAttackableTargetGoal.java +++ b/src/main/java/insane96mcp/progressivebosses/module/dragon/ai/PBNearestAttackableTargetGoal.java @@ -1,18 +1,18 @@ package insane96mcp.progressivebosses.module.dragon.ai; -import net.minecraft.core.Direction; +import net.minecraft.entity.MobEntity; +import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal; +import net.minecraft.entity.monster.ShulkerEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.Direction; +import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.Difficulty; -import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; -import net.minecraft.world.entity.monster.Shulker; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.phys.AABB; -public class PBNearestAttackableTargetGoal extends NearestAttackableTargetGoal { - public PBNearestAttackableTargetGoal(Mob shulkerEntity) { - super(shulkerEntity, Player.class, 0, false, false, null); +public class PBNearestAttackableTargetGoal extends NearestAttackableTargetGoal { + public PBNearestAttackableTargetGoal(MobEntity shulkerEntity) { + super(shulkerEntity, PlayerEntity.class, 0, false, false, null); //allowUnseeable - this.targetConditions.ignoreLineOfSight(); + this.targetConditions.allowUnseeable(); } public boolean canUse() { @@ -20,8 +20,8 @@ public boolean canUse() { } - protected AABB getTargetableArea(double targetDistance) { - Direction direction = ((Shulker) this.mob).getAttachFace(); + protected AxisAlignedBB getTargetableArea(double targetDistance) { + Direction direction = ((ShulkerEntity) this.mob).getAttachFace(); if (direction.getAxis() == Direction.Axis.X) { return this.mob.getBoundingBox().inflate(4.0D, targetDistance, targetDistance); diff --git a/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/AttackFeature.java b/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/AttackFeature.java index d63ab85b..89aa1aa8 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/AttackFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/AttackFeature.java @@ -9,25 +9,25 @@ import insane96mcp.progressivebosses.module.Modules; import insane96mcp.progressivebosses.setup.Config; import insane96mcp.progressivebosses.setup.Reflection; -import net.minecraft.core.BlockPos; -import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.damagesource.IndirectEntityDamageSource; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.AreaEffectCloud; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.boss.enderdragon.EndCrystal; -import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.entity.projectile.DragonFireball; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.levelgen.Heightmap; -import net.minecraft.world.level.levelgen.feature.EndPodiumFeature; -import net.minecraft.world.phys.*; +import net.minecraft.entity.AreaEffectCloudEntity; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.boss.dragon.EnderDragonEntity; +import net.minecraft.entity.boss.dragon.phase.PhaseType; +import net.minecraft.entity.item.EnderCrystalEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.entity.projectile.DragonFireballEntity; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.particles.ParticleTypes; +import net.minecraft.potion.EffectInstance; +import net.minecraft.potion.Effects; +import net.minecraft.util.IndirectEntityDamageSource; +import net.minecraft.util.math.*; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.World; +import net.minecraft.world.gen.Heightmap; +import net.minecraft.world.gen.feature.EndPodiumFeature; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; @@ -118,13 +118,13 @@ public void onSpawn(EntityJoinWorldEvent event) { } private void fireballSpeed(Entity entity) { - if (!(entity instanceof DragonFireball)) + if (!(entity instanceof DragonFireballEntity)) return; if (!this.isEnabled() || this.fireballVelocityMultiplier == 0d) return; - DragonFireball fireball = (DragonFireball) entity; + DragonFireballEntity fireball = (DragonFireballEntity) entity; if (Math.abs(fireball.xPower) > 10 || Math.abs(fireball.yPower) > 10 || Math.abs(fireball.zPower) > 10) { entity.kill(); @@ -149,11 +149,11 @@ public void onDamageDealt(LivingHurtEvent event) { } private void onDirectDamage(LivingHurtEvent event) { - if (!(event.getSource().getDirectEntity() instanceof EnderDragon) || event.getEntityLiving() instanceof EnderDragon) + if (!(event.getSource().getDirectEntity() instanceof EnderDragonEntity) || event.getEntityLiving() instanceof EnderDragonEntity) return; - EnderDragon wither = (EnderDragon) event.getSource().getDirectEntity(); + EnderDragonEntity wither = (EnderDragonEntity) event.getSource().getDirectEntity(); - CompoundTag compoundNBT = wither.getPersistentData(); + CompoundNBT compoundNBT = wither.getPersistentData(); float difficulty = compoundNBT.getFloat(Strings.Tags.DIFFICULTY); if (difficulty == 0f) @@ -163,11 +163,11 @@ private void onDirectDamage(LivingHurtEvent event) { } private void onAcidDamage(LivingHurtEvent event) { - if (!(event.getSource().getEntity() instanceof EnderDragon) || !(event.getSource().getDirectEntity() instanceof AreaEffectCloud)) + if (!(event.getSource().getEntity() instanceof EnderDragonEntity) || !(event.getSource().getDirectEntity() instanceof AreaEffectCloudEntity)) return; - EnderDragon dragon = (EnderDragon) event.getSource().getEntity(); + EnderDragonEntity dragon = (EnderDragonEntity) event.getSource().getEntity(); - CompoundTag compoundNBT = dragon.getPersistentData(); + CompoundNBT compoundNBT = dragon.getPersistentData(); float difficulty = compoundNBT.getFloat(Strings.Tags.DIFFICULTY); if (difficulty == 0f) @@ -176,7 +176,7 @@ private void onAcidDamage(LivingHurtEvent event) { event.setAmount(event.getAmount() * (float)(1d + (this.increasedAcidPoolDamage * difficulty))); } - public boolean onPhaseEnd(EnderDragon dragon) { + public boolean onPhaseEnd(EnderDragonEntity dragon) { boolean chargePlayer = shouldChargePlayer(dragon); boolean fireballPlayer = shouldFireballPlayer(dragon); @@ -193,24 +193,24 @@ else if (fireballPlayer) return chargePlayer || fireballPlayer; } - private boolean shouldChargePlayer(EnderDragon dragon) { + private boolean shouldChargePlayer(EnderDragonEntity dragon) { if (this.chargePlayerMaxChance == 0f) return false; if (dragon.getDragonFight() == null) return false; - CompoundTag tags = dragon.getPersistentData(); + CompoundNBT tags = dragon.getPersistentData(); float difficulty = tags.getFloat(Strings.Tags.DIFFICULTY); double chance = this.chargePlayerMaxChance * (difficulty / Modules.dragon.difficulty.maxDifficulty); - BlockPos centerPodium = dragon.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION); - AABB boundingBox = new AABB(centerPodium).inflate(128d); - List players = dragon.level.getEntitiesOfClass(Player.class, boundingBox); + BlockPos centerPodium = dragon.level.getHeightmapPos(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION); + AxisAlignedBB boundingBox = new AxisAlignedBB(centerPodium).inflate(128d); + List players = dragon.level.getLoadedEntitiesOfClass(PlayerEntity.class, boundingBox); - for (Player player : players) { - List endCrystals = player.level.getEntitiesOfClass(EndCrystal.class, player.getBoundingBox().inflate(10d)); + for (PlayerEntity player : players) { + List endCrystals = player.level.getLoadedEntitiesOfClass(EnderCrystalEntity.class, player.getBoundingBox().inflate(10d)); if (endCrystals.size() > 0) { chance *= 2d; break; @@ -223,33 +223,33 @@ private boolean shouldChargePlayer(EnderDragon dragon) { return rng < chance; } - private void chargePlayer(EnderDragon dragon) { - BlockPos centerPodium = dragon.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION); - AABB bb = new AABB(centerPodium).inflate(128d); - ServerPlayer player = (ServerPlayer) getRandomPlayerNearCrystal(dragon.level, bb); + private void chargePlayer(EnderDragonEntity dragon) { + BlockPos centerPodium = dragon.level.getHeightmapPos(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION); + AxisAlignedBB bb = new AxisAlignedBB(centerPodium).inflate(128d); + ServerPlayerEntity player = (ServerPlayerEntity) getRandomPlayerNearCrystal(dragon.level, bb); if (player == null) return; //LogHelper.info("charging"); - dragon.getPhaseManager().setPhase(EnderDragonPhase.CHARGING_PLAYER); - Vec3 targetPos = player.position(); + dragon.getPhaseManager().setPhase(PhaseType.CHARGING_PLAYER); + Vector3d targetPos = player.position(); if (targetPos.y < dragon.getY()) targetPos = targetPos.add(0d, -6d, 0d); else targetPos = targetPos.add(0d, 6d, 0d); - dragon.getPhaseManager().getPhase(EnderDragonPhase.CHARGING_PLAYER).setTarget(targetPos); + dragon.getPhaseManager().getPhase(PhaseType.CHARGING_PLAYER).setTarget(targetPos); } - private boolean shouldFireballPlayer(EnderDragon dragon) { + private boolean shouldFireballPlayer(EnderDragonEntity dragon) { if (this.fireballMaxChance == 0f) return false; if (dragon.getDragonFight() == null) return false; - CompoundTag tags = dragon.getPersistentData(); + CompoundNBT tags = dragon.getPersistentData(); float difficulty = tags.getFloat(Strings.Tags.DIFFICULTY); if (difficulty == 0f) @@ -264,22 +264,22 @@ private boolean shouldFireballPlayer(EnderDragon dragon) { return rng < chance; } - private void fireballPlayer(EnderDragon dragon) { - BlockPos centerPodium = dragon.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION); - AABB bb = new AABB(centerPodium).inflate(128d); - ServerPlayer player = (ServerPlayer) getRandomPlayer(dragon.level, bb); + private void fireballPlayer(EnderDragonEntity dragon) { + BlockPos centerPodium = dragon.level.getHeightmapPos(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION); + AxisAlignedBB bb = new AxisAlignedBB(centerPodium).inflate(128d); + ServerPlayerEntity player = (ServerPlayerEntity) getRandomPlayer(dragon.level, bb); if (player == null) return; //LogHelper.info("fireballing"); - dragon.getPhaseManager().setPhase(EnderDragonPhase.STRAFE_PLAYER); - dragon.getPhaseManager().getPhase(EnderDragonPhase.STRAFE_PLAYER).setTarget(player); + dragon.getPhaseManager().setPhase(PhaseType.STRAFE_PLAYER); + dragon.getPhaseManager().getPhase(PhaseType.STRAFE_PLAYER).setTarget(player); } - public boolean onFireballImpact(DragonFireball fireball, @Nullable Entity shooter, HitResult result) { + public boolean onFireballImpact(DragonFireballEntity fireball, @Nullable Entity shooter, RayTraceResult result) { if (!this.isEnabled()) return false; @@ -287,43 +287,43 @@ public boolean onFireballImpact(DragonFireball fireball, @Nullable Entity shoote return onImpact3DCloud(fireball, result); } - private void onImpactExplosion(DragonFireball fireball, @Nullable Entity shooter, HitResult result) { + private void onImpactExplosion(DragonFireballEntity fireball, @Nullable Entity shooter, RayTraceResult result) { if (!this.fireballExplosionDamages) return; float difficulty = 0; if (shooter != null) { - CompoundTag compoundNBT = shooter.getPersistentData(); + CompoundNBT compoundNBT = shooter.getPersistentData(); difficulty = compoundNBT.getFloat(Strings.Tags.DIFFICULTY); } float damage = 6 * (1f + (float) (this.increasedAcidPoolDamage * difficulty)); - AABB axisAlignedBB = new AABB(result.getLocation(), result.getLocation()).inflate(4d); - List livingEntities = fireball.level.getEntitiesOfClass(LivingEntity.class, axisAlignedBB); + AxisAlignedBB axisAlignedBB = new AxisAlignedBB(result.getLocation(), result.getLocation()).inflate(4d); + List livingEntities = fireball.level.getLoadedEntitiesOfClass(LivingEntity.class, axisAlignedBB); for (LivingEntity livingEntity : livingEntities) { if (livingEntity.distanceToSqr(fireball.position()) < 20.25d) livingEntity.hurt((new IndirectEntityDamageSource(Strings.Translatable.DRAGON_FIREBALL, fireball, shooter)).bypassArmor().setProjectile().setMagic(), damage); } } - private boolean onImpact3DCloud(DragonFireball fireball, HitResult result) { + private boolean onImpact3DCloud(DragonFireballEntity fireball, RayTraceResult result) { if (!this.isEnabled()) return false; if (!this.fireball3DEffectCloud) return false; - HitResult.Type raytraceresult$type = result.getType(); - if (raytraceresult$type == HitResult.Type.ENTITY) { - Reflection.ProjectileEntity_onEntityHit(fireball, (EntityHitResult)result); - } else if (raytraceresult$type == HitResult.Type.BLOCK) { - Reflection.ProjectileEntity_onBlockHit(fireball, (BlockHitResult)result); + RayTraceResult.Type raytraceresult$type = result.getType(); + if (raytraceresult$type == RayTraceResult.Type.ENTITY) { + Reflection.ProjectileEntity_onEntityHit(fireball, (EntityRayTraceResult)result); + } else if (raytraceresult$type == RayTraceResult.Type.BLOCK) { + Reflection.ProjectileEntity_onBlockHit(fireball, (BlockRayTraceResult)result); } Entity entity = fireball.getOwner(); - if (result.getType() != HitResult.Type.ENTITY || !((EntityHitResult)result).getEntity().is(entity)) { + if (result.getType() != RayTraceResult.Type.ENTITY || !((EntityRayTraceResult)result).getEntity().is(entity)) { if (!fireball.level.isClientSide) { - List list = fireball.level.getEntitiesOfClass(LivingEntity.class, fireball.getBoundingBox().inflate(4.0D, 2.0D, 4.0D)); + List list = fireball.level.getLoadedEntitiesOfClass(LivingEntity.class, fireball.getBoundingBox().inflate(4.0D, 2.0D, 4.0D)); AreaEffectCloud3DEntity areaeffectcloudentity = new AreaEffectCloud3DEntity(fireball.level, fireball.getX(), fireball.getY(), fireball.getZ()); if (entity instanceof LivingEntity) { areaeffectcloudentity.setOwner((LivingEntity)entity); @@ -334,7 +334,7 @@ private boolean onImpact3DCloud(DragonFireball fireball, HitResult result) { areaeffectcloudentity.setDuration(300); areaeffectcloudentity.setWaitTime(10); areaeffectcloudentity.setRadiusPerTick((7.0F - areaeffectcloudentity.getRadius()) / (float)areaeffectcloudentity.getDuration()); - areaeffectcloudentity.addEffect(new MobEffectInstance(MobEffects.HARM, 1, 1)); + areaeffectcloudentity.addEffect(new EffectInstance(Effects.HARM, 1, 1)); if (!list.isEmpty()) { for(LivingEntity livingentity : list) { double d0 = fireball.distanceToSqr(livingentity); @@ -347,15 +347,15 @@ private boolean onImpact3DCloud(DragonFireball fireball, HitResult result) { fireball.level.levelEvent(2006, fireball.blockPosition(), fireball.isSilent() ? -1 : 1); fireball.level.addFreshEntity(areaeffectcloudentity); - fireball.discard(); + fireball.remove(); } } return true; } - public void fireFireball(EnderDragon dragon, LivingEntity attackTarget) { - Vec3 vector3d2 = dragon.getViewVector(1.0F); + public void fireFireball(EnderDragonEntity dragon, LivingEntity attackTarget) { + Vector3d vector3d2 = dragon.getViewVector(1.0F); double d6 = dragon.head.getX() - vector3d2.x; double d7 = dragon.head.getY(0.5D) + 0.5D; double d8 = dragon.head.getZ() - vector3d2.z; @@ -366,11 +366,11 @@ public void fireFireball(EnderDragon dragon, LivingEntity attackTarget) { dragon.level.levelEvent(null, 1017, dragon.blockPosition(), 0); } - DragonFireball dragonfireballentity = new DragonFireball(dragon.level, dragon, d9, d10, d11); + DragonFireballEntity dragonfireballentity = new DragonFireballEntity(dragon.level, dragon, d9, d10, d11); dragonfireballentity.moveTo(d6, d7, d8, 0.0F, 0.0F); dragon.level.addFreshEntity(dragonfireballentity); - CompoundTag compoundNBT = dragon.getPersistentData(); + CompoundNBT compoundNBT = dragon.getPersistentData(); float difficulty = compoundNBT.getFloat(Strings.Tags.DIFFICULTY); double fireballs = RandomHelper.getDouble(dragon.getRandom(), 1f, maxBonusFireball * difficulty); double mod = fireballs - (int)fireballs; @@ -391,15 +391,15 @@ public void fireFireball(EnderDragon dragon, LivingEntity attackTarget) { dragon.level.levelEvent(null, 1017, dragon.blockPosition(), 0); } - dragonfireballentity = new DragonFireball(dragon.level, dragon, d9, d10, d11); + dragonfireballentity = new DragonFireballEntity(dragon.level, dragon, d9, d10, d11); dragonfireballentity.moveTo(d6, d7, d8, 0.0F, 0.0F); dragon.level.addFreshEntity(dragonfireballentity); } } @Nullable - public Player getRandomPlayer(Level world, AABB boundingBox) { - List players = world.getEntitiesOfClass(Player.class, boundingBox); + public PlayerEntity getRandomPlayer(World world, AxisAlignedBB boundingBox) { + List players = world.getLoadedEntitiesOfClass(PlayerEntity.class, boundingBox); if (players.isEmpty()) return null; @@ -409,15 +409,15 @@ public Player getRandomPlayer(Level world, AABB boundingBox) { //Returns a random player that is at least 10 blocks near a Crystal or a random player if no players are near crystals @Nullable - public Player getRandomPlayerNearCrystal(Level world, AABB boundingBox) { - List players = world.getEntitiesOfClass(Player.class, boundingBox); + public PlayerEntity getRandomPlayerNearCrystal(World world, AxisAlignedBB boundingBox) { + List players = world.getLoadedEntitiesOfClass(PlayerEntity.class, boundingBox); if (players.isEmpty()) return null; - List playersNearCrystals = new ArrayList<>(); + List playersNearCrystals = new ArrayList<>(); - for (Player player : players) { - List endCrystals = player.level.getEntitiesOfClass(EndCrystal.class, player.getBoundingBox().inflate(10d)); + for (PlayerEntity player : players) { + List endCrystals = player.level.getLoadedEntitiesOfClass(EnderCrystalEntity.class, player.getBoundingBox().inflate(10d)); if (endCrystals.size() > 0) playersNearCrystals.add(player); } diff --git a/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/CrystalFeature.java b/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/CrystalFeature.java index 8093cccb..7d38fc97 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/CrystalFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/CrystalFeature.java @@ -8,25 +8,25 @@ import insane96mcp.progressivebosses.base.Strings; import insane96mcp.progressivebosses.module.dragon.phase.CrystalRespawnPhase; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.util.Mth; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.boss.enderdragon.EndCrystal; -import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.entity.boss.enderdragon.phases.DragonPhaseInstance; -import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase; -import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.IronBarsBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.levelgen.Heightmap; -import net.minecraft.world.level.levelgen.feature.EndPodiumFeature; -import net.minecraft.world.level.levelgen.feature.SpikeFeature; -import net.minecraft.world.phys.Vec3; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.PaneBlock; +import net.minecraft.entity.boss.dragon.EnderDragonEntity; +import net.minecraft.entity.boss.dragon.phase.IPhase; +import net.minecraft.entity.boss.dragon.phase.PhaseType; +import net.minecraft.entity.item.EnderCrystalEntity; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.DamageSource; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; +import net.minecraft.world.gen.Heightmap; +import net.minecraft.world.gen.feature.EndPodiumFeature; +import net.minecraft.world.gen.feature.EndSpikeFeature; +import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingDamageEvent; @@ -104,22 +104,22 @@ public void loadConfig() { this.explosionImmune = this.explosionImmuneConfig.get(); } - private static final List> VALID_CRYSTAL_RESPAWN_PHASES = Arrays.asList(EnderDragonPhase.SITTING_SCANNING, EnderDragonPhase.SITTING_ATTACKING, EnderDragonPhase.SITTING_FLAMING, EnderDragonPhase.HOLDING_PATTERN, EnderDragonPhase.TAKEOFF); + private static final List> VALID_CRYSTAL_RESPAWN_PHASES = Arrays.asList(PhaseType.SITTING_SCANNING, PhaseType.SITTING_ATTACKING, PhaseType.SITTING_FLAMING, PhaseType.HOLDING_PATTERN, PhaseType.TAKEOFF); @SubscribeEvent public void onDragonDamage(LivingDamageEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof EnderDragon)) + if (!(event.getEntity() instanceof EnderDragonEntity)) return; if (!this.enableCrystalRespawn) return; - EnderDragon dragon = (EnderDragon) event.getEntity(); + EnderDragonEntity dragon = (EnderDragonEntity) event.getEntity(); - CompoundTag dragonTags = dragon.getPersistentData(); + CompoundNBT dragonTags = dragon.getPersistentData(); float difficulty = dragonTags.getFloat(Strings.Tags.DIFFICULTY); if (dragonTags.getBoolean(Strings.Tags.CRYSTAL_RESPAWN)) @@ -143,10 +143,10 @@ public void onDragonDamage(LivingDamageEvent event) { dragon.getPhaseManager().setPhase(CrystalRespawnPhase.getPhaseType()); CrystalRespawnPhase phase = (CrystalRespawnPhase) dragon.getPhaseManager().getCurrentPhase(); - ArrayList spikes = new ArrayList<>(SpikeFeature.getSpikesForLevel((ServerLevel)dragon.level)); - int maxTries = (int) Mth.clamp(difficulty * this.crystalRespawnMultiplier, 1, 100); + ArrayList spikes = new ArrayList<>(EndSpikeFeature.getSpikesForLevel((ServerWorld)dragon.level)); + int maxTries = (int) MathHelper.clamp(difficulty * this.crystalRespawnMultiplier, 1, 100); for (int i = 0; i < maxTries; i++) { - SpikeFeature.EndSpike targetSpike = spikes.get(RandomHelper.getInt(dragon.getRandom(), 0, spikes.size())); + EndSpikeFeature.EndSpike targetSpike = spikes.get(RandomHelper.getInt(dragon.getRandom(), 0, spikes.size())); phase.addCrystalRespawn(targetSpike); } dragonTags.putBoolean(Strings.Tags.CRYSTAL_RESPAWN, true); @@ -160,34 +160,34 @@ public void onSpawn(EntityJoinWorldEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof EnderDragon)) + if (!(event.getEntity() instanceof EnderDragonEntity)) return; - EnderDragon dragon = (EnderDragon) event.getEntity(); - CompoundTag dragonTags = dragon.getPersistentData(); + EnderDragonEntity dragon = (EnderDragonEntity) event.getEntity(); + CompoundNBT dragonTags = dragon.getPersistentData(); float difficulty = dragonTags.getFloat(Strings.Tags.DIFFICULTY); crystalCages(dragon, difficulty); moreCrystals(dragon, difficulty); } - private void crystalCages(EnderDragon dragon, float difficulty) { + private void crystalCages(EnderDragonEntity dragon, float difficulty) { if (this.moreCagesAtDifficulty == -1 || this.maxBonusCages == 0) return; if (difficulty < moreCagesAtDifficulty) return; - CompoundTag dragonTags = dragon.getPersistentData(); + CompoundNBT dragonTags = dragon.getPersistentData(); if (dragonTags.contains(Strings.Tags.CRYSTAL_CAGES)) return; dragonTags.putBoolean(Strings.Tags.CRYSTAL_CAGES, true); - List crystals = new ArrayList<>(); + List crystals = new ArrayList<>(); - for(SpikeFeature.EndSpike endspikefeature$endspike : SpikeFeature.getSpikesForLevel((ServerLevel) dragon.level)) { - crystals.addAll(dragon.level.getEntitiesOfClass(EndCrystal.class, endspikefeature$endspike.getTopBoundingBox())); + for(EndSpikeFeature.EndSpike endspikefeature$endspike : EndSpikeFeature.getSpikesForLevel((ServerWorld) dragon.level)) { + crystals.addAll(dragon.level.getEntitiesOfClass(EnderCrystalEntity.class, endspikefeature$endspike.getTopBoundingBox())); } //Remove all the crystals that already have cages around @@ -198,7 +198,7 @@ private void crystalCages(EnderDragon dragon, float difficulty) { int crystalsInvolved = Math.round(difficulty - this.moreCagesAtDifficulty + 1); int cagesGenerated = 0; - for (EndCrystal crystal : crystals) { + for (EnderCrystalEntity crystal : crystals) { generateCage(crystal.level, crystal.blockPosition()); cagesGenerated++; @@ -207,23 +207,23 @@ private void crystalCages(EnderDragon dragon, float difficulty) { } } - private void moreCrystals(EnderDragon dragon, float difficulty) { + private void moreCrystals(EnderDragonEntity dragon, float difficulty) { if (this.moreCrystalsAtDifficulty == -1 || this.maxMoreCrystals == 0) return; if (difficulty < this.moreCrystalsAtDifficulty) return; - CompoundTag dragonTags = dragon.getPersistentData(); + CompoundNBT dragonTags = dragon.getPersistentData(); if (dragonTags.contains(Strings.Tags.MORE_CRYSTALS)) return; dragonTags.putBoolean(Strings.Tags.MORE_CRYSTALS, true); - List crystals = new ArrayList<>(); + List crystals = new ArrayList<>(); - for(SpikeFeature.EndSpike endspikefeature$endspike : SpikeFeature.getSpikesForLevel((ServerLevel) dragon.level)) { - crystals.addAll(dragon.level.getEntitiesOfClass(EndCrystal.class, endspikefeature$endspike.getTopBoundingBox())); + for(EndSpikeFeature.EndSpike endspikefeature$endspike : EndSpikeFeature.getSpikesForLevel((ServerWorld) dragon.level)) { + crystals.addAll(dragon.level.getEntitiesOfClass(EnderCrystalEntity.class, endspikefeature$endspike.getTopBoundingBox())); } //Shuffle the list @@ -232,7 +232,7 @@ private void moreCrystals(EnderDragon dragon, float difficulty) { int crystalsInvolved = Math.round(difficulty - this.moreCrystalsAtDifficulty + 1); int crystalSpawned = 0; - for (EndCrystal crystal : crystals) { + for (EnderCrystalEntity crystal : crystals) { generateCrystalInTower(dragon.level, crystal.getX(), crystal.getY(), crystal.getZ()); crystalSpawned++; @@ -241,7 +241,7 @@ private void moreCrystals(EnderDragon dragon, float difficulty) { } } - public boolean onDamageFromExplosion(EndCrystal enderCrystalEntity, DamageSource source) { + public boolean onDamageFromExplosion(EnderCrystalEntity enderCrystalEntity, DamageSource source) { if (!this.isEnabled()) return false; @@ -253,8 +253,8 @@ public boolean onDamageFromExplosion(EndCrystal enderCrystalEntity, DamageSource private static final ResourceLocation ENDERGETIC_CRYSTAL_HOLDER_RL = new ResourceLocation("endergetic:crystal_holder"); - public static EndCrystal generateCrystalInTower(Level world, double x, double y, double z) { - Vec3 centerPodium = Vec3.atBottomCenterOf(world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION)); + public static EnderCrystalEntity generateCrystalInTower(World world, double x, double y, double z) { + Vector3d centerPodium = Vector3d.atBottomCenterOf(world.getHeightmapPos(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION)); int spawnY = (int) (y - RandomHelper.getInt(world.getRandom(), 12, 24)); if (spawnY < centerPodium.y()) @@ -273,27 +273,27 @@ public static EndCrystal generateCrystalInTower(Level world, double x, double y, LogHelper.warn("The Endergetic Expansion is loaded but the %s block was not registered", ENDERGETIC_CRYSTAL_HOLDER_RL); world.setBlockAndUpdate(crystalPos.offset(0, -1, 0), baseBlockState); - world.explode(null, crystalPos.getX() + .5f, crystalPos.getY(), crystalPos.getZ() + .5, 5f, Explosion.BlockInteraction.DESTROY); + world.explode(null, crystalPos.getX() + .5f, crystalPos.getY(), crystalPos.getZ() + .5, 5f, Explosion.Mode.DESTROY); - EndCrystal crystal = new EndCrystal(world, crystalPos.getX() + .5, crystalPos.getY(), crystalPos.getZ() + .5); + EnderCrystalEntity crystal = new EnderCrystalEntity(world, crystalPos.getX() + .5, crystalPos.getY(), crystalPos.getZ() + .5); world.addFreshEntity(crystal); return crystal; } - public static void generateCage(Level world, BlockPos pos) { + public static void generateCage(World world, BlockPos pos) { //Shamelessly copied from Vanilla Code - BlockPos.MutableBlockPos blockpos$mutable = new BlockPos.MutableBlockPos(); + BlockPos.Mutable blockpos$mutable = new BlockPos.Mutable(); for(int k = -2; k <= 2; ++k) { for(int l = -2; l <= 2; ++l) { for(int i1 = 0; i1 <= 3; ++i1) { - boolean flag = Mth.abs(k) == 2; - boolean flag1 = Mth.abs(l) == 2; + boolean flag = MathHelper.abs(k) == 2; + boolean flag1 = MathHelper.abs(l) == 2; boolean flag2 = i1 == 3; if (flag || flag1 || flag2) { boolean flag3 = k == -2 || k == 2 || flag2; boolean flag4 = l == -2 || l == 2 || flag2; - BlockState blockstate = Blocks.IRON_BARS.defaultBlockState().setValue(IronBarsBlock.NORTH, flag3 && l != -2).setValue(IronBarsBlock.SOUTH, flag3 && l != 2).setValue(IronBarsBlock.WEST, flag4 && k != -2).setValue(IronBarsBlock.EAST, flag4 && k != 2); + BlockState blockstate = Blocks.IRON_BARS.defaultBlockState().setValue(PaneBlock.NORTH, flag3 && l != -2).setValue(PaneBlock.SOUTH, flag3 && l != 2).setValue(PaneBlock.WEST, flag4 && k != -2).setValue(PaneBlock.EAST, flag4 && k != 2); world.setBlockAndUpdate(blockpos$mutable.set(pos.getX() + k, pos.getY() - 1 + i1, pos.getZ() + l), blockstate); } } diff --git a/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/DifficultyFeature.java b/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/DifficultyFeature.java index c2d111fe..3b13b9f8 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/DifficultyFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/DifficultyFeature.java @@ -5,17 +5,17 @@ import insane96mcp.insanelib.base.Module; import insane96mcp.insanelib.utils.LogHelper; import insane96mcp.progressivebosses.base.Strings; -import insane96mcp.progressivebosses.capability.Difficulty; +import insane96mcp.progressivebosses.capability.DifficultyCapability; import insane96mcp.progressivebosses.capability.IDifficulty; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.Util; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.level.dimension.DimensionType; -import net.minecraft.world.phys.AABB; +import net.minecraft.entity.boss.dragon.EnderDragonEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.Util; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.DimensionType; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; @@ -81,24 +81,24 @@ public void onSpawn(EntityJoinWorldEvent event) { if (!event.getWorld().dimension().location().equals(DimensionType.END_LOCATION.location())) return; - if (!(event.getEntity() instanceof EnderDragon)) + if (!(event.getEntity() instanceof EnderDragonEntity)) return; - EnderDragon dragon = (EnderDragon) event.getEntity(); + EnderDragonEntity dragon = (EnderDragonEntity) event.getEntity(); if (dragon.getDragonFight() == null) return; - CompoundTag dragonTags = dragon.getPersistentData(); + CompoundNBT dragonTags = dragon.getPersistentData(); if (dragonTags.contains(Strings.Tags.DIFFICULTY)) return; int radius = 256; BlockPos pos1 = new BlockPos(-radius, -radius, -radius); BlockPos pos2 = new BlockPos(radius, radius, radius); - AABB bb = new AABB(pos1, pos2); + AxisAlignedBB bb = new AxisAlignedBB(pos1, pos2); - List players = event.getWorld().getEntitiesOfClass(ServerPlayer.class, bb); + List players = event.getWorld().getLoadedEntitiesOfClass(ServerPlayerEntity.class, bb); if (players.size() == 0) return; @@ -106,8 +106,8 @@ public void onSpawn(EntityJoinWorldEvent event) { int playersFirstDragon = 0; float dragonDifficulty = 0; - for (ServerPlayer player : players) { - IDifficulty difficulty = player.getCapability(Difficulty.INSTANCE).orElse(null); + for (ServerPlayerEntity player : players) { + IDifficulty difficulty = player.getCapability(DifficultyCapability.DIFFICULTY).orElse(null); dragonDifficulty += difficulty.getKilledDragons(); if (difficulty.getFirstDragon() == (byte) 1) { playersFirstDragon++; @@ -135,27 +135,27 @@ public void onDeath(LivingDeathEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof EnderDragon)) + if (!(event.getEntity() instanceof EnderDragonEntity)) return; - EnderDragon dragon = (EnderDragon) event.getEntity(); + EnderDragonEntity dragon = (EnderDragonEntity) event.getEntity(); int radius = 256; BlockPos pos1 = new BlockPos(-radius, -radius, -radius); BlockPos pos2 = new BlockPos(radius, radius, radius); - AABB bb = new AABB(pos1, pos2); + AxisAlignedBB bb = new AxisAlignedBB(pos1, pos2); - List players = dragon.level.getEntitiesOfClass(ServerPlayer.class, bb); + List players = dragon.level.getLoadedEntitiesOfClass(ServerPlayerEntity.class, bb); //If no players are found in the "Spawn Radius Player Check", try to get the nearest player if (players.size() == 0) { - ServerPlayer nearestPlayer = (ServerPlayer) dragon.level.getNearestPlayer(dragon.getX(), dragon.getY(), dragon.getZ(), Double.MAX_VALUE, true); + ServerPlayerEntity nearestPlayer = (ServerPlayerEntity) dragon.level.getNearestPlayer(dragon.getX(), dragon.getY(), dragon.getZ(), Double.MAX_VALUE, true); players.add(nearestPlayer); } - for (ServerPlayer player : players) { - IDifficulty difficulty = player.getCapability(Difficulty.INSTANCE).orElse(null); + for (ServerPlayerEntity player : players) { + IDifficulty difficulty = player.getCapability(DifficultyCapability.DIFFICULTY).orElse(null); if (difficulty.getKilledDragons() <= this.startingDifficulty && this.showFirstKilledDragonMessage) - player.sendMessage(new TranslatableComponent(Strings.Translatable.FIRST_DRAGON_KILL), Util.NIL_UUID); + player.sendMessage(new TranslationTextComponent(Strings.Translatable.FIRST_DRAGON_KILL), Util.NIL_UUID); if (difficulty.getKilledDragons() < this.maxDifficulty) difficulty.addKilledDragons(1); } @@ -169,12 +169,12 @@ public void setPlayerData(EntityJoinWorldEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof ServerPlayer)) + if (!(event.getEntity() instanceof ServerPlayerEntity)) return; - ServerPlayer player = (ServerPlayer) event.getEntity(); + ServerPlayerEntity player = (ServerPlayerEntity) event.getEntity(); - IDifficulty difficulty = player.getCapability(Difficulty.INSTANCE).orElse(null); + IDifficulty difficulty = player.getCapability(DifficultyCapability.DIFFICULTY).orElse(null); if (difficulty.getKilledDragons() < this.startingDifficulty) { difficulty.setKilledDragons(this.startingDifficulty); diff --git a/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/HealthFeature.java b/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/HealthFeature.java index bd9a6b4b..a6debab5 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/HealthFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/HealthFeature.java @@ -8,11 +8,11 @@ import insane96mcp.progressivebosses.ProgressiveBosses; import insane96mcp.progressivebosses.base.Strings; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.ai.attributes.AttributeModifier; -import net.minecraft.world.entity.ai.attributes.Attributes; -import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.Attributes; +import net.minecraft.entity.boss.dragon.EnderDragonEntity; +import net.minecraft.entity.boss.dragon.phase.PhaseType; +import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingEvent; @@ -69,15 +69,15 @@ public void onSpawn(EntityJoinWorldEvent event) { if (this.bonusPerDifficulty == 0d) return; - if (!(event.getEntity() instanceof EnderDragon)) + if (!(event.getEntity() instanceof EnderDragonEntity)) return; - EnderDragon enderDragon = (EnderDragon) event.getEntity(); + EnderDragonEntity enderDragon = (EnderDragonEntity) event.getEntity(); if (enderDragon.getAttribute(Attributes.MAX_HEALTH).getModifier(Strings.AttributeModifiers.BONUS_HEALTH_UUID) != null) return; - CompoundTag dragonTags = enderDragon.getPersistentData(); + CompoundNBT dragonTags = enderDragon.getPersistentData(); double difficulty = dragonTags.getFloat(Strings.Tags.DIFFICULTY); MCUtils.applyModifier(enderDragon, Attributes.MAX_HEALTH, Strings.AttributeModifiers.BONUS_HEALTH_UUID, Strings.AttributeModifiers.BONUS_HEALTH, difficulty * this.bonusPerDifficulty, AttributeModifier.Operation.ADDITION); } @@ -98,7 +98,7 @@ public void onUpdate(LivingEvent.LivingUpdateEvent event) { world.spawnParticle(ParticleTypes.ANGRY_VILLAGER, part.getPosX(), part.getPosY(), part.getPosZ(), 1, 0, 0, 0, 0); if (part.getBoundingBox().intersects(player.getBoundingBox())) { part.attackEntityFrom(DamageSource.causePlayerDamage(player), 20f); - LogHelper.info("Colliding with %s", part.name); + LogHelper.info("Colliding with %s", part.field_213853_c); } } } @@ -106,15 +106,15 @@ public void onUpdate(LivingEvent.LivingUpdateEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof EnderDragon)) + if (!(event.getEntity() instanceof EnderDragonEntity)) return; - EnderDragon enderDragon = (EnderDragon) event.getEntity(); + EnderDragonEntity enderDragon = (EnderDragonEntity) event.getEntity(); - if (!enderDragon.isAlive() || enderDragon.getPhaseManager().getCurrentPhase().getPhase() == EnderDragonPhase.DYING) + if (!enderDragon.isAlive() || enderDragon.getPhaseManager().getCurrentPhase().getPhase() == PhaseType.DYING) return; - CompoundTag tags = enderDragon.getPersistentData(); + CompoundNBT tags = enderDragon.getPersistentData(); float difficulty = tags.getFloat(Strings.Tags.DIFFICULTY); @@ -142,7 +142,7 @@ private float getFlatBonusHeal(float difficulty) { return (float) Math.min(difficulty * this.bonusRegenPerDifficulty, this.maxBonusRegen); } - private float getCrystalBonusHeal(EnderDragon enderDragon, float difficulty) { + private float getCrystalBonusHeal(EnderDragonEntity enderDragon, float difficulty) { if (this.bonusCrystalRegen == 0d) return 0f; diff --git a/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/LarvaFeature.java b/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/LarvaFeature.java index bd0e4696..ccbc961a 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/LarvaFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/LarvaFeature.java @@ -8,23 +8,23 @@ import insane96mcp.progressivebosses.base.Strings; import insane96mcp.progressivebosses.module.dragon.ai.PBNearestAttackableTargetGoal; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.ai.attributes.AttributeModifier; -import net.minecraft.world.entity.ai.attributes.Attributes; -import net.minecraft.world.entity.ai.goal.Goal; -import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; -import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.entity.monster.Endermite; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.levelgen.Heightmap; -import net.minecraft.world.level.levelgen.feature.EndPodiumFeature; -import net.minecraft.world.level.storage.loot.BuiltInLootTables; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.Attributes; +import net.minecraft.entity.ai.goal.Goal; +import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal; +import net.minecraft.entity.boss.dragon.EnderDragonEntity; +import net.minecraft.entity.monster.EndermiteEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.loot.LootTables; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.World; +import net.minecraft.world.gen.Heightmap; +import net.minecraft.world.gen.feature.EndPodiumFeature; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.event.entity.EntityJoinWorldEvent; @@ -97,12 +97,12 @@ public void onDragonSpawn(EntityJoinWorldEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof EnderDragon)) + if (!(event.getEntity() instanceof EnderDragonEntity)) return; - EnderDragon dragon = (EnderDragon) event.getEntity(); + EnderDragonEntity dragon = (EnderDragonEntity) event.getEntity(); - CompoundTag dragonTags = dragon.getPersistentData(); + CompoundNBT dragonTags = dragon.getPersistentData(); int cooldown = (int) (RandomHelper.getInt(dragon.getRandom(), this.minCooldown, this.maxCooldown) * 0.5d); dragonTags.putInt(Strings.Tags.DRAGON_LARVA_COOLDOWN, cooldown); @@ -116,12 +116,12 @@ public void onLarvaSpawn(EntityJoinWorldEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof Endermite)) + if (!(event.getEntity() instanceof EndermiteEntity)) return; - Endermite endermite = (Endermite) event.getEntity(); + EndermiteEntity endermite = (EndermiteEntity) event.getEntity(); - CompoundTag tags = endermite.getPersistentData(); + CompoundNBT tags = endermite.getPersistentData(); if (!tags.contains(Strings.Tags.DRAGON_LARVA)) return; @@ -136,13 +136,13 @@ public void update(LivingEvent.LivingUpdateEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof EnderDragon)) + if (!(event.getEntity() instanceof EnderDragonEntity)) return; - Level world = event.getEntity().level; + World world = event.getEntity().level; - EnderDragon dragon = (EnderDragon) event.getEntity(); - CompoundTag dragonTags = dragon.getPersistentData(); + EnderDragonEntity dragon = (EnderDragonEntity) event.getEntity(); + CompoundNBT dragonTags = dragon.getPersistentData(); float difficulty = dragonTags.getFloat(Strings.Tags.DIFFICULTY); if (difficulty < this.larvaAtDifficulty) @@ -158,9 +158,9 @@ public void update(LivingEvent.LivingUpdateEvent event) { } //If there is no player in the main island don't spawn larvae - BlockPos centerPodium = dragon.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION); - AABB bb = new AABB(centerPodium).inflate(96d); - List players = world.getEntitiesOfClass(ServerPlayer.class, bb); + BlockPos centerPodium = dragon.level.getHeightmapPos(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION); + AxisAlignedBB bb = new AxisAlignedBB(centerPodium).inflate(96d); + List players = world.getLoadedEntitiesOfClass(ServerPlayerEntity.class, bb); if (players.isEmpty()) return; @@ -176,15 +176,15 @@ public void update(LivingEvent.LivingUpdateEvent event) { float angle = world.random.nextFloat() * (float) Math.PI * 2f; float x = (float) Math.floor(Math.cos(angle) * 3.33f); float z = (float) Math.floor(Math.sin(angle) * 3.33f); - int y = world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, new BlockPos(x, 255, z)).getY(); - Endermite endermite = summonLarva(world, new Vec3(x + 0.5, y, z + 0.5), difficulty); + int y = world.getHeightmapPos(Heightmap.Type.MOTION_BLOCKING, new BlockPos(x, 255, z)).getY(); + EndermiteEntity endermite = summonLarva(world, new Vector3d(x + 0.5, y, z + 0.5), difficulty); larvaSpawnedCount++; if (larvaSpawnedCount >= this.maxSpawned) break; } } - private static void setLarvaAI(Endermite endermite) { + private static void setLarvaAI(EndermiteEntity endermite) { ArrayList toRemove = new ArrayList<>(); endermite.targetSelector.availableGoals.forEach(goal -> { if (goal.getGoal() instanceof NearestAttackableTargetGoal) @@ -195,17 +195,17 @@ private static void setLarvaAI(Endermite endermite) { endermite.targetSelector.addGoal(2, new PBNearestAttackableTargetGoal(endermite)); } - public Endermite summonLarva(Level world, Vec3 pos, float difficulty) { - Endermite endermite = new Endermite(EntityType.ENDERMITE, world); - CompoundTag minionTags = endermite.getPersistentData(); + public EndermiteEntity summonLarva(World world, Vector3d pos, float difficulty) { + EndermiteEntity endermite = new EndermiteEntity(EntityType.ENDERMITE, world); + CompoundNBT minionTags = endermite.getPersistentData(); minionTags.putBoolean(Strings.Tags.DRAGON_LARVA, true); minionTags.putBoolean("mobspropertiesrandomness:processed", true); //TODO Scaling health endermite.setPos(pos.x, pos.y, pos.z); - endermite.setCustomName(new TranslatableComponent(Strings.Translatable.DRAGON_LARVA)); - endermite.lootTable = BuiltInLootTables.EMPTY; + endermite.setCustomName(new TranslationTextComponent(Strings.Translatable.DRAGON_LARVA)); + endermite.lootTable = LootTables.EMPTY; endermite.setPersistenceRequired(); MCUtils.applyModifier(endermite, Attributes.FOLLOW_RANGE, Strings.AttributeModifiers.FOLLOW_RANGE_BONUS_UUID, Strings.AttributeModifiers.FOLLOW_RANGE_BONUS, 64, AttributeModifier.Operation.ADDITION); @@ -226,15 +226,15 @@ public void onLarvaHurt(LivingAttackEvent event) { if (!this.dragonImmune) return; - if (!(event.getEntity() instanceof Endermite)) + if (!(event.getEntity() instanceof EndermiteEntity)) return; - Endermite endermite = (Endermite) event.getEntity(); - CompoundTag compoundNBT = endermite.getPersistentData(); + EndermiteEntity endermite = (EndermiteEntity) event.getEntity(); + CompoundNBT compoundNBT = endermite.getPersistentData(); if (!compoundNBT.contains(Strings.Tags.DRAGON_LARVA)) return; - if (event.getSource().getEntity() instanceof EnderDragon || event.getSource().getDirectEntity() instanceof EnderDragon) + if (event.getSource().getEntity() instanceof EnderDragonEntity || event.getSource().getDirectEntity() instanceof EnderDragonEntity) event.setCanceled(true); } } diff --git a/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/MinionFeature.java b/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/MinionFeature.java index 2e0e73a9..cfb207bb 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/MinionFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/MinionFeature.java @@ -10,33 +10,33 @@ import insane96mcp.progressivebosses.module.dragon.ai.PBNearestAttackableTargetGoal; import insane96mcp.progressivebosses.setup.Config; import insane96mcp.progressivebosses.utils.DragonMinionHelper; -import net.minecraft.core.BlockPos; -import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.ai.attributes.AttributeModifier; -import net.minecraft.world.entity.ai.attributes.Attributes; -import net.minecraft.world.entity.ai.goal.Goal; -import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; -import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; -import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.entity.monster.Shulker; -import net.minecraft.world.entity.projectile.ShulkerBullet; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.levelgen.Heightmap; -import net.minecraft.world.level.levelgen.feature.EndPodiumFeature; -import net.minecraft.world.level.storage.loot.BuiltInLootTables; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.EntityHitResult; -import net.minecraft.world.phys.Vec3; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.Attributes; +import net.minecraft.entity.ai.goal.Goal; +import net.minecraft.entity.ai.goal.HurtByTargetGoal; +import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal; +import net.minecraft.entity.boss.dragon.EnderDragonEntity; +import net.minecraft.entity.monster.ShulkerEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.entity.projectile.ShulkerBulletEntity; +import net.minecraft.loot.LootTables; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.particles.ParticleTypes; +import net.minecraft.potion.EffectInstance; +import net.minecraft.potion.Effects; +import net.minecraft.util.DamageSource; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.EntityRayTraceResult; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.World; +import net.minecraft.world.gen.Heightmap; +import net.minecraft.world.gen.feature.EndPodiumFeature; +import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingAttackEvent; @@ -107,12 +107,12 @@ public void onDragonSpawn(EntityJoinWorldEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof EnderDragon)) + if (!(event.getEntity() instanceof EnderDragonEntity)) return; - EnderDragon dragon = (EnderDragon) event.getEntity(); + EnderDragonEntity dragon = (EnderDragonEntity) event.getEntity(); - CompoundTag dragonTags = dragon.getPersistentData(); + CompoundNBT dragonTags = dragon.getPersistentData(); int cooldown = (int) (RandomHelper.getInt(dragon.getRandom(), this.minCooldown, this.maxCooldown) * 0.5d); dragonTags.putInt(Strings.Tags.DRAGON_MINION_COOLDOWN, cooldown); @@ -126,12 +126,12 @@ public void onShulkerSpawn(EntityJoinWorldEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof Shulker)) + if (!(event.getEntity() instanceof ShulkerEntity)) return; - Shulker shulker = (Shulker) event.getEntity(); + ShulkerEntity shulker = (ShulkerEntity) event.getEntity(); - CompoundTag tags = shulker.getPersistentData(); + CompoundNBT tags = shulker.getPersistentData(); if (!tags.contains(Strings.Tags.DRAGON_MINION)) return; @@ -146,13 +146,13 @@ public void update(LivingEvent.LivingUpdateEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof EnderDragon)) + if (!(event.getEntity() instanceof EnderDragonEntity)) return; - Level world = event.getEntity().level; + World world = event.getEntity().level; - EnderDragon dragon = (EnderDragon) event.getEntity(); - CompoundTag dragonTags = dragon.getPersistentData(); + EnderDragonEntity dragon = (EnderDragonEntity) event.getEntity(); + CompoundNBT dragonTags = dragon.getPersistentData(); float difficulty = dragonTags.getFloat(Strings.Tags.DIFFICULTY); if (difficulty < this.minionAtDifficulty) @@ -168,9 +168,9 @@ public void update(LivingEvent.LivingUpdateEvent event) { } //If there is no player in the main island don't spawn minions - BlockPos centerPodium = dragon.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION); - AABB bb = new AABB(centerPodium).inflate(96d); - List players = world.getEntitiesOfClass(ServerPlayer.class, bb); + BlockPos centerPodium = dragon.level.getHeightmapPos(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION); + AxisAlignedBB bb = new AxisAlignedBB(centerPodium).inflate(96d); + List players = world.getLoadedEntitiesOfClass(ServerPlayerEntity.class, bb); if (players.isEmpty()) return; @@ -185,14 +185,14 @@ public void update(LivingEvent.LivingUpdateEvent event) { float angle = world.random.nextFloat() * (float) Math.PI * 2f; float x = (float) (Math.cos(angle) * (RandomHelper.getFloat(dragon.getRandom(), 16f, 46f))); float z = (float) (Math.sin(angle) * (RandomHelper.getFloat(dragon.getRandom(), 16f, 46f))); - float y = world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, new BlockPos(x, 255, z)).getY(); - Shulker shulker = summonMinion(world, new Vec3(x, y, z), difficulty); + float y = world.getHeightmapPos(Heightmap.Type.MOTION_BLOCKING, new BlockPos(x, 255, z)).getY(); + ShulkerEntity shulker = summonMinion(world, new Vector3d(x, y, z), difficulty); } - private static void setMinionAI(Shulker shulker) { + private static void setMinionAI(ShulkerEntity shulker) { ArrayList toRemove = new ArrayList<>(); shulker.goalSelector.availableGoals.forEach(goal -> { - if (goal.getGoal() instanceof Shulker.ShulkerAttackGoal) + if (goal.getGoal() instanceof ShulkerEntity.AttackGoal) toRemove.add(goal.getGoal()); }); toRemove.forEach(shulker.goalSelector::removeGoal); @@ -208,12 +208,12 @@ private static void setMinionAI(Shulker shulker) { toRemove.forEach(shulker.targetSelector::removeGoal); shulker.targetSelector.addGoal(2, new PBNearestAttackableTargetGoal(shulker)); - shulker.targetSelector.addGoal(1, new HurtByTargetGoal(shulker, Shulker.class, EnderDragon.class)); + shulker.targetSelector.addGoal(1, new HurtByTargetGoal(shulker, ShulkerEntity.class, EnderDragonEntity.class)); } - public Shulker summonMinion(Level world, Vec3 pos, float difficulty) { - Shulker shulker = new Shulker(EntityType.SHULKER, world); - CompoundTag minionTags = shulker.getPersistentData(); + public ShulkerEntity summonMinion(World world, Vector3d pos, float difficulty) { + ShulkerEntity shulker = new ShulkerEntity(EntityType.SHULKER, world); + CompoundNBT minionTags = shulker.getPersistentData(); minionTags.putBoolean(Strings.Tags.DRAGON_MINION, true); minionTags.putBoolean("mobspropertiesrandomness:processed", true); @@ -222,8 +222,8 @@ public Shulker summonMinion(Level world, Vec3 pos, float difficulty) { boolean isBlindingMinion = world.getRandom().nextDouble() < this.blindingChance * difficulty; shulker.setPos(pos.x, pos.y, pos.z); - shulker.setCustomName(new TranslatableComponent(Strings.Translatable.DRAGON_MINION)); - shulker.lootTable = BuiltInLootTables.EMPTY; + shulker.setCustomName(new TranslationTextComponent(Strings.Translatable.DRAGON_MINION)); + shulker.lootTable = LootTables.EMPTY; shulker.setPersistenceRequired(); DragonMinionHelper.setMinionColor(shulker, isBlindingMinion); @@ -241,25 +241,25 @@ public void onMinionHurt(LivingAttackEvent event) { if (!this.dragonImmune) return; - if (!(event.getEntity() instanceof Shulker)) + if (!(event.getEntity() instanceof ShulkerEntity)) return; - Shulker shulker = (Shulker) event.getEntity(); - CompoundTag compoundNBT = shulker.getPersistentData(); + ShulkerEntity shulker = (ShulkerEntity) event.getEntity(); + CompoundNBT compoundNBT = shulker.getPersistentData(); if (!compoundNBT.contains(Strings.Tags.DRAGON_MINION)) return; - if (event.getSource().getEntity() instanceof EnderDragon || event.getSource().getDirectEntity() instanceof EnderDragon) + if (event.getSource().getEntity() instanceof EnderDragonEntity || event.getSource().getDirectEntity() instanceof EnderDragonEntity) event.setCanceled(true); } - public void onBulletTick(ShulkerBullet shulkerBulletEntity) { + public void onBulletTick(ShulkerBulletEntity shulkerBulletEntity) { if (!shulkerBulletEntity.level.isClientSide && shulkerBulletEntity.getPersistentData().getBoolean(Strings.Tags.BLINDNESS_BULLET)) { - ((ServerLevel)shulkerBulletEntity.level).sendParticles(ParticleTypes.ENTITY_EFFECT, shulkerBulletEntity.getX(), shulkerBulletEntity.getY(), shulkerBulletEntity.getZ(), 1, 0d, 0d, 0d, 0d); + ((ServerWorld)shulkerBulletEntity.level).sendParticles(ParticleTypes.ENTITY_EFFECT, shulkerBulletEntity.getX(), shulkerBulletEntity.getY(), shulkerBulletEntity.getZ(), 1, 0d, 0d, 0d, 0d); } } - public void onBulletEntityHit(ShulkerBullet shulkerBulletEntity, EntityHitResult rayTraceResult) { + public void onBulletEntityHit(ShulkerBulletEntity shulkerBulletEntity, EntityRayTraceResult rayTraceResult) { Entity entityHit = rayTraceResult.getEntity(); Entity entityOwner = shulkerBulletEntity.getOwner(); LivingEntity livingEntityOwner = entityOwner instanceof LivingEntity ? (LivingEntity)entityOwner : null; @@ -267,9 +267,9 @@ public void onBulletEntityHit(ShulkerBullet shulkerBulletEntity, EntityHitResult if (flag) { shulkerBulletEntity.doEnchantDamageEffects(livingEntityOwner, entityHit); if (entityHit instanceof LivingEntity) { - ((LivingEntity)entityHit).addEffect(new MobEffectInstance(MobEffects.LEVITATION, 200)); + ((LivingEntity)entityHit).addEffect(new EffectInstance(Effects.LEVITATION, 200)); if (shulkerBulletEntity.getPersistentData().getBoolean(Strings.Tags.BLINDNESS_BULLET)) - ((LivingEntity)entityHit).addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 150)); + ((LivingEntity)entityHit).addEffect(new EffectInstance(Effects.BLINDNESS, 150)); } } } diff --git a/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/ResistancesFeature.java b/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/ResistancesFeature.java index 30a54751..41f33b05 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/ResistancesFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/ResistancesFeature.java @@ -5,11 +5,11 @@ import insane96mcp.insanelib.base.Module; import insane96mcp.progressivebosses.base.Strings; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.entity.boss.enderdragon.phases.DragonPhaseInstance; -import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase; -import net.minecraft.world.entity.player.Player; +import net.minecraft.entity.boss.dragon.EnderDragonEntity; +import net.minecraft.entity.boss.dragon.phase.IPhase; +import net.minecraft.entity.boss.dragon.phase.PhaseType; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.living.LivingDamageEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -62,19 +62,19 @@ public void onDragonDamage(LivingDamageEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof EnderDragon)) + if (!(event.getEntity() instanceof EnderDragonEntity)) return; - EnderDragon dragon = (EnderDragon) event.getEntity(); + EnderDragonEntity dragon = (EnderDragonEntity) event.getEntity(); bonusDamageNotInCenter(event, dragon); meleeDamageReduction(event, dragon); explosionDamageReduction(event, dragon); } - private static final List> sittingPhases = Arrays.asList(EnderDragonPhase.SITTING_SCANNING, EnderDragonPhase.SITTING_ATTACKING, EnderDragonPhase.SITTING_FLAMING, EnderDragonPhase.TAKEOFF); + private static final List> sittingPhases = Arrays.asList(PhaseType.SITTING_SCANNING, PhaseType.SITTING_ATTACKING, PhaseType.SITTING_FLAMING, PhaseType.TAKEOFF); - private void bonusDamageNotInCenter(LivingDamageEvent event, EnderDragon dragon) { + private void bonusDamageNotInCenter(LivingDamageEvent event, EnderDragonEntity dragon) { if (this.bonusCurHealthDirectDamage == 0d && this.bonusCurHealthIndirectDamage == 0d) return; @@ -85,27 +85,27 @@ private void bonusDamageNotInCenter(LivingDamageEvent event, EnderDragon dragon) return; float curHealth = dragon.getHealth(); - if (event.getSource().getDirectEntity() instanceof Player) { + if (event.getSource().getDirectEntity() instanceof PlayerEntity) { event.setAmount(event.getAmount() + (float) (curHealth * this.bonusCurHealthDirectDamage)); } - else if (event.getSource().getEntity() instanceof Player) { + else if (event.getSource().getEntity() instanceof PlayerEntity) { event.setAmount(event.getAmount() + (float) (curHealth * this.bonusCurHealthIndirectDamage)); } } - private void meleeDamageReduction(LivingDamageEvent event, EnderDragon dragon) { + private void meleeDamageReduction(LivingDamageEvent event, EnderDragonEntity dragon) { if (this.damageRedutionWhenSitting == 0d) return; - CompoundTag compoundNBT = dragon.getPersistentData(); + CompoundNBT compoundNBT = dragon.getPersistentData(); float difficulty = compoundNBT.getFloat(Strings.Tags.DIFFICULTY); - if (sittingPhases.contains(dragon.getPhaseManager().getCurrentPhase().getPhase()) && event.getSource().getDirectEntity() instanceof Player) { + if (sittingPhases.contains(dragon.getPhaseManager().getCurrentPhase().getPhase()) && event.getSource().getDirectEntity() instanceof PlayerEntity) { event.setAmount((event.getAmount() - (float) (event.getAmount() * (this.damageRedutionWhenSitting * difficulty)))); } } - private void explosionDamageReduction(LivingDamageEvent event, EnderDragon dragon) { + private void explosionDamageReduction(LivingDamageEvent event, EnderDragonEntity dragon) { if (this.explosionDamageReduction == 0d) return; diff --git a/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/RewardFeature.java b/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/RewardFeature.java index 65daab2b..8d0a52d9 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/RewardFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/dragon/feature/RewardFeature.java @@ -6,11 +6,11 @@ import insane96mcp.progressivebosses.base.Strings; import insane96mcp.progressivebosses.classutils.Drop; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.ExperienceOrb; -import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.level.block.Blocks; +import net.minecraft.block.Blocks; +import net.minecraft.entity.boss.dragon.EnderDragonEntity; +import net.minecraft.entity.item.ExperienceOrbEntity; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingEvent; @@ -69,16 +69,16 @@ public void onUpdate(LivingEvent.LivingUpdateEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof EnderDragon)) + if (!(event.getEntity() instanceof EnderDragonEntity)) return; - EnderDragon dragon = (EnderDragon) event.getEntity(); + EnderDragonEntity dragon = (EnderDragonEntity) event.getEntity(); dropExperience(dragon); dropEgg(dragon); } - private void dropExperience(EnderDragon dragon) { + private void dropExperience(EnderDragonEntity dragon) { if (this.bonusExperience == 0d) return; @@ -88,7 +88,7 @@ private void dropExperience(EnderDragon dragon) { if (dragon.getDragonFight() == null) return; - CompoundTag dragonTags = dragon.getPersistentData(); + CompoundNBT dragonTags = dragon.getPersistentData(); float difficulty = dragonTags.getFloat(Strings.Tags.DIFFICULTY); if (difficulty == 0d) @@ -100,20 +100,20 @@ private void dropExperience(EnderDragon dragon) { bonusXP += (int) (500 * this.bonusExperience * difficulty * 0.2); while (bonusXP > 0) { - int i = ExperienceOrb.getExperienceValue(bonusXP); + int i = ExperienceOrbEntity.getExperienceValue(bonusXP); bonusXP -= i; - dragon.level.addFreshEntity(new ExperienceOrb(dragon.level, dragon.position().x(), dragon.position().y(), dragon.position().z(), i)); + dragon.level.addFreshEntity(new ExperienceOrbEntity(dragon.level, dragon.position().x(), dragon.position().y(), dragon.position().z(), i)); } } - private void dropEgg(EnderDragon dragon) { + private void dropEgg(EnderDragonEntity dragon) { if (!this.dragonEggPerPlayer) return; if (dragon.dragonDeathTime != 100) return; - CompoundTag tags = dragon.getPersistentData(); + CompoundNBT tags = dragon.getPersistentData(); int eggsToDrop = tags.getInt(Strings.Tags.EGGS_TO_DROP); @@ -134,12 +134,12 @@ public void onDeath(LivingDeathEvent event) { if (this.dropsList.isEmpty()) return; - if (!(event.getEntityLiving() instanceof EnderDragon)) + if (!(event.getEntityLiving() instanceof EnderDragonEntity)) return; - EnderDragon dragon = (EnderDragon) event.getEntityLiving(); + EnderDragonEntity dragon = (EnderDragonEntity) event.getEntityLiving(); - CompoundTag tags = dragon.getPersistentData(); + CompoundNBT tags = dragon.getPersistentData(); float difficulty = tags.getFloat(Strings.Tags.DIFFICULTY); for (Drop drop : this.dropsList) { drop.drop(dragon.level, dragon.position(), difficulty); diff --git a/src/main/java/insane96mcp/progressivebosses/module/dragon/phase/CrystalRespawnPhase.java b/src/main/java/insane96mcp/progressivebosses/module/dragon/phase/CrystalRespawnPhase.java index 36624b9f..0c591042 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/dragon/phase/CrystalRespawnPhase.java +++ b/src/main/java/insane96mcp/progressivebosses/module/dragon/phase/CrystalRespawnPhase.java @@ -3,29 +3,29 @@ import insane96mcp.progressivebosses.base.Strings; import insane96mcp.progressivebosses.module.Modules; import insane96mcp.progressivebosses.module.dragon.feature.CrystalFeature; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.boss.enderdragon.EndCrystal; -import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.entity.boss.enderdragon.phases.AbstractDragonPhaseInstance; -import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase; -import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.levelgen.feature.SpikeFeature; -import net.minecraft.world.phys.Vec3; +import net.minecraft.entity.boss.dragon.EnderDragonEntity; +import net.minecraft.entity.boss.dragon.phase.Phase; +import net.minecraft.entity.boss.dragon.phase.PhaseType; +import net.minecraft.entity.item.EnderCrystalEntity; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.DamageSource; +import net.minecraft.util.SoundEvents; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.Explosion; +import net.minecraft.world.gen.feature.EndSpikeFeature; import javax.annotation.Nullable; import java.util.ArrayList; -public class CrystalRespawnPhase extends AbstractDragonPhaseInstance { - private static EnderDragonPhase CRYSTAL_RESPAWN; +public class CrystalRespawnPhase extends Phase { + private static PhaseType CRYSTAL_RESPAWN; - public Vec3 targetLocation; + public Vector3d targetLocation; private int tick = 0; private boolean respawning = false; - private final ArrayList spikesToRespawn = new ArrayList<>(); + private final ArrayList spikesToRespawn = new ArrayList<>(); - public CrystalRespawnPhase(EnderDragon dragonIn) { + public CrystalRespawnPhase(EnderDragonEntity dragonIn) { super(dragonIn); } @@ -34,44 +34,44 @@ public CrystalRespawnPhase(EnderDragon dragonIn) { * Called by dragon's onLivingUpdate. Only used when !worldObj.isClientSide. */ public void doServerTick() { - CompoundTag dragonTags = this.dragon.getPersistentData(); + CompoundNBT dragonTags = this.dragon.getPersistentData(); float difficulty = dragonTags.getFloat(Strings.Tags.DIFFICULTY); if (this.targetLocation == null) { if (spikesToRespawn.isEmpty()) { - dragon.getPhaseManager().setPhase(EnderDragonPhase.TAKEOFF); + dragon.getPhaseManager().setPhase(PhaseType.TAKEOFF); return; } - this.targetLocation = new Vec3(spikesToRespawn.get(0).getCenterX() + 0.5, spikesToRespawn.get(0).getHeight() + 5.5, spikesToRespawn.get(0).getCenterZ() + 0.5); + this.targetLocation = new Vector3d(spikesToRespawn.get(0).getCenterX() + 0.5, spikesToRespawn.get(0).getHeight() + 5.5, spikesToRespawn.get(0).getCenterZ() + 0.5); } int tickSpawnCystal = (int) (50 - (difficulty / 4)); if (!respawning) { double d0 = this.targetLocation.distanceToSqr(dragon.getX(), dragon.getY(), dragon.getZ()); if (d0 < 16d) { - dragon.setDeltaMovement(Vec3.ZERO); + dragon.setDeltaMovement(Vector3d.ZERO); respawning = true; } } else { tick++; - dragon.setDeltaMovement(Vec3.ZERO); + dragon.setDeltaMovement(Vector3d.ZERO); if (tick <= 25) dragon.playSound(SoundEvents.ENDER_DRAGON_GROWL, 4F, 1.0F); if (tick >= tickSpawnCystal) { if (dragon.getHealth() < 10f) { - dragon.getPhaseManager().setPhase(EnderDragonPhase.TAKEOFF); + dragon.getPhaseManager().setPhase(PhaseType.TAKEOFF); return; } - EndCrystal crystal; + EnderCrystalEntity crystal; double x = spikesToRespawn.get(0).getCenterX(); double y = spikesToRespawn.get(0).getHeight(); double z = spikesToRespawn.get(0).getCenterZ(); if (dragon.getRandom().nextDouble() < Modules.dragon.crystal.crystalRespawnInsideTowerChance * difficulty) CrystalFeature.generateCrystalInTower(dragon.level, x + 0.5, y + 1, z + 0.5); else { - crystal = new EndCrystal(dragon.level, x + 0.5, y + 1, z + 0.5); + crystal = new EnderCrystalEntity(dragon.level, x + 0.5, y + 1, z + 0.5); crystal.setShowBottom(true); - crystal.level.explode(dragon, x + 0.5, y + 1.5, z + 0.5, 5f, Explosion.BlockInteraction.NONE); + crystal.level.explode(dragon, x + 0.5, y + 1.5, z + 0.5, 5f, Explosion.Mode.NONE); dragon.level.addFreshEntity(crystal); CrystalFeature.generateCage(crystal.level, crystal.blockPosition()); } @@ -107,24 +107,24 @@ public float getFlySpeed() { * Returns the location the dragon is flying toward */ @Nullable - public Vec3 getFlyTargetLocation() { + public Vector3d getFlyTargetLocation() { return this.targetLocation; } - public void addCrystalRespawn(SpikeFeature.EndSpike spike) { + public void addCrystalRespawn(EndSpikeFeature.EndSpike spike) { if (!this.spikesToRespawn.contains(spike)) this.spikesToRespawn.add(spike); } - public EnderDragonPhase getPhase() { + public PhaseType getPhase() { return CRYSTAL_RESPAWN; } - public static EnderDragonPhase getPhaseType() { + public static PhaseType getPhaseType() { return CRYSTAL_RESPAWN; } public static void init() { - CRYSTAL_RESPAWN = EnderDragonPhase.create(CrystalRespawnPhase.class, "CrystalRespawn"); + CRYSTAL_RESPAWN = PhaseType.create(CrystalRespawnPhase.class, "CrystalRespawn"); } } diff --git a/src/main/java/insane96mcp/progressivebosses/module/elderguardian/ai/ElderMinionAttackGoal.java b/src/main/java/insane96mcp/progressivebosses/module/elderguardian/ai/ElderMinionAttackGoal.java index a630307b..e76e2f4a 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/elderguardian/ai/ElderMinionAttackGoal.java +++ b/src/main/java/insane96mcp/progressivebosses/module/elderguardian/ai/ElderMinionAttackGoal.java @@ -1,23 +1,23 @@ package insane96mcp.progressivebosses.module.elderguardian.ai; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.ai.attributes.Attributes; +import net.minecraft.entity.ai.goal.Goal; +import net.minecraft.entity.monster.ElderGuardianEntity; +import net.minecraft.entity.monster.GuardianEntity; +import net.minecraft.util.DamageSource; import net.minecraft.world.Difficulty; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.ai.attributes.Attributes; -import net.minecraft.world.entity.ai.goal.Goal; -import net.minecraft.world.entity.monster.ElderGuardian; -import net.minecraft.world.entity.monster.Guardian; import java.util.EnumSet; public class ElderMinionAttackGoal extends Goal { - private final Guardian guardian; + private final GuardianEntity guardian; private int attackTime; private final boolean elder; - public ElderMinionAttackGoal(Guardian p_i45833_1_) { + public ElderMinionAttackGoal(GuardianEntity p_i45833_1_) { this.guardian = p_i45833_1_; - this.elder = p_i45833_1_ instanceof ElderGuardian; + this.elder = p_i45833_1_ instanceof ElderGuardianEntity; this.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK)); } diff --git a/src/main/java/insane96mcp/progressivebosses/module/elderguardian/ai/ElderMinionNearestAttackableTargetGoal.java b/src/main/java/insane96mcp/progressivebosses/module/elderguardian/ai/ElderMinionNearestAttackableTargetGoal.java index ae477a4a..40e7cf8f 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/elderguardian/ai/ElderMinionNearestAttackableTargetGoal.java +++ b/src/main/java/insane96mcp/progressivebosses/module/elderguardian/ai/ElderMinionNearestAttackableTargetGoal.java @@ -1,13 +1,13 @@ package insane96mcp.progressivebosses.module.elderguardian.ai; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.ai.goal.Goal; -import net.minecraft.world.entity.ai.goal.target.TargetGoal; -import net.minecraft.world.entity.ai.targeting.TargetingConditions; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.phys.AABB; +import net.minecraft.entity.EntityPredicate; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.MobEntity; +import net.minecraft.entity.ai.goal.Goal; +import net.minecraft.entity.ai.goal.TargetGoal; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.util.math.AxisAlignedBB; import javax.annotation.Nullable; import java.util.EnumSet; @@ -18,22 +18,22 @@ public class ElderMinionNearestAttackableTargetGoal exte protected int targetChance; protected LivingEntity nearestTarget; /** This filter is applied to the Entity search. Only matching entities will be targeted. */ - public TargetingConditions targetEntitySelector; + public EntityPredicate targetEntitySelector; - public ElderMinionNearestAttackableTargetGoal(Mob goalOwnerIn, Class targetClassIn, boolean checkSight) { + public ElderMinionNearestAttackableTargetGoal(MobEntity goalOwnerIn, Class targetClassIn, boolean checkSight) { this(goalOwnerIn, targetClassIn, checkSight, false); } - public ElderMinionNearestAttackableTargetGoal(Mob goalOwnerIn, Class targetClassIn, boolean checkSight, boolean nearbyOnlyIn) { + public ElderMinionNearestAttackableTargetGoal(MobEntity goalOwnerIn, Class targetClassIn, boolean checkSight, boolean nearbyOnlyIn) { this(goalOwnerIn, targetClassIn, checkSight, nearbyOnlyIn, null); } - public ElderMinionNearestAttackableTargetGoal(Mob goalOwnerIn, Class targetClassIn, boolean checkSight, boolean nearbyOnlyIn, @Nullable Predicate targetPredicate) { + public ElderMinionNearestAttackableTargetGoal(MobEntity goalOwnerIn, Class targetClassIn, boolean checkSight, boolean nearbyOnlyIn, @Nullable Predicate targetPredicate) { super(goalOwnerIn, checkSight, nearbyOnlyIn); this.targetClass = targetClassIn; this.targetChance = 10; this.setFlags(EnumSet.of(Goal.Flag.TARGET)); - TargetingConditions predicate = TargetingConditions.DEFAULT.range(this.getFollowDistance()).selector(targetPredicate).ignoreLineOfSight(); + EntityPredicate predicate = (new EntityPredicate()).range(this.getFollowDistance()).selector(targetPredicate).allowUnseeable(); this.targetEntitySelector = predicate; } @@ -51,13 +51,13 @@ public boolean canUse() { } } - protected AABB getTargetableArea(double targetDistance) { + protected AxisAlignedBB getTargetableArea(double targetDistance) { return this.mob.getBoundingBox().inflate(targetDistance, 4.0D, targetDistance); } protected void findNearestTarget() { - if (this.targetClass != Player.class && this.targetClass != ServerPlayer.class) { - this.nearestTarget = this.mob.level.getNearestEntity(this.targetClass, this.targetEntitySelector, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ(), this.getTargetableArea(this.getFollowDistance())); + if (this.targetClass != PlayerEntity.class && this.targetClass != ServerPlayerEntity.class) { + this.nearestTarget = this.mob.level.getNearestLoadedEntity(this.targetClass, this.targetEntitySelector, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ(), this.getTargetableArea(this.getFollowDistance())); } else { this.nearestTarget = this.mob.level.getNearestPlayer(this.targetEntitySelector, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ()); diff --git a/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/AttackFeature.java b/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/AttackFeature.java index 0473e918..79bfac0a 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/AttackFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/AttackFeature.java @@ -4,7 +4,7 @@ import insane96mcp.insanelib.base.Label; import insane96mcp.insanelib.base.Module; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.world.entity.monster.ElderGuardian; +import net.minecraft.entity.monster.ElderGuardianEntity; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -48,10 +48,10 @@ public void onDamageDealt(LivingHurtEvent event) { if (this.bonusDamage == 0d) return; - if (!(event.getSource().getEntity() instanceof ElderGuardian)) + if (!(event.getSource().getEntity() instanceof ElderGuardianEntity)) return; - ElderGuardian elderGuardian = (ElderGuardian) event.getSource().getEntity(); + ElderGuardianEntity elderGuardian = (ElderGuardianEntity) event.getSource().getEntity(); float bonusDamage = (float) (this.bonusDamage * BaseFeature.getDeadElderGuardians(elderGuardian)); @@ -60,10 +60,10 @@ public void onDamageDealt(LivingHurtEvent event) { private static final int BASE_ATTACK_DURATION = 60; - public int getAttackDuration(ElderGuardian elderGuardian) { + public int getAttackDuration(ElderGuardianEntity elderGuardian) { if (!this.isEnabled() || this.attackDurationReduction == 0) return BASE_ATTACK_DURATION; - int elderGuardiansNearby = elderGuardian.level.getEntities(elderGuardian, elderGuardian.getBoundingBox().inflate(48d), entity -> entity instanceof ElderGuardian).size(); + int elderGuardiansNearby = elderGuardian.level.getEntities(elderGuardian, elderGuardian.getBoundingBox().inflate(48d), entity -> entity instanceof ElderGuardianEntity).size(); if (elderGuardiansNearby == 2) return BASE_ATTACK_DURATION; diff --git a/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/BaseFeature.java b/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/BaseFeature.java index 6be9039c..84b3e78a 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/BaseFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/BaseFeature.java @@ -5,16 +5,16 @@ import insane96mcp.insanelib.base.Module; import insane96mcp.progressivebosses.base.Strings; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.Util; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.network.protocol.game.ClientboundGameEventPacket; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.world.entity.monster.ElderGuardian; -import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.GameType; +import net.minecraft.entity.monster.ElderGuardianEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.play.server.SChangeGameStatePacket; +import net.minecraft.util.SoundEvents; +import net.minecraft.util.Util; +import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.Explosion; +import net.minecraft.world.GameType; +import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; @@ -60,27 +60,27 @@ public void onPlayerTick(TickEvent.PlayerTickEvent event) { if (!event.player.isAlive()) return; - ServerPlayer serverPlayer = (ServerPlayer) event.player; - ServerLevel world = (ServerLevel) serverPlayer.level; + ServerPlayerEntity serverPlayer = (ServerPlayerEntity) event.player; + ServerWorld world = (ServerWorld) serverPlayer.level; - CompoundTag nbt = serverPlayer.getPersistentData(); + CompoundNBT nbt = serverPlayer.getPersistentData(); boolean previouslyNearElderGuardian = nbt.getBoolean(Strings.Tags.PREVIOUSLY_NEAR_ELDER_GUARDIAN); boolean adventureMessage = nbt.getBoolean(Strings.Tags.ADVENTURE_MESSAGE); - boolean nearElderGuardian = !world.getEntitiesOfClass(ElderGuardian.class, serverPlayer.getBoundingBox().inflate(32d), null).isEmpty(); + boolean nearElderGuardian = !world.getEntitiesOfClass(ElderGuardianEntity.class, serverPlayer.getBoundingBox().inflate(32d), null).isEmpty(); nbt.putBoolean(Strings.Tags.PREVIOUSLY_NEAR_ELDER_GUARDIAN, nearElderGuardian); if (serverPlayer.gameMode.getGameModeForPlayer() == GameType.SURVIVAL && nearElderGuardian) { - serverPlayer.gameMode.changeGameModeForPlayer(GameType.ADVENTURE); - serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float)GameType.ADVENTURE.getId())); + serverPlayer.gameMode.setGameModeForPlayer(GameType.ADVENTURE); + serverPlayer.connection.send(new SChangeGameStatePacket(SChangeGameStatePacket.CHANGE_GAME_MODE, (float)GameType.ADVENTURE.getId())); if (!adventureMessage) { - serverPlayer.sendMessage(new TranslatableComponent(Strings.Translatable.APPROACHING_ELDER_GUARDIAN), Util.NIL_UUID); + serverPlayer.sendMessage(new TranslationTextComponent(Strings.Translatable.APPROACHING_ELDER_GUARDIAN), Util.NIL_UUID); nbt.putBoolean(Strings.Tags.ADVENTURE_MESSAGE, true); } } else if (serverPlayer.gameMode.getGameModeForPlayer() == GameType.ADVENTURE && !nearElderGuardian && previouslyNearElderGuardian) { - serverPlayer.gameMode.changeGameModeForPlayer(GameType.SURVIVAL); - serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float)GameType.SURVIVAL.getId())); + serverPlayer.gameMode.setGameModeForPlayer(GameType.SURVIVAL); + serverPlayer.connection.send(new SChangeGameStatePacket(SChangeGameStatePacket.CHANGE_GAME_MODE, (float)GameType.SURVIVAL.getId())); } } @@ -92,17 +92,17 @@ public void onPlayerDeath(LivingDeathEvent event) { if (!this.adventure) return; - if (!(event.getEntity() instanceof ServerPlayer)) + if (!(event.getEntity() instanceof ServerPlayerEntity)) return; - ServerPlayer serverPlayer = (ServerPlayer) event.getEntity(); + ServerPlayerEntity serverPlayer = (ServerPlayerEntity) event.getEntity(); - CompoundTag nbt = serverPlayer.getPersistentData(); + CompoundNBT nbt = serverPlayer.getPersistentData(); boolean previouslyNearElderGuardian = nbt.getBoolean(Strings.Tags.PREVIOUSLY_NEAR_ELDER_GUARDIAN); if (previouslyNearElderGuardian && serverPlayer.gameMode.getGameModeForPlayer() == GameType.ADVENTURE) { - serverPlayer.gameMode.changeGameModeForPlayer(GameType.SURVIVAL); - serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float)GameType.SURVIVAL.getId())); + serverPlayer.gameMode.setGameModeForPlayer(GameType.SURVIVAL); + serverPlayer.connection.send(new SChangeGameStatePacket(SChangeGameStatePacket.CHANGE_GAME_MODE, (float)GameType.SURVIVAL.getId())); } } @@ -117,13 +117,13 @@ public void onExplosionDetonate(ExplosionEvent.Start event) { if (event.getExplosion().getExploder() == null) return; - if (event.getExplosion().blockInteraction == Explosion.BlockInteraction.NONE) + if (event.getExplosion().blockInteraction == Explosion.Mode.NONE) return; - boolean nearElderGuardian = !event.getWorld().getEntitiesOfClass(ElderGuardian.class, event.getExplosion().getExploder().getBoundingBox().inflate(32d)).isEmpty(); + boolean nearElderGuardian = !event.getWorld().getEntitiesOfClass(ElderGuardianEntity.class, event.getExplosion().getExploder().getBoundingBox().inflate(32d)).isEmpty(); if (nearElderGuardian) { event.setCanceled(true); - event.getWorld().explode(event.getExplosion().getExploder(), event.getExplosion().getPosition().x, event.getExplosion().getPosition().y, event.getExplosion().getPosition().z, event.getExplosion().radius, event.getExplosion().fire, Explosion.BlockInteraction.NONE); + event.getWorld().explode(event.getExplosion().getExploder(), event.getExplosion().getPosition().x, event.getExplosion().getPosition().y, event.getExplosion().getPosition().z, event.getExplosion().radius, event.getExplosion().fire, Explosion.Mode.NONE); } } @@ -132,20 +132,20 @@ public void onElderGuardianDeath(LivingDeathEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof ElderGuardian)) + if (!(event.getEntity() instanceof ElderGuardianEntity)) return; - ElderGuardian elderGuardian = (ElderGuardian) event.getEntity(); + ElderGuardianEntity elderGuardian = (ElderGuardianEntity) event.getEntity(); - int elderGuardiansNearby = elderGuardian.level.getEntities(elderGuardian, elderGuardian.getBoundingBox().inflate(48d), entity -> entity instanceof ElderGuardian).size(); + int elderGuardiansNearby = elderGuardian.level.getEntities(elderGuardian, elderGuardian.getBoundingBox().inflate(48d), entity -> entity instanceof ElderGuardianEntity).size(); if (elderGuardiansNearby == 0) return; elderGuardian.playSound(SoundEvents.ELDER_GUARDIAN_CURSE, 2f, 0.5f); } - public static int getDeadElderGuardians(ElderGuardian elderGuardian) { - int elderGuardiansNearby = elderGuardian.level.getEntities(elderGuardian, elderGuardian.getBoundingBox().inflate(48d), entity -> entity instanceof ElderGuardian).size(); + public static int getDeadElderGuardians(ElderGuardianEntity elderGuardian) { + int elderGuardiansNearby = elderGuardian.level.getEntities(elderGuardian, elderGuardian.getBoundingBox().inflate(48d), entity -> entity instanceof ElderGuardianEntity).size(); return 2 - elderGuardiansNearby; } } diff --git a/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/HealthFeature.java b/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/HealthFeature.java index 89a2b236..28a312b4 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/HealthFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/HealthFeature.java @@ -6,10 +6,10 @@ import insane96mcp.insanelib.utils.MCUtils; import insane96mcp.progressivebosses.base.Strings; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.ai.attributes.AttributeModifier; -import net.minecraft.world.entity.ai.attributes.Attributes; -import net.minecraft.world.entity.monster.ElderGuardian; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.Attributes; +import net.minecraft.entity.monster.ElderGuardianEntity; +import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingEvent; @@ -60,11 +60,11 @@ public void onSpawn(EntityJoinWorldEvent event) { if (this.bonusHealth == 0d && this.absorptionHealth == 0d) return; - if (!(event.getEntity() instanceof ElderGuardian)) + if (!(event.getEntity() instanceof ElderGuardianEntity)) return; - ElderGuardian elderGuardian = (ElderGuardian) event.getEntity(); - CompoundTag nbt = elderGuardian.getPersistentData(); + ElderGuardianEntity elderGuardian = (ElderGuardianEntity) event.getEntity(); + CompoundNBT nbt = elderGuardian.getPersistentData(); if (nbt.getBoolean(Strings.Tags.DIFFICULTY)) return; @@ -88,13 +88,13 @@ public void onUpdate(LivingEvent.LivingUpdateEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof ElderGuardian)) + if (!(event.getEntity() instanceof ElderGuardianEntity)) return; if (this.healthRegen == 0d) return; - ElderGuardian elderGuardian = (ElderGuardian) event.getEntity(); + ElderGuardianEntity elderGuardian = (ElderGuardianEntity) event.getEntity(); if (!elderGuardian.isAlive()) return; diff --git a/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/MinionFeature.java b/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/MinionFeature.java index 4a534492..5b86e741 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/MinionFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/MinionFeature.java @@ -7,22 +7,22 @@ import insane96mcp.progressivebosses.base.Strings; import insane96mcp.progressivebosses.module.elderguardian.ai.ElderMinionNearestAttackableTargetGoal; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.ai.attributes.AttributeModifier; -import net.minecraft.world.entity.ai.goal.Goal; -import net.minecraft.world.entity.ai.goal.WrappedGoal; -import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; -import net.minecraft.world.entity.monster.ElderGuardian; -import net.minecraft.world.entity.monster.Guardian; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.storage.loot.BuiltInLootTables; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.goal.Goal; +import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal; +import net.minecraft.entity.ai.goal.PrioritizedGoal; +import net.minecraft.entity.monster.ElderGuardianEntity; +import net.minecraft.entity.monster.GuardianEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.loot.LootTables; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.World; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.event.entity.EntityJoinWorldEvent; @@ -68,12 +68,12 @@ public void onElderGuardianSpawn(EntityJoinWorldEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof ElderGuardian)) + if (!(event.getEntity() instanceof ElderGuardianEntity)) return; - ElderGuardian elderGuardian = (ElderGuardian) event.getEntity(); + ElderGuardianEntity elderGuardian = (ElderGuardianEntity) event.getEntity(); - CompoundTag witherTags = elderGuardian.getPersistentData(); + CompoundNBT witherTags = elderGuardian.getPersistentData(); witherTags.putInt(Strings.Tags.ELDER_MINION_COOLDOWN, this.baseCooldown); } @@ -86,13 +86,13 @@ public void update(LivingEvent.LivingUpdateEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof ElderGuardian)) + if (!(event.getEntity() instanceof ElderGuardianEntity)) return; - Level world = event.getEntity().level; + World world = event.getEntity().level; - ElderGuardian elderGuardian = (ElderGuardian) event.getEntity(); - CompoundTag elderGuardianTags = elderGuardian.getPersistentData(); + ElderGuardianEntity elderGuardian = (ElderGuardianEntity) event.getEntity(); + CompoundNBT elderGuardianTags = elderGuardian.getPersistentData(); if (elderGuardian.getHealth() <= 0) return; @@ -107,24 +107,24 @@ public void update(LivingEvent.LivingUpdateEvent event) { int radius = 24; BlockPos pos1 = elderGuardian.blockPosition().offset(-radius, -radius, -radius); BlockPos pos2 = elderGuardian.blockPosition().offset(radius, radius, radius); - AABB bb = new AABB(pos1, pos2); - List players = world.getEntitiesOfClass(ServerPlayer.class, bb); + AxisAlignedBB bb = new AxisAlignedBB(pos1, pos2); + List players = world.getLoadedEntitiesOfClass(ServerPlayerEntity.class, bb); if (players.isEmpty()) return; - List minionsInAABB = world.getEntitiesOfClass(Guardian.class, elderGuardian.getBoundingBox().inflate(12), entity -> entity.getPersistentData().contains(Strings.Tags.ELDER_MINION)); + List minionsInAABB = world.getLoadedEntitiesOfClass(GuardianEntity.class, elderGuardian.getBoundingBox().inflate(12), entity -> entity.getPersistentData().contains(Strings.Tags.ELDER_MINION)); int minionsCountInAABB = minionsInAABB.size(); if (minionsCountInAABB >= 5) return; - summonMinion(world, new Vec3(elderGuardian.getX(), elderGuardian.getY(), elderGuardian.getZ())); + summonMinion(world, new Vector3d(elderGuardian.getX(), elderGuardian.getY(), elderGuardian.getZ())); } - public Guardian summonMinion(Level world, Vec3 pos) { - Guardian elderMinion = new Guardian(EntityType.GUARDIAN, world); - CompoundTag minionTags = elderMinion.getPersistentData(); + public GuardianEntity summonMinion(World world, Vector3d pos) { + GuardianEntity elderMinion = new GuardianEntity(EntityType.GUARDIAN, world); + CompoundNBT minionTags = elderMinion.getPersistentData(); minionTags.putBoolean("mobspropertiesrandomness:processed", true); //TODO Scaling health @@ -132,13 +132,13 @@ public Guardian summonMinion(Level world, Vec3 pos) { minionTags.putBoolean(Strings.Tags.ELDER_MINION, true); elderMinion.setPos(pos.x, pos.y, pos.z); - elderMinion.setCustomName(new TranslatableComponent(Strings.Translatable.ELDER_MINION)); - elderMinion.lootTable = BuiltInLootTables.EMPTY; + elderMinion.setCustomName(new TranslationTextComponent(Strings.Translatable.ELDER_MINION)); + elderMinion.lootTable = LootTables.EMPTY; MCUtils.applyModifier(elderMinion, ForgeMod.SWIM_SPEED.get(), Strings.AttributeModifiers.SWIM_SPEED_BONUS_UUID, Strings.AttributeModifiers.SWIM_SPEED_BONUS, 2d, AttributeModifier.Operation.MULTIPLY_BASE); ArrayList goalsToRemove = new ArrayList<>(); - for (WrappedGoal prioritizedGoal : elderMinion.targetSelector.availableGoals) { + for (PrioritizedGoal prioritizedGoal : elderMinion.targetSelector.availableGoals) { if (!(prioritizedGoal.getGoal() instanceof NearestAttackableTargetGoal)) continue; @@ -146,7 +146,7 @@ public Guardian summonMinion(Level world, Vec3 pos) { } goalsToRemove.forEach(elderMinion.goalSelector::removeGoal); - elderMinion.targetSelector.addGoal(1, new ElderMinionNearestAttackableTargetGoal<>(elderMinion, Player.class, true)); + elderMinion.targetSelector.addGoal(1, new ElderMinionNearestAttackableTargetGoal<>(elderMinion, PlayerEntity.class, true)); world.addFreshEntity(elderMinion); return elderMinion; diff --git a/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/ResistancesFeature.java b/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/ResistancesFeature.java index 5a27ea6a..27d9bda3 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/ResistancesFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/ResistancesFeature.java @@ -4,7 +4,7 @@ import insane96mcp.insanelib.base.Label; import insane96mcp.insanelib.base.Module; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.world.entity.monster.ElderGuardian; +import net.minecraft.entity.monster.ElderGuardianEntity; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.living.LivingDamageEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -39,10 +39,10 @@ public void onElderGuardianDamage(LivingDamageEvent event) { if (this.resistancePerElderGuardianDefeated == 0d) return; - if (!(event.getEntity() instanceof ElderGuardian)) + if (!(event.getEntity() instanceof ElderGuardianEntity)) return; - ElderGuardian elderGuardian = (ElderGuardian) event.getEntity(); + ElderGuardianEntity elderGuardian = (ElderGuardianEntity) event.getEntity(); float damageReduction = (float) (BaseFeature.getDeadElderGuardians(elderGuardian) * this.resistancePerElderGuardianDefeated); diff --git a/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/RewardFeature.java b/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/RewardFeature.java index 8281c3f1..578a64d2 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/RewardFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/elderguardian/feature/RewardFeature.java @@ -5,7 +5,7 @@ import insane96mcp.insanelib.base.Module; import insane96mcp.progressivebosses.classutils.Drop; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.world.entity.monster.ElderGuardian; +import net.minecraft.entity.monster.ElderGuardianEntity; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; @@ -74,10 +74,10 @@ public void onSpawn(EntityJoinWorldEvent event) { if (this.baseExperience == 0d) return; - if (!(event.getEntity() instanceof ElderGuardian)) + if (!(event.getEntity() instanceof ElderGuardianEntity)) return; - ElderGuardian elderGuardian = (ElderGuardian) event.getEntity(); + ElderGuardianEntity elderGuardian = (ElderGuardianEntity) event.getEntity(); elderGuardian.xpReward = this.baseExperience; } @@ -90,7 +90,7 @@ public void onExperienceDrop(LivingExperienceDropEvent event) { if (this.bonusExperience == 0d) return; - if (!(event.getEntity() instanceof ElderGuardian)) + if (!(event.getEntity() instanceof ElderGuardianEntity)) return; int bonusExperience = (int) (event.getOriginalExperience() * (this.bonusExperience)); @@ -105,10 +105,10 @@ public void onDeath(LivingDeathEvent event) { if (this.dropsList.isEmpty()) return; - if (!(event.getEntityLiving() instanceof ElderGuardian)) + if (!(event.getEntityLiving() instanceof ElderGuardianEntity)) return; - ElderGuardian elderGuardian = (ElderGuardian) event.getEntityLiving(); + ElderGuardianEntity elderGuardian = (ElderGuardianEntity) event.getEntityLiving(); for (Drop drop : this.dropsList) { drop.drop(elderGuardian.level, elderGuardian.position(), BaseFeature.getDeadElderGuardians(elderGuardian)); diff --git a/src/main/java/insane96mcp/progressivebosses/module/wither/ai/WitherChargeAttackGoal.java b/src/main/java/insane96mcp/progressivebosses/module/wither/ai/WitherChargeAttackGoal.java index d308360c..531c4834 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/wither/ai/WitherChargeAttackGoal.java +++ b/src/main/java/insane96mcp/progressivebosses/module/wither/ai/WitherChargeAttackGoal.java @@ -2,37 +2,37 @@ import insane96mcp.progressivebosses.base.Strings; import insane96mcp.progressivebosses.module.wither.feature.AttackFeature; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.sounds.SoundSource; -import net.minecraft.world.damagesource.EntityDamageSource; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.ai.goal.Goal; -import net.minecraft.world.entity.boss.wither.WitherBoss; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.storage.loot.LootContext; -import net.minecraft.world.level.storage.loot.parameters.LootContextParams; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.ai.goal.Goal; +import net.minecraft.entity.boss.WitherEntity; +import net.minecraft.entity.item.ItemEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.loot.LootContext; +import net.minecraft.loot.LootParameters; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EntityDamageSource; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvents; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.Explosion; +import net.minecraft.world.server.ServerWorld; import java.util.EnumSet; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Stream; public class WitherChargeAttackGoal extends Goal { - private final WitherBoss wither; + private final WitherEntity wither; private LivingEntity target; - private Vec3 targetPos; + private Vector3d targetPos; private double lastDistanceFromTarget = 0d; - public WitherChargeAttackGoal(WitherBoss wither) { + public WitherChargeAttackGoal(WitherEntity wither) { this.wither = wither; this.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.JUMP, Goal.Flag.LOOK, Flag.TARGET)); } @@ -44,7 +44,7 @@ public WitherChargeAttackGoal(WitherBoss wither) { public boolean canUse() { if (this.wither.getInvulnerableTicks() != AttackFeature.Consts.CHARGE_ATTACK_TICK_START) return false; - CompoundTag witherTags = wither.getPersistentData(); + CompoundNBT witherTags = wither.getPersistentData(); return witherTags.contains(Strings.Tags.CHARGE_ATTACK); } @@ -66,7 +66,7 @@ public boolean canContinueToUse() { */ public void stop() { this.target = null; - CompoundTag witherTags = wither.getPersistentData(); + CompoundNBT witherTags = wither.getPersistentData(); witherTags.remove(Strings.Tags.CHARGE_ATTACK); this.wither.setDeltaMovement(this.wither.getDeltaMovement().multiply(0.02d, 0.02d, 0.02d)); this.lastDistanceFromTarget = 0d; @@ -78,38 +78,38 @@ public void stop() { */ public void tick() { if (this.wither.getInvulnerableTicks() > AttackFeature.Consts.CHARGE_ATTACK_TICK_CHARGE) - this.wither.setDeltaMovement(Vec3.ZERO); + this.wither.setDeltaMovement(Vector3d.ZERO); if (this.wither.getInvulnerableTicks() == AttackFeature.Consts.CHARGE_ATTACK_TICK_START) - this.wither.level.playSound(null, this.wither.blockPosition(), SoundEvents.WITHER_DEATH, SoundSource.HOSTILE, 5.0f, 2.0f); + this.wither.level.playSound(null, this.wither.blockPosition(), SoundEvents.WITHER_DEATH, SoundCategory.HOSTILE, 5.0f, 2.0f); else if (this.wither.getInvulnerableTicks() == AttackFeature.Consts.CHARGE_ATTACK_TICK_CHARGE) { this.target = this.wither.level.getNearestPlayer(this.wither, 64d); if (target != null) { this.targetPos = this.target.position(); - Vec3 forward = this.targetPos.subtract(this.wither.position()).normalize(); + Vector3d forward = this.targetPos.subtract(this.wither.position()).normalize(); this.targetPos = this.targetPos.add(forward.multiply(4d, 4d, 4d)); this.lastDistanceFromTarget = this.targetPos.distanceToSqr(this.wither.position()); - this.wither.level.playSound(null, new BlockPos(this.targetPos), SoundEvents.WITHER_SPAWN, SoundSource.HOSTILE, 4.0f, 2.0f); + this.wither.level.playSound(null, new BlockPos(this.targetPos), SoundEvents.WITHER_SPAWN, SoundCategory.HOSTILE, 4.0f, 2.0f); } else { - this.wither.level.explode(this.wither, this.wither.getX(), this.wither.getY() + 1.75d, this.wither.getZ(), 6f, Explosion.BlockInteraction.DESTROY); + this.wither.level.explode(this.wither, this.wither.getX(), this.wither.getY() + 1.75d, this.wither.getZ(), 6f, Explosion.Mode.DESTROY); this.wither.setInvulnerableTicks(0); } } else if (this.wither.getInvulnerableTicks() < AttackFeature.Consts.CHARGE_ATTACK_TICK_CHARGE) { //Done so it goes faster and faster double mult = 60d / this.wither.getInvulnerableTicks(); - Vec3 diff = this.targetPos.subtract(this.wither.position()).normalize().multiply(mult, mult, mult); + Vector3d diff = this.targetPos.subtract(this.wither.position()).normalize().multiply(mult, mult, mult); this.wither.setDeltaMovement(diff.x, diff.y * 0.5, diff.z); this.wither.getLookControl().setLookAt(this.targetPos); - AABB axisAlignedBB = new AABB(this.wither.getX() - 2, this.wither.getY() - 2, this.wither.getZ() - 2, this.wither.getX() + 2, this.wither.getY() + 6, this.wither.getZ() + 2); + AxisAlignedBB axisAlignedBB = new AxisAlignedBB(this.wither.getX() - 2, this.wither.getY() - 2, this.wither.getZ() - 2, this.wither.getX() + 2, this.wither.getY() + 6, this.wither.getZ() + 2); Stream blocks = BlockPos.betweenClosedStream(axisAlignedBB); AtomicBoolean hasBrokenBlocks = new AtomicBoolean(false); blocks.forEach(blockPos -> { BlockState state = wither.level.getBlockState(blockPos); if (state.canEntityDestroy(wither.level, blockPos, wither) && net.minecraftforge.event.ForgeEventFactory.onEntityDestroyBlock(wither, blockPos, state) && !state.getBlock().equals(Blocks.AIR)) { - BlockEntity tileentity = state.hasBlockEntity() ? this.wither.level.getBlockEntity(blockPos) : null; - LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerLevel)this.wither.level)).withRandom(this.wither.level.random).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(blockPos)).withParameter(LootContextParams.TOOL, ItemStack.EMPTY).withOptionalParameter(LootContextParams.BLOCK_ENTITY, tileentity); + TileEntity tileentity = state.hasTileEntity() ? this.wither.level.getBlockEntity(blockPos) : null; + LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld)this.wither.level)).withRandom(this.wither.level.random).withParameter(LootParameters.ORIGIN, Vector3d.atCenterOf(blockPos)).withParameter(LootParameters.TOOL, ItemStack.EMPTY).withOptionalParameter(LootParameters.BLOCK_ENTITY, tileentity); state.getDrops(lootcontext$builder).forEach(itemStack -> { ItemEntity itemEntity = new ItemEntity(this.wither.level, blockPos.getX() + .5d, blockPos.getY() + .5d, blockPos.getZ() + .5d, itemStack); itemEntity.lifespan = 1200; @@ -121,10 +121,10 @@ else if (this.wither.getInvulnerableTicks() < AttackFeature.Consts.CHARGE_ATTACK }); if (hasBrokenBlocks.get()) - this.wither.level.playSound(null, new BlockPos(this.targetPos), SoundEvents.WITHER_BREAK_BLOCK, SoundSource.HOSTILE, 1.0f, 0.75f); + this.wither.level.playSound(null, new BlockPos(this.targetPos), SoundEvents.WITHER_BREAK_BLOCK, SoundCategory.HOSTILE, 1.0f, 0.75f); axisAlignedBB = axisAlignedBB.inflate(1d); - this.wither.level.getEntitiesOfClass(LivingEntity.class, axisAlignedBB).forEach(entity -> { + this.wither.level.getLoadedEntitiesOfClass(LivingEntity.class, axisAlignedBB).forEach(entity -> { if (entity == this.wither) return; entity.hurt(new EntityDamageSource(Strings.Translatable.WITHER_CHARGE_ATTACK, this.wither), 16f); diff --git a/src/main/java/insane96mcp/progressivebosses/module/wither/ai/WitherDoNothingGoal.java b/src/main/java/insane96mcp/progressivebosses/module/wither/ai/WitherDoNothingGoal.java index c508d213..232a7815 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/wither/ai/WitherDoNothingGoal.java +++ b/src/main/java/insane96mcp/progressivebosses/module/wither/ai/WitherDoNothingGoal.java @@ -1,16 +1,16 @@ package insane96mcp.progressivebosses.module.wither.ai; import insane96mcp.progressivebosses.base.Strings; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.ai.goal.Goal; -import net.minecraft.world.entity.boss.wither.WitherBoss; +import net.minecraft.entity.ai.goal.Goal; +import net.minecraft.entity.boss.WitherEntity; +import net.minecraft.nbt.CompoundNBT; import java.util.EnumSet; public class WitherDoNothingGoal extends Goal { - WitherBoss wither; + WitherEntity wither; - public WitherDoNothingGoal(WitherBoss wither) { + public WitherDoNothingGoal(WitherEntity wither) { this.wither = wither; this.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.JUMP, Goal.Flag.LOOK)); } @@ -20,7 +20,7 @@ public WitherDoNothingGoal(WitherBoss wither) { * method as well. */ public boolean canUse() { - CompoundTag tags = this.wither.getPersistentData(); + CompoundNBT tags = this.wither.getPersistentData(); return this.wither.getInvulnerableTicks() > 0 && !tags.contains(Strings.Tags.CHARGE_ATTACK); } } \ No newline at end of file diff --git a/src/main/java/insane96mcp/progressivebosses/module/wither/ai/WitherRangedAttackGoal.java b/src/main/java/insane96mcp/progressivebosses/module/wither/ai/WitherRangedAttackGoal.java index 93d1d25e..0e5ad768 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/wither/ai/WitherRangedAttackGoal.java +++ b/src/main/java/insane96mcp/progressivebosses/module/wither/ai/WitherRangedAttackGoal.java @@ -1,19 +1,18 @@ package insane96mcp.progressivebosses.module.wither.ai; import insane96mcp.insanelib.utils.RandomHelper; -import insane96mcp.progressivebosses.ProgressiveBosses; import insane96mcp.progressivebosses.base.Strings; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.ai.goal.Goal; -import net.minecraft.world.entity.boss.wither.WitherBoss; -import net.minecraft.world.entity.player.Player; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.ai.goal.Goal; +import net.minecraft.entity.boss.WitherEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.nbt.CompoundNBT; import java.util.EnumSet; public class WitherRangedAttackGoal extends Goal { - private final WitherBoss wither; + private final WitherEntity wither; private LivingEntity target; private int attackTime = -1; private int seeTime; @@ -23,7 +22,7 @@ public class WitherRangedAttackGoal extends Goal { //Increases the rate of attack of the middle head the closer the player is to the wither private final boolean increaseASOnNear; - public WitherRangedAttackGoal(WitherBoss wither, int attackInterval, float attackRadius, boolean increaseASOnNear) { + public WitherRangedAttackGoal(WitherEntity wither, int attackInterval, float attackRadius, boolean increaseASOnNear) { this.wither = wither; this.attackInterval = attackInterval; this.attackRadius = attackRadius; @@ -75,10 +74,10 @@ public void stop() { * Keep ticking a continuous task that has already been started */ public void tick() { - CompoundTag witherTags = wither.getPersistentData(); + CompoundNBT witherTags = wither.getPersistentData(); double distanceSq = this.wither.distanceToSqr(this.target.getX(), this.target.getY(), this.target.getZ()); - boolean canSee = this.wither.getSensing().hasLineOfSight(this.target); + boolean canSee = this.wither.getSensing().canSee(this.target); int unseenPlayerTicks = witherTags.getInt(Strings.Tags.UNSEEN_PLAYER_TICKS); if (canSee) { ++this.seeTime; @@ -87,7 +86,7 @@ public void tick() { } else { this.seeTime = 0; - if (this.target instanceof Player) + if (this.target instanceof PlayerEntity) witherTags.putInt(Strings.Tags.UNSEEN_PLAYER_TICKS, unseenPlayerTicks + 2); } @@ -103,7 +102,6 @@ else if (this.seeTime <= 0 && !this.wither.level.getBlockState(this.wither.block int barrageAttackTick = witherTags.getInt(Strings.Tags.BARRAGE_ATTACK); if (barrageAttackTick > 0) { - ProgressiveBosses.LOGGER.info("barrageAttackTick: " + barrageAttackTick); if (!canSee) return; witherTags.putInt(Strings.Tags.BARRAGE_ATTACK, barrageAttackTick - 1); diff --git a/src/main/java/insane96mcp/progressivebosses/module/wither/ai/minion/MinionNearestAttackableTargetGoal.java b/src/main/java/insane96mcp/progressivebosses/module/wither/ai/minion/MinionNearestAttackableTargetGoal.java index 15772c78..f1a1c920 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/wither/ai/minion/MinionNearestAttackableTargetGoal.java +++ b/src/main/java/insane96mcp/progressivebosses/module/wither/ai/minion/MinionNearestAttackableTargetGoal.java @@ -1,17 +1,17 @@ package insane96mcp.progressivebosses.module.wither.ai.minion; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; -import net.minecraft.world.entity.ai.targeting.TargetingConditions; -import net.minecraft.world.entity.player.Player; +import net.minecraft.entity.EntityPredicate; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.MobEntity; +import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal; +import net.minecraft.entity.player.PlayerEntity; import javax.annotation.Nullable; import java.util.function.Predicate; -public class MinionNearestAttackableTargetGoal extends NearestAttackableTargetGoal { - public MinionNearestAttackableTargetGoal(Mob goalOwner, Class targetClass, int targetChance, boolean checkSight, boolean nearbyOnly, @Nullable Predicate targetPredicate) { +public class MinionNearestAttackableTargetGoal extends NearestAttackableTargetGoal { + public MinionNearestAttackableTargetGoal(MobEntity goalOwner, Class targetClass, int targetChance, boolean checkSight, boolean nearbyOnly, @Nullable Predicate targetPredicate) { super(goalOwner, targetClass, targetChance, checkSight, nearbyOnly, targetPredicate); - this.targetConditions = TargetingConditions.DEFAULT.range(this.getFollowDistance()).ignoreLineOfSight().selector(targetPredicate); + this.targetConditions = (new EntityPredicate()).range(this.getFollowDistance()).allowUnseeable().selector(targetPredicate); } } diff --git a/src/main/java/insane96mcp/progressivebosses/module/wither/dispenser/WitherSkullDispenseBehavior.java b/src/main/java/insane96mcp/progressivebosses/module/wither/dispenser/WitherSkullDispenseBehavior.java index 258df16b..87a7c359 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/wither/dispenser/WitherSkullDispenseBehavior.java +++ b/src/main/java/insane96mcp/progressivebosses/module/wither/dispenser/WitherSkullDispenseBehavior.java @@ -1,31 +1,31 @@ package insane96mcp.progressivebosses.module.wither.dispenser; import insane96mcp.progressivebosses.module.wither.feature.MiscFeature; -import net.minecraft.core.BlockPos; -import net.minecraft.core.BlockSource; -import net.minecraft.core.Direction; -import net.minecraft.core.dispenser.OptionalDispenseItemBehavior; -import net.minecraft.world.item.ArmorItem; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.DispenserBlock; -import net.minecraft.world.level.block.SkullBlock; -import net.minecraft.world.level.block.WitherSkullBlock; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.entity.SkullBlockEntity; +import net.minecraft.block.Blocks; +import net.minecraft.block.DispenserBlock; +import net.minecraft.block.SkullBlock; +import net.minecraft.block.WitherSkeletonSkullBlock; +import net.minecraft.dispenser.IBlockSource; +import net.minecraft.dispenser.OptionalDispenseBehavior; +import net.minecraft.item.ArmorItem; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.SkullTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; -public class WitherSkullDispenseBehavior extends OptionalDispenseItemBehavior { +public class WitherSkullDispenseBehavior extends OptionalDispenseBehavior { - public ItemStack execute(BlockSource source, ItemStack stack) { - Level world = source.getLevel(); + public ItemStack execute(IBlockSource source, ItemStack stack) { + World world = source.getLevel(); Direction direction = source.getBlockState().getValue(DispenserBlock.FACING); BlockPos blockpos = source.getPos().relative(direction); - if (world.isEmptyBlock(blockpos) && WitherSkullBlock.canSpawnMob(world, blockpos, stack) && MiscFeature.canPlaceSkull(world, blockpos)) { + if (world.isEmptyBlock(blockpos) && WitherSkeletonSkullBlock.canSpawnMob(world, blockpos, stack) && MiscFeature.canPlaceSkull(world, blockpos)) { world.setBlock(blockpos, Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(SkullBlock.ROTATION, direction.getAxis() == Direction.Axis.Y ? 0 : direction.getOpposite().get2DDataValue() * 4), 3); - BlockEntity tileentity = world.getBlockEntity(blockpos); - if (tileentity instanceof SkullBlockEntity) { - WitherSkullBlock.checkSpawn(world, blockpos, (SkullBlockEntity)tileentity); + TileEntity tileentity = world.getBlockEntity(blockpos); + if (tileentity instanceof SkullTileEntity) { + WitherSkeletonSkullBlock.checkSpawn(world, blockpos, (SkullTileEntity)tileentity); } stack.shrink(1); diff --git a/src/main/java/insane96mcp/progressivebosses/module/wither/entity/WitherMinionEntity.java b/src/main/java/insane96mcp/progressivebosses/module/wither/entity/WitherMinionEntity.java index c39003d5..fc8a634b 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/wither/entity/WitherMinionEntity.java +++ b/src/main/java/insane96mcp/progressivebosses/module/wither/entity/WitherMinionEntity.java @@ -1,43 +1,39 @@ package insane96mcp.progressivebosses.module.wither.entity; import insane96mcp.progressivebosses.module.wither.ai.minion.MinionNearestAttackableTargetGoal; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.sounds.SoundEvent; -import net.minecraft.sounds.SoundEvents; +import net.minecraft.entity.*; +import net.minecraft.entity.ai.attributes.AttributeModifierMap; +import net.minecraft.entity.ai.attributes.Attributes; +import net.minecraft.entity.ai.goal.*; +import net.minecraft.entity.boss.WitherEntity; +import net.minecraft.entity.monster.AbstractSkeletonEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.projectile.AbstractArrowEntity; +import net.minecraft.entity.projectile.ArrowEntity; +import net.minecraft.inventory.EquipmentSlotType; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.potion.EffectInstance; +import net.minecraft.potion.Effects; +import net.minecraft.potion.PotionUtils; +import net.minecraft.util.DamageSource; +import net.minecraft.util.SoundEvent; +import net.minecraft.util.SoundEvents; import net.minecraft.world.DifficultyInstance; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.*; -import net.minecraft.world.entity.ai.attributes.AttributeSupplier; -import net.minecraft.world.entity.ai.attributes.Attributes; -import net.minecraft.world.entity.ai.goal.FloatGoal; -import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal; -import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal; -import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal; -import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; -import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; -import net.minecraft.world.entity.boss.wither.WitherBoss; -import net.minecraft.world.entity.monster.AbstractSkeleton; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.entity.projectile.AbstractArrow; -import net.minecraft.world.entity.projectile.Arrow; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.item.alchemy.PotionUtils; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.ServerLevelAccessor; +import net.minecraft.world.IServerWorld; +import net.minecraft.world.World; import javax.annotation.Nullable; import java.util.Arrays; import java.util.List; import java.util.function.Predicate; -public class WitherMinionEntity extends AbstractSkeleton { +public class WitherMinionEntity extends AbstractSkeletonEntity { - private static final Predicate NOT_UNDEAD = livingEntity -> livingEntity != null && livingEntity.getMobType() != MobType.UNDEAD && livingEntity.attackable(); + private static final Predicate NOT_UNDEAD = livingEntity -> livingEntity != null && livingEntity.getMobType() != CreatureAttribute.UNDEAD && livingEntity.attackable(); - public WitherMinionEntity(EntityType type, Level worldIn) { + public WitherMinionEntity(EntityType type, World worldIn) { super(type, worldIn); } @@ -48,14 +44,14 @@ protected SoundEvent getStepSound() { @Override protected void registerGoals() { - this.goalSelector.addGoal(1, new FloatGoal(this)); - this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0D)); - this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 8.0F)); - this.goalSelector.addGoal(6, new RandomLookAroundGoal(this)); + this.goalSelector.addGoal(1, new SwimGoal(this)); + this.goalSelector.addGoal(5, new WaterAvoidingRandomWalkingGoal(this, 1.0D)); + this.goalSelector.addGoal(6, new LookAtGoal(this, PlayerEntity.class, 8.0F)); + this.goalSelector.addGoal(6, new LookRandomlyGoal(this)); - this.targetSelector.addGoal(1, new HurtByTargetGoal(this, WitherBoss.class, WitherMinionEntity.class)); - this.targetSelector.addGoal(2, new MinionNearestAttackableTargetGoal(this, Player.class, 0, false, false, null)); - this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Mob.class, 0, false, false, NOT_UNDEAD)); + this.targetSelector.addGoal(1, new HurtByTargetGoal(this, WitherEntity.class, WitherMinionEntity.class)); + this.targetSelector.addGoal(2, new MinionNearestAttackableTargetGoal(this, PlayerEntity.class, 0, false, false, null)); + this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, MobEntity.class, 0, false, false, NOT_UNDEAD)); } protected SoundEvent getAmbientSound() { @@ -70,14 +66,14 @@ protected SoundEvent getDeathSound() { return SoundEvents.WITHER_SKELETON_DEATH; } - protected float getStandingEyeHeight(Pose poseIn, EntityDimensions sizeIn) { + protected float getStandingEyeHeight(Pose poseIn, EntitySize sizeIn) { return 1.3F; } /** * Gets the pitch of living sounds in living entities. */ - public float getVoicePitch() { + protected float getVoicePitch() { return (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.33F; } @@ -85,12 +81,12 @@ public float getVoicePitch() { * Gives armor or weapon for entity based on given DifficultyInstance */ protected void populateDefaultEquipmentSlots(DifficultyInstance difficulty) { - this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.BOW)); + this.setItemSlot(EquipmentSlotType.MAINHAND, new ItemStack(Items.BOW)); } @Nullable - public SpawnGroupData finalizeSpawn(ServerLevelAccessor worldIn, DifficultyInstance difficultyIn, MobSpawnType reason, @Nullable SpawnGroupData spawnDataIn, @Nullable CompoundTag dataTag) { - SpawnGroupData ilivingentitydata = super.finalizeSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); + public ILivingEntityData finalizeSpawn(IServerWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, @Nullable ILivingEntityData spawnDataIn, @Nullable CompoundNBT dataTag) { + ILivingEntityData ilivingentitydata = super.finalizeSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(4.0D); this.reassessWeaponGoal(); return ilivingentitydata; @@ -101,7 +97,7 @@ public boolean doHurtTarget(Entity entityIn) { return false; } else { if (entityIn instanceof LivingEntity) { - ((LivingEntity)entityIn).addEffect(new MobEffectInstance(MobEffects.WITHER, 200)); + ((LivingEntity)entityIn).addEffect(new EffectInstance(Effects.WITHER, 200)); } return true; @@ -114,21 +110,21 @@ public boolean hurt(DamageSource source, float amount) { return !this.isInvulnerableTo(source) && super.hurt(source, amount); } - public boolean canBeAffected(MobEffectInstance potioneffectIn) { - return potioneffectIn.getEffect() != MobEffects.WITHER && super.canBeAffected(potioneffectIn); + public boolean canBeAffected(EffectInstance potioneffectIn) { + return potioneffectIn.getEffect() != Effects.WITHER && super.canBeAffected(potioneffectIn); } - private static final List ARROW_EFFECTS = Arrays.asList(new MobEffectInstance(MobEffects.WITHER, 200)); + private static final List ARROW_EFFECTS = Arrays.asList(new EffectInstance(Effects.WITHER, 200)); /** * Fires an arrow */ - protected AbstractArrow getArrow(ItemStack arrowStack, float distanceFactor) { - AbstractArrow abstractarrowentity = super.getArrow(arrowStack, distanceFactor); - if (abstractarrowentity instanceof Arrow) { + protected AbstractArrowEntity getArrow(ItemStack arrowStack, float distanceFactor) { + AbstractArrowEntity abstractarrowentity = super.getArrow(arrowStack, distanceFactor); + if (abstractarrowentity instanceof ArrowEntity) { ItemStack witherArrow = new ItemStack(Items.TIPPED_ARROW, 1); PotionUtils.setCustomEffects(witherArrow, ARROW_EFFECTS); - ((Arrow)abstractarrowentity).setEffectsFromItem(witherArrow); + ((ArrowEntity)abstractarrowentity).setEffectsFromItem(witherArrow); } return abstractarrowentity; } @@ -137,7 +133,7 @@ protected AbstractArrow getArrow(ItemStack arrowStack, float distanceFactor) { protected void createWitherRose(@Nullable LivingEntity entitySource) { } - public static AttributeSupplier.Builder prepareAttributes() { + public static AttributeModifierMap.MutableAttribute prepareAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.ATTACK_DAMAGE, 3.0d) .add(Attributes.MAX_HEALTH, 20.0d) diff --git a/src/main/java/insane96mcp/progressivebosses/module/wither/entity/WitherMinionModel.java b/src/main/java/insane96mcp/progressivebosses/module/wither/entity/WitherMinionModel.java index 8ed8bd1e..616d0c07 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/wither/entity/WitherMinionModel.java +++ b/src/main/java/insane96mcp/progressivebosses/module/wither/entity/WitherMinionModel.java @@ -1,52 +1,56 @@ package insane96mcp.progressivebosses.module.wither.entity; -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.model.AnimationUtils; -import net.minecraft.client.model.HumanoidModel; -import net.minecraft.client.model.geom.ModelPart; -import net.minecraft.util.Mth; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.entity.HumanoidArm; -import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.monster.RangedAttackMob; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; +import com.mojang.blaze3d.matrix.MatrixStack; +import net.minecraft.client.renderer.entity.model.BipedModel; +import net.minecraft.client.renderer.model.ModelHelper; +import net.minecraft.client.renderer.model.ModelRenderer; +import net.minecraft.entity.IRangedAttackMob; +import net.minecraft.entity.MobEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.util.Hand; +import net.minecraft.util.HandSide; +import net.minecraft.util.math.MathHelper; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) -public class WitherMinionModel extends HumanoidModel { +public class WitherMinionModel extends BipedModel { - public WitherMinionModel(ModelPart part) { - super(part); - //if (!part.visible) { - // this.rightArm = new ModelPart(this, 40, 16); - // this.rightArm.setPos(-1.0F, -2.0F, -1.0F, 2.0F, 12.0F, 2.0F, modelSize); - // this.rightArm.setPos(-5.0F, 2.0F, 0.0F); - // this.leftArm = new ModelPart(this, 40, 16); - // this.leftArm.mirror = true; - // this.leftArm.addBox(-1.0F, -2.0F, -1.0F, 2.0F, 12.0F, 2.0F, modelSize); - // this.leftArm.setPos(5.0F, 2.0F, 0.0F); - // this.rightLeg = new ModelPart(this, 0, 16); - // this.rightLeg.addBox(-1.0F, 0.0F, -1.0F, 2.0F, 12.0F, 2.0F, modelSize); - // this.rightLeg.setPos(-2.0F, 12.0F, 0.0F); - // this.leftLeg = new ModelPart(this, 0, 16); - // this.leftLeg.mirror = true; - // this.leftLeg.addBox(-1.0F, 0.0F, -1.0F, 2.0F, 12.0F, 2.0F, modelSize); - // this.leftLeg.setPos(2.0F, 12.0F, 0.0F); - //} + public WitherMinionModel() { + this(0.0F, false); + } + + public WitherMinionModel(float modelSize, boolean p_i46303_2_) { + super(modelSize); + if (!p_i46303_2_) { + this.rightArm = new ModelRenderer(this, 40, 16); + this.rightArm.addBox(-1.0F, -2.0F, -1.0F, 2.0F, 12.0F, 2.0F, modelSize); + this.rightArm.setPos(-5.0F, 2.0F, 0.0F); + this.leftArm = new ModelRenderer(this, 40, 16); + this.leftArm.mirror = true; + this.leftArm.addBox(-1.0F, -2.0F, -1.0F, 2.0F, 12.0F, 2.0F, modelSize); + this.leftArm.setPos(5.0F, 2.0F, 0.0F); + this.rightLeg = new ModelRenderer(this, 0, 16); + this.rightLeg.addBox(-1.0F, 0.0F, -1.0F, 2.0F, 12.0F, 2.0F, modelSize); + this.rightLeg.setPos(-2.0F, 12.0F, 0.0F); + this.leftLeg = new ModelRenderer(this, 0, 16); + this.leftLeg.mirror = true; + this.leftLeg.addBox(-1.0F, 0.0F, -1.0F, 2.0F, 12.0F, 2.0F, modelSize); + this.leftLeg.setPos(2.0F, 12.0F, 0.0F); + } } public void prepareMobModel(T entityIn, float limbSwing, float limbSwingAmount, float partialTick) { - this.rightArmPose = HumanoidModel.ArmPose.EMPTY; - this.leftArmPose = HumanoidModel.ArmPose.EMPTY; - ItemStack itemstack = entityIn.getItemInHand(InteractionHand.MAIN_HAND); + this.rightArmPose = BipedModel.ArmPose.EMPTY; + this.leftArmPose = BipedModel.ArmPose.EMPTY; + ItemStack itemstack = entityIn.getItemInHand(Hand.MAIN_HAND); if (itemstack.getItem() == Items.BOW && entityIn.isAggressive()) { - if (entityIn.getMainArm() == HumanoidArm.RIGHT) { - this.rightArmPose = HumanoidModel.ArmPose.BOW_AND_ARROW; + if (entityIn.getMainArm() == HandSide.RIGHT) { + this.rightArmPose = BipedModel.ArmPose.BOW_AND_ARROW; } else { - this.leftArmPose = HumanoidModel.ArmPose.BOW_AND_ARROW; + this.leftArmPose = BipedModel.ArmPose.BOW_AND_ARROW; } } @@ -60,8 +64,8 @@ public void setupAnim(T entityIn, float limbSwing, float limbSwingAmount, float super.setupAnim(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch); ItemStack itemstack = entityIn.getMainHandItem(); if (entityIn.isAggressive() && (itemstack.isEmpty() || itemstack.getItem() != Items.BOW)) { - float f = Mth.sin(this.attackTime * (float)Math.PI); - float f1 = Mth.sin((1.0F - (1.0F - this.attackTime) * (1.0F - this.attackTime)) * (float)Math.PI); + float f = MathHelper.sin(this.attackTime * (float)Math.PI); + float f1 = MathHelper.sin((1.0F - (1.0F - this.attackTime) * (1.0F - this.attackTime)) * (float)Math.PI); this.rightArm.zRot = 0.0F; this.leftArm.zRot = 0.0F; this.rightArm.yRot = -(0.1F - f * 0.6F); @@ -70,14 +74,14 @@ public void setupAnim(T entityIn, float limbSwing, float limbSwingAmount, float this.leftArm.xRot = (-(float)Math.PI / 2F); this.rightArm.xRot -= f * 1.2F - f1 * 0.4F; this.leftArm.xRot -= f * 1.2F - f1 * 0.4F; - AnimationUtils.bobArms(this.rightArm, this.leftArm, ageInTicks); + ModelHelper.bobArms(this.rightArm, this.leftArm, ageInTicks); } } - public void translateToHand(HumanoidArm sideIn, PoseStack matrixStackIn) { - float f = sideIn == HumanoidArm.RIGHT ? 1.0F : -1.0F; - ModelPart modelrenderer = this.getArm(sideIn); + public void translateToHand(HandSide sideIn, MatrixStack matrixStackIn) { + float f = sideIn == HandSide.RIGHT ? 1.0F : -1.0F; + ModelRenderer modelrenderer = this.getArm(sideIn); modelrenderer.x += f; modelrenderer.translateAndRotate(matrixStackIn); modelrenderer.x -= f; diff --git a/src/main/java/insane96mcp/progressivebosses/module/wither/entity/WitherMinionRenderer.java b/src/main/java/insane96mcp/progressivebosses/module/wither/entity/WitherMinionRenderer.java index 85c27410..6d14b75e 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/wither/entity/WitherMinionRenderer.java +++ b/src/main/java/insane96mcp/progressivebosses/module/wither/entity/WitherMinionRenderer.java @@ -1,27 +1,21 @@ package insane96mcp.progressivebosses.module.wither.entity; -import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.matrix.MatrixStack; import insane96mcp.progressivebosses.ProgressiveBosses; -import net.minecraft.client.model.geom.ModelLayerLocation; -import net.minecraft.client.model.geom.ModelLayers; -import net.minecraft.client.renderer.entity.EntityRendererProvider; -import net.minecraft.client.renderer.entity.HumanoidMobRenderer; -import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.client.renderer.entity.BipedRenderer; +import net.minecraft.client.renderer.entity.EntityRendererManager; +import net.minecraft.client.renderer.entity.layers.BipedArmorLayer; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) -public class WitherMinionRenderer extends HumanoidMobRenderer> { +public class WitherMinionRenderer extends BipedRenderer> { private static final ResourceLocation MINION_TEXTURES = new ResourceLocation(ProgressiveBosses.MOD_ID, "textures/entity/wither_minion.png"); - public WitherMinionRenderer(EntityRendererProvider.Context context) { - this(context, ModelLayers.SKELETON, ModelLayers.SKELETON_INNER_ARMOR, ModelLayers.SKELETON_OUTER_ARMOR); - } - - public WitherMinionRenderer(EntityRendererProvider.Context p_174382_, ModelLayerLocation p_174383_, ModelLayerLocation p_174384_, ModelLayerLocation p_174385_) { - super(p_174382_, new WitherMinionModel<>(p_174382_.bakeLayer(p_174383_)), 0.5F); - this.addLayer(new HumanoidArmorLayer<>(this, new WitherMinionModel(p_174382_.bakeLayer(p_174384_)), new WitherMinionModel(p_174382_.bakeLayer(p_174385_)))); + public WitherMinionRenderer(EntityRendererManager renderManagerIn) { + super(renderManagerIn, new WitherMinionModel<>(), 0.5F); + this.addLayer(new BipedArmorLayer<>(this, new WitherMinionModel(0.5F, true), new WitherMinionModel(1.0F, true))); } /** @@ -31,7 +25,7 @@ public ResourceLocation getTextureLocation(WitherMinionEntity entity) { return MINION_TEXTURES; } - protected void scale(WitherMinionEntity entitylivingbaseIn, PoseStack matrixStackIn, float partialTickTime) { + protected void scale(WitherMinionEntity entitylivingbaseIn, MatrixStack matrixStackIn, float partialTickTime) { matrixStackIn.scale(0.75f, 0.75f, 0.75f); } } diff --git a/src/main/java/insane96mcp/progressivebosses/module/wither/feature/AttackFeature.java b/src/main/java/insane96mcp/progressivebosses/module/wither/feature/AttackFeature.java index 8fe0d93b..a1bbe475 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/wither/feature/AttackFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/wither/feature/AttackFeature.java @@ -8,14 +8,14 @@ import insane96mcp.progressivebosses.module.wither.ai.WitherDoNothingGoal; import insane96mcp.progressivebosses.module.wither.ai.WitherRangedAttackGoal; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.ai.goal.Goal; -import net.minecraft.world.entity.ai.goal.RangedAttackGoal; -import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; -import net.minecraft.world.entity.boss.wither.WitherBoss; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.entity.projectile.WitherSkull; +import net.minecraft.entity.Entity; +import net.minecraft.entity.ai.goal.Goal; +import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal; +import net.minecraft.entity.ai.goal.RangedAttackGoal; +import net.minecraft.entity.boss.WitherEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.projectile.WitherSkullEntity; +import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingEvent; @@ -127,11 +127,11 @@ public void onSpawn(EntityJoinWorldEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof WitherBoss)) + if (!(event.getEntity() instanceof WitherEntity)) return; - WitherBoss wither = (WitherBoss) event.getEntity(); - CompoundTag compoundNBT = wither.getPersistentData(); + WitherEntity wither = (WitherEntity) event.getEntity(); + CompoundNBT compoundNBT = wither.getPersistentData(); if ((!compoundNBT.contains(Strings.Tags.DIFFICULTY) || compoundNBT.getFloat(Strings.Tags.DIFFICULTY) == 0f) && !this.applyToVanillaWither) return; @@ -139,13 +139,13 @@ public void onSpawn(EntityJoinWorldEvent event) { } private void witherSkullSpeed(Entity entity) { - if (!(entity instanceof WitherSkull)) + if (!(entity instanceof WitherSkullEntity)) return; if (!this.isEnabled() || this.skullVelocityMultiplier == 0d) return; - WitherSkull witherSkullEntity = (WitherSkull) entity; + WitherSkullEntity witherSkullEntity = (WitherSkullEntity) entity; if (Math.abs(witherSkullEntity.xPower) > 10 || Math.abs(witherSkullEntity.yPower) > 10 || Math.abs(witherSkullEntity.zPower) > 10) { entity.kill(); @@ -171,11 +171,11 @@ public void onUpdate(LivingEvent.LivingUpdateEvent event) { if (!event.getEntity().isAlive()) return; - if (!(event.getEntity() instanceof WitherBoss)) + if (!(event.getEntity() instanceof WitherEntity)) return; - WitherBoss wither = (WitherBoss) event.getEntity(); - CompoundTag witherTags = wither.getPersistentData(); + WitherEntity wither = (WitherEntity) event.getEntity(); + CompoundNBT witherTags = wither.getPersistentData(); // When in charge attack remove the vanilla health regeneration when he's invulnerable and add 1% health regeneration of the missing health per second if (witherTags.contains(Strings.Tags.CHARGE_ATTACK) && wither.tickCount % 10 == 0){ float missingHealth = wither.getMaxHealth() - wither.getHealth(); @@ -200,15 +200,15 @@ public void onDamageDealt(LivingHurtEvent event) { return; - WitherBoss wither; - if (event.getSource().getDirectEntity() instanceof WitherBoss) - wither = (WitherBoss) event.getSource().getDirectEntity(); - else if (event.getSource().getEntity() instanceof WitherBoss) - wither = (WitherBoss) event.getSource().getEntity(); + WitherEntity wither; + if (event.getSource().getDirectEntity() instanceof WitherEntity) + wither = (WitherEntity) event.getSource().getDirectEntity(); + else if (event.getSource().getEntity() instanceof WitherEntity) + wither = (WitherEntity) event.getSource().getEntity(); else return; - CompoundTag compoundNBT = wither.getPersistentData(); + CompoundNBT compoundNBT = wither.getPersistentData(); float difficulty = compoundNBT.getFloat(Strings.Tags.DIFFICULTY); event.setAmount(event.getAmount() * (float)(1d + (this.increasedDamage * difficulty))); @@ -226,20 +226,20 @@ public void onDamaged(LivingHurtEvent event) { if (!event.getEntity().isAlive()) return; - if (!(event.getEntityLiving() instanceof WitherBoss)) + if (!(event.getEntityLiving() instanceof WitherEntity)) return; - WitherBoss wither = (WitherBoss) event.getEntityLiving(); + WitherEntity wither = (WitherEntity) event.getEntityLiving(); doBarrage(wither, event.getAmount()); doCharge(wither, event.getAmount()); } - private void doBarrage(WitherBoss wither, float damageTaken) { + private void doBarrage(WitherEntity wither, float damageTaken) { if (this.maxBarrageChancePerDiff == 0d/* || this.maxBarrageAttackChance == 0d*/) return; - CompoundTag witherTags = wither.getPersistentData(); + CompoundNBT witherTags = wither.getPersistentData(); float difficulty = witherTags.getFloat(Strings.Tags.DIFFICULTY); double missingHealthPerc = 1d - wither.getHealth() / wither.getMaxHealth(); @@ -253,11 +253,11 @@ private void doBarrage(WitherBoss wither, float damageTaken) { } } - private void doCharge(WitherBoss wither, float damageTaken) { + private void doCharge(WitherEntity wither, float damageTaken) { if (this.maxChargeAttackChance == 0d) return; - CompoundTag witherTags = wither.getPersistentData(); + CompoundNBT witherTags = wither.getPersistentData(); double missingHealthPerc = 1d - wither.getHealth() / wither.getMaxHealth(); double chance = this.maxChargeAttackChance * missingHealthPerc; @@ -269,12 +269,12 @@ private void doCharge(WitherBoss wither, float damageTaken) { } } - public void setWitherAI(WitherBoss wither) { + public void setWitherAI(WitherEntity wither) { ArrayList toRemove = new ArrayList<>(); wither.goalSelector.availableGoals.forEach(goal -> { if (goal.getGoal() instanceof RangedAttackGoal) toRemove.add(goal.getGoal()); - if (goal.getGoal() instanceof WitherBoss.WitherDoNothingGoal) + if (goal.getGoal() instanceof WitherEntity.DoNothingGoal) toRemove.add(goal.getGoal()); }); @@ -285,7 +285,7 @@ public void setWitherAI(WitherBoss wither) { wither.goalSelector.addGoal(2, new WitherChargeAttackGoal(wither)); //Fixes https://bugs.mojang.com/browse/MC-29274 - wither.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(wither, Player.class, 0, false, false, null)); + wither.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(wither, PlayerEntity.class, 0, false, false, null)); } public static class Consts { diff --git a/src/main/java/insane96mcp/progressivebosses/module/wither/feature/DifficultyFeature.java b/src/main/java/insane96mcp/progressivebosses/module/wither/feature/DifficultyFeature.java index 8e19e414..5784b6fc 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/wither/feature/DifficultyFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/wither/feature/DifficultyFeature.java @@ -5,17 +5,17 @@ import insane96mcp.insanelib.base.Module; import insane96mcp.insanelib.utils.LogHelper; import insane96mcp.progressivebosses.base.Strings; -import insane96mcp.progressivebosses.capability.Difficulty; +import insane96mcp.progressivebosses.capability.DifficultyCapability; import insane96mcp.progressivebosses.capability.IDifficulty; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.Util; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.boss.wither.WitherBoss; -import net.minecraft.world.phys.AABB; +import net.minecraft.entity.boss.WitherEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Util; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.eventbus.api.EventPriority; @@ -101,35 +101,35 @@ public void onSpawn(EntityJoinWorldEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof WitherBoss)) + if (!(event.getEntity() instanceof WitherEntity)) return; if (this.entityBlacklist.contains(event.getEntity().getType().getRegistryName().toString())) return; - WitherBoss wither = (WitherBoss) event.getEntity(); + WitherEntity wither = (WitherEntity) event.getEntity(); - CompoundTag witherTags = wither.getPersistentData(); + CompoundNBT witherTags = wither.getPersistentData(); if (witherTags.contains(Strings.Tags.DIFFICULTY)) return; BlockPos pos1 = wither.blockPosition().offset(-this.spawnRadiusPlayerCheck, -this.spawnRadiusPlayerCheck, -this.spawnRadiusPlayerCheck); BlockPos pos2 = wither.blockPosition().offset(this.spawnRadiusPlayerCheck, this.spawnRadiusPlayerCheck, this.spawnRadiusPlayerCheck); - AABB bb = new AABB(pos1, pos2); + AxisAlignedBB bb = new AxisAlignedBB(pos1, pos2); - List players = event.getWorld().getEntitiesOfClass(ServerPlayer.class, bb); + List players = event.getWorld().getLoadedEntitiesOfClass(ServerPlayerEntity.class, bb); if (players.size() == 0) return; float witherDifficulty = 0; - for (ServerPlayer player : players) { - IDifficulty difficulty = player.getCapability(Difficulty.INSTANCE).orElse(null); + for (ServerPlayerEntity player : players) { + IDifficulty difficulty = player.getCapability(DifficultyCapability.DIFFICULTY).orElse(null); witherDifficulty += difficulty.getSpawnedWithers(); if (difficulty.getSpawnedWithers() >= this.maxDifficulty) continue; if (difficulty.getKilledDragons() <= this.startingDifficulty && this.showFirstSummonedWitherMessage) - player.sendMessage(new TranslatableComponent(Strings.Translatable.FIRST_WITHER_SUMMON), Util.NIL_UUID); + player.sendMessage(new TranslationTextComponent(Strings.Translatable.FIRST_WITHER_SUMMON), Util.NIL_UUID); difficulty.addSpawnedWithers(1); } @@ -150,12 +150,12 @@ public void setPlayerData(EntityJoinWorldEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof ServerPlayer)) + if (!(event.getEntity() instanceof ServerPlayerEntity)) return; - ServerPlayer player = (ServerPlayer) event.getEntity(); + ServerPlayerEntity player = (ServerPlayerEntity) event.getEntity(); - IDifficulty difficulty = player.getCapability(Difficulty.INSTANCE).orElse(null); + IDifficulty difficulty = player.getCapability(DifficultyCapability.DIFFICULTY).orElse(null); if (difficulty.getSpawnedWithers() < this.startingDifficulty) { difficulty.setSpawnedWithers(this.startingDifficulty); diff --git a/src/main/java/insane96mcp/progressivebosses/module/wither/feature/HealthFeature.java b/src/main/java/insane96mcp/progressivebosses/module/wither/feature/HealthFeature.java index 7ebc08a9..b19922d2 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/wither/feature/HealthFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/wither/feature/HealthFeature.java @@ -6,10 +6,10 @@ import insane96mcp.insanelib.utils.MCUtils; import insane96mcp.progressivebosses.base.Strings; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.ai.attributes.AttributeModifier; -import net.minecraft.world.entity.ai.attributes.Attributes; -import net.minecraft.world.entity.boss.wither.WitherBoss; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.Attributes; +import net.minecraft.entity.boss.WitherEntity; +import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingEvent; @@ -60,15 +60,15 @@ public void onSpawn(EntityJoinWorldEvent event) { if (this.bonusPerDifficulty == 0d) return; - if (!(event.getEntity() instanceof WitherBoss)) + if (!(event.getEntity() instanceof WitherEntity)) return; - WitherBoss wither = (WitherBoss) event.getEntity(); + WitherEntity wither = (WitherEntity) event.getEntity(); if (wither.getAttribute(Attributes.MAX_HEALTH).getModifier(Strings.AttributeModifiers.BONUS_HEALTH_UUID) != null) return; - CompoundTag witherTags = wither.getPersistentData(); + CompoundNBT witherTags = wither.getPersistentData(); double difficulty = witherTags.getFloat(Strings.Tags.DIFFICULTY); MCUtils.applyModifier(wither, Attributes.MAX_HEALTH, Strings.AttributeModifiers.BONUS_HEALTH_UUID, Strings.AttributeModifiers.BONUS_HEALTH, difficulty * this.bonusPerDifficulty, AttributeModifier.Operation.ADDITION); @@ -86,20 +86,20 @@ public void onUpdate(LivingEvent.LivingUpdateEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof WitherBoss)) + if (!(event.getEntity() instanceof WitherEntity)) return; if (this.bonusRegenPerDifficulty == 0d || this.maxBonusRegen == 0d) return; - WitherBoss wither = (WitherBoss) event.getEntity(); + WitherEntity wither = (WitherEntity) event.getEntity(); fixInvulBossBar(wither); if (wither.getInvulnerableTicks() > 0) return; - CompoundTag tags = wither.getPersistentData(); + CompoundNBT tags = wither.getPersistentData(); float difficulty = tags.getFloat(Strings.Tags.DIFFICULTY); @@ -117,10 +117,10 @@ public void onUpdate(LivingEvent.LivingUpdateEvent event) { } - private void fixInvulBossBar(WitherBoss wither) { + private void fixInvulBossBar(WitherEntity wither) { if (wither.getInvulnerableTicks() == 0) return; - wither.bossEvent.setProgress(wither.getHealth() / wither.getMaxHealth()); + wither.bossEvent.setPercent(wither.getHealth() / wither.getMaxHealth()); } } diff --git a/src/main/java/insane96mcp/progressivebosses/module/wither/feature/MinionFeature.java b/src/main/java/insane96mcp/progressivebosses/module/wither/feature/MinionFeature.java index 11921aa6..a4097697 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/wither/feature/MinionFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/wither/feature/MinionFeature.java @@ -9,27 +9,27 @@ import insane96mcp.progressivebosses.module.wither.entity.WitherMinionEntity; import insane96mcp.progressivebosses.setup.Config; import insane96mcp.progressivebosses.setup.PBEntities; -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.Tag; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.entity.ai.attributes.AttributeModifier; -import net.minecraft.world.entity.ai.attributes.Attributes; -import net.minecraft.world.entity.boss.wither.WitherBoss; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.item.enchantment.Enchantments; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.Attributes; +import net.minecraft.entity.boss.WitherEntity; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.inventory.EquipmentSlotType; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.potion.EffectInstance; +import net.minecraft.potion.Effects; +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.world.server.ServerWorld; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeMod; +import net.minecraftforge.common.util.Constants; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingDamageEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; @@ -144,7 +144,6 @@ public void loadConfig() { this.minCooldown = this.maxCooldown; this.cooldownMultiplierBelowHalfHealth = this.cooldownMultiplierBelowHalfHealthConfig.get(); this.bonusSpeedPerDifficulty = this.bonusSpeedPerDifficultyConfig.get(); - this.magicDamageMultiplier = this.magicDamageMultiplierConfig.get(); this.killMinionOnWitherDeath = this.killMinionOnWitherDeathConfig.get(); //Equipment this.hasSword = this.hasSwordConfig.get(); @@ -162,12 +161,12 @@ public void onWitherSpawn(EntityJoinWorldEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof WitherBoss)) + if (!(event.getEntity() instanceof WitherEntity)) return; - WitherBoss wither = (WitherBoss) event.getEntity(); + WitherEntity wither = (WitherEntity) event.getEntity(); - CompoundTag witherTags = wither.getPersistentData(); + CompoundNBT witherTags = wither.getPersistentData(); int cooldown = (int) (RandomHelper.getInt(wither.level.random, this.minCooldown, this.maxCooldown) * this.cooldownMultiplierBelowHalfHealth); witherTags.putInt(Strings.Tags.WITHER_MINION_COOLDOWN, cooldown); @@ -181,13 +180,13 @@ public void update(LivingEvent.LivingUpdateEvent event) { if (!this.isEnabled()) return; - if (!(event.getEntity() instanceof WitherBoss)) + if (!(event.getEntity() instanceof WitherEntity)) return; - Level world = event.getEntity().level; + World world = event.getEntity().level; - WitherBoss wither = (WitherBoss) event.getEntity(); - CompoundTag witherTags = wither.getPersistentData(); + WitherEntity wither = (WitherEntity) event.getEntity(); + CompoundNBT witherTags = wither.getPersistentData(); float difficulty = witherTags.getFloat(Strings.Tags.DIFFICULTY); if (difficulty < this.minionAtDifficulty) @@ -209,13 +208,13 @@ public void update(LivingEvent.LivingUpdateEvent event) { int radius = 32; BlockPos pos1 = wither.blockPosition().offset(-radius, -radius, -radius); BlockPos pos2 = wither.blockPosition().offset(radius, radius, radius); - AABB bb = new AABB(pos1, pos2); - List players = world.getEntitiesOfClass(ServerPlayer.class, bb); + AxisAlignedBB bb = new AxisAlignedBB(pos1, pos2); + List players = world.getLoadedEntitiesOfClass(ServerPlayerEntity.class, bb); if (players.isEmpty()) return; - List minionsInAABB = world.getEntitiesOfClass(WitherMinionEntity.class, wither.getBoundingBox().inflate(16)); + List minionsInAABB = world.getLoadedEntitiesOfClass(WitherMinionEntity.class, wither.getBoundingBox().inflate(16)); int minionsCountInAABB = minionsInAABB.size(); if (minionsCountInAABB >= this.maxAround) @@ -243,16 +242,16 @@ public void update(LivingEvent.LivingUpdateEvent event) { if (y != -1) break; } - if (y <= wither.level.getMinBuildHeight()) + if (y <= 0) continue; - WitherMinionEntity witherMinion = summonMinion(world, new Vec3(x + 0.5, y + 0.5, z + 0.5), difficulty, wither.isPowered()); + WitherMinionEntity witherMinion = summonMinion(world, new Vector3d(x + 0.5, y + 0.5, z + 0.5), difficulty, wither.isPowered()); //No need since EntityJoinWorldEvent is triggered //setMinionAI(witherMinion); - ListTag minionsList = witherTags.getList(Strings.Tags.MINIONS, Tag.TAG_COMPOUND); - CompoundTag uuid = new CompoundTag(); + ListNBT minionsList = witherTags.getList(Strings.Tags.MINIONS, Constants.NBT.TAG_COMPOUND); + CompoundNBT uuid = new CompoundNBT(); uuid.putUUID("uuid", witherMinion.getUUID()); minionsList.add(uuid); witherTags.put(Strings.Tags.MINIONS, minionsList); @@ -295,26 +294,26 @@ public void onDeath(LivingDeathEvent event) { if (!this.killMinionOnWitherDeath) return; - if (!(event.getEntity() instanceof WitherBoss)) + if (!(event.getEntity() instanceof WitherEntity)) return; - WitherBoss wither = (WitherBoss) event.getEntity(); - ServerLevel world = (ServerLevel) wither.level; + WitherEntity wither = (WitherEntity) event.getEntity(); + ServerWorld world = (ServerWorld) wither.level; - CompoundTag tags = wither.getPersistentData(); - ListTag minionsList = tags.getList(Strings.Tags.MINIONS, Tag.TAG_COMPOUND); + CompoundNBT tags = wither.getPersistentData(); + ListNBT minionsList = tags.getList(Strings.Tags.MINIONS, Constants.NBT.TAG_COMPOUND); for (int i = 0; i < minionsList.size(); i++) { UUID uuid = minionsList.getCompound(i).getUUID("uuid"); WitherMinionEntity witherMinionEntity = (WitherMinionEntity) world.getEntity(uuid); if (witherMinionEntity == null) continue; - witherMinionEntity.addEffect(new MobEffectInstance(MobEffects.HEAL, 10000, 0, false, false)); + witherMinionEntity.addEffect(new EffectInstance(Effects.HEAL, 10000, 0, false, false)); } } private void setEquipment(WitherMinionEntity witherMinionEntity, float difficulty, boolean isCharged) { - witherMinionEntity.setDropChance(EquipmentSlot.MAINHAND, Float.MIN_VALUE); + witherMinionEntity.setDropChance(EquipmentSlotType.MAINHAND, Float.MIN_VALUE); int powerSharpnessLevel = (int) (this.powerSharpnessChance * difficulty); if (RandomHelper.getDouble(witherMinionEntity.level.getRandom(), 0d, 1d) < (this.powerSharpnessChance * difficulty) - powerSharpnessLevel) @@ -330,7 +329,7 @@ private void setEquipment(WitherMinionEntity witherMinionEntity, float difficult if (punchKnockbackLevel > 0) sword.enchant(Enchantments.KNOCKBACK, punchKnockbackLevel); if (this.hasSword) - witherMinionEntity.setItemSlot(EquipmentSlot.MAINHAND, sword); + witherMinionEntity.setItemSlot(EquipmentSlotType.MAINHAND, sword); ItemStack bow = new ItemStack(Items.BOW); if (powerSharpnessLevel > 0) @@ -339,12 +338,12 @@ private void setEquipment(WitherMinionEntity witherMinionEntity, float difficult bow.enchant(Enchantments.POWER_ARROWS, punchKnockbackLevel); if (isCharged) { if (RandomHelper.getDouble(witherMinionEntity.level.getRandom(), 0d, 1d) < this.halfHealthBowChance) { - witherMinionEntity.setItemSlot(EquipmentSlot.MAINHAND, bow); + witherMinionEntity.setItemSlot(EquipmentSlotType.MAINHAND, bow); } } else { if (RandomHelper.getDouble(witherMinionEntity.level.getRandom(), 0d, 1d) < this.preHalfHealthBowChance) { - witherMinionEntity.setItemSlot(EquipmentSlot.MAINHAND, bow); + witherMinionEntity.setItemSlot(EquipmentSlotType.MAINHAND, bow); } } } @@ -356,7 +355,7 @@ private void setEquipment(WitherMinionEntity witherMinionEntity, float difficult * @param minRelativeY * @return */ - private static int getYSpawn(EntityType entityType, BlockPos pos, Level world, int minRelativeY) { + private static int getYSpawn(EntityType entityType, BlockPos pos, World world, int minRelativeY) { int height = (int) Math.ceil(entityType.getHeight()); int fittingYPos = -1; for (int y = pos.getY(); y > pos.getY() - minRelativeY; y--) { @@ -378,9 +377,9 @@ private static int getYSpawn(EntityType entityType, BlockPos pos, Level world, i return fittingYPos; } - public WitherMinionEntity summonMinion(Level world, Vec3 pos, float difficulty, boolean isCharged) { + public WitherMinionEntity summonMinion(World world, Vector3d pos, float difficulty, boolean isCharged) { WitherMinionEntity witherMinion = new WitherMinionEntity(PBEntities.WITHER_MINION.get(), world); - CompoundTag minionTags = witherMinion.getPersistentData(); + CompoundNBT minionTags = witherMinion.getPersistentData(); minionTags.putBoolean("mobspropertiesrandomness:processed", true); //TODO Scaling health diff --git a/src/main/java/insane96mcp/progressivebosses/module/wither/feature/MiscFeature.java b/src/main/java/insane96mcp/progressivebosses/module/wither/feature/MiscFeature.java index d9b42bd5..3edd4777 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/wither/feature/MiscFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/wither/feature/MiscFeature.java @@ -6,17 +6,17 @@ import insane96mcp.progressivebosses.base.Strings; import insane96mcp.progressivebosses.module.wither.dispenser.WitherSkullDispenseBehavior; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.util.Mth; -import net.minecraft.world.entity.boss.wither.WitherBoss; -import net.minecraft.world.item.Items; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.DispenserBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.DispenserBlock; +import net.minecraft.entity.boss.WitherEntity; +import net.minecraft.item.Items; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.world.DimensionType; +import net.minecraft.world.World; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; @@ -95,10 +95,10 @@ public void onUpdate(LivingEvent.LivingUpdateEvent event) { if (!this.biggerBlockBreaking) return; - if (!(event.getEntity() instanceof WitherBoss)) + if (!(event.getEntity() instanceof WitherEntity)) return; - WitherBoss wither = (WitherBoss) event.getEntity(); + WitherEntity wither = (WitherEntity) event.getEntity(); if (!wither.isAlive()) return; @@ -107,9 +107,9 @@ public void onUpdate(LivingEvent.LivingUpdateEvent event) { if (wither.destroyBlocksTick == 1) { --wither.destroyBlocksTick; if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(wither.level, wither)) { - int i1 = Mth.floor(wither.getY()); - int l1 = Mth.floor(wither.getX()); - int i2 = Mth.floor(wither.getZ()); + int i1 = MathHelper.floor(wither.getY()); + int l1 = MathHelper.floor(wither.getX()); + int i2 = MathHelper.floor(wither.getZ()); boolean flag = false; int yOffsetLow = -1; @@ -138,7 +138,7 @@ public void onUpdate(LivingEvent.LivingUpdateEvent event) { } } - private boolean canWitherDestroy(WitherBoss wither, BlockPos pos, BlockState state) { + private boolean canWitherDestroy(WitherEntity wither, BlockPos pos, BlockState state) { if (this.ignoreWitherProofBlocks) return !state.isAir() && state.getDestroySpeed(wither.level, pos) >= 0f; else @@ -153,15 +153,15 @@ public void onExplosion(ExplosionEvent.Start event) { if (this.explosionCausesFireAtDifficulty == -1 && this.explosionPowerBonus == 0d) return; - if (!(event.getExplosion().getExploder() instanceof WitherBoss)) + if (!(event.getExplosion().getExploder() instanceof WitherEntity)) return; //Check if the explosion is the one from the wither if (event.getExplosion().radius != 7f) return; - WitherBoss wither = (WitherBoss) event.getExplosion().getExploder(); - CompoundTag tags = wither.getPersistentData(); + WitherEntity wither = (WitherEntity) event.getExplosion().getExploder(); + CompoundNBT tags = wither.getPersistentData(); float difficulty = tags.getFloat(Strings.Tags.DIFFICULTY); @@ -192,10 +192,10 @@ public void onWitherDamage(LivingHurtEvent event) { if (!event.getEntity().isAlive()) return; - if (!(event.getEntityLiving() instanceof WitherBoss)) + if (!(event.getEntityLiving() instanceof WitherEntity)) return; - WitherBoss wither = (WitherBoss) event.getEntityLiving(); + WitherEntity wither = (WitherEntity) event.getEntityLiving(); wither.destroyBlocksTick = 10; } @@ -215,7 +215,7 @@ public void onRightClickBlock(PlayerInteractEvent.RightClickBlock event) { /** * Returns true if at the specified position a Wither Skull can be placed */ - public static boolean canPlaceSkull(Level world, BlockPos pos) { + public static boolean canPlaceSkull(World world, BlockPos pos) { boolean isNether = world.dimension().location().equals(DimensionType.NETHER_LOCATION); boolean hasSoulSandNearby = false; diff --git a/src/main/java/insane96mcp/progressivebosses/module/wither/feature/ResistancesFeature.java b/src/main/java/insane96mcp/progressivebosses/module/wither/feature/ResistancesFeature.java index 550e4641..a9b5fc12 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/wither/feature/ResistancesFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/wither/feature/ResistancesFeature.java @@ -5,8 +5,8 @@ import insane96mcp.insanelib.base.Module; import insane96mcp.progressivebosses.base.Strings; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.boss.wither.WitherBoss; +import net.minecraft.entity.boss.WitherEntity; +import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.living.LivingDamageEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -65,10 +65,10 @@ public void onWitherDamage(LivingDamageEvent event) { if ((this.meleeDamageReductionOnHalfHealth == 0d || this.maxDamageReductionOnHalfHealth == 0d) && (this.meleeDamageReductionBeforeHalfHealth == 0d || this.maxMeleeDamageReductionBeforeHalfHealth == 0d) && this.magicDamageBonus == 0d) return; - if (!(event.getEntity() instanceof WitherBoss)) + if (!(event.getEntity() instanceof WitherEntity)) return; - WitherBoss wither = (WitherBoss) event.getEntity(); + WitherEntity wither = (WitherEntity) event.getEntity(); //Handle Magic Damage if (event.getSource().isMagic() && this.magicDamageBonus > 0d) { double missingHealth = wither.getMaxHealth() - wither.getHealth(); @@ -78,7 +78,7 @@ public void onWitherDamage(LivingDamageEvent event) { if (event.getSource().getDirectEntity() != event.getSource().getEntity()) return; - CompoundTag tags = wither.getPersistentData(); + CompoundNBT tags = wither.getPersistentData(); float difficulty = tags.getFloat(Strings.Tags.DIFFICULTY); //Handle Damage Reduction float damageReduction; diff --git a/src/main/java/insane96mcp/progressivebosses/module/wither/feature/RewardFeature.java b/src/main/java/insane96mcp/progressivebosses/module/wither/feature/RewardFeature.java index 3595bd76..f14b8dfc 100644 --- a/src/main/java/insane96mcp/progressivebosses/module/wither/feature/RewardFeature.java +++ b/src/main/java/insane96mcp/progressivebosses/module/wither/feature/RewardFeature.java @@ -6,8 +6,8 @@ import insane96mcp.progressivebosses.base.Strings; import insane96mcp.progressivebosses.classutils.Drop; import insane96mcp.progressivebosses.setup.Config; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.boss.wither.WitherBoss; +import net.minecraft.entity.boss.WitherEntity; +import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; @@ -69,12 +69,12 @@ public void onSpawn(EntityJoinWorldEvent event) { if (this.bonusExperience == 0d) return; - if (!(event.getEntity() instanceof WitherBoss)) + if (!(event.getEntity() instanceof WitherEntity)) return; - WitherBoss wither = (WitherBoss) event.getEntity(); + WitherEntity wither = (WitherEntity) event.getEntity(); - CompoundTag witherTags = wither.getPersistentData(); + CompoundNBT witherTags = wither.getPersistentData(); float difficulty = witherTags.getFloat(Strings.Tags.DIFFICULTY); wither.xpReward = 50 + (int) (50 * (this.bonusExperience * difficulty)); @@ -88,12 +88,12 @@ public void onDeath(LivingDeathEvent event) { if (this.dropsList.isEmpty()) return; - if (!(event.getEntityLiving() instanceof WitherBoss)) + if (!(event.getEntityLiving() instanceof WitherEntity)) return; - WitherBoss wither = (WitherBoss) event.getEntityLiving(); + WitherEntity wither = (WitherEntity) event.getEntityLiving(); - CompoundTag tags = wither.getPersistentData(); + CompoundNBT tags = wither.getPersistentData(); float difficulty = tags.getFloat(Strings.Tags.DIFFICULTY); for (Drop drop : this.dropsList) { drop.drop(wither.level, wither.position(), difficulty); diff --git a/src/main/java/insane96mcp/progressivebosses/setup/ClientSetup.java b/src/main/java/insane96mcp/progressivebosses/setup/ClientSetup.java index 0c726af3..7b138222 100644 --- a/src/main/java/insane96mcp/progressivebosses/setup/ClientSetup.java +++ b/src/main/java/insane96mcp/progressivebosses/setup/ClientSetup.java @@ -1,10 +1,11 @@ package insane96mcp.progressivebosses.setup; import insane96mcp.progressivebosses.module.wither.entity.WitherMinionRenderer; -import net.minecraftforge.client.event.EntityRenderersEvent; +import net.minecraftforge.fml.client.registry.RenderingRegistry; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; public class ClientSetup { - public static void init(final EntityRenderersEvent.RegisterRenderers event) { - event.registerEntityRenderer(PBEntities.WITHER_MINION.get(), WitherMinionRenderer::new); + public static void init(final FMLClientSetupEvent event) { + RenderingRegistry.registerEntityRenderingHandler(PBEntities.WITHER_MINION.get(), WitherMinionRenderer::new); } } \ No newline at end of file diff --git a/src/main/java/insane96mcp/progressivebosses/setup/Config.java b/src/main/java/insane96mcp/progressivebosses/setup/Config.java index c099a81a..26baf525 100644 --- a/src/main/java/insane96mcp/progressivebosses/setup/Config.java +++ b/src/main/java/insane96mcp/progressivebosses/setup/Config.java @@ -5,7 +5,6 @@ import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.config.ModConfigEvent; import org.apache.commons.lang3.tuple.Pair; @Mod.EventBusSubscriber(modid = ProgressiveBosses.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) @@ -29,7 +28,7 @@ public CommonConfig(final ForgeConfigSpec.Builder builder) { } @SubscribeEvent - public static void onModConfigEvent(final ModConfigEvent event) { + public static void onModConfigEvent(final net.minecraftforge.fml.config.ModConfig.ModConfigEvent event) { Modules.loadConfig(); } } diff --git a/src/main/java/insane96mcp/progressivebosses/setup/PBEntities.java b/src/main/java/insane96mcp/progressivebosses/setup/PBEntities.java index 4de7cdbd..d674d0a3 100644 --- a/src/main/java/insane96mcp/progressivebosses/setup/PBEntities.java +++ b/src/main/java/insane96mcp/progressivebosses/setup/PBEntities.java @@ -2,17 +2,17 @@ import insane96mcp.progressivebosses.ProgressiveBosses; import insane96mcp.progressivebosses.module.wither.entity.WitherMinionEntity; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.MobCategory; -import net.minecraft.world.level.block.Blocks; +import net.minecraft.block.Blocks; +import net.minecraft.entity.EntityClassification; +import net.minecraft.entity.EntityType; +import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; public class PBEntities { public static final DeferredRegister> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, ProgressiveBosses.MOD_ID); - public static final RegistryObject> WITHER_MINION = ENTITIES.register("wither_minion", () -> EntityType.Builder.of(WitherMinionEntity::new, MobCategory.MONSTER) + public static final RegistryObject> WITHER_MINION = ENTITIES.register("wither_minion", () -> EntityType.Builder.of(WitherMinionEntity::new, EntityClassification.MONSTER) .sized(0.55f, 1.5f) .fireImmune() .immuneTo(Blocks.WITHER_ROSE) diff --git a/src/main/java/insane96mcp/progressivebosses/setup/PBItems.java b/src/main/java/insane96mcp/progressivebosses/setup/PBItems.java index 84e0a0f2..5926f666 100644 --- a/src/main/java/insane96mcp/progressivebosses/setup/PBItems.java +++ b/src/main/java/insane96mcp/progressivebosses/setup/PBItems.java @@ -2,15 +2,15 @@ import insane96mcp.progressivebosses.ProgressiveBosses; import insane96mcp.progressivebosses.base.Strings; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; +import net.minecraft.item.Item; +import net.minecraft.item.ItemGroup; +import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; public class PBItems { public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ProgressiveBosses.MOD_ID); - public static final RegistryObject NETHER_STAR_SHARD = ITEMS.register(Strings.Items.NETHER_STAR_SHARD, () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_MATERIALS))); - public static final RegistryObject ELDER_GUARDIAN_SPIKE = ITEMS.register(Strings.Items.ELDER_GUARDIAN_SPIKE, () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_MATERIALS))); + public static final RegistryObject NETHER_STAR_SHARD = ITEMS.register(Strings.Items.NETHER_STAR_SHARD, () -> new Item(new Item.Properties().tab(ItemGroup.TAB_MATERIALS))); + public static final RegistryObject ELDER_GUARDIAN_SPIKE = ITEMS.register(Strings.Items.ELDER_GUARDIAN_SPIKE, () -> new Item(new Item.Properties().tab(ItemGroup.TAB_MATERIALS))); } diff --git a/src/main/java/insane96mcp/progressivebosses/setup/Reflection.java b/src/main/java/insane96mcp/progressivebosses/setup/Reflection.java index 1b2642ac..ff5ba688 100644 --- a/src/main/java/insane96mcp/progressivebosses/setup/Reflection.java +++ b/src/main/java/insane96mcp/progressivebosses/setup/Reflection.java @@ -1,22 +1,21 @@ package insane96mcp.progressivebosses.setup; import insane96mcp.progressivebosses.ProgressiveBosses; -import net.minecraft.world.entity.projectile.Projectile; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.EntityHitResult; -import net.minecraftforge.fml.util.ObfuscationReflectionHelper; +import net.minecraft.entity.projectile.ProjectileEntity; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.EntityRayTraceResult; +import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.reflect.Method; -//TODO Dafuq is this public class Reflection { static MethodHandles.Lookup lookup = MethodHandles.lookup(); static Method onEntityHitMethod; public static MethodHandle onEntityHitMH; - public static void ProjectileEntity_onEntityHit(Projectile projectileEntity, EntityHitResult p_213868_1_) { + public static void ProjectileEntity_onEntityHit(ProjectileEntity projectileEntity, EntityRayTraceResult p_213868_1_) { try { onEntityHitMH.invoke(projectileEntity, p_213868_1_); } @@ -27,7 +26,7 @@ public static void ProjectileEntity_onEntityHit(Projectile projectileEntity, Ent static Method onBlockHitMethod; public static MethodHandle onBlockHitMH; - public static void ProjectileEntity_onBlockHit(Projectile projectileEntity, BlockHitResult p_213868_1_) { + public static void ProjectileEntity_onBlockHit(ProjectileEntity projectileEntity, BlockRayTraceResult p_213868_1_) { try { onBlockHitMH.invoke(projectileEntity, p_213868_1_); } @@ -38,10 +37,10 @@ public static void ProjectileEntity_onBlockHit(Projectile projectileEntity, Bloc public static void init() { try { - onEntityHitMethod = ObfuscationReflectionHelper.findMethod(Projectile.class, "onHitEntity", EntityHitResult.class); + onEntityHitMethod = ObfuscationReflectionHelper.findMethod(ProjectileEntity.class, "func_213868_a", EntityRayTraceResult.class); onEntityHitMH = lookup.unreflect(onEntityHitMethod); - onBlockHitMethod = ObfuscationReflectionHelper.findMethod(Projectile.class, "onHitBlock", BlockHitResult.class); + onBlockHitMethod = ObfuscationReflectionHelper.findMethod(ProjectileEntity.class, "func_230299_a_", BlockRayTraceResult.class); onBlockHitMH = lookup.unreflect(onBlockHitMethod); } catch (IllegalAccessException e) { ProgressiveBosses.LOGGER.error(e.toString()); diff --git a/src/main/java/insane96mcp/progressivebosses/utils/DragonMinionHelper.java b/src/main/java/insane96mcp/progressivebosses/utils/DragonMinionHelper.java index c5d6248f..0540d664 100644 --- a/src/main/java/insane96mcp/progressivebosses/utils/DragonMinionHelper.java +++ b/src/main/java/insane96mcp/progressivebosses/utils/DragonMinionHelper.java @@ -1,16 +1,16 @@ package insane96mcp.progressivebosses.utils; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.world.entity.monster.Shulker; +import net.minecraft.entity.monster.ShulkerEntity; +import net.minecraft.nbt.CompoundNBT; public class DragonMinionHelper { - public static boolean isBlindingMinion(Shulker shulker) { - CompoundTag compound = shulker.serializeNBT(); + public static boolean isBlindingMinion(ShulkerEntity shulker) { + CompoundNBT compound = shulker.serializeNBT(); return compound.getByte("Color") == 15; } - public static void setMinionColor(Shulker shulker, boolean blinding) { - CompoundTag compound = shulker.serializeNBT(); + public static void setMinionColor(ShulkerEntity shulker, boolean blinding) { + CompoundNBT compound = shulker.serializeNBT(); if (blinding) compound.putByte("Color", (byte) 15); else