diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c2ff692..e0ed07d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,4 +37,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: Artifacts - path: build/libs/ + path: build/libs/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 33bf41b..12f8644 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,6 @@ build # other eclipse run -logs # Files from Forge MDK forge*changelog.txt diff --git a/build.gradle b/build.gradle index 2ede4f8..834992f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,11 @@ buildscript { repositories { - maven { url = 'https://files.minecraftforge.net/maven' } + // These repositories are only for Gradle plugins, put any other repositories in the repository block further below + maven { url = 'https://maven.minecraftforge.net' } mavenCentral() } dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true } } apply plugin: 'net.minecraftforge.gradle' @@ -12,22 +13,48 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' -version = '1.0.0' -group = 'teamdraco.frozenup' -archivesBaseName = 'frozenup' +version = '1.0' +group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html +archivesBaseName = 'modid' -java.toolchain.languageVersion = JavaLanguageVersion.of(8) +// Mojang ships Java 16 to end users in 1.17+ instead of Java 8 in 1.16 or lower, so your mod should target Java 16. +java.toolchain.languageVersion = JavaLanguageVersion.of(16) println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) minecraft { - mappings channel: 'snapshot', version: '20201028-1.16.3' + // The mappings can be changed at any time and must be in the following format. + // Channel: Version: + // snapshot YYYYMMDD Snapshot are built nightly. + // stable # Stables are built at the discretion of the MCP team. + // official MCVersion Official field/method names from Mojang mapping files + // + // You must be aware of the Mojang license when using the 'official' mappings. + // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md + // + // 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.17.1' - // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default. + // Default run configurations. + // These can be tweaked, removed, or duplicated as needed. runs { client { workingDirectory project.file('run') + // Recommended logging data for a userdev environment + // The markers can be added/remove as needed separated by commas. + // "SCAN": For mods scan. + // "REGISTRIES": For firing of registry events. + // "REGISTRYDUMP": For getting the contents of all registries. + property 'forge.logging.markers', 'REGISTRIES' + + // Recommended logging level for the console + // You can set various levels here. + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels + property 'forge.logging.console.level', 'debug' + mods { examplemod { source sourceSets.main @@ -38,6 +65,43 @@ minecraft { server { workingDirectory project.file('run') + // Recommended logging data for a userdev environment + // The markers can be added/remove as needed separated by commas. + // "SCAN": For mods scan. + // "REGISTRIES": For firing of registry events. + // "REGISTRYDUMP": For getting the contents of all registries. + property 'forge.logging.markers', 'REGISTRIES' + + // Recommended logging level for the console + // You can set various levels here. + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels + property 'forge.logging.console.level', 'debug' + + mods { + examplemod { + source sourceSets.main + } + } + } + + data { + workingDirectory project.file('run') + + // Recommended logging data for a userdev environment + // The markers can be added/remove as needed separated by commas. + // "SCAN": For mods scan. + // "REGISTRIES": For firing of registry events. + // "REGISTRYDUMP": For getting the contents of all registries. + property 'forge.logging.markers', 'REGISTRIES' + + // Recommended logging level for the console + // You can set various levels here. + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels + property 'forge.logging.console.level', 'debug' + + // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. + args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') + mods { examplemod { source sourceSets.main @@ -47,26 +111,58 @@ minecraft { } } +// Include resources generated by data generators. +sourceSets.main.resources { srcDir 'src/generated/resources' } + +repositories { + // Put repositories for dependencies here + // ForgeGradle automatically adds the Forge maven and Maven Central for you + + // If you have mod jar dependencies in ./libs, you can declare them as a repository like so: + // flatDir { + // dir 'libs' + // } +} + dependencies { - minecraft 'net.minecraftforge:forge:1.16.5-36.1.32' + // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed + // that the dep is a ForgeGradle 'patcher' dependency, and its 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.17.1-37.0.84' + + // Real mod deobf dependency examples - these get remapped to your current mappings + // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency + // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency + // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency + + // Examples using mod jars from ./libs + // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}") + // For more info... + // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html + // http://www.gradle.org/docs/current/userguide/dependency_management.html } +// Example for how to get properties into the manifest for reading at runtime. jar { manifest { attributes([ - "Specification-Title": "frozenup", - "Specification-Vendor": "teamdraco", - "Specification-Version": "1", // We are version 1 of ourselves - "Implementation-Title": project.name, - "Implementation-Version": "${version}", - "Implementation-Vendor" :"teamdraco", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + "Specification-Title" : "examplemod", + "Specification-Vendor" : "examplemodsareus", + "Specification-Version" : "1", // We are version 1 of ourselves + "Implementation-Title" : project.name, + "Implementation-Version" : project.jar.archiveVersion, + "Implementation-Vendor" : "examplemodsareus", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } } +// Example configuration to allow publishing using the maven-publish plugin +// This is the preferred method to reobfuscate your jar file jar.finalizedBy('reobfJar') +// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing +// publish.dependsOn('reobfJar') publishing { publications { @@ -76,7 +172,7 @@ publishing { } repositories { maven { - url "file:///${project.projectDir}/mcmodsrepo" + url "file://${project.projectDir}/mcmodsrepo" } } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7a3265e..7454180 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 b9d52d8..ffed3a2 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.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip diff --git a/gradlew b/gradlew index cccdd3d..c53aefa 100644 --- a/gradlew +++ b/gradlew @@ -1,78 +1,129 @@ -#!/usr/bin/env sh +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -81,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -89,84 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# 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 +# 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 Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f955316..107acd3 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/src/main/java/teamdraco/frozenup/FrozenUp.java b/src/main/java/teamdraco/frozenup/FrozenUp.java index b2e0cc4..38a2b10 100644 --- a/src/main/java/teamdraco/frozenup/FrozenUp.java +++ b/src/main/java/teamdraco/frozenup/FrozenUp.java @@ -1,14 +1,8 @@ package teamdraco.frozenup; -import net.minecraft.entity.EntityClassification; -import net.minecraft.entity.EntitySpawnPlacementRegistry; -import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes; -import net.minecraft.entity.passive.AnimalEntity; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.MobSpawnInfo; -import net.minecraft.world.gen.Heightmap; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraftforge.common.BiomeManager.BiomeType; import net.minecraftforge.event.world.BiomeLoadingEvent; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.IEventBus; @@ -38,7 +32,7 @@ public FrozenUp() { @SubscribeEvent(priority = EventPriority.LOWEST) public static void registerBiomes(BiomeLoadingEvent event) { - if (event.getCategory() == Biome.Category.ICY && event.getClimate().temperature <= 0.0f) { + if (event.getCategory() == BiomeType.Category.ICY && event.getClimate().temperature <= 0.0f) { event.getSpawns().getSpawner(EntityClassification.CREATURE).add(new MobSpawnInfo.Spawners(FrozenUpEntities.CHILLOO.get(), 1, 2, 3)); } } @@ -46,7 +40,7 @@ public static void registerBiomes(BiomeLoadingEvent event) { private void registerCommon(FMLCommonSetupEvent event) { CommonEvents.setup(); registerEntityAttributes(); - EntitySpawnPlacementRegistry.register(FrozenUpEntities.CHILLOO.get(), EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::canAnimalSpawn); + EntitySpawnPlacementRegistry.register(FrozenUpEntities.CHILLOO.get(), EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Animal::canAnimalSpawn); } @SuppressWarnings("deprecation") diff --git a/src/main/java/teamdraco/frozenup/block/FeatherLampBlock.java b/src/main/java/teamdraco/frozenup/block/FeatherLampBlock.java index d66d1de..97315a3 100644 --- a/src/main/java/teamdraco/frozenup/block/FeatherLampBlock.java +++ b/src/main/java/teamdraco/frozenup/block/FeatherLampBlock.java @@ -1,53 +1,52 @@ package teamdraco.frozenup.block; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.RedstoneTorchBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.state.BooleanProperty; -import net.minecraft.state.StateContainer; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.World; -import teamdraco.frozenup.init.FrozenUpSoundEvents; - import javax.annotation.Nullable; -@SuppressWarnings("deprecation") +import net.minecraft.core.BlockPos; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.RedstoneTorchBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.phys.BlockHitResult; +import teamdraco.frozenup.init.FrozenUpSoundEvents; + public class FeatherLampBlock extends Block { public static final BooleanProperty LIT = RedstoneTorchBlock.LIT; public FeatherLampBlock(Properties settings) { super(settings); - this.setDefaultState(this.stateContainer.getBaseState().with(LIT, false)); + this.registerDefaultState(this.stateDefinition.any().setValue(LIT, false)); } @Override - protected void fillStateContainer(StateContainer.Builder builder) { + protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(LIT); } @Nullable @Override - public BlockState getStateForPlacement(BlockItemUseContext ctx) { + public BlockState getStateForPlacement(BlockPlaceContext ctx) { BlockState state = super.getStateForPlacement(ctx); - PlayerEntity player = ctx.getPlayer(); - return state == null ? null : state.with(LIT, player != null && player.isSneaking()); + Player player = ctx.getPlayer(); + return state == null ? null : state.setValue(LIT, player != null && player.isShiftKeyDown()); } @Override - public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - boolean newLit = !state.get(LIT); + public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { + boolean newLit = !state.getValue(LIT); - world.setBlockState(pos, state.with(LIT, newLit)); - if (!world.isRemote) { - world.playMovingSound(null, player, newLit ? FrozenUpSoundEvents.BLOCK_CHILLOO_FEATHER_LAMP_TOGGLE_ON : FrozenUpSoundEvents.BLOCK_CHILLOO_FEATHER_LAMP_TOGGLE_OFF, SoundCategory.PLAYERS, 1.0f, 1.0f); + world.setBlockAndUpdate(pos, state.setValue(LIT, newLit)); + if (!world.isClientSide) { + world.playSound(null, player, newLit ? FrozenUpSoundEvents.BLOCK_CHILLOO_FEATHER_LAMP_TOGGLE_ON : FrozenUpSoundEvents.BLOCK_CHILLOO_FEATHER_LAMP_TOGGLE_OFF, SoundSource.PLAYERS, 1.0f, 1.0f); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } } diff --git a/src/main/java/teamdraco/frozenup/block/FrozenUpSoundTypes.java b/src/main/java/teamdraco/frozenup/block/FrozenUpSoundTypes.java index 7d2cece..ad17951 100644 --- a/src/main/java/teamdraco/frozenup/block/FrozenUpSoundTypes.java +++ b/src/main/java/teamdraco/frozenup/block/FrozenUpSoundTypes.java @@ -1,17 +1,17 @@ package teamdraco.frozenup.block; -import net.minecraft.block.SoundType; -import net.minecraft.util.SoundEvents; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.level.block.SoundType; import net.minecraftforge.common.util.ForgeSoundType; import teamdraco.frozenup.init.FrozenUpSoundEvents; public class FrozenUpSoundTypes { public static final SoundType CHILLOO_FEATHER_BLOCK = new ForgeSoundType( - 1, 1, + 1F, 1F, () -> FrozenUpSoundEvents.BLOCK_CHILLOO_FEATHER_BLOCK_BREAK, - () -> SoundEvents.BLOCK_WOOL_STEP, + () -> SoundEvents.WOOL_STEP, () -> FrozenUpSoundEvents.BLOCK_CHILLOO_FEATHER_BLOCK_PLACE, - () -> SoundEvents.BLOCK_WOOL_HIT, - () -> SoundEvents.BLOCK_WOOL_FALL + () -> SoundEvents.WOOL_HIT, + () -> SoundEvents.WOOL_FALL ); } diff --git a/src/main/java/teamdraco/frozenup/block/MugBlock.java b/src/main/java/teamdraco/frozenup/block/MugBlock.java index 67f2419..f879af8 100644 --- a/src/main/java/teamdraco/frozenup/block/MugBlock.java +++ b/src/main/java/teamdraco/frozenup/block/MugBlock.java @@ -1,22 +1,13 @@ package teamdraco.frozenup.block; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.HorizontalBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItemUseContext; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.state.DirectionProperty; -import net.minecraft.state.StateContainer; +import net.minecraft.core.Direction; import net.minecraft.util.*; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Item.Properties; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; +import net.minecraft.world.level.block.state.properties.DirectionProperty; +import net.minecraft.world.phys.shapes.VoxelShape; import teamdraco.frozenup.init.FrozenUpBlocks; import teamdraco.frozenup.item.AbstractDrinkableMugItem; @@ -24,16 +15,16 @@ import java.util.function.Supplier; @SuppressWarnings("deprecation") -public class MugBlock extends HorizontalBlock { - public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING; +public class MugBlock extends HorizontalDirectionalBlock { + public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; - protected static final VoxelShape MUG = makeCuboidShape(4.0D, 0.0D, 4.0D, 12.0D, 9.0D, 12.0D); - protected static final VoxelShape HANDLE = makeCuboidShape(7.0D, 2.5D, 2.0D, 9.0D, 7.5D, 4.0D); + protected static final VoxelShape MUG = Block.box(4.0D, 0.0D, 4.0D, 12.0D, 9.0D, 12.0D); + protected static final VoxelShape HANDLE = Block.box(7.0D, 2.5D, 2.0D, 9.0D, 7.5D, 4.0D); protected static final VoxelShape SHAPE = VoxelShapes.or(MUG, HANDLE); protected static final VoxelShape NORTH_SHAPE = VoxelShapes.or(MUG, HANDLE); - protected static final VoxelShape SOUTH_SHAPE = VoxelShapes.or(Block.makeCuboidShape(7, 2.5, 12, 9, 7.5, 14), Block.makeCuboidShape(4, 0, 4, 12, 9, 12)); - protected static final VoxelShape EAST_SHAPE = VoxelShapes.or(Block.makeCuboidShape(12, 2.5, 7, 14, 7.5, 9), Block.makeCuboidShape(4, 0, 4, 12, 9, 12)); - protected static final VoxelShape WEST_SHAPE = VoxelShapes.or(Block.makeCuboidShape(2, 2.5, 7, 4, 7.5, 9), Block.makeCuboidShape(4, 0, 4, 12, 9, 12)); + protected static final VoxelShape SOUTH_SHAPE = VoxelShapes.or(Block.box(7, 2.5, 12, 9, 7.5, 14), Block.box(4, 0, 4, 12, 9, 12)); + protected static final VoxelShape EAST_SHAPE = VoxelShapes.or(Block.box(12, 2.5, 7, 14, 7.5, 9), Block.box(4, 0, 4, 12, 9, 12)); + protected static final VoxelShape WEST_SHAPE = VoxelShapes.or(Block.box(2, 2.5, 7, 4, 7.5, 9), Block.box(4, 0, 4, 12, 9, 12)); @Nullable private final Supplier mugItem; diff --git a/src/main/java/teamdraco/frozenup/client/ClientEventHandler.java b/src/main/java/teamdraco/frozenup/client/ClientEventHandler.java index 8337b3b..0f11237 100644 --- a/src/main/java/teamdraco/frozenup/client/ClientEventHandler.java +++ b/src/main/java/teamdraco/frozenup/client/ClientEventHandler.java @@ -1,16 +1,10 @@ package teamdraco.frozenup.client; -import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.client.renderer.color.IItemColor; -import net.minecraft.client.renderer.color.ItemColors; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.ColorHandlerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.RegistryObject; -import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import teamdraco.frozenup.FrozenUp; diff --git a/src/main/java/teamdraco/frozenup/client/model/ChillooModel.java b/src/main/java/teamdraco/frozenup/client/model/ChillooModel.java index dd19c1c..f39eac8 100644 --- a/src/main/java/teamdraco/frozenup/client/model/ChillooModel.java +++ b/src/main/java/teamdraco/frozenup/client/model/ChillooModel.java @@ -3,10 +3,6 @@ import java.util.Collections; import java.util.List; -import net.minecraft.client.renderer.entity.model.AgeableModel; -import net.minecraft.client.renderer.model.ModelRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.MathHelper; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import teamdraco.frozenup.entity.ChillooEntity; diff --git a/src/main/java/teamdraco/frozenup/client/renderer/ChillooRenderer.java b/src/main/java/teamdraco/frozenup/client/renderer/ChillooRenderer.java index 598588c..e79c02b 100644 --- a/src/main/java/teamdraco/frozenup/client/renderer/ChillooRenderer.java +++ b/src/main/java/teamdraco/frozenup/client/renderer/ChillooRenderer.java @@ -2,10 +2,7 @@ import java.util.function.Function; -import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.entity.MobRenderer; -import net.minecraft.item.DyeColor; -import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import teamdraco.frozenup.FrozenUp; diff --git a/src/main/java/teamdraco/frozenup/common/CommonEvents.java b/src/main/java/teamdraco/frozenup/common/CommonEvents.java index 16e6e15..2e2488d 100644 --- a/src/main/java/teamdraco/frozenup/common/CommonEvents.java +++ b/src/main/java/teamdraco/frozenup/common/CommonEvents.java @@ -1,7 +1,5 @@ package teamdraco.frozenup.common; -import net.minecraft.block.ComposterBlock; -import net.minecraft.util.IItemProvider; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; import teamdraco.frozenup.FrozenUp; diff --git a/src/main/java/teamdraco/frozenup/entity/ChillooEntity.java b/src/main/java/teamdraco/frozenup/entity/ChillooEntity.java index 256ce11..12f8f95 100644 --- a/src/main/java/teamdraco/frozenup/entity/ChillooEntity.java +++ b/src/main/java/teamdraco/frozenup/entity/ChillooEntity.java @@ -10,51 +10,65 @@ import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.pattern.BlockStateMatcher; -import net.minecraft.entity.AgeableEntity; -import net.minecraft.entity.EntitySize; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.MobEntity; -import net.minecraft.entity.Pose; -import net.minecraft.entity.ai.attributes.AttributeModifierMap; -import net.minecraft.entity.ai.attributes.Attributes; -import net.minecraft.entity.ai.goal.*; -import net.minecraft.entity.passive.TameableEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.InventoryHelper; -import net.minecraft.item.DyeColor; -import net.minecraft.item.DyeItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.loot.LootContext; -import net.minecraft.loot.LootParameterSets; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.datasync.DataParameter; -import net.minecraft.network.datasync.DataSerializers; -import net.minecraft.network.datasync.EntityDataManager; +import net.minecraft.core.BlockPos; +import net.minecraft.core.NonNullList; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.*; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.AgeableMob; +import net.minecraft.world.entity.EntityDimensions; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.Pose; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.ai.attributes.AttributeMap; +import net.minecraft.world.entity.ai.attributes.AttributeSupplier; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.ai.goal.BreedGoal; +import net.minecraft.world.entity.ai.goal.FloatGoal; +import net.minecraft.world.entity.ai.goal.FollowOwnerGoal; +import net.minecraft.world.entity.ai.goal.FollowParentGoal; +import net.minecraft.world.entity.ai.goal.Goal; +import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal; +import net.minecraft.world.entity.ai.goal.PanicGoal; +import net.minecraft.world.entity.ai.goal.SitWhenOrderedToGoal; +import net.minecraft.world.entity.ai.goal.TemptGoal; +import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal; +import net.minecraft.world.entity.animal.Wolf; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.DyeItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.storage.loot.LootContext; import net.minecraftforge.event.ForgeEventFactory; import teamdraco.frozenup.FrozenUp; import teamdraco.frozenup.init.FrozenUpEntities; import teamdraco.frozenup.init.FrozenUpItems; import teamdraco.frozenup.init.FrozenUpSoundEvents; -public class ChillooEntity extends TameableEntity { +public class ChillooEntity extends TamableAnimal { public static final int DIG_ANIMATION_ID = 10; - private static final Ingredient TEMPTATION_ITEMS = Ingredient.fromItems(Items.WHEAT_SEEDS, Items.BEETROOT_SEEDS, Items.MELON_SEEDS, Items.COCOA_BEANS, Items.POTATO, Items.CARROT); + private static final Ingredient TEMPTATION_ITEMS = Ingredient.of(Items.WHEAT_SEEDS, Items.BEETROOT_SEEDS, Items.MELON_SEEDS, Items.COCOA_BEANS, Items.POTATO, Items.CARROT); private static final BiMap WOOL_BLOCKS = HashBiMap.create(16); - private static final DataParameter COLOR = EntityDataManager.createKey(ChillooEntity.class, DataSerializers.BYTE); - public int timeUntilNextFeather = this.rand.nextInt(10000) + 2500; + private static final EntityDataAccessor COLOR = SynchedEntityData.defineId(ChillooEntity.class, EntityDataSerializers.BYTE); + public int timeUntilNextFeather = this.random.nextInt(10000) + 2500; public int digTimer = 0; static { @@ -76,67 +90,65 @@ public class ChillooEntity extends TameableEntity { WOOL_BLOCKS.put(Blocks.BLACK_WOOL, DyeColor.BLACK); } - public ChillooEntity(EntityType type, World worldIn) { + public ChillooEntity(EntityType type, Level worldIn) { super(type, worldIn); - this.stepHeight = 1; - this.setTamed(false); + this.setTame(false); } @Override protected void registerGoals() { - this.goalSelector.addGoal(0, new SwimGoal(this)); - this.goalSelector.addGoal(1, new SitGoal(this)); + this.goalSelector.addGoal(0, new FloatGoal(this)); + this.goalSelector.addGoal(1, new SitWhenOrderedToGoal(this)); this.goalSelector.addGoal(2, new PanicGoal(this, 1.4D)); this.goalSelector.addGoal(3, new FollowOwnerGoal(this, 1.0D, 10.0F, 2.0F, false)); this.goalSelector.addGoal(4, new BreedGoal(this, 1.0D)); - this.goalSelector.addGoal(5, new TemptGoal(this, 1.0D, false, TEMPTATION_ITEMS)); + this.goalSelector.addGoal(5, new TemptGoal(this, 1.0D, TEMPTATION_ITEMS, false)); this.goalSelector.addGoal(6, new DiggingGoal(this)); this.goalSelector.addGoal(7, new FollowParentGoal(this, 1.1D) { @Override - public boolean shouldExecute() { - return !isTamed() && super.shouldExecute(); + public boolean canUse() { + return !isTame() && super.canUse(); } }); - this.goalSelector.addGoal(8, new WaterAvoidingRandomWalkingGoal(this, 1.0D)); - this.goalSelector.addGoal(9, new LookAtGoal(this, PlayerEntity.class, 6.0F)); + this.goalSelector.addGoal(8, new WaterAvoidingRandomStrollGoal(this, 1.0D)); + this.goalSelector.addGoal(9, new LookAtPlayerGoal(this, Player.class, 6.0F)); } @Override - protected float getStandingEyeHeight(Pose poseIn, EntitySize sizeIn) { - return this.isChild() ? 0.5F : 0.7F; + protected float getStandingEyeHeight(Pose poseIn, EntityDimensions sizeIn) { + return this.isBaby() ? 0.5F : 0.7F; } - public static AttributeModifierMap.MutableAttribute createAttributes() { - return MobEntity.func_233666_p_().createMutableAttribute(Attributes.MAX_HEALTH, 12.0D).createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.2F); + public static AttributeSupplier.Builder createAttributes() { + return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 12.0D).add(Attributes.MOVEMENT_SPEED, 0.2F); } @Override - public boolean isBreedingItem(ItemStack stack) { + public boolean isFood(ItemStack stack) { return stack.getItem() == Items.WHEAT_SEEDS || stack.getItem() == Items.BEETROOT_SEEDS || stack.getItem() == Items.MELON_SEEDS || stack.getItem() == Items.COCOA_BEANS || stack.getItem() == Items.POTATO || stack.getItem() == Items.CARROT; } public void setBandColor(DyeColor color) { - dataManager.set(COLOR, color == null ? -1 : (byte) color.ordinal()); + entityData.set(COLOR, color == null ? -1 : (byte) color.ordinal()); } public DyeColor getBandColor() { - byte color = dataManager.get(COLOR); + byte color = entityData.get(COLOR); return color == -1 || color >= 16 ? null : DyeColor.byId(color); } public void setSweaterColor(DyeColor color) { - dataManager.set(COLOR, color == null ? -1 : (byte) (color.ordinal() + 16)); + entityData.set(COLOR, color == null ? -1 : (byte) (color.ordinal() + 16)); } public DyeColor getSweaterColor() { - byte color = dataManager.get(COLOR); + byte color = entityData.get(COLOR); return color < 16 ? null : DyeColor.byId(color - 16); } - @SuppressWarnings("ConstantConditions") @Override - public void setTamed(boolean tamed) { - super.setTamed(tamed); + public void setTame(boolean tamed) { + super.setTame(tamed); if (tamed) { this.setBandColor(DyeColor.RED); this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(20.0D); @@ -147,30 +159,30 @@ public void setTamed(boolean tamed) { } @Override - public ActionResultType func_230254_b_(PlayerEntity player, Hand hand) { - ItemStack stack = player.getHeldItem(hand); + public InteractionResult mobInteract(Player player, InteractionHand hand) { + ItemStack stack = player.getItemInHand(hand); Item item = stack.getItem(); - if (item == FrozenUpItems.FROZEN_TRUFFLE.get() && !this.isTamed()) { - if (!player.abilities.isCreativeMode) { + if (item == FrozenUpItems.FROZEN_TRUFFLE.get() && !this.isTame()) { + if (!player.isCreative()) { stack.shrink(1); } if (!ForgeEventFactory.onAnimalTame(this, player)) { - this.setTamedBy(player); - this.navigator.clearPath(); - this.func_233687_w_(true); - this.world.setEntityState(this, (byte) 7); + this.tame(player); + this.navigation.stop();; + this.setOrderedToSit(true); + this.level.broadcastEntityEvent(this, (byte) 7); } else { - this.world.setEntityState(this, (byte) 6); + this.level.broadcastEntityEvent(this, (byte) 6); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - if (this.isOwner(player)) { + if (this.isOwnedBy(player)) { if (item instanceof DyeItem) { setBandColor(((DyeItem) item).getDyeColor()); stack.shrink(1); } else { - DyeColor dyeColor = WOOL_BLOCKS.get(Block.getBlockFromItem(item)); + DyeColor dyeColor = WOOL_BLOCKS.get(Block.byItem(item)); if (dyeColor == null) { if (item == Items.SHEARS) { boolean failed = false; @@ -180,18 +192,22 @@ public ActionResultType func_230254_b_(PlayerEntity player, Hand hand) { if (sweaterColor == null) { failed = true; } else { - entityDropItem(WOOL_BLOCKS.inverse().get(sweaterColor)); + ItemEntity itementity = this.spawnAtLocation(WOOL_BLOCKS.inverse().get(sweaterColor), 1); + if (itementity != null) { + itementity.setDeltaMovement(itementity.getDeltaMovement().add((double)((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double)(this.random.nextFloat() * 0.05F), (double)((this.random.nextFloat() - this.random.nextFloat()) * 0.1F))); + } } } if (!failed) { setBandColor(DyeColor.RED); - this.world.playMovingSound(null, this, SoundEvents.ENTITY_SHEEP_SHEAR, SoundCategory.PLAYERS, 1.0F, 1.0F); - stack.damageItem(1, player, playerEntity -> playerEntity.sendBreakAnimation(hand)); - } + this.level.playSound(null, this, SoundEvents.SHEEP_SHEAR, SoundSource.PLAYERS, 1.0F, 1.0F); + stack.hurtAndBreak(1, player, (p_29822_) -> { + p_29822_.broadcastBreakEvent(hand); + }); } } else { - func_233687_w_(!isEntitySleeping()); - this.isJumping = false; - this.navigator.clearPath(); + func_233687_w_(!isSleeping()); + this.jumping = false; + this.navigation.stop(); stack.shrink(1); } } else { @@ -199,20 +215,20 @@ public ActionResultType func_230254_b_(PlayerEntity player, Hand hand) { stack.shrink(1); } } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return super.func_230254_b_(player, hand); + return super.mobInteract(player, hand); } @Override public void livingTick() { super.livingTick(); - if (!this.world.isRemote) { - if (this.isAlive() && !this.isChild() && --this.timeUntilNextFeather <= 0 && this.isTamed()) { - this.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); + if (!this.level.isRemote) { + if (this.isAlive() && !this.isBaby() && --this.timeUntilNextFeather <= 0 && this.isTame()) { + this.playSound(SoundEvents.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); this.entityDropItem(FrozenUpItems.CHILLOO_FEATHER.get()); - this.timeUntilNextFeather = this.rand.nextInt(10000) + 5000; + this.timeUntilNextFeather = this.random.nextInt(10000) + 5000; } } else if (digTimer > 0) { --digTimer; @@ -221,15 +237,16 @@ public void livingTick() { @Nullable @Override - public AgeableEntity func_241840_a(ServerWorld world, AgeableEntity ageable) { - ChillooEntity chilloo = FrozenUpEntities.CHILLOO.get().create(this.world); - UUID uuid = this.getOwnerId(); - if (chilloo != null) { - chilloo.setOwnerId(uuid); - chilloo.setTamed(true); + public ChillooEntity getBreedOffspring(ServerLevel p_149088_, AgeableMob p_149089_) { + ChillooEntity chilloo = FrozenUpEntities.CHILLOO.get().create(p_149088_); + UUID uuid = this.getOwnerUUID(); + if (uuid != null) { + chilloo.setOwnerUUID(uuid); + chilloo.setTame(true); } + return chilloo; - } + } @Override protected SoundEvent getAmbientSound() { @@ -248,7 +265,7 @@ protected SoundEvent getDeathSound() { @Override protected void playStepSound(BlockPos pos, BlockState blockIn) { - this.playSound(SoundEvents.ENTITY_SHEEP_STEP, 0.15F, 1.0F); + this.playSound(SoundEvents.SHEEP_STEP, 0.15F, 1.0F); } @Override @@ -269,7 +286,7 @@ public void readAdditional(CompoundNBT compound) { @Override public void writeAdditional(CompoundNBT compound) { super.writeAdditional(compound); - compound.putByte("Colors", this.dataManager.get(COLOR)); + compound.putByte("Colors", this.entityData.get(COLOR)); compound.putInt("FeatherLayTime", this.timeUntilNextFeather); } @@ -306,17 +323,17 @@ public boolean shouldExecute() { --digTimer; return false; } - if (entity.isEntitySleeping()) { + if (entity.isSleeping()) { return false; } - if (entity.getRNG().nextInt(entity.isChild() ? 100 : 1000) != 0) { + if (entity.getRandom().nextInt(entity.isBaby() ? 100 : 1000) != 0) { return false; } else { BlockPos blockpos = entity.getPosition(); - if (IS_GRASS.test(entity.world.getBlockState(blockpos))) { + if (IS_GRASS.test(entity.level.getBlockState(blockpos))) { return true; } else { - return entity.world.getBlockState(blockpos.down()).isIn(Blocks.GRASS_BLOCK); + return entity.level.getBlockState(blockpos.world()).isIn(Blocks.GRASS_BLOCK); } } } @@ -325,8 +342,8 @@ public boolean shouldExecute() { public void startExecuting() { eatingGrassTimer = 40; digTimer = 6000; - entity.world.setEntityState(entity, (byte) 10); - entity.getNavigator().clearPath(); + entity.level.broadcastEntityEvent(entity, (byte) 10); + entity.getNavigation().stop(); } @Override @@ -349,17 +366,17 @@ public void tick() { } if (eatingGrassTimer == 25) { BlockPos blockpos = entity.getPosition(); - if (IS_GRASS.test(entity.world.getBlockState(blockpos))) { + if (IS_GRASS.test(entity.level.getBlockState(blockpos))) { entity.eatGrassBonus(); } else { - BlockPos blockpos1 = blockpos.down(); - if (entity.world.getBlockState(blockpos1).isIn(Blocks.GRASS_BLOCK)) { + BlockPos blockpos1 = blockpos.below(); + if (entity.level.getBlockState(blockpos1).is(Blocks.GRASS_BLOCK)) { entity.eatGrassBonus(); - entity.world.playEvent(2001, blockpos1, Block.getStateId(Blocks.GRASS_BLOCK.getDefaultState())); - MinecraftServer server = entity.world.getServer(); + entity.level.playEvent(2001, blockpos1, Block.getStateId(Blocks.GRASS_BLOCK.defaultBlockState())); + MinecraftServer server = entity.level.getServer(); if (server != null) { - List items = server.getLootTableManager().getLootTableFromLocation(DIGGING_LOOT).generate(new LootContext.Builder((ServerWorld) entity.world).withRandom(entity.getRNG()).build(LootParameterSets.EMPTY)); - InventoryHelper.dropItems(entity.world, blockpos, NonNullList.from(ItemStack.EMPTY, items.toArray(new ItemStack[0]))); + List items = server.getLootTableManager().getLootTableFromLocation(DIGGING_LOOT).generate(new LootContext.Builder((ServerLevel) entity.level).withRandom(entity.getRandom()).build(LootParameterSets.EMPTY)); + InventoryHelper.dropItems(entity.level, blockpos, NonNullList.from(ItemStack.EMPTY, items.toArray(new ItemStack[0]))); } } } diff --git a/src/main/java/teamdraco/frozenup/init/FrozenUpBlocks.java b/src/main/java/teamdraco/frozenup/init/FrozenUpBlocks.java index d2b4923..2a48a25 100644 --- a/src/main/java/teamdraco/frozenup/init/FrozenUpBlocks.java +++ b/src/main/java/teamdraco/frozenup/init/FrozenUpBlocks.java @@ -2,11 +2,6 @@ import java.util.function.ToIntFunction; -import net.minecraft.block.*; -import net.minecraft.block.material.Material; -import net.minecraft.item.DyeColor; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import teamdraco.frozenup.FrozenUp; diff --git a/src/main/java/teamdraco/frozenup/init/FrozenUpEntities.java b/src/main/java/teamdraco/frozenup/init/FrozenUpEntities.java index 6de9d20..b8559be 100644 --- a/src/main/java/teamdraco/frozenup/init/FrozenUpEntities.java +++ b/src/main/java/teamdraco/frozenup/init/FrozenUpEntities.java @@ -1,9 +1,5 @@ package teamdraco.frozenup.init; -import net.minecraft.entity.EntityClassification; -import net.minecraft.entity.EntityType; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import teamdraco.frozenup.FrozenUp; diff --git a/src/main/java/teamdraco/frozenup/init/FrozenUpFeatures.java b/src/main/java/teamdraco/frozenup/init/FrozenUpFeatures.java index 23fc2be..2aa3dea 100644 --- a/src/main/java/teamdraco/frozenup/init/FrozenUpFeatures.java +++ b/src/main/java/teamdraco/frozenup/init/FrozenUpFeatures.java @@ -1,7 +1,5 @@ package teamdraco.frozenup.init; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.NoFeatureConfig; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import teamdraco.frozenup.FrozenUp; diff --git a/src/main/java/teamdraco/frozenup/init/FrozenUpItems.java b/src/main/java/teamdraco/frozenup/init/FrozenUpItems.java index 1c8b5e6..3ab9f58 100644 --- a/src/main/java/teamdraco/frozenup/init/FrozenUpItems.java +++ b/src/main/java/teamdraco/frozenup/init/FrozenUpItems.java @@ -1,11 +1,5 @@ package teamdraco.frozenup.init; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Food; -import net.minecraft.item.Item; -import net.minecraft.potion.EffectInstance; -import net.minecraft.potion.Effects; -import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import teamdraco.frozenup.FrozenUp; diff --git a/src/main/java/teamdraco/frozenup/init/FrozenUpSoundEvents.java b/src/main/java/teamdraco/frozenup/init/FrozenUpSoundEvents.java index aabdd76..1c2ea07 100644 --- a/src/main/java/teamdraco/frozenup/init/FrozenUpSoundEvents.java +++ b/src/main/java/teamdraco/frozenup/init/FrozenUpSoundEvents.java @@ -1,9 +1,7 @@ package teamdraco.frozenup.init; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.registry.Registry; -import net.minecraftforge.fml.RegistryObject; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvent; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import teamdraco.frozenup.FrozenUp; @@ -36,7 +34,8 @@ private static SoundEvent block(String block, String type) { private static SoundEvent entity(String entity, String type) { return register("entity." + entity + "." + type); } - private static SoundEvent ambient(String id, String type) { + @SuppressWarnings("unused") + private static SoundEvent ambient(String id, String type) { return register("ambient." + type + "." + id); } diff --git a/src/main/java/teamdraco/frozenup/item/AbstractDrinkableMugItem.java b/src/main/java/teamdraco/frozenup/item/AbstractDrinkableMugItem.java index 489ce9b..04c80b9 100644 --- a/src/main/java/teamdraco/frozenup/item/AbstractDrinkableMugItem.java +++ b/src/main/java/teamdraco/frozenup/item/AbstractDrinkableMugItem.java @@ -1,15 +1,5 @@ package teamdraco.frozenup.item; -import net.minecraft.block.Block; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemStack; -import net.minecraft.item.UseAction; -import net.minecraft.util.ActionResult; -import net.minecraft.util.DrinkHelper; -import net.minecraft.util.Hand; -import net.minecraft.world.World; import teamdraco.frozenup.init.FrozenUpItems; public abstract class AbstractDrinkableMugItem extends BlockItem { diff --git a/src/main/java/teamdraco/frozenup/item/ChocolateMilkMugItem.java b/src/main/java/teamdraco/frozenup/item/ChocolateMilkMugItem.java index 6c0f200..c85c44a 100644 --- a/src/main/java/teamdraco/frozenup/item/ChocolateMilkMugItem.java +++ b/src/main/java/teamdraco/frozenup/item/ChocolateMilkMugItem.java @@ -1,12 +1,5 @@ package teamdraco.frozenup.item; -import net.minecraft.block.Block; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.EffectInstance; -import net.minecraft.potion.Effects; -import net.minecraft.world.World; - public class ChocolateMilkMugItem extends MilkMugItem { public ChocolateMilkMugItem(Block block, Properties properties) { super(block, properties); diff --git a/src/main/java/teamdraco/frozenup/item/FrozenUpSpawnEggItem.java b/src/main/java/teamdraco/frozenup/item/FrozenUpSpawnEggItem.java index c31b527..937b220 100644 --- a/src/main/java/teamdraco/frozenup/item/FrozenUpSpawnEggItem.java +++ b/src/main/java/teamdraco/frozenup/item/FrozenUpSpawnEggItem.java @@ -4,20 +4,8 @@ import java.util.List; import java.util.Map; -import net.minecraft.block.DispenserBlock; -import net.minecraft.dispenser.DefaultDispenseItemBehavior; -import net.minecraft.dispenser.IBlockSource; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnReason; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.SpawnEggItem; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Direction; import net.minecraftforge.common.util.Lazy; import net.minecraftforge.common.util.NonNullSupplier; -import net.minecraftforge.fml.RegistryObject; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; @SuppressWarnings("unused") public class FrozenUpSpawnEggItem extends SpawnEggItem { diff --git a/src/main/java/teamdraco/frozenup/item/MilkMugItem.java b/src/main/java/teamdraco/frozenup/item/MilkMugItem.java index 1df2068..34d48cd 100644 --- a/src/main/java/teamdraco/frozenup/item/MilkMugItem.java +++ b/src/main/java/teamdraco/frozenup/item/MilkMugItem.java @@ -1,10 +1,5 @@ package teamdraco.frozenup.item; -import net.minecraft.block.Block; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - public class MilkMugItem extends AbstractDrinkableMugItem { public MilkMugItem(Block block, Properties properties) { super(block, properties); diff --git a/src/main/java/teamdraco/frozenup/item/TestItem.java b/src/main/java/teamdraco/frozenup/item/TestItem.java index e501e5b..1b10ab2 100644 --- a/src/main/java/teamdraco/frozenup/item/TestItem.java +++ b/src/main/java/teamdraco/frozenup/item/TestItem.java @@ -1,12 +1,5 @@ package teamdraco.frozenup.item; -import net.minecraft.item.Item; -import net.minecraft.item.ItemUseContext; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.NoFeatureConfig; -import net.minecraft.world.server.ServerWorld; import teamdraco.frozenup.init.FrozenUpFeatures; public class TestItem extends Item { diff --git a/src/main/java/teamdraco/frozenup/item/TruffleHotChocolateMugItem.java b/src/main/java/teamdraco/frozenup/item/TruffleHotChocolateMugItem.java index cdf7d72..87814ae 100644 --- a/src/main/java/teamdraco/frozenup/item/TruffleHotChocolateMugItem.java +++ b/src/main/java/teamdraco/frozenup/item/TruffleHotChocolateMugItem.java @@ -1,10 +1,5 @@ package teamdraco.frozenup.item; -import net.minecraft.block.Block; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.EffectType; -import net.minecraft.world.World; import teamdraco.frozenup.util.Util; public class TruffleHotChocolateMugItem extends AbstractDrinkableMugItem { diff --git a/src/main/java/teamdraco/frozenup/util/Util.java b/src/main/java/teamdraco/frozenup/util/Util.java index 328655e..41887d4 100644 --- a/src/main/java/teamdraco/frozenup/util/Util.java +++ b/src/main/java/teamdraco/frozenup/util/Util.java @@ -1,24 +1,24 @@ package teamdraco.frozenup.util; -import net.minecraft.entity.LivingEntity; -import net.minecraft.potion.Effect; -import net.minecraft.potion.EffectInstance; - import java.util.HashSet; import java.util.Set; import java.util.function.Predicate; +import net.minecraft.client.renderer.EffectInstance; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.entity.LivingEntity; + public class Util { public static void removeEffects(LivingEntity entity, Predicate predicate) { - if (!entity.getEntityWorld().isRemote()) { - Set toRemove = new HashSet<>(); + if (!entity.().is()) { + Set toRemove = new HashSet<>(); for (EffectInstance instance : entity.getActivePotionEffects()) { if (predicate.test(instance)) { toRemove.add(instance.getPotion()); } } - for (Effect effect : toRemove) { - entity.removePotionEffect(effect); + for (MobEffect effect : toRemove) { + entity.removeEffect(effect); } } } diff --git a/src/main/java/teamdraco/frozenup/world/gen/feature/IceTreeFeature.java b/src/main/java/teamdraco/frozenup/world/gen/feature/IceTreeFeature.java index 319eb9e..365526e 100644 --- a/src/main/java/teamdraco/frozenup/world/gen/feature/IceTreeFeature.java +++ b/src/main/java/teamdraco/frozenup/world/gen/feature/IceTreeFeature.java @@ -1,20 +1,7 @@ package teamdraco.frozenup.world.gen.feature; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.LeavesBlock; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.ISeedReader; -import net.minecraft.world.World; -import net.minecraft.world.gen.ChunkGenerator; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.NoFeatureConfig; - import java.util.Random; -import static net.minecraft.world.gen.feature.NoFeatureConfig.field_236558_a_; - public class IceTreeFeature extends Feature { public IceTreeFeature() { super(field_236558_a_); diff --git a/src/main/java/teamdraco/frozenup/world/gen/feature/IcicleFeature.java b/src/main/java/teamdraco/frozenup/world/gen/feature/IcicleFeature.java index 012af11..631b86b 100644 --- a/src/main/java/teamdraco/frozenup/world/gen/feature/IcicleFeature.java +++ b/src/main/java/teamdraco/frozenup/world/gen/feature/IcicleFeature.java @@ -1,19 +1,19 @@ package teamdraco.frozenup.world.gen.feature; -import net.minecraft.block.*; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.ISeedReader; -import net.minecraft.world.World; -import net.minecraft.world.gen.ChunkGenerator; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.NoFeatureConfig; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.DirectionProperty; +import net.minecraft.world.level.chunk.ChunkGenerator; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import java.util.Random; -import static net.minecraft.world.gen.feature.NoFeatureConfig.field_236558_a_; - -public class IcicleFeature extends Feature { +public class IcicleFeature extends Feature { public IcicleFeature() { super(field_236558_a_); } @@ -27,12 +27,12 @@ public IcicleFeature() { public static int extraSideIcicleHeight = 1; //maximum possible randomized increase in height public static BlockState iceBlock() { - return Blocks.PACKED_ICE.getDefaultState(); + return Blocks.PACKED_ICE.defaultBlockState(); } @Override - public boolean generate(ISeedReader reader, ChunkGenerator generator, Random rand, BlockPos pos, NoFeatureConfig config) { - if (reader.isAirBlock(pos.down())) { + public boolean generate(LevelAccessor reader, ChunkGenerator generator, Random rand, BlockPos pos, NoneFeatureConfiguration config) { + if (reader.isEmptyBlock(pos.below())) { return false; } @@ -43,7 +43,7 @@ public boolean generate(ISeedReader reader, ChunkGenerator generator, Random ran for (int i = 0; i <= height; i++) //trunk placement { - BlockPos icePos = pos.up(i); + BlockPos icePos = pos.above(i); if (canPlace(reader, icePos)) { filler.entries.add(new WorldGenFiller.BlockStateEntry(iceBlock(), icePos)); } else { @@ -67,11 +67,11 @@ public boolean generate(ISeedReader reader, ChunkGenerator generator, Random ran return true; } - public static void downwardsIce(ISeedReader reader, WorldGenFiller filler, BlockPos pos) { + public static void downwardsIce(LevelAccessor reader, WorldGenFiller filler, BlockPos pos) { int i = 0; do { i++; - BlockPos icePos = pos.down(i); + BlockPos icePos = pos.below(i); if (canPlace(reader, icePos)) { filler.entries.add(new WorldGenFiller.BlockStateEntry(iceBlock(), icePos)); } else { @@ -83,11 +83,11 @@ public static void downwardsIce(ISeedReader reader, WorldGenFiller filler, Block } while (true); } - public static boolean canPlace(ISeedReader reader, BlockPos pos) { - if (World.isOutsideBuildHeight(pos)) { + public static boolean canPlace(LevelAccessor reader, BlockPos pos) { + if (Level.isOutsideBuildHeight(pos)) { return false; } BlockState state = reader.getBlockState(pos); - return reader.isAirBlock(pos) || state.getMaterial().isReplaceable(); + return reader.isEmptyBlock(pos) || state.getMaterial().isReplaceable(); } } diff --git a/src/main/java/teamdraco/frozenup/world/gen/feature/WorldGenFiller.java b/src/main/java/teamdraco/frozenup/world/gen/feature/WorldGenFiller.java index 95f512e..caf78de 100644 --- a/src/main/java/teamdraco/frozenup/world/gen/feature/WorldGenFiller.java +++ b/src/main/java/teamdraco/frozenup/world/gen/feature/WorldGenFiller.java @@ -1,13 +1,12 @@ package teamdraco.frozenup.world.gen.feature; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.ISeedReader; -import net.minecraft.world.World; - import java.util.ArrayList; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; + @SuppressWarnings("unused") public class WorldGenFiller { public ArrayList entries = new ArrayList<>(); @@ -23,9 +22,9 @@ public void fill(ISeedReader reader, boolean safetyCheck) { } reader.setBlockState(entry.pos, entry.state, 3); entry.additionalPlacement(reader); - if (reader instanceof World) { + if (reader instanceof Level) { BlockState state = reader.getBlockState(entry.pos); - ((World) reader).notifyBlockUpdate(entry.pos, state, state, 2); + ((Level) reader).notifyBlockUpdate(entry.pos, state, state, 2); } } } @@ -45,7 +44,7 @@ public boolean canPlace(ISeedReader reader) { } public boolean canPlace(ISeedReader reader, BlockPos pos) { - if (World.isOutsideBuildHeight(pos)) { + if (Level.isOutsideBuildHeight(pos)) { return false; } BlockState state = reader.getBlockState(pos); @@ -53,7 +52,7 @@ public boolean canPlace(ISeedReader reader, BlockPos pos) { } public boolean canPlace(ISeedReader reader, BlockPos pos, Block block) { - if (World.isOutsideBuildHeight(pos)) { + if (Level.isOutsideBuildHeight(pos)) { return false; } BlockState state = reader.getBlockState(pos);